Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upFails with import errors with modules on Go 1.11 #213
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
|
@evanphx? This is a complete blocker on Go 1.11 with modules. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
mjlangan
Sep 4, 2018
We are seeing similar errors from mockery after trying Go 1.11 with modules
Generating mock for: Adapter in file: mocks/Adapter.go
/Users/michaell/go/src/golang.org/x/crypto/ssh/terminal/util.go:20:2: could not import golang.org/x/sys/unix (cannot find package "golang.org/x/sys/unix" in any of:
/usr/local/go/src/golang.org/x/sys/unix (from $GOROOT)
/Users/michaell/go/src/golang.org/x/sys/unix (from $GOPATH))
/Users/michaell/go/pkg/mod/github.com/!sirupsen/logrus@v1.0.6/terminal_bsd.go:6:8: could not import golang.org/x/sys/unix (cannot find package "golang.org/x/sys/unix" in any of:
/usr/local/go/src/golang.org/x/sys/unix (from $GOROOT)
/Users/michaell/go/src/golang.org/x/sys/unix (from $GOPATH))
...
go mod vendor does pull these dependencies into the repository's /vendor/ folder, but it appears that mockery doesn't look there for dependencies when generating mocks.
mjlangan
commented
Sep 4, 2018
•
|
We are seeing similar errors from mockery after trying Go 1.11 with modules
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
atombender commentedAug 28, 2018
If I have a simple file such as this that refers to an imported package:
then it fails with:
In other words, it's looking for the source in the old location, not in
$GOPATH/pkg/mod.I'm able to reproduce this in a small Go program that uses
golang.org/x/tools/go/loaderto load files, and I can confirm that it does not work with Go modules. (E.g. see this issue for discussion.) Apparently thegolang.org/x/tools/go/loaderlibrary has been superceded by golang.org/x/tools/go/packages, which is module-aware.