$ mkdir -p ~/go
$ echo 'export GOPATH="$HOME/go"' >> ~/.bash_profile
$ echo 'export PATH="$GOPATH/bin:$PATH"' >> ~/.bash_profile
$ source ~/.bash_profile
Go installs binaries to $GOPATH/bin
.
Go source code for projects you contribute to, as well as any dependencies, shall be placed in the directory structure $GOPATH/src/<domain>/<owner>/<project>
.
Example: Installing gcss
go get
downloads Go source projects into the $GOPATH/src/<domain>/<owner>/<project>
structure. If the ellipsis (...
) syntax is used, any binaries will be built and installed in $GOPATH
.
$ go get github.com/yosssi/gcss/...
Confirm installation:
$ [ -e $GOPATH/src/github.com/yosssi/gcss ] && echo $?
0
$ which gcss
/Users/andrewpennebaker/go/bin/gcss
$ echo '$base-font: Helvetica, sans-serif
$main-color: blue
body
font: 100% $base-font
color: $main-color' | gcss
body{font:100% Helvetica, sans-serif;color:blue;}
Example: Contributing to go-ios7crypt
When contributing to Go projects, the user is responsible for cloning projects into the $GOPATH/src/<domain>/<owner>/<project>
structure.
$ mkdir -p $GOPATH/src/github.com/mcandre
$ git clone [email protected]:mcandre/go-ios7crypt.git $GOPATH/src/github.com/mcandre/go-ios7crypt
$ cd $GOPATH/src/github.com/mcandre/go-ios7crypt
$ git submodule update --init --recursive
$ vi cmd/ios7crypt/main.go
:wq
Test code changes:
$ sh -c 'cd cmd/ios7crypt && go install'
$ make
ios7crypt -e monkey
0941410712000e
ios7crypt -d 07022e42450c00
monkey
While Go lacks an intelligent way to manage uninstalling packages, Go is very tolerant of manual modification of $GOPATH/bin and $GOPATH/src changes:
$ rm $GOPATH/bin/gccs
$ rm -rf $GOPATH/src/github.com/yosssi/gccs