Download Go from:
and download and install the .PKG package. Uninstall any previous install.
If a previous version was already installed, run:
sudo rm -rf /usr/local/go
brew install go
The GOPATH is where all your Go code will live.
Run:
mkdir ~/go
Download from:
Open a NEW Terminal (with new env vars), paste this in to install those sweet tools:
# if in zsh, do also: export PATH=/usr/local/go/bin:$PATH
export GOPATH=$HOME/go
go get -u 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.
VisualStudio Code has one of the best support for coding in Go. It has excellent plugins and works across platforms.
Download from:
After installation, do:
- Hit Cmd+Shift+P and type in
Install exte
* Hit Enter
to accept Install extensions
* From the list, select Go
, and click Install
. Wait and then click Enable
.
In VS Code, open ~/.profile
.
If you use
zsh
, open~/.zshrc
instead.
Tweak your profile file to add these lines and save the file:
export GOPATH=$HOME/go
export PATH=$HOME/go/bin:$PATH
Open the file ~/.gitconfig
in VS Code.
Make sure similar lines are in there:
[user]
name = Your Name
email = [email protected]
Save & exit.
Run:
cat $HOME/.ssh/id_rsa.pub
If you see No such file or directory
, continue on, otherwise skip
this ssh-keygen
step and go to Register your key on GitHub
.
Still in "Git Bash", run:
ssh-keygen
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.
Run:
cat $HOME/.ssh/id_rsa.pub
Go to:
Click "Add SSH key" (at the top right of the box).
Copy the 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.
In a terminal, run:
mkdir -p $GOPATH/src/github.com/abourget
cd $GOPATH/src/github.com/abourget
git clone [email protected]:abourget/getting-started-with-golang
cd getting-started-with-golang
go install -v
getting-started-with-golang
Modify main.go
in this repository and rerun go install -v
to compile and
getting-started-with-golang
to re-execute the program.