How To Install and Start Programming With Golang
Go Setup
Installing GoLang on your system Requires Three Steps:
Downloading the installation files from the link.
Installing the packages
Verifying the GoLang installation by running programs
Installing on Linux system:
- Extract the .tar.gz file downloaded from the above link to /usr/local
sudo tar -C /usr/local <go_tar_filename>.tar.gz
- Add
/usr/local/go/bin
to thePATH
environment variable.
export PATH=$PATH:/usr/local/go/bin
Verifying Installation:
Now check the Go installation by building a simple program, as follows:
- Open a terminal and create the following file structure.
$ mkdir golang/src/test
- Now change the directory to the above path.
$ cd golang/src/test
- Now, create a file named test.go and write your first test program.
package mainimport "fmt"func main() {
fmt.Printf("Installation Successful..!!")
}
- Now, save the file and go back to the terminal and run the following command.
$ go build
- The above command creates a binary file called test.exe, now run the executable to run the above code.
$ ./test
- If the installation had correct, then it prints “ Installation Successful..!!”
Commands For Linux Terminal
Congratulations! The installation had been finished and you are ready Go!