I tried blowing away my entire ~/go tree to be sure.  Starting from a fresh 
checkout (outside the ~/go tree), and a fresh checkout and go mod init ..., 
here's what the build does:

$ go build ./...
go: downloading github.com/go-kit/kit v0.5.1-0.20170917202734-0d313fb5fb3a
*go: downloading github.com/prometheus/common 
v0.0.0-20170908161822-2f17f4a9d485*
go: downloading gopkg.in/alecthomas/kingpin.v2 v2.2.5
go: finding github.com/prometheus/client_golang v1.2.1
go: downloading github.com/prometheus/client_golang v1.2.1
go: finding github.com/aperum/nrpe latest
*go: extracting github.com/prometheus/common 
v0.0.0-20170908161822-2f17f4a9d485*
go: downloading github.com/pkg/errors v0.8.1-0.20170910134614-2b3a18b5f0fb
go: extracting gopkg.in/alecthomas/kingpin.v2 v2.2.5
go: downloading github.com/alecthomas/units 
v0.0.0-20151022065526-2efee857e7cf
go: downloading github.com/alecthomas/template 
v0.0.0-20160405071501-a0175ee3bccc
go: downloading github.com/aperum/nrpe v0.0.0-20170524093721-53d9ca02dfca
go: extracting github.com/alecthomas/units 
v0.0.0-20151022065526-2efee857e7cf
go: extracting github.com/pkg/errors v0.8.1-0.20170910134614-2b3a18b5f0fb
go: extracting github.com/alecthomas/template 
v0.0.0-20160405071501-a0175ee3bccc
go: extracting github.com/prometheus/client_golang v1.2.1
go: extracting github.com/go-kit/kit v0.5.1-0.20170917202734-0d313fb5fb3a
go: extracting github.com/aperum/nrpe v0.0.0-20170524093721-53d9ca02dfca
go: downloading github.com/go-stack/stack v1.6.0
go: downloading github.com/go-logfmt/logfmt v0.3.0
go: extracting github.com/go-logfmt/logfmt v0.3.0
go: extracting github.com/go-stack/stack v1.6.0
go: downloading gopkg.in/alecthomas/kingpin.v2 v2.2.6
go: downloading github.com/go-kit/kit v0.9.0
go: downloading github.com/prometheus/procfs v0.0.5
go: downloading github.com/golang/protobuf v1.3.2
go: downloading github.com/cespare/xxhash/v2 v2.1.0
*go: downloading github.com/prometheus/common v0.7.0*
go: downloading github.com/prometheus/client_model 
v0.0.0-20190812154241-14fe0d1b01d4
go: extracting gopkg.in/alecthomas/kingpin.v2 v2.2.6
go: extracting github.com/prometheus/procfs v0.0.5
go: extracting github.com/cespare/xxhash/v2 v2.1.0
go: extracting github.com/go-kit/kit v0.9.0
go: extracting github.com/prometheus/client_model 
v0.0.0-20190812154241-14fe0d1b01d4
go: downloading github.com/alecthomas/units 
v0.0.0-20190717042225-c3de453c63f4
go: downloading github.com/alecthomas/template 
v0.0.0-20190718012654-fb15b899a751
*go: extracting github.com/prometheus/common v0.7.0*
go: downloading github.com/beorn7/perks v1.0.1
go: extracting github.com/golang/protobuf v1.3.2
go: downloading github.com/pkg/errors v0.8.1
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.1
go: downloading github.com/go-logfmt/logfmt v0.4.0
go: extracting github.com/alecthomas/units 
v0.0.0-20190717042225-c3de453c63f4
go: extracting github.com/go-logfmt/logfmt v0.4.0
go: extracting github.com/matttproud/golang_protobuf_extensions v1.0.1
go: extracting github.com/pkg/errors v0.8.1
go: extracting github.com/alecthomas/template 
v0.0.0-20190718012654-fb15b899a751
go: extracting github.com/beorn7/perks v1.0.1
go: finding github.com/go-kit/kit v0.9.0
*go: finding github.com/prometheus/common v0.7.0*
go: finding gopkg.in/alecthomas/kingpin.v2 v2.2.6
go: finding github.com/go-logfmt/logfmt v0.4.0
go: finding github.com/pkg/errors v0.8.1
go: finding github.com/prometheus/client_model 
v0.0.0-20190812154241-14fe0d1b01d4
go: finding github.com/beorn7/perks v1.0.1
go: finding github.com/cespare/xxhash/v2 v2.1.0
go: finding github.com/golang/protobuf v1.3.2
go: finding github.com/alecthomas/template 
v0.0.0-20190718012654-fb15b899a751
go: finding github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4
go: finding github.com/matttproud/golang_protobuf_extensions v1.0.1
go: finding github.com/prometheus/procfs v0.0.5
# github.com/RobustPerception/nrpe_exporter
./nrpe_exporter.go:124:37: cannot use &allowedLevel (type 
*promlog.AllowedLevel) as type *promlog.Config in argument to flag.AddFlags
./nrpe_exporter.go:128:23: cannot use allowedLevel (type 
promlog.AllowedLevel) as type *promlog.Config in argument to promlog.New

So it seems to be downloading both the old versions of packages as they 
were in the initial go.mod, *and* the newer ones.  Here is how go.mod 
changes:

--- go.mod.orig 2019-11-27 22:43:06.884601059 +0000
+++ go.mod 2019-11-27 22:43:20.733075672 +0000
@@ -3,13 +3,15 @@
 go 1.13

 require (
- github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc
- github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf
- github.com/go-kit/kit v0.5.1-0.20170917202734-0d313fb5fb3a
- github.com/go-logfmt/logfmt v0.3.0
- github.com/go-stack/stack v1.6.0
+ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
+ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4
+ github.com/aperum/nrpe v0.0.0-20170524093721-53d9ca02dfca
+ github.com/go-kit/kit v0.9.0
+ github.com/go-logfmt/logfmt v0.4.0
+ github.com/go-stack/stack v1.8.0
  github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515
- github.com/pkg/errors v0.8.1-0.20170910134614-2b3a18b5f0fb
- github.com/prometheus/common v0.0.0-20170908161822-2f17f4a9d485
- gopkg.in/alecthomas/kingpin.v2 v2.2.5
+ github.com/pkg/errors v0.8.1
+ github.com/prometheus/client_golang v1.2.1
+ github.com/prometheus/common v0.7.0
+ gopkg.in/alecthomas/kingpin.v2 v2.2.6
 )

Almost every package gets a new version.

"go mod tidy" changes it again, but still brings everything up to latest:

--- go.mod.orig 2019-11-27 22:43:06.884601059 +0000
+++ go.mod 2019-11-27 22:49:49.218179240 +0000
@@ -3,13 +3,10 @@
 go 1.13

 require (
- github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc
- github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf
- github.com/go-kit/kit v0.5.1-0.20170917202734-0d313fb5fb3a
- github.com/go-logfmt/logfmt v0.3.0
- github.com/go-stack/stack v1.6.0
- github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515
- github.com/pkg/errors v0.8.1-0.20170910134614-2b3a18b5f0fb
- github.com/prometheus/common v0.0.0-20170908161822-2f17f4a9d485
- gopkg.in/alecthomas/kingpin.v2 v2.2.5
+ github.com/aperum/nrpe v0.0.0-20170524093721-53d9ca02dfca
+ github.com/go-kit/kit v0.9.0
+ github.com/prometheus/client_golang v1.2.1
+ github.com/prometheus/common v0.7.0
+ github.com/stretchr/testify v1.4.0 // indirect
+ gopkg.in/alecthomas/kingpin.v2 v2.2.6
 )



I've re-read the blog posting here 
<https://blog.golang.org/migrating-to-go-modules> on changing to modules.  
It says:

*go mod init creates a new go.mod file and automatically imports 
dependencies from Godeps.json, Gopkg.lock, or a number of other supported 
formats 
<https://go.googlesource.com/go/+/362625209b6cd2bc059b6b0a67712ddebab312d9/src/cmd/go/internal/modconv/modconv.go#9>.*

*...*

*This is a good time to pause and run go build ./... and go test 
./... before continuing. Later steps may modify your go.mod file*

But what I'm finding is that the "go build ./..." step itself is modifying 
go.mod, and that's what's confusing me.

A separate wiki page 
<https://github.com/golang/go/wiki/Modules#version-selection> talks about 
"minimal version selection" algorithm.  Starting with the initial go.mod, 
"go list -m all" doesn't mention the newer versions:

$ go list -m all
go: finding github.com/alecthomas/template 
v0.0.0-20160405071501-a0175ee3bccc
go: finding github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf
go: finding github.com/go-kit/kit v0.5.1-0.20170917202734-0d313fb5fb3a
go: finding github.com/go-logfmt/logfmt v0.3.0
go: finding github.com/go-stack/stack v1.6.0
go: finding github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515
go: finding github.com/pkg/errors v0.8.1-0.20170910134614-2b3a18b5f0fb
*go: finding github.com/prometheus/common 
v0.0.0-20170908161822-2f17f4a9d485*
go: finding gopkg.in/alecthomas/kingpin.v2 v2.2.5
github.com/RobustPerception/nrpe_exporter
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf
github.com/go-kit/kit v0.5.1-0.20170917202734-0d313fb5fb3a
github.com/go-logfmt/logfmt v0.3.0
github.com/go-stack/stack v1.6.0
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515
github.com/pkg/errors v0.8.1-0.20170910134614-2b3a18b5f0fb
*github.com/prometheus/common v0.0.0-20170908161822-2f17f4a9d485*
gopkg.in/alecthomas/kingpin.v2 v2.2.5

Therefore, if there is some nested dependency which is forcing newer 
versions of packages to be picked up, I can't work out what it is.

Thanks for any clues!

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/185cb200-8d1f-46b2-a942-f317fefa787e%40googlegroups.com.

Reply via email to