First of all if you are using go 1.7, you'll need to change the ownership of your GOROOT's pkg directory:
[ `ls -ld $GOROOT/pkg | awk '{print $3}'` != `whoami` ] && sudo chown -Rv `whoami` $GOROOT/pkg
Then if you are upgrading or downgrading, you'll need to remove the GOPATH's pkg directory, there's the bash snippet to check if gitlab.com/kokizzu/gokil library was precompiled with different golang version than installed:
PKG_OS_ARCH=`go version | cut -d ' ' -f 4 | tr '/' '_'`
[ `strings $GOPATH/pkg/$PKG_OS_ARCH/gitlab.com/kokizzu/gokil/A.a | grep 'go object' | head -n 1 | cut -f 5 -d ' '` != `go version | cut -f 3 -d ' '` ] && rm -rf $GOPATH/pkg
go list -f '{{.Deps}}' ./... | tr "[" " " | tr "]" " " | \
xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' | \
xargs go install -a
Alternatively, you can use
go build -i
The last 2 commands above looks for all dependencies and recompile/preinstall them, it's better than I expected, normally it took about 15 seconds to recompile on go1.6.2.
# go 1.4.3
[gin] Build Successful in 1802.47 ms
[gin] Build Successful in 2854.65 ms
[gin] Build Successful in 2325.35 ms
# go 1.6.2
[gin] Build Successful in 5673.43 ms
[gin] Build Successful in 8081.75 ms
[gin] Build Successful in 6867.12 ms
# go 1.7b1
[gin] Build Successful in 2579.98 ms
[gin] Build Successful in 3649.08 ms
[gin] Build Successful in 4182.04 ms
[gin] Build Successful in 3881.66 ms
[gin] Build Successful in 3722.20 ms
[gin] Build Successful in 2785.84 ms
[gin] Build Successful in 2981.62 ms
[gin] Build Successful in 3793.66 ms
[gin] Build Successful in 4458.86 ms
[gin] Build Successful in 4376.60 ms
Anyway I still stick with go1.4.3 since it has the fastest compile, it makes our edit-compile-test cycle faster.