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

cmd/go: mod vendor modules.txt sort order is inconsitent between linux and freebsd #34538

Closed
pgier opened this issue Sep 25, 2019 · 6 comments
Closed

Comments

@pgier
Copy link

@pgier pgier commented Sep 25, 2019

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

$ go version
go version go1.13 freebsd/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
GO111MODULE="on"                                                                                                                                                                   
GOARCH="amd64"                                                                           
GOBIN=""
GOCACHE="/home/ec2-user/.cache/go-build"
GOENV="/home/ec2-user/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="freebsd"
GONOPROXY=""
GONOSUMDB=""
GOOS="freebsd"
GOPATH="/home/ec2-user/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/home/ec2-user/go1.13"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/home/ec2-user/go1.13/pkg/tool/freebsd_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/home/ec2-user/go/src/github.com/prometheus/node_exporter/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=/tmp/go-build431750408=/tmp/go-build -gno-record-gcc-switches"
e

What did you do?

Ran go mod vendor on freebsd.

What did you expect to see?

vendor/modules.txt should not be modified

What did you see instead?

vendor/modules.txt was modified to sort in a different order from the committed version

@pgier

This comment has been minimized.

Copy link
Author

@pgier pgier commented Sep 25, 2019

Providing some more information here. There appears to be a difference in the sorting order of vendor/modules.txt between linux and freebsd.

Freebsd uses pure alpha ordering and linux takes the number of path components into account

 github.com/prometheus/procfs
 github.com/prometheus/procfs/bcache
+github.com/prometheus/procfs/internal/fs
+github.com/prometheus/procfs/internal/util
 github.com/prometheus/procfs/nfs
 github.com/prometheus/procfs/sysfs
 github.com/prometheus/procfs/xfs
-github.com/prometheus/procfs/internal/fs
-github.com/prometheus/procfs/internal/util

From the diff excerpt you can see that bsd is trying to sort procfs/internal before procfs/nfs. However, running on linux the procfs/internal packages are placed later, I'm guessing because there are 5 path components instead of 4.

@ALTree ALTree changed the title go mod vendor modules.txt sort order is inconsitent between linux and freebsd cmd/go: mod vendor modules.txt sort order is inconsitent between linux and freebsd Sep 26, 2019
@ALTree ALTree added this to the Go1.14 milestone Sep 26, 2019
@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Sep 27, 2019

@pgier, want to send a fix? Should be a pretty easy one.
(https://golang.org/doc/contribute.html)

@pgier

This comment has been minimized.

Copy link
Author

@pgier pgier commented Sep 27, 2019

Yeah, I can git it a shot. Which way is the right behaviour? The bsd way (pure alpha) seems better to me because it would group together packages with their subpackages, but changing the linux version will probably affect more people, and I'm not sure if there is a specific reason it was done that way.

@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Sep 27, 2019

Probably we should sort lexically by path. (That is: use the same order that sort.Strings would produce for the paths.)

@pgier

This comment has been minimized.

Copy link
Author

@pgier pgier commented Sep 27, 2019

Testing this further it seem to be a difference between go 1.12 and 1.13. I had been using 1.12 on Linux when I thought I was using 1.13. Sorry for the faulty bug report!

@pgier pgier closed this Sep 27, 2019
@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Sep 27, 2019

Oh, yep! There it is: https://golang.org/cl/174527.

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