This is a part of my 24Days of Golang challenge preparation. If you don’t want to install Go locally, maybe you are just checking out the language and need no Internet capabilities, you can try Go playground.
Here’s a brief guide to setup your Go development Environment on Linux platform (Fedora 25) and Windows 10.
Linux | Fedora 25
I’m on Linux platform, and fortunately Golang package is already available in the repo! Here’re the instructions to install Go on Fedora 25. These instructions should be pretty much similar for Debian/Ubuntu linux flavor. Shamefully, ripped off from Fedora dev site
- Go installation
- To install Go compiler, type:
go, godoc and gofmt binaries will become available on the system.
- Go code lives in a workspace which is defined by GOPATH environment variable. Upstream documentation uses $HOME/work for your Go workspace:
- Run go env to check that $GOPATH is set correctly:
Windows has a pretty good support for Golang, especially with Visual Studio Code.
Step 1 (Install Go for windows)
Download Golang for windows platform from here
Step 2 (Setup Environment variables & GOPATH)
Add these following to environment variables
- Path variables : Add Golang to Path (C:\Go\bin or your Go install location) variables
- GOPATH : This is your workspace directory (it should contain bin,pkg and src subfolders). Add it to user environment variables.
- GOROOT : This is location where Go is installed on your system. Add it system environment variables.
Step 3 (Install Visual Studio code & Go extension)
Finally, you can download Visual studio code from here and then launch the visualstudio, and open up your workspace directory.
To install Go-lang support:
- press ctrl + `
- paste or type ‘ext install Go’
- Install Go extension provided by lukehoban
- Reload windows/visualstudio
Step 4 (optional) Run Go project site locally
Following command will start local Go project page (http://localhost:4000)