Advertisement
johnlockwood

Go Env Setup Tips

May 29th, 2014
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. GO ENV SETUP TIPS
  2. In your ~/.bashrc or ~/.bash_profile, where ever you set your environmental vars, set GOROOT, GOPATH and add them to the PATH:
  3.  
  4. export GOROOT=/usr/local/go
  5. export GOPATH=$HOME/go
  6. export PATH=$PATH:$GOROOT:$GOROOT/bin/:$GOPATH:$GOPATH/bin
  7.  
  8. Notice the bin directories are specified. With GOPATH/bin added, the command line will find your compiled go applications.
  9.  
  10. $GOPATH is where you put ALL your go projects. The go directory in your home directory is a good choice.
  11. Put the source code in $GOPATH/src.
  12. It is recommended to put a specific project in a directory that matches the path of your project/package in your online repo. If the package is github.com/yourname/my_go_package, then it goes in ~/go/src/github.com/yourname/my_go_package.
  13. If you need to use third party packages you would clone them to match the path of their repo, such as ~/go/src/github.com/someoneelse/their_go_package.
  14.  
  15. When you write your package and then go install it, from the package directory, it will be compiled an put in $GOPATH/bin.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement