Skip to content

cmd/go: errors while testing go modules  #28336

@SuchithArodi

Description

@SuchithArodi

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 !

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.modules

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions