Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (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
)?
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/pprasanthi/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/pprasanthi/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/pprasanthi/gomodtry/tests/src/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/43/hr2mln315bgdqfyr9_bcr38r0000gn/T/go-build210705843=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
1. find the repo in https://github.com/pprasanthi/gomodtry
2. export GO111MODULE=on
3. cd /tmp/gomodtry/tests/src
4. go mod init github.com/pprasanthi/gomodtry
5. go get github.com/stretchr/testify/assert
6. This added the dependencies in go.mod and go.sum was created.
7. ⁃ module github.com/pprasanthi/gomodtry
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.2.2
)
8. go test ./… throws error:
⁃ pprasanthi-MBP-A6F84:src pprasanthi$ go test ./... -v
⁃ # github.com/pprasanthi/gomodtry/hello
⁃ hello/hello_test.go:5:2: unknown import path "lib/helper": cannot find module providing package lib/helper
⁃ github.com/pprasanthi/gomodtry/hello [setup failed]
⁃ ? github.com/pprasanthi/gomodtry/lib/helper [no test files]
9. The tests work fine, when
⁃ unset GO111MODULE
⁃ export GOPATH=/tmp/gomodtry/tests:/tmp/gomodtry/tests/src/lib/
⁃ go get github.com/stretchr/testify/assert
⁃ go test ./… -v
⁃
10. Why am I getting error when I set GO111MODULE and run tests, how to fix it?
If possible, provide a recipe for reproducing the error.
https://github.com/pprasanthi/gomodtry
What did you expect to see?
I want my tests to run without failures.
What did you see instead?
$ go test ./... -v
⁃ # github.com/pprasanthi/gomodtry/hello
⁃ hello/hello_test.go:5:2: unknown import path "lib/helper": cannot find module providing package lib/helper
⁃ github.com/pprasanthi/gomodtry/hello [setup failed]
⁃ ? github.com/pprasanthi/gomodtry/lib/helper [no test files]