"Cannot resolve symbol" in package import
已完成
I am just getting started with Go, with a new private module that has a dependency on the
github.com/timescale/promscale
go get github.com/timescale/promscale@0.6.2 + go mod tidy worked fine from the command line, and generated the go.mod below.
In the IDE however imported packages from that module are flagged with a "Cannot find symbol xxx" error
import (
"fmt"
"github.com/timescale/promscale/pkg/version"
)
If I open go.mod in Goland then the line below
require github.com/timescale/promscale v0.0.0-20211012192453-b648bcd6ee27
is flagged with a "Missing dependency" error.
Using Sync dependencies (either in the source file, or in go.mod) gives me a "finishied successfully" message, but the errors are still there.
What am I missing?
go.mod:
module acme.com/prommeter
go 1.17
require github.com/timescale/promscale v0.0.0-20211012192453-b648bcd6ee27
require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
...
github.com/uber/jaeger-client-go v2.29.1+incompatible // indirect
...
)
请先登录再写评论。
I've reproduced your steps and got a bit different results:
After these steps, you should get go list -m -json -mod=mod all execution by the IDE and it fails with the following error:
It means that semantic import versioning is not followed in k8s.io/client-go dependency. You can get the same error from the terminal by executing go list -m -json -mod=mod all.
However, there is a workaround. You can use replace directive in your go.mod file and specify the semver version in the right way:
After that, execute Sync Go Module again and go list -m -json -mod=mod all returns your dependencies and resolve them inside the IDE.
As you can see, the same approach is applied inside go.mod file for timescale/promscale project and prometheus/prometheus dependency.
If you did not get invalid version: +incompatible suffix not allowed error, please let me know and we'll investigate it together.
I hope it helps.
Thanks, that works.
I also got dependency resolution working by add this to the Git env variables:
GOFLAGS=-e
All my problems got fixed by adding the env var “GOFLAGS=-e” aswell, thank you very much Franck