 Okay, so now we're going to look at the actual real go programming language having learned to go pigeon. And the first thing to understand about goes that it's a real programming language and in a real programming language, you're going to be creating much larger programs, where you don't want all of your code to just sit in one single source file that would be inconvenient and awkward in many ways, you want to be able to spread your code across many files. And those files will be organized into directories in larger projects. And so these directories in go, we call packages. And the rule is that to access the code from one package in another, it's not available automatically, you have to import it. So in this program, this is just an extremely simple program, short as possible program, we're just spinning on Hello World to console. But we still have to specify that this source file, this single source file we have is part of a package called main because your, your base level package or the root package of your program is always called main. So that's what this says here. But even for this very simple program, we need to spit text out to console and in go and in other real languages, they don't have print and prompt operators, they don't have operators built in the language. Instead, there's a part of the so called standard library, some some existing code that we have to bring into our programs that will do printing and prompting another kind of input and output for us. And in go, the part of the standard library that does that for us is called the fun to package, fun to short for format. And so we need to bring in the fun to package by importing it at the top of our file, as a rule, your source file has to start with a package statement declaring what package the source files in. And if you have imports, they have to go after the package statement before everything else. In this case, we're just importing one package, the fun to package. And now having imported the fun to package, we can call the functions of the fun to package as we're doing here, recalling the function print line from fun. So we're specifying from fun dot, and then what we want to call from that package. And it's called print line with capital P. Unlike in go pigeon, capital names don't imply that it's a type name, you can have variables and functions starting with capital letters and type names don't necessarily start with capital letters, they can, but they don't necessarily. So it's a, there's a different significance of capitalization and go, which we'll talk about shortly. Anyway, so this is our main function and functions are written in go with funk, just like in go pigeon, then the name of the function. And then you put parameters of the function inside parents. And even if your function doesn't have any parameters, then you still need the prints. And then the body of the function, go does not use indentation to denote bodies. Instead, it uses curly braces to surround the bodies of your of your functions and the bodies of your ifs and loops and all those things. And so you put a curly brace here. And then you have some number of statements in this case, just one, and then you end the body of the function with a curly brace. And the language really doesn't care how I indent this body, I could do that. And it's still validated the language just really does not care. But despite that, for good style, you should format your code, you should indent it exactly like we did in go pigeon. So in practice, that's how you're going to indent your code anyway. But I understand the language itself does not care, the language is looking for these curly braces to know when your, your bodies begin and end, it doesn't really care about the invitation. So also notice that function calls, they're not in prefix notation. Instead, you put the name of the function first here, it's fump dot print line, that's specifying the function print line from the fump package. You then put parents after the name of the function and any arguments to the function, go inside the parents, and you separate them by commas. So if we had multiple arguments here, we put a comma here and some some other argument and then more arguments, etc. But in this case, we just have the one argument the string. So this is a complete go program, and we can now execute it. And the way we'll do that from the command line is so the way you can run a go program is by type of go. There are a few different sub commands. If we just type go help, it'll list all the sub commands. And we'll explain the most important of these down the line. The most important is generally will build compiles, your packages compiles your code, but it doesn't run it. And then run will compile and run it. So just in one one command, if you want to compile and run your program, you should just do go run. So let's do that go run. And then you specify with run, you specify all the files that make up your program. Go run, you don't it's just used for quick and dirty examples. It's not something you use all that much in more serious development. It's useful for quick demos and and educational examples. But otherwise, it's not used all that much. But I'm going to use it here. So go run and the name of this file is go lesson.go. It compiled it and ran it and it's about console hello there just like we wanted to right here. So we ran our first go program, real go program. Okay, let's do something slightly more interesting and copy this over. Here is a program which again is just a single source file. So we have to say it's part of package main. It's important from because we want to spit text out the console down here. And let's look at our main function first. So the go pigeon code would look like this, we're creating two locals, one called numbers, which is a slice of ends and results, which is an integer. In Go, the way you declare a variable is with a var statement, you write var, the name of the variable, and then the type and this is how you specify a slice of ends, you have an empty pair of square brackets, then the type of slice it is, notice again, our type names are not necessarily capitalized. And we can have instead of this one local statement, we have multiple var statements. So this is declaring also a variable results of type int. And then for an assignment in Go and actually almost all mainstream languages, you write the target on the left of an equal sign and then the value to sign on the right. It looks like an equation in mathematics, but that's highly misleading because it's not really an equation. We're not saying that these two things are are always equal to each other. We're just saying take this value on the right and store it in the thing on the left. That's what it really means. So it's an assignment. And the way you write a slice, you create a slice in actual Go syntax is you specify the type of slice, and you have curly braces, and you list the values separated by commas inside the curly braces. So this is a slice with five int values. We wanted an empty slice that would look like that. But we want five values. And then we're going to call the sum function, which we declared up above, we'll look at that in a second, but we're passing in this slice of numbers. And the result we are storing we're assigning to this variable called result. And then we're going to print out the value of result. We of course don't actually need the variable result, we could just directly plug the value in there. But let's keep it. And lastly, we actually don't have to put our variable declarations at the top of our function, we can put them anywhere in the function, as long as the variable declared isn't used before its declaration. So we can put this declaration of result down here before result is used, but we couldn't put it down here, that would then be a compilation error. So we can do this. And in fact, we can combine a declaration of a variable and its initial assignment into one statement. So I'm just going to do this. This is declaring a variable called numbers, which is a slice of ends and then assigning its initial value. And we can do the same thing here, we can just combine this into one statement. So this is still valid. And as a further convenience, Go has what's called inferred typing where when we declare a variable and we initialize it, the compiler, because it knows the type of the value being assigned to the variable, we don't have to explicitly say what the type is, we can just leave this implied, we can leave it implicit. And the compiler will know, Oh, because this is a slice of ends, it knows that this variable we're creating should be a slice of ends. So it's implicitly as if we wrote slice of ends there. And same thing here, because some is a function that the compiler knows returns an int, it knows that the type of result is supposed to be an end. And as a further convenience, instead of writing var in this form, we can just write colon equals. And so that's more compact. So this is in fact how Go programmers will almost always write their variable declarations. The only time you need var is when you're creating a variable and you just wanted to default to the so called default value with go calls zero value. So if we wanted a variable result type int, and we just wanted to default to zero value, we don't want to specify what the value is, then we can just have a far statement like this. Otherwise, we almost always use the colon equals syntax. So in fact, in this case, the way almost any Go programmer would write it is like this colon equals. So numbers and results are being declared here implicitly from the colon equals. Okay. And so looking at the sum function here, in go pigeon code, we're declaring a local verbal total of type integer, assigning initial values zero, which we don't actually need to do because it defaults to zero, but it's made that explicit. And then we have a four H loop, where we have I and V both integers, we're looping over the values of nums, which is a parameter, which is a slice of integers. And we are each time through assigning to total, the addition of total and V. So we're accumulating all the values into total. And once we're done with the loop, we're going to return the value of total. The go code equivalent is declaring a function sum, single parameter called nums, which is a slice of hints. And this function returns an int. And we're declaring our variable total to be an int and have the initial value zero, we don't need this line, because this is actually probably how most programmers would write it, because this creates a variable total of type int and it will default to zero because that's an default int value. Actually, probably most people would write this. And this would be the same thing. If you have an integer number as the value of a colon equals assignment, the compiler assumes that the variable supposed to be an int. So that's probably how most people would write this. And then a four H loop is not written for each you write the word for. And then you have the two variables, which I call I and V here, you separate by commas, you don't specify the type instead we use colon equals. And so their type is inferred, it's left inferred, it's left implicit, you write the reserved word range. And then you put the slice array or map or whatever the thing that is we're iterating through you put that here. And notice here, instead of I I wrote underscore. This is the so called blank identifier, which is a special variable name, which means I don't actually want to use this thing, because the GogoPilot is actually very picky about unused variables. If I wrote I here, we're not using I anywhere in the code and the compiler will complain that I is unused. So to get around that because we have to put something here, there has to be something that the four range syntax is expecting us to create two variables, one for the index. And so to get around this problem, I can use this so called blank identifier to say, I don't actually care about this value. So I'm not going to use this variable. And then looking inside the loop, which again is surrounded in curly braces, because that's how we denote the bodies of things and go you put curly braces around them. It's just a single statement. And again, the compiler doesn't care how we indent the lines inside this body, we can do whatever kind of indentation we want, though we should just stick to the normal style. And our single statement here is assigning to total the result of adding total and V. Again, we don't have prefix notation and go or in most any mainstream language. Instead, we have infix notation where most of the operators are binary operators, they take two operands, and they go in between their two operands. And so this is adding total and V together. And we don't necessarily put them in friends, we could put friends. The thing about infix notation is you can actually just put any number of friends around your expressions. And it's still equivalent. And sometimes that's useful for style. But in this case, there would be no reason to do so. The only reason we really need parentheses in our expressions as well, one, when we're calling a function, of course, so like some numbers here to call some you suffix the function name with friends and put the arguments inside. We use friends surrounding our parameters of our functions, but that's totally unrelated just to totally different meaning there of the friends. And then the other time we use friends is when you have a mix of operations, like say, we multiply this by three. Well, with infix operators, we have an order of precedence amongst operators, the multiplication operator has a higher precedence than the addition operator. And so this would be multiplying V times three, and then adding the result of that to total. And so implicitly, it's as if there are perrens around this multiplication because it's done first. And in fact, we could write these parentheses explicitly. This is valid, though, whether we do so is just a matter of style in this case. But when we need friends is what if we want the addition here to be done first, it has lower precedence than the multiplication. So to make it be done first, we would have to put that in friends. And now it's clear that okay, this is added together, then the result of that is multiplied by three. So we use perrens with our binary operators to subvert the normal order of precedence. It's how we control our order of precedence in certain cases. And the last thing here is that there's actually a shorthand for this particular kind of statement where we're signing to total, we're signing to a variable, the result of that variable added to another thing. And so we just write total plus equals V and that's just shorthand for this. If we were multiplying things together, like if it was total times V, same deal, you could write times equals as a shorthand. These are the compound assignment operators and they're just little shorthand conveniences for some common cases. And in fact, there's a special shorthand for incrementing and documenting variables. So instead of having to write total equals total plus one, well, you could write total plus equals one. And that would be shorthand, but there's even more convenient shorthand total plus plus. And that's the same thing. So these are all incrementing the value of total by one. And if you want to decrement a value by one, same deal, you instead of writing total minus one, you could write minus equals one or minus minus to decrement total by one. So that's all just shorthand conveniences. Okay, so that's our complete program. And let's see this in action. Let's run the program. Go run in the name of our source file goal is go hit enter and prints out negative 39 because that's what is stored in result the results returned from some. And that's apparently what we get when you add together six to one eight and negative 56. So yeah, eight plus nine 17 17 plus negative 56 is negative 39. Okay.