Go programming language! Have you decided to start with Golang programming and looking to set up the development environment correctly? It is easy to install Go and also use the language for defined web app development tasks. This blog highlights the installation of Go development programming platforms, their extensions, and the relevant way to start a simple program.
Go is the preferred type of programming language that suits website development tasks. Both, new & old developers are shifting their preferences to Go development language due to its fast execution. Golang was designed for faster compilation of websites & apps and also powers the overall efficiency of development. It also assists modern-day programmers in using a strong set of tools and adding relevant features for Go development tasks. These days the demand of Golang developer enhancing very rapidly and here you can check remote and onsite Golang developer jobs which can provide you an idea how golang developers are earning much more than other developers in software world.
Prerequisites To Setting Up go programming language
Make sure that you have the right systems for your development activities and also complete app-building tasks swiftly. Also, the developer needs to have active internet connectivity to start their Go development language tasks.
Before downloading the Golang platform, it is crucial to be in the home (~) directory –
$ cd ~
To retrieve the tarball URL, it is advisable to use ‘curl’ by copying it from the Go download official page –
$ curl -LO https://dl.google.com/go/go1.12.1.linux-amd64.tar.gz
Next, verify the tarball with ‘sha256sum’ –
$ sha256sum go1.12.1.linux-amd64.tar.gz
The hash that is displayed from running the above program should match the hash present on the download page. If it doesn’t match, then it won’t be a valid file and the file should be downloaded again.
Output
2a3fdabf665496a0db5f41ec6af7a9b15a49fbe71a85a50ca38b1f13a103aeec go1.12.1.linux-amd64.tar.gz
Now by extracting the downloaded archive, install it to the desired location on your system. Using it under ‘/usr/local’ will provide best outcomes –
$ sudo tar -xvf go1.12.1.linux-amd64.tar.gz -C /usr/local
This will result in having the directory call ‘go’ in the ‘/usr/local’ directory. The next step will be to install the Go on your development system.
Go Installation on Our Machine
To start writing programs in the Go Google programming language, developers need to install tools. It can be done by visiting the Go website and installing the package (.msi for Windows, .pkg for Mac and .tar.gz for Linux) or compiling it from the right source. By following the package route one can automatically install the Go platform from Golang company in the correct locations, and also put the binary in the default executable path.
The Windows users can install Go with Chocolatey –
choco install golang
The Mac user can install Go with Homebrew –
Brew install golang
Then the developers can validate the Golang installation through the use of a command prompt or terminal and run the specific command for the best output:
go version
Once the setup is completed correctly, the following output can be seen –
go version go1.14.4 windows/amd64
The command will provide information that you run the Go version 1.14.4 on the Windows system. In the case of using a Mac or Linux system, the output will be different. Also, the developers need to install third-party tools that can be installed with ‘go install’ command. These tools will be installed in the ‘$HOME/go’ location by default and the location of the source code will be ‘$HOME/go/src’.
Installation of Go Extensions on VS Code
To install the Visual Studio Code, use these steps –
- Visit ‘code.visualstudio.com’ in your web browser.
- Download the latest version of your operating system that supports Windows, Linux, or Mac.
- After the download is complete, run the installer safely. The tasks will take a few minutes as per the speed in your system.
Next, it’s the turn to install Go extension –
- Open the Visual Studio and click on the Extension icon on the bar to bring up the Extension views. Also, use the shortcut ‘Ctrl+Shift+X’ to get to the Extensions.
- Search for the relevant Go extension and then click on the ‘Install’ option.
To update the Go tools, use the steps –
- Open ‘Command Palette’ in the Visual Studio Code, go to ‘Help’, and then select ‘Show All Commands’. Or else use the shortcut ‘Ctrl+Shift+P’.
- Also, search for ‘Go: Install/Update tools’ option and then run the command.
- As prompted, select the relevant Go tools and then click on ‘OK’.
- Now finally, wait for the Go tools to complete the finish of updates.
Creation of a Simple Program
After the Golang workspace is set up correctly, it will be time to create a “Hello, World!” program. It will ensure the appropriate setup of the Go Google programming language workspace and also provide the opportunity to familiarize yourself with the Golang language.
Open up the text editor from the home directory, like ‘nano’, and also create a relevant file –
$ nano hello.go
Also, write a program in the new file –
package main
import “fmt”
func main () {
fmt.Println(“Hello, World!”)
}
The specific kind of code will use the ‘fmt’ package and also call the ‘Println’ function and the argument ‘Hello, World!’. Press the ‘CTRL’ and ‘X’ buttons to exit ‘nano’. And as prompted, save the file by pressing ‘Y’ and then press ‘Enter’.
After the exit out of ‘nano’ and returning to the shell, also run the program –
go run hello.go
The program will ensure that the terminal produces the relevant output –
Hello, World!
To run the debugger use the steps –
- Place the cursor on the line 7 and press the button ‘F9’.
- Click on the debug icon to bring up the ‘Debug’ view.
- Click ‘Run and Debug’ or press ‘F5’ for running the debugger.
Also, the developer can use a basic program for accurate verification to run the Go workspace the correct way. After that, you can start your programming tasks and process your development project through Golang company.
Final Thoughts!
Hope you have installed the Golang platform by now and best of luck for your programming journey. The steps can be incorporated easily and you need to have patience and follow the steps correctly. Start your programming journey and complete relevant website app development projects correctly. Plan your moves correctly related to Go programming and fit your upcoming development tasks.