Getting Started with Golang - Windows
Download Go from:
and download and install the .MSI package WITH ALL DEFAULT. Just hit NEXT.
- If a previous version was already installed, go to "Add / Remove Programs", and remove it beforehand.
Create your GOPATH
The GOPATH is where all your Go code will live.
Create new folder in
Go to the
System control panel, click the
Advanced tab. Select
Environment Variables and under
Install go tools
Open a NEW Command Prompt (
cmd.exe with new env vars), paste this in to install
those sweet tools:
go get -u -ldflags -H=windowsgui github.com/nsf/gocode/... go get -u github.com/rogpeppe/godef/... go get -u golang.org/x/tools/cmd/...
You might see an error with
godoc. Ignore it.
Install VisualStudio Code
VisualStudio Code has one of the best support for coding in Go. It has excellent plugins and works across platforms.
After installation, do:
- Hit Cmd+Shift+P and type in
Enter to accept
* From the list, select
Go, and click
Install. Wait and then click
Go environment variables
In VS Code, open
Tweak it and add these:
export GOPATH=/c/GoPath export PATH=/c/GoPath/bin:$PATH # Uncomment to load your SSH keys when you open Git Bash # eval $(ssh-agent) # ssh-add $HOME/.ssh/id_rsa
Setup of global
Open the file
%USERPROFILE%/.gitconfig in VS Code.
Make sure similar lines are in there:
[user] name = Your Name email = firstname.lastname@example.org
Save & exit.
Setup GitHub authentication
Generate a new key
If you see
No such file or directory, continue on, otherwise skip
ssh-keygen step and go to
Register your key on GitHub.
Still in "Git Bash", run:
Accept the default file name (hit ENTER). This key gives access to all your github repos. Secure it with a password when asked.
- This password never leaves your computer, the key shouldn't either, but if lost, it is encrypted with this password.
Register your key on GitHub
Click "Add SSH key" (at the top right of the box).
ssh-rsa ....... in the
Key input field. Don't fill in
Title (it will use the key comment).
GitHub will ask you to confirm with your GitHub password.
Check out your first project, get ready to run and build
Open "Git Gui" (right click on the Desktop, or run
git gui in Git
Clone Existing Repository, punch in:
- Source location:
- Target directory:
Go to Atom, select "File" -> "Add Project Folder", and navigate to
Git Bash, run:
cd /c/GoPath/src/github.com/abourget/getting-started-with-golang go install -v getting-started-with-golang
main.go in this repository and rerun
go install -v to compile and
getting-started-with-golang to re-execute the program.