golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.99k stars 17.67k forks source link

go mod why fails to find import graph for github.com/golang/lint #32412

Closed jaloren closed 5 years ago

jaloren commented 5 years ago

What version of Go are you using (go version)?

go1.12.5 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
GOARCH="amd64"
GOBIN="/Volumes/Repositories/go/bin"
GOCACHE="/Users/jlorenzini/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Volumes/Repositories/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/jlorenzini/repos/dep/example.com/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/8w/7ndx_j6s36x9hm9dns67j21s3hynqn/T/go-build128423874=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I have the following go.mod:

module example.com

require (
    github.com/BurntSushi/toml v0.3.1 // indirect
    github.com/Jeffail/gabs v1.1.1 // indirect
    github.com/SAP/go-hdb v0.13.1 // indirect
    github.com/SermoDigital/jose v0.9.1 // indirect
    github.com/StackExchange/wmi v0.0.0-20181212234831-e0a55b97c705 // indirect
    github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect
    github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect
    github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da // indirect
    github.com/armon/go-radix v0.0.0-20170727155443-1fca145dffbc // indirect
    github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf // indirect
    github.com/aws/aws-lambda-go v1.8.2 // indirect
    github.com/aws/aws-sdk-go v1.13.54 // indirect
    github.com/beevik/ntp v0.2.0 // indirect
    github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 // indirect
    github.com/bgentry/speakeasy v0.1.0 // indirect
    github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 // indirect
    github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
    github.com/cenkalti/backoff v2.0.0+incompatible // indirect
    github.com/coreos/go-systemd v0.0.0-20180202092358-40e2722dffea // indirect
    github.com/denisenkom/go-mssqldb v0.0.0-20181014144952-4e0d7dc8888f // indirect
    github.com/docker/distribution v0.0.0-20180522175653-f0cc92778478 // indirect
    github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
    github.com/dsnet/compress v0.0.1 // indirect
    github.com/duosecurity/duo_api_golang v0.0.0-20181024123116-92fea9203dbc // indirect
    github.com/f5devcentral/go-bigip v0.0.0-20180523221152-f965982c0fc1 // indirect
    github.com/fatih/color v1.7.0 // indirect
    github.com/fatih/structs v1.0.0 // indirect
    github.com/fsouza/go-dockerclient v1.3.1 // indirect
    github.com/go-ini/ini v1.41.0 // indirect
    github.com/go-ole/go-ole v1.2.2 // indirect
    github.com/go-sql-driver/mysql v1.4.1 // indirect
    github.com/go-yaml/yaml v2.1.0+incompatible // indirect
    github.com/gocql/gocql v0.0.0-20181023221251-2127b8d1a772 // indirect
    github.com/gofrs/uuid v3.2.0+incompatible // indirect
    github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
    github.com/google/go-github v17.0.0+incompatible // indirect
    github.com/google/go-querystring v1.0.0 // indirect
    github.com/google/uuid v1.1.1 // indirect
    github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect
    github.com/gotestyourself/gotestyourself v2.1.0+incompatible // indirect
    github.com/hashicorp/consul v1.1.0 // indirect
    github.com/hashicorp/go-cleanhttp v0.0.0-20171218145408-d5fe4b57a186 // indirect
    github.com/hashicorp/go-hclog v0.0.0-20181001195459-61d530d6c27f // indirect
    github.com/hashicorp/go-immutable-radix v1.0.0 // indirect
    github.com/hashicorp/go-memdb v0.0.0-20180223233045-1289e7fffe71 // indirect
    github.com/hashicorp/go-msgpack v0.0.0-20150518234257-fa3f63826f7c // indirect
    github.com/hashicorp/go-multierror v1.0.0 // indirect
    github.com/hashicorp/go-plugin v0.0.0-20181004024435-314501b665e0 // indirect
    github.com/hashicorp/go-rootcerts v0.0.0-20160503143440-6bb64b370b90 // indirect
    github.com/hashicorp/go-sockaddr v0.0.0-20180320115054-6d291a969b86 // indirect
    github.com/hashicorp/hcl v1.0.0 // indirect
    github.com/hashicorp/memberlist v0.1.0 // indirect
    github.com/hashicorp/serf v0.8.1 // indirect
    github.com/hashicorp/vault v0.9.1 // indirect
    github.com/heroku/docker-registry-client v0.0.0-20171019183014-fd2fe8034968 // indirect
    github.com/inconshreveable/mousetrap v1.0.0 // indirect
    github.com/jefferai/jsonx v0.0.0-20160721235117-9cc31c3135ee // indirect
    github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect
    github.com/jmoiron/sqlx v1.2.0 // indirect
    github.com/jtolds/gls v4.2.1+incompatible // indirect
    github.com/keybase/go-crypto v0.0.0-20181017165231-e696c8039bba // indirect
    github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
    github.com/kr/pretty v0.1.0 // indirect
    github.com/mattn/go-colorable v0.0.9 // indirect
    github.com/mattn/go-isatty v0.0.3 // indirect
    github.com/matttproud/golang_protobuf_extensions v1.0.0 // indirect
    github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
    github.com/mgutz/logxi v0.0.0-20161027140823-aebf8a7d67ab // indirect
    github.com/mholt/archiver v3.1.1+incompatible // indirect
    github.com/miekg/dns v1.0.14 // indirect
    github.com/mitchellh/cli v0.0.0-20180414170447-c48282d14eba // indirect
    github.com/mitchellh/copystructure v0.0.0-20170525013902-d23ffcb85de3 // indirect
    github.com/mitchellh/go-homedir v0.0.0-20180523094522-3864e76763d9 // indirect
    github.com/mitchellh/mapstructure v1.1.2 // indirect
    github.com/mitchellh/reflectwalk v0.0.0-20170726202117-63d60e9d0dbc // indirect
    github.com/montanaflynn/stats v0.5.0 // indirect
    github.com/newrelic/infra-integrations-sdk v3.0.2+incompatible // indirect
    github.com/nwaples/rardecode v1.0.0 // indirect
    github.com/onrik/logrus v0.2.2 // indirect
    github.com/opentracing/opentracing-go v1.1.0 // indirect
    github.com/ory/dockertest v3.3.2+incompatible // indirect
    github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c // indirect
    github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
    github.com/pierrec/lz4 v2.0.5+incompatible // indirect
    github.com/posener/complete v1.1.1 // indirect
    github.com/prometheus/client_golang v0.8.0 // indirect
    github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5 // indirect
    github.com/prometheus/common v0.0.0-20180518154759-7600349dcfe1 // indirect
    github.com/prometheus/procfs v0.0.0-20180408092902-8b1c2da0d56d // indirect
    github.com/ryanuber/go-glob v0.0.0-20170128012129-256dc444b735 // indirect
    github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect
    github.com/sethgrid/pester v0.0.0-20180430140037-03e26c9abbbf // indirect
    github.com/shirou/gopsutil v2.18.10+incompatible // indirect
    github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect
    github.com/sirupsen/logrus v1.3.0 // indirect
    github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304 // indirect
    github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c // indirect
    github.com/spf13/cobra v0.0.3 // indirect
    github.com/spf13/pflag v1.0.3 // indirect
    github.com/stretchr/testify v1.3.0 // indirect
    github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
    golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25 // indirect
    golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4 // indirect
    golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect
    golang.org/x/sys v0.0.0-20190228124157-a34e9553db1e // indirect
    google.golang.org/grpc v1.16.0 // indirect
    gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect
    gopkg.in/couchbase/gocb.v1 v1.6.1 // indirect
    gopkg.in/couchbase/gocbcore.v7 v7.1.13 // indirect
    gopkg.in/couchbaselabs/gocbconnstr.v1 v1.0.2 // indirect
    gopkg.in/couchbaselabs/gojcbmock.v1 v1.0.3 // indirect
    gopkg.in/couchbaselabs/jsonx.v1 v1.0.0 // indirect
    gopkg.in/ini.v1 v1.41.0 // indirect
    gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce // indirect
    gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
    gopkg.in/ory-am/dockertest.v3 v3.3.2 // indirect
    gopkg.in/vmihailenco/msgpack.v2 v2.9.1 // indirect
    gopkg.in/yaml.v2 v2.2.2 // indirect
    labix.org/v2/mgo v0.0.0-20140701140051-000000000287 // indirect
    launchpad.net/gocheck v0.0.0-20140225173054-000000000087 // indirect
)

If run go get -u, it fails with the following error:

go: github.com/golang/lint@v0.0.0-20190409202823-959b441ac422: parsing go.mod: unexpected module path "golang.org/x/lint"

This is because of https://github.com/golang/go/issues/30831. So then I was curious about why go get was trying to update so I did the following

jlorenzini@jlorenzini-mb example.com$ go mod why -m github.com/golang/lint
# github.com/golang/lint
(main module does not need module github.com/golang/lint)

Note it does not matter what go source code you have in the repo.

What did you expect to see?

Either go mod why says its not in use therefore go get -u shouldn't have been trying to upgrade it or go get -u does not try to update it because go mod why says its not in use.

What did you see instead?

go get -u tried to upgrade github.com/golang/lint but go mod why says my main module does not have a dependency on that module.

jaloren commented 5 years ago

I was able to narrow this down using go mod graph. Looks like the issue is related to grpc. Grpc is a transitive dependency. and if i do a go mod why on that it also says the main module does not depend on it.

jlorenzini@jlorenzini-mb operator$ go mod graph | grep lint
google.golang.org/grpc@v1.16.0 github.com/golang/lint@v0.0.0-20180702182130-06c8688daad7
google.golang.org/grpc@v1.16.0 golang.org/x/lint@v0.0.0-20180702182130-06c8688daad7
jlorenzini@jlorenzini-mb operator$ go mod why google.golang.org/grpc@v1.16.0
go: finding github.com/golang/protobuf/proto/testdata latest
go: finding github.com/golang/protobuf/proto latest
# google.golang.org/grpc@v1.16.0
(main module does not need package google.golang.org/grpc@v1.16.0)
bcmills commented 5 years ago

Duplicate of #27900

bcmills commented 5 years ago

(Also note that if you want to answer the question “why this module?” rather than “why this package?”, you want go mod why -m.)

bcmills commented 5 years ago

And #26902 should make get -u much less aggressive about upgrading things that aren't actually in your package-import graph.