2

I downloaded Golang 1.11.1, but in the terminal when I type go version, I get: go version go1.6.2 darwin/amd64.

When I type which go in the terminal, I get: /usr/local/bin/go

I can see in /usr/local that there is a go directory, and when I open the file VERSION, it says 1.11.1

When I try go get https://github.com/blablabla in the terminal, it spits out package github.com/google/uuid: cannot download, $GOPATH not set. For more details see: go help gopath.

What is the issue here? Could it be that I am one of the users (and not the original user) on my mac? To get to my files, I have to go to Users/myusername first... How do I change my GOPATH so that this works?

Thank you -S

Update: I set my $GOPATH to /Users/myusername/go by editing my bash_profile, but the version still has not changed, although I re-downloaded Go.

tijko
  • 7,599
  • 11
  • 44
  • 64
johndisk
  • 187
  • 1
  • 9
  • 1
    run `go env` and check the value of your `GOROOT` and or `GOBIN` variables. It's possible that you have an older golang version (go1.6.2) installed (possibly with homebrew) – IronGeek Oct 11 '18 at 03:33
  • GOROOT="/usr/local/Cellar/go/1.6.2/libexec". How can I change this? Thank you! – johndisk Oct 11 '18 at 03:47
  • Try setting the value in the `~/.profile` or `~/.bashrc` or `~/.zshrc` (depending on which shell you're using) – IronGeek Oct 11 '18 at 04:02
  • Resolved! I ran 'brew upgrade' and go is now updated. Not sure if that is a long term solution though... – johndisk Oct 11 '18 at 05:02

1 Answers1

3

you can try this

  1. You can go to user/local/go/src

    if the golang is install .it show many file.

  2. Then you can open terminal. and type go env

  3. after that set the $GOPATH

    export GOPATH=/user/local/go

  4. Also set the $GOBIN

    export GOBIN= $GOPATH/bin

Anshu
  • 1,277
  • 2
  • 13
  • 28