go-tools: Build errors when Go modules are enabled
In https://github.com/grpc/grpc-go/pull/2281, I converted grpc-go to support the new modules in Go. However, without a workaround, staticcheck gave the following error:
$ staticcheck -ignore '
> internal/transport/transport_test.go:SA2002
> benchmark/benchmain/main.go:SA1019
> stats/stats_test.go:SA1019
> test/end2end_test.go:SA1019
> balancer_test.go:SA1019
> balancer.go:SA1019
> clientconn_test.go:SA1019
> internal/transport/handler_server_test.go:SA1019
> internal/transport/handler_server.go:SA1019
> ' ./...
.../go/pkg/mod/github.com/golang/mock@v1.1.1/gomock/controller.go:60:2: could not import golang.org/x/net/context (cannot find package "golang.org/x/net/context" in any of:
.../go111/go/src/golang.org/x/net/context (from $GOROOT)
.../go/src/golang.org/x/net/context (from $GOPATH))
couldn't load packages due to errors: google.golang.org/genproto/googleapis/rpc/status, github.com/golang/protobuf/ptypes/any, ./channelz/service and 21 more
The workaround: make a symlink in $GOPATH/src for every package needed from $GOPATH/pkg/mod (see vet.sh immediately before running staticcheck).
I found this related issue: https://github.com/golang/go/issues/26504. However, it was resolved before the 1.11 release and was marked as a release blocker, so my best guess is it was incorporated in the release. The advice in that issue is to switch to golang.org/x/tools/go/packages from go/build. Maybe that will fix all related issues?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 17 (8 by maintainers)
Commits related to this issue
- Initial go.mod definition using go mod init and go mod tidy * Issue #135. * Unclear on how to proceed with dep. For now we keep the Gopkg.toml around. * Repopulate vendor folder (some tools still nee... — committed to bpicode/fritzctl by bpicode 6 years ago
- Initial go.mod definition using go mod init and go mod tidy * Issue #135. * Unclear on how to proceed with dep. For now we keep the Gopkg.toml around. * Repopulate vendor folder (some tools still nee... — committed to bpicode/fritzctl by bpicode 6 years ago
- Initial go.mod definition using go mod init and go mod tidy * Issue #135. * Unclear on how to proceed with dep. For now we keep the Gopkg.toml around. * Repopulate vendor folder (some tools still nee... — committed to bpicode/fritzctl by bpicode 6 years ago
Staticcheck supports modules now.