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: errors while testing go modules #28336

Closed
SuchithArodi opened this issue Oct 23, 2018 · 8 comments
Closed

cmd/go: errors while testing go modules #28336

SuchithArodi opened this issue Oct 23, 2018 · 8 comments
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@SuchithArodi
Copy link

Please answer these questions before submitting your issue. Thanks!

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

$ go version
go version go1.11 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/sarodi/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/sarodi/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/sarodi/temp/stream-service/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=/var/folders/5g/yq5b2dfd7bgf424t0ff3dcmc0000gn/T/go-build557600271=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Trying the new go modules.
Currently, the repo uses the dep and I want to move from dep to go modules.

Steps followed to move to go modules from dep (As described in https://github.com/golang/go/wiki/Modules):

  1. In the project root directory create the mod file go.mod: go mod init (This will read from the Gopkg.lock file for all the dependency information)
  2. Build the module. This will create a go.sum file in the root directory: go build ./...
  3. Test the module: go test ./...

It builds fine, but when I do go test ./... I see this error.

$ go test ./...
# /Users/sarodi/temp/stream-service/pkg/txhandler.test
/var/folders/5g/yq5b2dfd7bgf424t0ff3dcmc0000gn/T/go-build102201698/b391/_testmain.go:12:2: import path cannot be absolute path
/var/folders/5g/yq5b2dfd7bgf424t0ff3dcmc0000gn/T/go-build102201698/b391/_testmain.go:20:24: undefined: _test
/var/folders/5g/yq5b2dfd7bgf424t0ff3dcmc0000gn/T/go-build102201698/b391/_testmain.go:22:21: undefined: _test
# /Users/sarodi/temp/stream-service/pkg/util.test
/var/folders/5g/yq5b2dfd7bgf424t0ff3dcmc0000gn/T/go-build102201698/b394/_testmain.go:12:2: import path cannot be absolute path
/var/folders/5g/yq5b2dfd7bgf424t0ff3dcmc0000gn/T/go-build102201698/b394/_testmain.go:20:21: undefined: _test
/var/folders/5g/yq5b2dfd7bgf424t0ff3dcmc0000gn/T/go-build102201698/b394/_testmain.go:22:20: undefined: _test
# /Users/sarodi/temp/stream-service/pkg/controller.test
/var/folders/5g/yq5b2dfd7bgf424t0ff3dcmc0000gn/T/go-build102201698/b372/_testmain.go:12:2: import path cannot be absolute path
/var/folders/5g/yq5b2dfd7bgf424t0ff3dcmc0000gn/T/go-build102201698/b372/_testmain.go:20:19: undefined: _test
/var/folders/5g/yq5b2dfd7bgf424t0ff3dcmc0000gn/T/go-build102201698/b372/_testmain.go:22:17: undefined: _test
/var/folders/5g/yq5b2dfd7bgf424t0ff3dcmc0000gn/T/go-build102201698/b372/_testmain.go:24:17: undefined: _test
/var/folders/5g/yq5b2dfd7bgf424t0ff3dcmc0000gn/T/go-build102201698/b372/_testmain.go:26:16: undefined: _test
/var/folders/5g/yq5b2dfd7bgf424t0ff3dcmc0000gn/T/go-build102201698/b372/_testmain.go:28:25: undefined: _test
/var/folders/5g/yq5b2dfd7bgf424t0ff3dcmc0000gn/T/go-build102201698/b372/_testmain.go:30:18: undefined: _test
/var/folders/5g/yq5b2dfd7bgf424t0ff3dcmc0000gn/T/go-build102201698/b372/_testmain.go:32:25: undefined: _test
/var/folders/5g/yq5b2dfd7bgf424t0ff3dcmc0000gn/T/go-build102201698/b372/_testmain.go:34:22: undefined: _test
/var/folders/5g/yq5b2dfd7bgf424t0ff3dcmc0000gn/T/go-build102201698/b372/_testmain.go:36:18: undefined: _test
/var/folders/5g/yq5b2dfd7bgf424t0ff3dcmc0000gn/T/go-build102201698/b372/_testmain.go:36:18: too many errors
?   	/Users/sarodi/temp/stream-service/cmd/streamservice	[no test files]
FAIL	/Users/sarodi/temp/stream-service/pkg/controller [build failed]
?   	/Users/sarodi/temp/stream-service/pkg/mocks	[no test files]
FAIL	/Users/sarodi/temp/stream-service/pkg/txhandler [build failed]
FAIL	/Users/sarodi/temp/stream-service/pkg/util [build failed]

when I do 'go test all' I see this error:

$ go test all
go: finding github.com/pierrec/lz4/v2/internal/xxh32 latest
go: finding github.com/onsi/ginkgo/extensions/table latest
go: finding github.com/Shopify/toxiproxy/client latest
go: finding github.com/pierrec/lz4/v2/internal latest
go: downloading github.com/pierrec/lz4/v2 v2.0.7
go: finding github.com/onsi/ginkgo/extensions latest
can't load package: package github.com/pierrec/lz4/v2/internal/xxh32: unknown import path "github.com/pierrec/lz4/v2/internal/xxh32": cannot find module providing package github.com/pierrec/lz4/v2/internal/xxh32

What did you expect to see?

I expected the transition from dep to go mod with ease.

What did you see instead?

Errors !

@bcmills
Copy link
Contributor

bcmills commented Oct 23, 2018

The first error message says import path cannot be absolute path. Does your code have an import statement that uses an absolute path?

@bcmills
Copy link
Contributor

bcmills commented Oct 23, 2018

The second error message seems to be accurate. It says cannot find module providing package github.com/pierrec/lz4/v2/internal/xxh32. If we look at the latest v2 tag for that repository (v2.0.7), we find that it declares its module to be github.com/pierrec/lz4 (note the lack of /v2).

See also pierrec/lz4#33.

@bcmills bcmills added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. modules labels Oct 23, 2018
@bcmills bcmills changed the title Errors while testing go modules cmd/go: errors while testing go modules Oct 23, 2018
@bcmills bcmills added this to the Go1.12 milestone Oct 23, 2018
@SuchithArodi
Copy link
Author

The first error message says import path cannot be absolute path. Does your code have an import statement that uses an absolute path?

I am not aware of any absolute paths in the import statements other than "github.com/...". Basically, all the import paths I see starts with "github.com/..." or a similar github private repo. I have "sync", "time", "container/list" but these are golang packages.

May be it is complaining about the absolute path in some dependency which I use ?

@bcmills
Copy link
Contributor

bcmills commented Oct 23, 2018

Possibly. Can you attach a code sample and exact commands to reproduce the error?

@SuchithArodi
Copy link
Author

SuchithArodi commented Oct 23, 2018

So, while initiating the mod I was giving an absolute path for the module like 'go mod init /user/temp' this was the cause of the first error!

Now, when I change the module path to something else like 'go mod init user/temp' it works fine.
Can you please direct me to some resources where I can learn how exactly the go modules works internally.

But, if I do 'go test all' I still see this error which is expected as you mentioned earlier.

$ go test all
go: finding github.com/pierrec/lz4/v2/internal/xxh32 latest
go: finding github.com/Shopify/toxiproxy/client latest
go: finding github.com/onsi/ginkgo/extensions/table latest
go: finding github.com/pierrec/lz4/v2/internal latest
go: downloading github.com/pierrec/lz4/v2 v2.0.7
go: finding github.com/onsi/ginkgo/extensions latest
can't load package: package github.com/pierrec/lz4/v2/internal/xxh32: unknown import path "github.com/pierrec/lz4/v2/internal/xxh32": cannot find module providing package github.com/pierrec/lz4/v2/internal/xxh32

@agnivade
Copy link
Contributor

The v2 change has been reverted for that repo - pierrec/lz4@bb6bfd1. You can remove that. The repo README is out of date.

Please see this https://golang.org/cmd/go/#hdr-Module_maintenance for more info.

@bcmills
Copy link
Contributor

bcmills commented Oct 25, 2018

It appears that all of the errors are now accounted for. Is there anything more to do?

@rsc
Copy link
Contributor

rsc commented Oct 25, 2018

Closing this issue as fixed in part and covered by #28389 for the rest.

@rsc rsc closed this as completed Oct 25, 2018
@golang golang locked and limited conversation to collaborators Oct 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants