Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/vgo: require in `vgo.mod` should list directly dependences first? #26103

Closed
morlay opened this issue Jun 28, 2018 · 3 comments

Comments

@morlay
Copy link

commented Jun 28, 2018

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

go version go1.10.3 darwin/amd64 vgo:2018-02-20.1

db7cbb0 (HEAD -> master, origin/master, origin/HEAD) cmd/go/internal/modfetch/gitrepo: fix fetch of tags

Does this issue reproduce with the latest release?

Yes

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

GOARCH="amd64"
GOBIN="/Users/morlay/Go/bin"
GOCACHE="/Users/morlay/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/morlay/Go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.10.3/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.10.3/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
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/l1/sr0pz92x5n7fwmdjszmjfcrc0000gn/T/go-build825814425=/tmp/go-build -gno-record-gcc-switches -fno-common"
VGOMODROOT="/Users/morlay/Go/src/github.com/morlay/vgo-require-local-first"

What did you do?

There a mini repo to should the issue:
https://github.com/morlay/vgo-require-local-first

When use vgo run main.go

vgo: resolving import "github.com/go-courier/loaderx"
vgo: finding github.com/go-courier/loaderx latest
vgo: finding github.com/go-courier/loaderx (latest)
vgo: adding github.com/go-courier/loaderx v0.0.0-20180627072405-a228eebb5123
vgo: resolving import "github.com/stretchr/testify/assert"
vgo: finding github.com/stretchr/testify/assert latest
vgo: finding github.com/stretchr/testify (latest)
vgo: adding github.com/stretchr/testify v1.2.2

What did you expect to see?

the package require it directly. then expect to got github.com/stretchr/testify in go.mod.

module github.com/morlay/vgo-require-local-first

require (
     github.com/go-courier/loaderx v0.0.0-20180627072405-a228eebb5123
     github.com/stretchr/testify v1.2.2
)

What did you see instead?

module github.com/morlay/vgo-require-local-first

require github.com/go-courier/loaderx v0.0.0-20180627072405-a228eebb5123

because github.com/go-courier/loaderx have the same dependence github.com/stretchr/testify@v1.2.2

@gopherbot gopherbot added this to the vgo milestone Jun 28, 2018

@mwf

This comment has been minimized.

Copy link

commented Jul 2, 2018

Looks like a duplicate of #25969

cc @oiooj

@morlay

This comment has been minimized.

Copy link
Author

commented Jul 3, 2018

@mwf.
Yes. it is a duplicate about direct imports.
And I think go.mod should only contains directly-used modules.

I have a project only direct require github.com/stretchr/testify.
But when I use vgo mod -sync, vgo will list indirectly-used modules github.com/davecgh/go-spew and github.com/pmezard/go-difflib too (vgo test and vgo build have the same results)
It makes me confused.
And after go.sum file generated, indirectly-used modules is unnecessary in go.mod file.

module x

require (
	github.com/davecgh/go-spew v1.1.0
	github.com/pmezard/go-difflib v1.0.0
	github.com/stretchr/testify v1.2.2
)

How do you think about omitting indirectly-used modules in go.mod?

@mwf

This comment has been minimized.

Copy link

commented Jul 4, 2018

Ah, it's OK.
There was an old issue about it where Russ answered in details.

In a nutshell, it happens only because github.com/stretchr/testify doesn't have a go.mod file. As soon as go.mod is introduced there, vgo mod -sync will remove it from your project.
Until then it's essential to have the version pinned somewhere.

So it works as designed.

@morlay morlay closed this Jul 5, 2018

@golang golang locked and limited conversation to collaborators Jul 5, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants
You can’t perform that action at this time.