Getting start with GO/Golang

Hi, Today in this tutorial we will learn how to print "Hello,World!".

Basically we will learn about Print function of Go/Golang. But before that we need to download two things, A compiler and code editor.

First, lets download GoLang in our computer. It’s so easy you can follow as I did below.

Steps to Download Go/Golang

Step 1: Open any browser you use and search Go Download or Download Go. Anything will work.

Responsive Image

Step 2: Open the first link you will see in search result.It’s official website so it’s trustful.

       



Step 3: Click on Download button. And you will be redirected to downloading page.


Here choose and download according to your operating system. If you scroll below you can see older version of Go. If you have older PC or laptop I would recommend to download 1.18 or 1.20 version.

It works and support older system well.



Click on run and install. When the installation box will appear simply click on next and next no need to change any setting simply click on next and install it.




After this we need to install a code editor. There are many code writter but the popular and mostly used by majority people is Vs Code (Visual studio Code).

Downloading and installation process is easy. You can find latest version here code.visualstudio.com.

Tutorial of Printing “Hello,World!”


 

Noe Open VS code and click on New File or simple press CTRL + N to create new file.




 


Search box will appear. Here type GO and press ENTER button or you can click on the GO compiler shown in search result.



After that a new window will appear which will ask you to save file. Save it will name of Main.go. We always save Go file as Main.go. And one more thing, There should be only one GO file in one folder.



Responsive Image

Click on file “Main.go”  to open it.


 

Responsive Image

After it’s open, right click on file name and click on “Open in Integeated Window”. It will open terminal.



Responsive Image

In terminal you need write this codego mod init example.com/hello. it’s fine if you don’t understand. Just think of it as we always do when we create a GO file. We will learn about it in other chapter of Modules.

Responsive Image


Now copy the code below and paste it in code editor and run the code by typing this in Terminal go run Main.go” .

package main
import ("fmt")

func main() {
 fmt.Println("Hello, World!")
}


Responsive Image

Congratulation You learned how to print “Hello, World!” in GO.

There a error you may face. Some people face it and I did a swell n starting.

If you see this errormain.go:1:1: expected 'package', found 'EOF' no need to panic save your file with CTRL + S. It will be fixed.

There are other function we can use to print such as”fmt.Println()” and “fmt.Printf()”. We will learn about it in next tutorial of “I/O Modules”.