I am trying to run the go list -mod=readonly -m -u -json all
command on the opentelemetry-collector-contrib project.
It fails with the below error:
$ go list -mod=readonly -m -u -json all
go list -m: loading module retractions for github.com/DataDog/datadog-agent/pkg/trace/exportable@v0.0.0-20201016145401-4646cf596b02: no matching versions for query "latest"
go list -m: loading module retractions for github.com/influxdata/line-protocol/v2@v2.0.0-20210428091617-0567a5134992: no matching versions for query "latest"
$ echo $?
1
I am using go 1.16.5:
$ go version
go version go1.16.5 linux/amd64
I have cleaned the go cache with go clean -modcache
with the same result.
I have found both modules https://pkg.go.dev/:
It seems the exact version exists for github.com/DataDog/datadog-agent/pkg/trace/exportable but not for github.com/influxdata/line-protocol, but both report the same error anyway.
I have no clue what golang expects here and how to start troubleshooting the issue.
Can anybody help?
It seems it's a bug (https://github.com/golang/go/issues/45305) due to the introduction of the retract
directive in go.mod
in Go 1.16. In fact if you omit the -m
flag, the command runs fine.
As mentioned in the issue thread, you can add the -e
flag to move on despite errors:
$ go list -mod=readonly -m -u -e -json all
{
"Path": "github.com/open-telemetry/opentelemetry-collector-contrib",
"Main": true,
"Dir": "/Users/me/go/opentelemetry-collector-contrib",
"GoMod": "/Users/me/go/opentelemetry-collector-contrib/go.mod",
"GoVersion": "1.16"
}
... much more
About the -e
flag, go help list
:
The
-e
flag changes the handling of erroneous packages, those that cannot be found or are malformed. [...] With the-e
flag, the list command never prints errors to standard error and instead processes the erroneous packages with the usual printing. Erroneous packages will have a non-empty ImportPath and a non-nil Error field; other information may or may not be missing (zeroed).
The bug is fixed in Go 1.17.