Best Golang Basics and Web Development Course for 2019?

Hello and welcome back to the series where you’re learning Go programming language. In this video we will talk about how we will set up Go Language in our system. First of all, we need to go here to the golang.org website. You can see that.

Best Golang Basics and Web Development Course for 2019?

The Go Lang programming language, golang.org, and then you can easily see this big button: “Download Go”

You need to click on that button and once you click on that button you will have the options. These are stable versions or the featured downloads.

Best Golang Basics and Web Development Course for 2019?

You can find any of the downloads from here. There are a lot of download options but I’m going to go to one of these four. You can see that the Microsoft Windows, Apple, and MacOS, Linux or the source because I’m going to teach you how to use Microsoft Windows. I’m going to use this one but if you have these systems you can use any of the systems anyway.

I’m clicking here on Microsoft Windows. You’re download should begin shortly if it does not click this link but I do not need to click on that link because it is working fine here. It’s getting downloaded.

You can see that it is downloaded here. I need to click on this one and it’s opening the Google LLC which is a verification that it is coming from the Google sources, so it’s all good. I need to run on that. It’s asking me what I want to do. I want to install this setup so now click on the next button now we absolutely have to accept the terms.

Best Golang Basics and Web Development Course for 2019?

The next button again. I’m asking for the place here I want to install the location. I’m clicking on the next button. It’s simply asking me to install it.

Watch this video on YouTube.

If you will enjoy reading and contributing to the discussion for this post, will you please join us on the YouTube video above and leave a comment there because I read and respond to most comments on YouTube?

If you find anything helpful in this video or funny, will you please leave a like because you will feel great helping other people find it?

I’m clicking there now, it’s processing. It’s validating the install and it will take a few minutes to install the Go Language in our system. It is pretty easy.

In many different languages, we often use we have to use the NPM or different kinds of package managers. For PHP there is a different manager like composer, for JavaScript technologies, we use NPM, but this one is simply the installer of the simple exe installer nothing more complex. You need to click on the next button, next button, and install button and there, you need to click on the finish button and it is in your system.

Best Golang Basics and Web Development Course for 2019?

This has done a lot of things. You can see that when you install it with the Windows MSI installer, so this is how you need to install it. Open the MSI files and follow the prompts to install the Go tool, but the interesting thing is the installer should put the c:\Go\bin directory in your path environment variable. You may need to restart and open the command prompt for the change to take effect.

Setting Environment Variables Under Windows.

If you want to set up the environment variables, you can choose these options, but this is not the point by now. Because we already did that using the Go installer.

All we need to verify is if it is working fine so we need to create a script in the Go Language. I’m going there and I’m inside a folder whose name is golang.

I’m making a new file here and inside this file I’m going to save it like this and the name should be like test.go. The format should be test.go. Instead of testing we can put index, you can put the home, you can put anything like that but the extension must be .go.

Then click on the Save button. Now here is the file.

Best Golang Basics and Web Development Course for 2019?

I’m going to put some commands you may not understand by now, but you need to be patient because I will be teaching what I’m doing.

Package main

Import “fmt”

func main () {

fmt.Println “ Hello World”

}

Best Golang Basics and Web Development Course for 2019?

I have made a function here. First of all, I loaded a package then I imported fmt from that package, then I ran a function here. I called a function here. I’m going to run that function. I’m going to run that function. I’m going to run that function, in the PowerShell. There is a PowerShell. First of all I need to write go run test.go.

Before doing anything you need to make sure that your PowerShell is located in a position where your file is. You can see that \official\tutorials\jerry-banfield\golang> there is a test.go. This file is in the exact location where I opened my PowerShell. The inside of the file on the jerry-banfield\golang> go run test go. I opened the PowerShell in a golang folder. You can see that.

Best Golang Basics and Web Development Course for 2019?

I need to now press the line break, the intro key, and now Hello World is visible here. That means this script is working. That means we have setup the Go Language in our system.

Best Golang Basics and Web Development Course for 2019?

Part Two: Install the Golang compiler.

We’re going to download and install the Go compiler. Without the compiler, we can write code on Go Language but we cannot run that, so we cannot testify if our code is okay or not. All we need is to go to the download Go button – click on this button, and now you’re going to see the page golang.org/dl. On the official Go Lang website, you can see that the downloads are heading and then the future downloads and the stable versions. We absolutely need nothing to do with these stable versions because we are going to use the feature download ones. You can use the Microsoft Windows if you’re using the Windows or if you’re doing with the Apple MacOS or the Linux, so according to your system download any of these like I’m downloading this one.

They are asking me to confirm if this download is suitable for my system. Right click there and now it’s downloading in my system which can take hardly one minute.

There are some different settings that you need to do but the good thing is you do not need to do many of the things because as you can see, open the MSI file, and follow the prompts to install the Go tools. By default the installer puts the Go distribution in c:\Go and the installer should put the directory in your path environment variable.

Best Golang Basics and Web Development Course for 2019?

Whenever you install or setup any program you have to setup them in the path environment variables but Go did it itself if you go with the download installer. All we need is to wait a few more seconds then we will be able to install that.

It may be useful to have multiple Go versions installed on the same machine to ensure that a package’s test passes on multiple Go versions. Once you have one Go version installed you can install another one.

Best Golang Basics and Web Development Course for 2019?

But we do not need that. This is an extra thing for us.

I’m clicking on this file and all I need is to run it. The setup is now asking me to click on the next button. All I need is to accept the terms of the license agreement and now I need to select the destination, the c:\Go and click on the next button again, and absolutely the install button. All we can do is to wait a few minutes. Once the installation is done then we will be able to testify if the Go programming language is successfully installed in our system.

Best Golang Basics and Web Development Course for 2019?

After the verification we will absolutely go to the next lesson to understand the Go Language methods, and to work something on the Go Language.

I need to click on the finish button. I have now installed it. Here is the code editor as you know we were using the VSC Visual Studio code for the Go Language.

Best Golang Basics and Web Development Course for 2019?

First of all we need to make a new file in any directory you can choose in your system. I made the directory name as Go and the file name I’m writing as in index.go and go here.

First of all, we are going to write a program. I’m not going to tell you exactly what I’m doing because it is a little detailed things but we’ll talk about them. Do what I’m doing now. The package main, import “fmt”, we are importing something into our program. Then func main (). It is a function if you know some JavaScript or basic other function languages. You may know about this but this is something new. Fmt.Println().

We are absolutely going to talk about these things later but not right now. Hello World func main () {fmt.Println(“Hello World!”)}. The most famous sentence for the programmers is this Hello World!.

Best Golang Basics and Web Development Course for 2019?

We have written something here in a document. How do you testify to this? I need to click on the terminal and in the terminal all I need is to test this file. We are in the specific folder and the GO folder. That means we’re inside this Go Folder. All we need is to type the file name but before that we need to run the command, the go run index.go.

Best Golang Basics and Web Development Course for 2019?

You can see that the Hello World is visible. That means the Go Language is successfully installed in our system.

Best Golang Basics and Web Development Course for 2019?

Part Three: Code Structure Discussion.

In this lecture we’re going to talk about this structure we wrote. The very first thing is a package main. So what is this thing?

Best Golang Basics and Web Development Course for 2019?

The package main is the name of the package which is going to run the whole program. That means without this package this program is not going to run. We need to know that the Go Language works on the packages. The packages are the base of the Go Language so if you have added the package main, because of this package, we’re going to get the result of all these lines.

The second line you can see is fmt is a preprocessor command which gets data or imports data of fmt from this package main. The main package.

First we attached the package main then we picked some data from this main package, and the data we picked we imported the fmt, then after that, if you ever heard of the functions or maybe you are from the JavaScript background or any functional language background, this is a function. Interestingly you do not need to call the function as generally in Java Script if you know some previously. If you have experience with any programming language, this is a function you’ve made.

You cannot call this function unless you write the function name somewhere as a caller, but here you do not need this. You need to write the function and inside the main function – the main function – means it is what we are going to get on the screen. That means this is the area where the execution of the program begins.

You can add more things instead of this single line, you can add more statements, more coding, and more programming in this area. Whatever you add in this area – the main area – that thing will automatically run through the compiler, and you will be able to see the result.

Best Golang Basics and Web Development Course for 2019?

This is the interesting thing about the fmt.Println. Println is a function. One thing you need to know is that whenever you see something with the curly braces, the parentheses, that is a function. The fmt.Println() this is a function. The reason we added the fmt is because we have imported the fmt and we are using that fmt here, and because of this point the period sign, we know that this Println is coming from this fmt.

That means it is all connected together. It’s very simple, but you need to focus on the logic behind it. The package main picks data from the fmt through importing and then the data after importing, we are running inside a function the Println from the fmt.

We’re going to use this fmt multiple times. One more thing you need to know that you may have noticed that P is capital in this Println method. In the Go Language, a name is exported if it starts with a capital letter. It’s exported, it’s not from scratch we’re making. We are picking from this main function and the part of the main function which is called fmt. So the Println is coming from fmt ultimately so the P is capital. That means we are exporting it.

These are some basic logics you need to know. In the next part, we will talk about the basic syntax of the Go Language.

Part Four: Basic Syntax for the Go Language

We are going to talk about the basic syntax for the Go Language. In many programming languages when you want to terminate any statement or end any statement you add a ; (semicolon). This semicolon identifies that this statement ended.

Best Golang Basics and Web Development Course for 2019?

If you want to start a new statement you can add any space and even write something. When we’re talking about the Go Language, we need to know that we cannot add the semicolon, we have to go to the next line. The line break, pressing the Enter key to add a line break is the way to end any statement in the Go Language. Ultimately you do it, you add a line break, so you can add further coding here.

Best Golang Basics and Web Development Course for 2019?

You might be wondering why the main function didn’t get a break here when we added a line break. Because the { } (curly braces) on this looks for its end. It is something which is connected together.

Here, if we add a line break, you are ultimately now able to add a new statement. Let me try this fmatPrintln(“2nd Hello world!”). Save it.

Best Golang Basics and Web Development Course for 2019?

I’m going to go here and I am simply going to run the terminal and I’m running the file. You can see that the Hello World and the second Hello World. That means both of them are here so it is working fine.

This is how you end any statement by adding a line break. A few more things you need to know.

White space law.

So, for example, we haven’t talked about the variables yet but let me draw something. The variables are something you can say store data in the Go Language.

We’re not going to talk about the variables specifically by now. To mention the white spaces I’m adding a var val1 = 4, var val2 = 6 + 8.

Best Golang Basics and Web Development Course for 2019?

They’re showing a red line because the Go Language thinks I did something wrong and what wrong I did here is they’re unused. This is a great thing about the Go Language in any way that you cannot import a thing that you are not using or you cannot declare a variable if you’re not using it.

Because these things can slow down the process, so for better coding it means you cannot add anything unused and for proper readable documentation. The code doesn’t allow us to add something which you’re not going to use or you’re not using anyway.

A better way is to comment on them. We will talk about the comment later in this video. For example, here I have added import fmt but here I’ve used the import fmt but if I simply delete that, you would notice that here it’s going to be a bug. You can see that now.

Best Golang Basics and Web Development Course for 2019?

The fmt became a bug because it was imported and not used. That means we imported something we’re not using so we should not even import that. We have to do that and then we are down and we have to use that fmt package here again for the Println and here first of all, we are calling the val1 (fmt.Println(val1). You should notice that it became right. No bugs anymore.

It was not a kind of real bug but the Go Language was not allowing us to do so because the rule is we cannot add some unused things. There, the val2 (fmt.Println(val2). If I run that, you can see that. First of all, you should see the Hello World and the second Hello World then 4 and 14.

Best Golang Basics and Web Development Course for 2019?

The thing is, I have added space here. I have added space here. I have added space here. If I delete the space here, and there, and there, and there, it won’t affect the coding.

Best Golang Basics and Web Development Course for 2019?

Go ahead and check that again. So you would notice that you can see that the 4 and the 14 are still exactly the same.

Best Golang Basics and Web Development Course for 2019?

I can remove this space from here and from there too. If I save it again, I would have the same result again but I cannot remove this space from here because if I remove this space from here it won’t be a keyword var anymore. I mean, we have to add some spaces in some places. For example, I am removing this space. You can see the bug.

Best Golang Basics and Web Development Course for 2019?

What’s the meaning of a bug? We didn’t even define it. It’s not unused anymore. We can call it unused even because this is val2 and this is value val2, but what is the type of this thing? Here we’re declaring it as a variable then we are adding the name of the variable. You’re first telling us that if we want to make a variable then we are adding a variable name and the value. We’re not identifying what this is, we’re not defining the method here.

Adding space here to this space is defining this thing. The var val2. Unnecessary spaces are not important even if these unnecessary spaces will be automatically ignored. So whether you add them or don’t add them it doesn’t matter.

Best Golang Basics and Web Development Course for 2019?

You can see that the program is still the same and that means the extra space is ignored. Even these spaces are ignored. You do not need to add these spaces. You can compress the program this way but for the code readability especially for us because you’re about to learn the Go Language, I have added those spaces.

Best Golang Basics and Web Development Course for 2019?

You can see that. It should still be the same. You can see that we’re getting the same, same result, but I’m adding these spaces because I’m teaching the very basics by now.

What if we need to add something which is unused but we want that in a document? We may use that later. So for example I’m making a variable. This is what we call a comment in a programming language and this is another word I’m talking about in a video. For example I’m making a var val3 = 89 but we’re not using it.

How can we secure this thing while not using it?

All we need to do is to add some comments here. Adding comment in a Go Language is pretty simple, you need to add a / slash and then you have to add the * asterisk sign but be careful because once you add the slash in the * sign you can see that everything went green, so I want to end the comment here.

Best Golang Basics and Web Development Course for 2019?

The starting tag of the comment and ending tag of the comment both are very important to identify which area of the code I want to comment on.

You can see that this is now commented and now ultimately, this will be ignored by the compiler. Compiler will not read it. Go here and practice this. You will notice it here. You can see that there are four and 14.

If I remove the signs from the comment I’m going to debug it because it won’t allow us to do that. The val3 was declared and not used so this is something not good for the Go Language. So these are the basic logics.

We need to know the basic syntax of the Go Language. There is one very important thing you need to know. There are some keywords or you can say reserved words for the Go Language, for example, the var is a reserved word. You cannot use this word for a variable.

For example, here I’m typing var and then using var var = 5. This is not a good thing to write the variable name.

Best Golang Basics and Web Development Course for 2019?

This is a single word by now but this is not alone, we have many other reserved words, for example, the func is a reserved word. The import, the package, these are the reserved words.

However, it is attached but it won’t work because it is not programmatically attached, so you’re getting a syntax error. We cannot use the var because it is a keyword, we can add something like var1. It should be okay. We will get the error declared and not used because the variable is declared.

Best Golang Basics and Web Development Course for 2019?

We’re not calling it var we’re calling it var1 where var1 can be a word but exactly the same reserved word cannot be used. This is the basic thing you need to know when you’re making the values.

One more thing you need to know that the Go Language is a case sensitive language. What’s the meaning of the case sensitivity? For example, you have made a variable var1 so make a variable here Var2 = 9. Save it. I’m commenting on this.

One more thing if you want to comment on a single line you can add the // (double slashes). If you want to comment on multiple lines you can use this / *. */ .

The comment will be applied but on the other hand, you can add some more actual codes right after the ending tag of the comment, but here you cannot add anything unless the line ends. You can line break it like this one.

We’re going here and we are typing fmt.Println(Val2). V is capital by now. I’m going here and I’m running this now so you’re getting the result. First of all, the var1 = 4 and the var2 = 6+ 8 = 14. This Var2 = 9 has the V capital. It is 9. If I add +28 I’m going to have the results anyway so you will see that here the 14 and the 37 because 28 + 9 = 37. You need to know that it is case-sensitive you cannot go with the V capital and the V small as one thing. Both are different.

Best Golang Basics and Web Development Course for 2019?

There are some more things when we would talk about the variables, we would discuss them, but for now, we were only discussing the basic syntax. In the next lecture we’re going to talk about something different.

Part Five: Data Types.

We’re going to talk about the data types. While working with any programming language you have to know the data types, so you would know what you need to do. For example, here you can see the double but when you go down and type the same thing but here if you add it without single or double quotes and save it you can see that you’re getting the error right there because it’s telling that it is unexpected.

Best Golang Basics and Web Development Course for 2019?

If I go to the terminal and if I run this you can see that the same error we got here we’re getting in the TERMINAL too. Why is this happening?

Because this (“ “) indicates that this is in a string and here there are no (“ “). This is not supposed to be a string. If I go down and if I use the same thing again fmt.Println ( 7+ 9) and save it. I then type fmt.Println (“7+ 9”). Note what I’m doing here. The 16, 7+9.

What’s the meaning and what’s the basic difference between them? It is now considered to be in a string and this is the integer and this is absolutely a string. Let me first talk about the string by now and then we will proceed to the next one.

Any string is a text in the programming language. Wherever you want to add the text you don’t want to subtract, multiply, plus, minus, or anything, divide, any kind of mathematical operation you don’t want to perform, so you call that thing as text.

Ultimately you cannot perform any kind of mathematical operation on the hello world because this is the text after all. You can program the variables. We talked about the variables very little. We have to talk about it later but on the variables you use the English words but you don’t use the (“ “) or (‘ ‘) because they are variables.

They are not ultimately the text, but this is the integer. Integers are something where you can apply mathematically operations but if you use (“ “) around the integers, they won’t be the integers anymore. They have become the string by now. This is the string because it has the (“ “). This is the number and this is the text but both are strings. I mean, a number can be a string after all and a number can be an integer too, so this is what’s happening here.

Best Golang Basics and Web Development Course for 2019?

The string and the integer. I’m going down and I’m going to talk about more data types.

One data type is the boolean. Boolean cannot be used like this but the boolean can be used and here we want two kinds of answers. When you want the answer to be true or false, you use boolean’s.

These are called boolean’s when you want the answer as true or as false you use the Boolean. There are more types when we talk about the Go Language. One type is the variables too, so this one is ultimately the type.

A variable is the data type which has nothing which is itself nothing but can store data like you can store some kind of data like var var1 = 5. The variable has a data type. Its own data type is variable. The value data type is integer. This variable will behave like an integer. Go there and type the var str1 = “Hello there!”.

This variable will behave like an integer and this one will behave like a string. So why are we getting the red signs? We have declared the variables and we are not using it which is not a recommended thing in a Go Language to have any unused variable. This is another data type which is a variable.

In the same way, we have some words like array data type. We will talk about them later. In the next lecture we will talk about the integer data types so we will learn more about the integers more in the next lecture.

Part Six: Integer Types.

We are going to talk about integer types. This video is the complete theoretical video so you need to know a few facts about the integer types of the Go Language so this is why I’m describing them here. The very first integer type is the uint8 u-integer means the unsigned integer and because it is uint8 like this one. This is an unsigned 8-bit integer.

This starts from 0 to 255. In the same context there is another one which is uint16. It is 16-bit unsigned like this one. It starts from 0 and it goes up to 65535. This is a big digit after all. They’re all considered the integer but the levels.

There is another one which is uint32 and it is again the unsigned 32-bit integer and it starts from 0 to 429496 7295. It is a big number.

It comes to the basic integer so this is a signed integer and this is called Int8 not the uint8. This is a signed integer. It starts from – 128 to 127. This is the int8 integer, meaning the 8-bit integer.

Int16 which is again the signed integer. It starts from -32768 to 32767.

If we talk about the int32 it is a signed integer which starts from -2147483648 and goes up to 2147483647.

In the same direction there is another one which is int64 and if we go down it is again something interesting and it’s a real big number by the way. -9223372036854775808 and it goes up to 9223372036854775807.

Let’s talk about another type of integer which is the floating points. We’re talking about floating points. We will discuss them too.

What’s the difference between a simple integer and the floating point? Floating point is like it has the 5.20 it has the point. It’s like a decimal number and an integer is like 5. The integer can be 5, 6, 7, 10, but the floating point can be 5.20, 7.39 like this one.

There are multiple kinds of floating points in types. If you talk about the types there is the float32 and it is a 32-bit floating-point number. There is a float64 then there is complex64 and then there is complex128. These are the floating points.

If I talk about how we can check the value of any number, to check the data type of any integer all we need is to first make a variable like I’m making var var3 = 5 here and I’m going down and I’m typing fmt.Printf(“%T\n”,var3). Save it.

Best Golang Basics and Web Development Course for 2019?

GET MORE OF THIS COURSE

Would you like to continue learning about the Start Google Go Programming Today and Become a Master of Golang Course? If you are interested will you please buy the complete course, Start Google Go Programming Today and Become a Master of Golang Course, on the Uthena Education Platform..

You can also get the first 8 hours and 41 minutes of the course completely for free on YouTube.

Thank you for reading the blog post or watching the course on YouTube.

I love you.

You’re awesome.

Thank you very much for checking out the Start Google Go Programming Today and Become a Master of Golang Course and I hope to see you again in the next blog post or video.

You may enjoy reading this post: Java Programming for Beginners from Development Kit Installation to Exceptions

Love,

Jerry Banfield.