Skip to content

cmd/go: go mod fails to find direct dependencies #28629

Closed
@jeanbza

Description

@jeanbza

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

$ go version
go version go1.11.2 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
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/deklerk/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/deklerk/workspace/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=""
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/lk/zs4m7sv12mq2vzk_wfn2tfvm00h16k/T/go-build259032920=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

git clone https://github.com/golang/oauth2.git
cd oauth2/google
go mod init
go mod tidy

What did you expect to see?

A go.mod file with,

module golang.org/x/oauth2/google

require (
	cloud.google.com/go/compute/metadata v0.0.0-20181107005212-dafb9c8d8707
	golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288
	google.golang.org/appengine v1.3.0
)

And a populated go.sum.

What did you see instead?

module golang.org/x/oauth2/google

And an empty go.sum.

Note: another weirdness is that when I run go.vendor, I get:

$ go mod vendor
go: finding google.golang.org/appengine/urlfetch latest
go: finding golang.org/x/oauth2 latest
go: finding golang.org/x/oauth2/internal latest
go: finding golang.org/x/oauth2/jws latest
go: finding golang.org/x/oauth2/jwt latest
go: finding cloud.google.com/go/compute/metadata latest
go: no dependencies to vendor
$ cat go.mod
module golang.org/x/oauth2/google

require (
	cloud.google.com/go/compute/metadata v0.0.0-20181107005212-dafb9c8d8707 // indirect
	golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288 // indirect
	google.golang.org/appengine v1.3.0 // indirect
)

It found several dependencies, but it labeled them indirect. That's odd, because golang.org/x/oauth2/google directly depends on all of these. Furthermore, go mod vendor then goes on to state no dependencies to vendor immediately after it just vendored a bunch of things.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions