Build constraints exclude all the Go files in ...

已完成

MacbookPro, Intel.

Loaded a small project into GoLand for the first time.  A generated protobuf file, 'chargen_proto_grpc.pb.go' has a healthy redline under one of the generated imports:

import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)

That `grpc` import, and only that one, is underlined in red with the mouse-over comment of: "Build constraints exclude all the Go files in '/usr/local/Cellar/go/1.17.1/libexec/src/google.golang.org/grpc'"

I mention that it's generated because making local edits to this file as a possible work around isn't going to be practical.

The other two grpc related imports (codes, status) generate no such error and the rest of the code in the file that depends on code and status resolve fine.

GOROOT as per GoLand is (Go 1.17.1)  "/usr/local/Cellar/go/1.17.1/libexec"
GOPATH as per GoLand is the default "/Users/myuserid/go"

I've tried changing the GOROOT and GOPATH around (both point to my /User/myuserid/go dir; both point to the brew installed 'Cellar' dir; etc) with no change in behavior.

What am I doing wrong?

Thanks!

评论操作 固定链接
正式评论

I can't reproduce it so far. Could you please navigate to grpc library under External Libraries, open any file and attach a screenshot?

What version of GoLand are you using (GoLand | About GoLand)? Have you tried to clean Go modules cache (go clean --modcache) and synchronize the imports again?

评论操作 固定链接

So, looking at the External Libraries listing pointed me to the problem.  Apparently, I had a stale empty grpc directory in the module dirs under GOROOT.  The 'real' stuff was under GOPATH.  Once I deleted the empty dirs under GOROOT, GoLand got happy again.

Thanks for dropping the hint that got me to the solution!

3

请先登录再写评论。