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: golang.org/x/time/rate not resolved by go.mod #31149

Closed
baha-ai opened this issue Mar 29, 2019 · 4 comments
Closed

cmd/go: golang.org/x/time/rate not resolved by go.mod #31149

baha-ai opened this issue Mar 29, 2019 · 4 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@baha-ai
Copy link

baha-ai commented Mar 29, 2019

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

$ go version
go version go1.12 darwin/amd64

Does this issue reproduce with the latest release?

I think so

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/my.user/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/my.user/work/go-workspace"
GOPROXY="https://at----STRIPPEDURL----.ca"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/sl/vxkljrms20q3_70c05w4zz596ggp_f/T/go-build007651624=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

when referencing "golang.org/x/time/rate" in my code, then do
$ GO111MODULE=on go mod tidy

go.mod is updated with this entry:
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c

What did you expect to see?

my project build to pass

What did you see instead?

cmd/verify.go:20:2: cannot find package "golang.org/x/time/rate" in any of:
/usr/local/Cellar/go/1.12/libexec/src/golang.org/x/time/rate (from $GOROOT)
/Users/my.user/work/go-workspace/src/golang.org/x/time/rate (from $GOPATH)

I don't want to use :
$go get golang.org/x/time/rate
which works fine locally
but this should work through CI builds.

the same package commit version (85acf8d2951c) works fine using dep, but not with go.mod.

am I missing something?

note:
using Dep, this entry is added in Gopkg.lock (works fine in projects using Dep):

[[projects]]

  | branch = "master"
  | digest = "1:9fdc2b55e8e0fafe4b41884091e51e77344f7dc511c5acedcfd98200003bff90"
  | name = "golang.org/x/time"
  | packages = ["rate"]
  | pruneopts = "NUT"
  | revision = "85acf8d2951cb2a3bde7632f9ff273ef0379bcbd"

but my go.sum file shows these 2 entries as added:
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c h1:fqgJT0MGcGpPgpWU7VRdRjuArfcOvC4AoJmILihzhDg=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=

@baha-ai
Copy link
Author

baha-ai commented Mar 29, 2019

also tried latest commit from rate package by replacing time package like this in go.mod:

golang.org/x/time v0.0.0-20191108174840-9d24e82272b4

but got the same error

@dmitshur
Copy link
Contributor

cmd/verify.go:20:2: cannot find package "golang.org/x/time/rate" in any of:
/usr/local/Cellar/go/1.12/libexec/src/golang.org/x/time/rate (from $GOROOT)
/Users/my.user/work/go-workspace/src/golang.org/x/time/rate (from $GOPATH)

What command did you run when you got that error? Did you set GO111MODULE=on while running it?

@dmitshur dmitshur changed the title golang.org/x/time/rate not resolved by go.mod cmd/go: golang.org/x/time/rate not resolved by go.mod Mar 29, 2019
@dmitshur dmitshur added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 29, 2019
@baha-ai
Copy link
Author

baha-ai commented Mar 29, 2019

ah!! spot on @dmitshur

my build script is doing:
$go build -tags pkcs11 -o pkcs11perf

didn't know I had to add G111MODULE=on even for go build, it works when doing this:
$G111MODULE=on go build -tags pkcs11 -o pkcs11perf

thank you @dmitshur

Hopefully this flag will be gone with the next major Go release..

@dmitshur
Copy link
Contributor

Yes, the GO111MODULE environment variable applies to all go commands and need to be set accordingly.

You could do something like export GO111MODULE=on so that you don't need to explicitly provide it to each invocation of the go command.

Also see https://github.com/golang/go/wiki/Modules#when-do-i-get-old-behavior-vs-new-module-based-behavior for relevant information.

I'll close this since there's no bug in cmd/go here. For more questions, see https://golang.org/wiki/Questions for a list of places that are a better fit for asking questions. Thanks!

@golang golang locked and limited conversation to collaborators Mar 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants