Goで依存ライブラリのバージョンを上げる

別のPCでgo getで取得したライブラリのバージョンが違っていたので、ビルドが失敗した。 ライブラリのバージョンを合わせるときに、つまずいたのでその時のメモ。

go version
go version go1.7.3 darwin/amd64

go helpで見たときに、updateの項目がなかった。 ネットで調べたらgo get -uというoptionがあるようだ。

実際に使ってみたら、pullできないと。。。!?

go get -u github.com/jinzhu/gorm

# cd $GOPATH/github.com/jinzhu/gorm; git pull --ff-only
You are not currently on a branch. Please specify which
branch you want to merge with. See git-pull(1) for details.

    git pull <remote> <branch>

package github.com/jinzhu/gorm: exit status 1

コマンドを調べてみたら。。。

go help get
≈
The -u flag instructs get to use the network to update the named packages
and their dependencies.  By default, get uses the network to check out
missing packages but does not use it to look for updates to existing packages.

既存のパッケージの更新を探すものではないと。。。

but does not use it to look for updates to existing packages.

結局やり方がわからなかったので、 masterをcheckoutをして調整をした。。。

cd $GOPATH/github.com/jinzhu/gorm
git checkout master
git pull --ff-only