Though you can learn and execute Go programs in go playground but it is recommended to setup a development environment on the local system.
Setting up development environment on local system requires following steps.
- Install Code editor.
- Installing go language.
- Configure code editor.
Following is a list of editors that you can use for developing applications in Go.
- Microsoft Visual Studio Code.
- JetBrains GoLand.
Installing Code editor
In this Go lang tutorial, we will be using Microsoft Visual Studio Code or simply VS Code. In order to install it, head over to Visual Studio code download page and choose the download as per your operating system.
Once downloaded, install it and open. You should see a window as below.
You have successfully installed a code editor for Go programming.
Next step is to download and install the language itself. Navigate to the downloads page and download the file according to your operating system.
After the file is downloaded, install it using the instructions. If you face any trouble installing, follow the instructions here.
In order to check if Go is successfully installed, open command prompt on Windows or terminal in Linux/Mac systems, type go and hit enter, you should see an output as below.
Go is a tool for managing Go source code.
go <command> [arguments]
The commands are:
bug start a bug report
build compile packages and dependencies
clean remove object files and cached files
doc show documentation for package or symbol
env print Go environment information
fix update packages to use new APIs
fmt gofmt (reformat) package sources
generate generate Go files by processing source
get add dependencies to current module and install them
install compile and install packages and dependencies
list list packages or modules
mod module maintenance
run compile and run Go program
test test packages
tool run specified go tool
version print Go version
vet report likely mistakes in packages
Use “go help <command>” for more information about a command.
You have completed second step of environment configuration.
We have installed the code editor and Go language. Final step is to install Go tools in the editor so that you can write Go code easily in the editor.
Open code editor, click the Extensions button(last button in the left pane) or click View -> Extensions menu and type “go” in the search bar.
From the list of options, install Go extension by Microsoft and click Install.
Installing this extension will provide you features such as
- Intellisense(Auto code suggestion and completion),
- Code Navigation(moving from one file to another on click),
- Code debugging etc.
After the extension is installed, restart VS code.