Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Go Caveats #31288

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions Library/Formula/go.rb
Expand Up @@ -78,9 +78,16 @@ def caveats; <<-EOS.undent
To get `go vet` and `go doc` run:
go get code.google.com/p/go.tools/cmd/godoc
go get code.google.com/p/go.tools/cmd/vet
Note to use go get you will need 'Mercurial' installed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that not just for mercurial repos?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be for any 'Go' project hosted on code.google.com, and so far I'm struggling to find 'Go' projects that don't tap at least one of the many go resources hosted on code.google.com.

I'm willing to remove the line though. Chances are 90%+ of people using Google Go are likely to have Mercurial installed already and so it may well be redundant.


There are issues with go & non-default shells.
If you're using zsh you'll need to modify your .zshrc file to include:
export GOPATH=$HOME/go
or similar, depending on your setup.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a reproducible failure case? Pretty sure environment variables like this won't fail just based on your shell unless Go is added stuff to e.g. .bashrc for you?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried both Fish & zsh and failed on both of them. It's pretty easy to reproduce.

➜  ~  export GOPATH=$HOME/test
➜  ~  echo $GOPATH
/Users/Bob/test
➜  ~

Close Terminal & Re-Open:

➜  ~  echo $GOPATH
(Blank Response here)

It's the same with setting $PATH inside Fish or zsh. Unless you either use the global path in /etc/paths or set the $PATH in .zshrc or config.fish the $PATH will self-erase the next time you open up a new terminal window/tab.

The problem is that both fish & zsh read from their own config files for such things, so unless you set the variable permanently in that shells config it won't sustain throughout new tabs/windows/etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's expected behaviour; bash will do the same thing. export only sets the scope for the current shell rather than setting it across shells.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aye. I just wondered whether it was worth chucking in a notation about that behaviour, given Go tells people to use the export command to set the GOPATH. I'll happily bow to your knowledge on this front though, If you feel like it isn't necessary that's all cool with me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We try to keep the Homebrew caveats limited to stuff that's Homebrew specific i.e. only applies to the Homebrew go formula and not other Go distributions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. I appreciate that. Will bear it in mind for the future 😄. If you're not a go (no pun intended) on the Mercurial line either this can be closed.


You may wish to add the GOROOT-based install location to your PATH:
export PATH=$PATH:#{opt_libexec}/bin
If you aren't using the default shell you may need to manually modify your shell profile or /etc/paths.
EOS
end

Expand Down