Go 1.11.4 以上で Go Modules を使って依存関係解決しようとしたら checksum mismatch で怒られる
checksum mismatch で怒られる
go: downloading github.com/docker/docker v0.7.3-0.20180827131323-0c5f8d2b9b23 go: verifying github.com/docker/docker@v0.7.3-0.20180827131323-0c5f8d2b9b23: checksum mismatch downloaded: h1:mJtkfC9RUrUWHMk0cFDNhVoc9U3k2FRAzEZ+5pqSIHo= go.sum: h1:Zl/9mUfPbYbnv895OXx9WfxPjwqSZHohuZzVcjJ5QPQ=
原因
Go 1.11.4で入った bugfix で symlinks 含んだ時のチェックサムの計算方法が変わったらしいです。
対処方法
メンバ全員の Go のバージョンを 1.11.4 以上に上げる
仕事でチーム開発等をしている場合、可能であればこれが一番簡単だと思います。1.11.3 以下にさようならしましょう。
go.sum ファイルをコミットしない
go.mod ファイルだけで依存バージョン等の管理は一応できているので、問題の go.sum を commit しないという方法。 一応解決にはなるがこれをするのであれば後述の vender を使う方法でいいかもしれないと思ってます。
Go 公式の Blog の Using Go Modules - The Go Blog では go.mod と go.sum は両方とも管理しろ書かれていたりします。
The go command uses the go.sum file to ensure that future downloads of these modules retrieve the same bits as the first download, to ensure the modules your project depends on do not change unexpectedly, whether for malicious, accidental, or other reasons. Both go.mod and go.sum should be checked into version control.
wiki にもそう書いてある。
Should I commit my 'go.sum' file as well as my 'go.mod' file?
go mod vendor
vendor を使うことで確実に再現性のあるビルドができます。
Go 1.11.2 の時にも似たようなことがあったらしい
ひとつは 1.11.2 でバックポートされたこれ。https://t.co/7ApMCtldkE
— ymmt (@ymmt2005) 2019年2月12日
もうひとつは 1.11.4 で symlink 入れるようにしたこれ。https://t.co/PuBPK4so7u
1.11 のリビジョン更新で go.sum 変わってしまって厳しかった。
Go のバージョン上げたけどまだチェックサムで怒られる
キャッシュを消すといいかもしれません。
$ go clean -modcache
What are some general things I can spot check if I am seeing a problem?