Go で "build constraints exclude all Go files in... " が発生する
go で特定のパッケージをビルドした場合に、以下のメッセージが表示されてビルドできないケースに遭遇した。
# go build . package example.com/hoge/fuga imports example.com/hoge/fuga: build constraints exclude all Go files in ... (path)
- ビルドタグによって明示的にビルドから除外されているケース
$ head -n1 huga.go //go:build ignore
- よう分からんけど Module の Cache 消したら直るケース
https://stackoverflow.com/questions/55348458/build-constraints-exclude-all-go-files-in$ go clean -modcache
Cgoに依存したパッケージがあるが、Cの開発環境がインストールされていないケース
$ go build . package example.com/hoge/fuga imports example.com/hoge/fuga: build constraints exclude all Go files in ... (path) $ sudo apt install build-essential : (snip) $ go build . (通る)
このエラーメッセージから最後の内容は想像できんて。$PATHに cc
が無ければ自動的にビルド除外するのがお作法?