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: go.mod be modified after "go test" #30921

Closed
guhan121 opened this issue Mar 19, 2019 · 3 comments
Closed

cmd/go: go.mod be modified after "go test" #30921

guhan121 opened this issue Mar 19, 2019 · 3 comments

Comments

@guhan121
Copy link

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

$ go version
go version go1.11.5 linux/amd64

Does this issue reproduce with the latest release?

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

go env Output
$ go env
```
gitlab-runner@it-Z97X-Gaming-3:~/go/bin$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/gitlab-runner/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/gitlab-runner/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build735453683=/tmp/go-build -gno-record-gcc-switches"
```

What did you do?

go test -race $(go list ./... | grep -v /vendor/ | grep -v /examples/)

What did you expect to see?

Don't change the version in go.mod

What did you see instead?

gitlab-runner@it-Z97X-Gaming-3:~/go/src/git.hezi.com/golang/tfy$ go test -race $(go list ./... | grep -v /vendor/ | grep -v /examples/)
go: finding github.com/petermattis/goid latest
go: finding github.com/petermattis/goid latest
go: finding github.com/micro/go-micro/registry/mock latest
go: finding github.com/micro/go-micro/registry latest
.........
gitlab-runner@it-Z97X-Gaming-3:~/go/src/git.hezi.com/golang/tfy$ git diff go.mod
 module git.hezi.com/golang/tfy
 
-        require (
-        golang.org/x/crypto v0.0.0-20181025213731-e84da0312774
-        golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519
-        git.hezi.com/golang/golang-config v0.0.2
-        git.hezi.com/golang/trpc v1.17.2
-        git.hezi.com/monitor/golang-sdk v2.2.1+incompatible
-        git.hezi.com/monitor/m_go_sdk v2.0.2+incompatible
-        github.com/apache/thrift v0.0.0-20171203172758-327ebb6c2b6d
-        github.com/golang/protobuf v1.2.0
-        github.com/google/uuid v1.1.0
-        github.com/micro/go-log v0.0.0-20170512141327-cbfa9447f9b6
-        github.com/micro/go-micro v0.12.0
-        github.com/micro/go-web v0.5.2
-        github.com/micro/go-plugins v0.16.1
-        github.com/micro/grpc-go v0.0.0-20180913204047-2c703400301b
-        github.com/micro/util v0.0.0-20180417104657-4b7ed83e8520
-        github.com/micro/cli v0.0.0-20181223203424-1b0c9793c300
-        github.com/micro/go-rcache v0.0.0-20180418165751-a581a57b5133
-        github.com/micro/mdns v0.0.0-20181201230301-9c3770d4057a
-        github.com/fsnotify/fsnotify v1.4.7
-        github.com/pkg/errors v0.8.0
-        github.com/confluentinc/confluent-kafka-go v0.11.6
-        gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce
-        go.uber.org/zap v1.9.1
-        go.uber.org/atomic v1.3.2
-        go.uber.org/multierr v1.1.0
-
-
-        //indirect
-        github.com/json-iterator/go v1.1.5 // indirect
-        github.com/DataDog/zstd v1.3.4 // indirect
-        github.com/Shopify/sarama v1.20.0 // indirect
-        github.com/cloudfoundry/gosigar v1.1.0 // indirect
-        github.com/eapache/go-resiliency v1.1.0 // indirect
-        github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
-        github.com/eapache/queue v1.1.0 // indirect
-        github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
-        github.com/go-log/log v0.1.0 // indirect
-        github.com/hashicorp/go-cleanhttp v0.5.0 // indirect
-        github.com/hashicorp/go-rootcerts v0.0.0-20160503143440-6bb64b370b90 // indirect
-        github.com/hashicorp/serf v0.8.1 // indirect
-        github.com/miekg/dns v1.1.1 // indirect
-        github.com/mitchellh/hashstructure v1.0.0 // indirect
-        github.com/mitchellh/mapstructure v1.1.2 // indirect
-        github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
-        github.com/modern-go/reflect2 v1.0.1 // indirect
-        github.com/orcaman/concurrent-map v0.0.0-20180723183937-b28018939af9 // indirect
-        github.com/pborman/uuid v1.2.0 // indirect
-        github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
-        github.com/pierrec/lz4 v2.0.5+incompatible // indirect
-        github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a // indirect
-        gopkg.in/bsm/sarama-cluster.v2 v2.1.15 // indirect
-        )
+require (
+       git.hezi.com/golang/tfy/examples/service_tfy v0.0.0-20190318124557-8a4acfc723d1
+       git.hezi.com/golang/go-config v0.0.2
+       git.hezi.com/golang/trpc v1.17.2
+       git.hezi.com/monitor/golang-sdk v2.2.1+incompatible
+       git.hezi.com/monitor/m_go_sdk v2.0.2+incompatible
+       github.com/Shopify/sarama v1.20.1
+       github.com/apache/thrift v0.0.0-20171203172758-327ebb6c2b6d
+       github.com/confluentinc/confluent-kafka-go v0.11.6
+       github.com/fsnotify/fsnotify v1.4.7
+       github.com/golang/protobuf v1.2.0
+       github.com/google/uuid v1.1.0
+       github.com/json-iterator/go v1.1.6 // indirect
+       github.com/micro/cli v0.1.0
+       github.com/micro/examples v0.1.0
+       github.com/micro/go-log v0.1.0
+       github.com/micro/go-micro v0.24.0
+       github.com/micro/go-plugins v0.22.0
+       github.com/micro/go-rcache v0.1.0
+       github.com/micro/go-web v0.6.0
+       github.com/micro/grpc-go v0.0.0-20180913204047-2c703400301b
+       github.com/micro/mdns v0.1.0
+       github.com/micro/util v0.1.0
+       github.com/miekg/dns v1.1.6 // indirect
+       github.com/orcaman/concurrent-map v0.0.0-20190314100340-2693aad1ed75 // indirect
+       github.com/pborman/uuid v1.2.0
+       github.com/pkg/errors v0.8.1
+       github.com/serialx/hashring v0.0.0-20180504054112-49a4782e9908
+       go.uber.org/atomic v1.3.2
+       go.uber.org/multierr v1.1.0
+       go.uber.org/zap v1.9.1
+       golang.org/x/crypto v0.0.0-20190130090550-b01c7a725664
+       golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3
+       google.golang.org/grpc v1.18.0
+       gopkg.in/bsm/sarama-cluster.v2 v2.1.15
+       gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce
+)
(END)


important:
this version of `github.com/micro/go-micro` change 0.12.0 -> v0.24.0 !

how to fix it?
@guhan121 guhan121 changed the title go.mod be modified after "go test" cmd/go:go.mod be modified after "go test" Mar 19, 2019
@guhan121 guhan121 changed the title cmd/go:go.mod be modified after "go test" cmd/go: go.mod be modified after "go test" Mar 19, 2019
@guhan121
Copy link
Author

i find in project https://github.com/micro/examples/blob/master/go.mod
the version of go-micro set under:
github.com/micro/go-micro v0.24.0

I run go mod download the version in ../pkg/mod/.. is v0.12.0 .
next I run go test -race the version in ../pkg/mod/.. is v0.24.0 .
or
I run go mod vendor the version in vendor is v0.24.0,too .

@jayconrod
Copy link
Contributor

It's very likely that a module you require (either directly, transitively, or implicitly) depends on v0.24.0. This could be due to a package that is only imported in race mode (something imported from a file with // +build race. In general, it is expected that go test will update go.mod if a required module is missing or a newer version is needed.

You can use go mod why github.com/micro/go-micro to understand what package imports something in this module.

You can also use go mod graph to understand the relationships between modules.

You can build / test / list with go test -mod=readonly to prevent go.mod from being written (but it may print an error if the requirements are incomplete or out of date).

If none of those solve the issue, feel free to reopen this issue.

@guhan121
Copy link
Author

@jayconrod thanks!
i check the code。

the developers use github.com/micro/go-micro@v0.12.0 for function s, and use github.com/micro/examples@v0.1.0 for unit test.

but github.com/micro/examples@v0.1.0 Depends on the github.com/micro/go-micro@v0.24.0

when i go test, update the version of github.com/micro/go-micro. so the functions has error!

I have reminded them to revise!

@golang golang locked and limited conversation to collaborators Mar 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants