Hi,

you are importing github.com/aperum/nrpe, but you don't vendor it or
mention it in vendor.json.
go mod init synthesizes a go.mod from vendor.json, using all versions you
use there. Note that it doesn't mention nrpe.
You then do a `go build`, which sees an import from a module not mentioned
in `go.mod`, assumes you added a new dependency, and tries to add that to
`go.mod`. This then causes it to pull in the newest versions of *its*
dependencies (as it doesn't have a g `go.mod` itself).
You should update your vendor.json to start with. And/or add nrpe manually
to go.mod with a version that suits you.

On Thu, Nov 28, 2019 at 9:08 AM Brian Candler <b.cand...@pobox.com> wrote:

> I got a private reply saying to try "go mod why -m
> github.com/prometheus/common"
>
> Starting with the original go.mod, I get different answers the first and
> second time I run it - by which time, go.mod contents have been updated.
>
> $ go mod why -m github.com/prometheus/common
> go: finding github.com/aperum/nrpe latest
> go: finding github.com/alecthomas/assert latest
> # github.com/prometheus/common
> (main module does not need module github.com/prometheus/common)
>
> $ go mod why -m github.com/prometheus/common
> # github.com/prometheus/common
> github.com/RobustPerception/nrpe_exporter
> github.com/prometheus/common/promlog
>
> Note that the main module (nrpe_exporter.go) *does* require the following:
>
>         "github.com/prometheus/common/promlog"
>         "github.com/prometheus/common/promlog/flag"
>         "github.com/prometheus/common/version"
>
> vendor/vendor.json pins specific versions of prometheus/common/promlog and
> prometheus/common/promlog/flag, but not prometheus/common/version - and
> oddly, prometheus/common/version hasn't been imported into the vendor/
> directory either.  So now I'm starting to suspect that the latest
> prometheus/common/version is being picked up, which in turn is forcing
> refresh of the other dependencies; but this is just an idea, I don't have
> any output from any of the go commands telling me this is what is happening.
>
> I also tried adding -v to go build:
>
> $ go build -n -v -x ./...
> # get https://proxy.golang.org/github.com/@v/list
> # get
> https://proxy.golang.org/github.com/prometheus/client_golang/prometheus/promhttp/@v/list
> # get
> https://proxy.golang.org/github.com/prometheus/client_golang/prometheus/@v/list
> # get https://proxy.golang.org/github.com/prometheus/client_golang/@v/list
> # get https://proxy.golang.org/github.com/prometheus/@v/list
> # get https://proxy.golang.org/github.com/aperum/nrpe/@v/list
> # get https://proxy.golang.org/github.com/aperum/@v/list
> # get https://proxy.golang.org/github.com/aperum/@v/list: 410 Gone
> (0.349s)
> # get
> https://proxy.golang.org/github.com/prometheus/client_golang/prometheus/promhttp/@v/list:
> 410 Gone (0.363s)
> # get
> https://proxy.golang.org/github.com/prometheus/client_golang/prometheus/@v/list:
> 410 Gone (0.363s)
> # get https://proxy.golang.org/github.com/@v/list: 410 Gone (0.364s)
> # get https://proxy.golang.org/github.com/prometheus/client_golang/@v/list:
> 200 OK (0.363s)
> # get https://proxy.golang.org/github.com/aperum/nrpe/@v/list: 200 OK
> (0.353s)
> go: finding github.com/aperum/nrpe latest
> # get https://proxy.golang.org/github.com/aperum/nrpe/@latest
> # get https://proxy.golang.org/github.com/prometheus/@v/list: 410 Gone
> (0.368s)
> # get https://proxy.golang.org/github.com/aperum/nrpe/@latest: 200 OK
> (0.012s)
>
> #
> # github.com/RobustPerception/nrpe_exporter
> #
>
> github.com/RobustPerception/nrpe_exporter
> mkdir -p $WORK/b001/
> cat >$WORK/b001/_gomod_.go << 'EOF' # internal
> package main
> import _ "unsafe"
> //go:linkname __debug_modinfo__ runtime.modinfo
> var __debug_modinfo__ =
> "0w\xaf\f\x92t\b\x02A\xe1\xc1\a\xe6\xd6\x18\xe6path\
> tgithub.com/RobustPerception/nrpe_exporter\nmod\tgithub.com/RobustPerception/nrpe_exporter\t(devel)\t\ndep\tgithub.com/alecthomas/template\tv0.0.0-20190718012654-fb15b899a751\th1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=\ndep\tgithub.com/alecthomas/units\tv0.0.0-20190717042225-c3de453c63f4\th1:Hs82Z41s6SdL1CELW+XaDYmOH4hkBN4/N9og/AsOv7E=\ndep\tgithub.com/aperum/nrpe\tv0.0.0-20170524093721-53d9ca02dfca\th1:2d9vZl6mzbSG+3cr0ghfKvM0nOa15OGkbW1vx+R5+Ww=\ndep\tgithub.com/beorn7/perks\tv1.0.1\th1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=\ndep\tgithub.com/cespare/xxhash/v2\tv2.1.0\th1:yTUvW7Vhb89inJ+8irsUqiWjh8iT6sQPZiQzI6ReGkA=\ndep\tgithub.com/go-kit/kit\tv0.9.0\th1:wDJmvq38kDhkVxi50ni9ykkdUr1PKgqKOoi01fa0Mdk=\ndep\tgithub.com/go-logfmt/logfmt\tv0.4.0\th1:MP4Eh7ZCb31lleYCFuwm0oe4/YGak+5l1vA2NOE80nA=\ndep\tgithub.com/golang/protobuf\tv1.3.2\th1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=\ndep\tgithub.com/matttproud/golang_protobuf_extensions\tv1.0.1\th1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=\ndep\tgithub.com/pkg/errors\tv0.8.1\th1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=\ndep\tgithub.com/prometheus/client_golang\tv1.2.1\th1:JnMpQc6ppsNgw9QPAGF6Dod479itz7lvlsMzzNayLOI=\ndep\tgithub.com/prometheus/client_model\tv0.0.0-20190812154241-14fe0d1b01d4\th1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM=\ndep\tgithub.com/prometheus/common\tv0.7.0\th1:L+1lyG48J1zAQXA3RBX/nG/B3gjlHq0zTt2tlbJLyCY=\ndep\tgithub.com/prometheus/procfs\tv0.0.5\th1:3+auTFlqw+ZaQYJARz6ArODtkaIwtvBTx3N2NehQlL8=\ndep\tgopkg.in/alecthomas/kingpin.v2\tv2.2.6\th1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=\n\xf92C1\x86\x18
> <http://tgithub.com/RobustPerception/nrpe_exporter%5Cnmod%5Ctgithub.com/RobustPerception/nrpe_exporter%5Ct(devel)%5Ct%5Cndep%5Ctgithub.com/alecthomas/template%5Ctv0.0.0-20190718012654-fb15b899a751%5Cth1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=%5Cndep%5Ctgithub.com/alecthomas/units%5Ctv0.0.0-20190717042225-c3de453c63f4%5Cth1:Hs82Z41s6SdL1CELW+XaDYmOH4hkBN4/N9og/AsOv7E=%5Cndep%5Ctgithub.com/aperum/nrpe%5Ctv0.0.0-20170524093721-53d9ca02dfca%5Cth1:2d9vZl6mzbSG+3cr0ghfKvM0nOa15OGkbW1vx+R5+Ww=%5Cndep%5Ctgithub.com/beorn7/perks%5Ctv1.0.1%5Cth1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=%5Cndep%5Ctgithub.com/cespare/xxhash/v2%5Ctv2.1.0%5Cth1:yTUvW7Vhb89inJ+8irsUqiWjh8iT6sQPZiQzI6ReGkA=%5Cndep%5Ctgithub.com/go-kit/kit%5Ctv0.9.0%5Cth1:wDJmvq38kDhkVxi50ni9ykkdUr1PKgqKOoi01fa0Mdk=%5Cndep%5Ctgithub.com/go-logfmt/logfmt%5Ctv0.4.0%5Cth1:MP4Eh7ZCb31lleYCFuwm0oe4/YGak+5l1vA2NOE80nA=%5Cndep%5Ctgithub.com/golang/protobuf%5Ctv1.3.2%5Cth1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=%5Cndep%5Ctgithub.com/matttproud/golang_protobuf_extensions%5Ctv1.0.1%5Cth1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=%5Cndep%5Ctgithub.com/pkg/errors%5Ctv0.8.1%5Cth1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=%5Cndep%5Ctgithub.com/prometheus/client_golang%5Ctv1.2.1%5Cth1:JnMpQc6ppsNgw9QPAGF6Dod479itz7lvlsMzzNayLOI=%5Cndep%5Ctgithub.com/prometheus/client_model%5Ctv0.0.0-20190812154241-14fe0d1b01d4%5Cth1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM=%5Cndep%5Ctgithub.com/prometheus/common%5Ctv0.7.0%5Cth1:L+1lyG48J1zAQXA3RBX/nG/B3gjlHq0zTt2tlbJLyCY=%5Cndep%5Ctgithub.com/prometheus/procfs%5Ctv0.0.5%5Cth1:3+auTFlqw+ZaQYJARz6ArODtkaIwtvBTx3N2NehQlL8=%5Cndep%5Ctgopkg.in/alecthomas/kingpin.v2%5Ctv2.2.6%5Cth1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=%5Cn%5Cxf92C1%5Cx86%5Cx18>
> r\x00\x82B\x10A\x16\xd8\xf2"
> EOF
> cat >$WORK/b001/importcfg << 'EOF' # internal
> # import config
> packagefile
> github.com/aperum/nrpe=/home/ubuntu/.cache/go-build/94/94dbafe6b911cead6a82b65f6813a13a7841b632e2f1d1542dbae22da55c9f66-d
> packagefile
> github.com/go-kit/kit/log=/home/ubuntu/.cache/go-build/32/32be124c4b729b856dadcc18107a3b6a2e815d2759098d45cc4f9de7250bf558-d
> packagefile
> github.com/go-kit/kit/log/level=/home/ubuntu/.cache/go-build/32/321c67b9166aa103cfce5cd6bc0eba5d17639d048f7953fffb85e30a2226f3d5-d
> packagefile
> github.com/prometheus/client_golang/prometheus=/home/ubuntu/.cache/go-build/3f/3fd233112523bf5b5825c83c747c812cfa8b1440918d424a8c683f35a78bfb63-d
> packagefile
> github.com/prometheus/client_golang/prometheus/promhttp=/home/ubuntu/.cache/go-build/d9/d93df1d4b900cdfe2def522d5da770b93809ec1a01453618de31a5743a60fd1c-d
> packagefile
> github.com/prometheus/common/promlog=/home/ubuntu/.cache/go-build/a1/a1a67b5d356d131e4558967de13b0b0125ef325bcfdffee37937803dad737e80-d
> packagefile
> github.com/prometheus/common/promlog/flag=/home/ubuntu/.cache/go-build/06/06fe34f36bac0935f0793bcbd22db2beedbb3bf7213be3002e2af290bea9c6fd-d
> packagefile
> github.com/prometheus/common/version=/home/ubuntu/.cache/go-build/d2/d2665ffaa92b18b01af13148ac8e48def0da7a3d427132aaad0c5fad15391fad-d
> packagefile
> gopkg.in/alecthomas/kingpin.v2=/home/ubuntu/.cache/go-build/16/16be93b771990bca04b445f0e883bd4c207e97f9cb5e2c7be3eb98169c49a5fa-d
> packagefile net=/usr/local/go/pkg/linux_amd64/net.a
> packagefile net/http=/usr/local/go/pkg/linux_amd64/net/http.a
> packagefile os=/usr/local/go/pkg/linux_amd64/os.a
> packagefile time=/usr/local/go/pkg/linux_amd64/time.a
> packagefile runtime=/usr/local/go/pkg/linux_amd64/runtime.a
> EOF
> cd /home/ubuntu/nrpe_exporter
> /usr/local/go/pkg/tool/linux_amd64/compile -o $WORK/b001/_pkg_.a -trimpath
> "$WORK/b001=>" -p main -lang=go1.13 -complete -buildid
> 0fKvaL6612In9ont9l8M/0fKvaL6612In9ont9l8M -goversion go1.13.4 -D ""
> -importcfg $WORK/b001/importcfg -pack -c=2 ./nrpe_exporter.go
> $WORK/b001/_gomod_.go
> ... snip rest
>
>
> --
> 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/4beafd04-012d-43c7-b5fe-3089bdab51ef%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/4beafd04-012d-43c7-b5fe-3089bdab51ef%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAEkBMfFywbsA9xaPXGVHjADroKtor2ksPe4_WtonWb6F8Xqx5Q%40mail.gmail.com.

Reply via email to