Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command not found go — on Mac after installing Go

Tags:

macos

go

zsh

I installed go1.5.2 darwin/amd64, but when I run the command go version, I get an error in the terminal zsh: command not found: go.

I added the path export PATH=$PATH:/usr/local/go/bin to the bash profile, but I still get the error (I restarted the terminal btw).

I uninstalled and reinstalled, but no luck.

like image 959
medev21 Avatar asked Jan 10 '16 16:01

medev21


People also ask

Where is Go on Macos?

In the Finder on your Mac, choose Go > Go to Folder.


2 Answers

Like bjhaid mentioned in the comments above:

This is happening because you must add your PATH to your ~/.zshrc file.

in the ~/.zshrc you should add the line:

export PATH=$PATH:/usr/local/go/bin
export PATH=$PATH:$GOPATH/bin

you should then source you .zshrc file:

. ~/.zshrc
like image 111
Caleb Adams Avatar answered Sep 29 '22 06:09

Caleb Adams


I kept running into issues and followed the steps on here and finally got a working solution: http://totzyuta.github.io/blog/2015/06/21/installing-go-by-homebrew-on-mac-os-x/

Install w/brew:

brew install golang

Edit bash_profile and add following paths:

nano ~/.bash_profile

export GOROOT=/usr/local/opt/go/libexec
export GOPATH=$HOME/.go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

Source it:

source ~/.bash_profile

Then restart terminal

go version

Output: go version go1.12 darwin/amd64

like image 21
mgrotheer Avatar answered Sep 29 '22 05:09

mgrotheer