go version)?go1.11 linux/amd64
Yes.
go env)?GOARCH="amd64"
GOBIN=""
GOCACHE="/home/opennota/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/opennota/gocode"
GOPROXY=""
GORACE=""
GOROOT="/home/opennota/go"
GOTMPDIR=""
GOTOOLDIR="/home/opennota/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build560781445=/tmp/go-build -gno-record-gcc-switches"
~/gocode/src/gitlab.com/opennota/fb2index $ GO111MODULE=on go mod tidy
go: finding google.golang.org/appengine/cloudsql latest
~/gocode/src/gitlab.com/opennota/fb2index $ cat go.mod
module gitlab.com/opennota/fb2index
require (
github.com/go-sql-driver/mysql v1.4.0 // indirect
github.com/jmoiron/sqlx v0.0.0-20180614180643-0dae4fefe7c0
github.com/lib/pq v1.0.0 // indirect
github.com/mattn/go-sqlite3 v1.9.0
golang.org/x/text v0.3.0
google.golang.org/appengine v1.1.0 // indirect
)
~/gocode/src/gitlab.com/opennota/fb2index $ GO111MODULE=on go mod why google.golang.org/appengine
go: finding github.com/golang/protobuf/proto latest
go: finding golang.org/x/net/context latest
go: finding golang.org/x/net latest
# google.golang.org/appengine
(main module does not need package google.golang.org/appengine)
go mod why shows why go mod tidy added google.golang.org/appengine to go.mod.
(main module does not need package google.golang.org/appengine)
In order to track this down, we're probably going to need an input that reproduces it.
Can you share a (hopefully minimal) set of Go source files that reproduce the problem?
The code is here: https://gitlab.com/opennota/fb2index
I can try to minimize it tomorrow.
google.golang.org/appengine seems to be coming from /home/opennota/gocode/pkg/mod/github.com/go-sql-driver/[email protected]/appengine.go, but go mod why doesn't see this. go-sql-driver/mysql is itself an indirect dependency.
Thanks, that's at least a good start. I assume it still reproduces at the current commit (ee9d8829)?
Yes.
Here is a simpler reproducer:
package a
import _ "github.com/jmoiron/sqlx"
go mod init example
go mod tidy
cat go.mod
go mod why google.golang.org/appengine
Looks like I was doing it wrong. go mod why -m google.golang.org/appengine does show why the module is in go.mod. Without -m it doesn't. go help mod why says that
Why shows a shortest path in the import graph from the main module to
each of the listed packages. If the -m flag is given, why treats the
arguments as a list of modules and finds a path to any package in each
of the modules.
The main module depends on google.golang.org/appengine/cloudsql, not on google.golang.org/appengine.
Thanks for the explanation. It's always good to find out what went wrong even when things are working as documented: if we notice a pattern we can at least improve the documentation.
Perhaps go mod why could detect when it is given a name present in go.mod without -m and print a warning.
Most helpful comment
The code is here: https://gitlab.com/opennota/fb2index
I can try to minimize it tomorrow.
google.golang.org/appengineseems to be coming from/home/opennota/gocode/pkg/mod/github.com/go-sql-driver/[email protected]/appengine.go, butgo mod whydoesn't see this.go-sql-driver/mysqlis itself an indirect dependency.