You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 so, that could be one source of issues. See some related discussion here regarding domain names and dots in import paths and modules in #27503, including this comment from @bcmills:
Dotless paths in general are reserved for the standard library; go get has (to my knowledge) never worked with them, but go get is also the main entry point for working with versioned modules.
Also note that relative imports like import "./subdir" do not work with modules. See for example #26645 (comment).
Do you think either of those might explain what you are seeing?
Sorry if this is not a 100% helpful comment, but just trying to see if a question or two might help advance the conversation here...
myitcv
changed the title
Cannot find module providing package of custom libraries
cmd/go: Cannot find module providing package of custom libraries
Oct 21, 2018
go mod init github.com/pprasanthi/gomodtry tells the go command that all of the packages within that module begin with the prefix github.com/pprasanthi/gomodtry.
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?
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]
The text was updated successfully, but these errors were encountered: