atlassian / bazel-tools

Reusable bits for Bazel
Apache License 2.0
113 stars 36 forks source link

golangci-lint does not depend on Go binary #50

Closed terinjokes closed 5 years ago

terinjokes commented 5 years ago

The golangci-lint rules do not depend on the Go binary from the SDK. Without the dependency Bazel include the binary in the execution directory, resulting in the following error:

level=warning msg="Failed to discover go env: failed to run 'go env': exec: \"go\": executable file not found in $PATH"
level=error msg="Running error: context loading failed: failed to load program with go/packages: couldn't exec 'go [list -e -json -compiled -test=true -export=false -deps=true -find=false -- ./cmd/... ./internal/...]': exec: \"go\": executable file not found in $PATH *exec.Error"

By adding depset([sdk.go]) to the transitive dependencies list the Go binary is added to execution directory and everything is happy.

https://github.com/atlassian/bazel-tools/blob/02472d814d1867de2ad75801760732c9e595c9d9/golangcilint/def.bzl#L27-L30