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

Update to support Go 1.11 modules #8

Closed
atombender opened this issue Oct 2, 2018 · 4 comments
Closed

Update to support Go 1.11 modules #8

atombender opened this issue Oct 2, 2018 · 4 comments

Comments

@atombender
Copy link

go-sumtype seems to fail with "could not import" errors, even (surprisingly) after go mod vendor. From what I can tell, it needs to be updated to understand Go modules.

@BurntSushi
Copy link
Owner

Can you provide a reproducible example on which to run?

@atombender
Copy link
Author

atombender commented Oct 3, 2018

@BurntSushi Here. There's something weird going on. If I use a GOPATH that's somewhere outside the working directory, it fails:

$ GOPATH=$HOME/.go ./run.sh
+ export GO111MODULE=on
+ GO111MODULE=on
+ go mod download
+ go build -o st .
+ go-sumtype .
/Users/alex/.go/pkg/mod/golang.org/x/sync@v0.0.0-20180314180146-1d60e4601c6f/semaphore/semaphore.go:15:2: could not import golang.org/x/net/context (cannot find package "golang.org/x/net/context" in any of:
	/usr/local/opt/go/libexec/src/golang.org/x/net/context (from $GOROOT)
	/Users/alex/.go/src/golang.org/x/net/context (from $GOPATH))
couldn't load packages due to errors: golang.org/x/sync/semaphore

But if I put the GOPATH under the current directory, there are no issues.

$ GOPATH=$PWD/.go ./run.sh
+ export GO111MODULE=on
+ GO111MODULE=on
+ go mod download
+ go build -o st .
+ go-sumtype .

The problem appears to be with transitive dependencies. It can resolve the direct dependencies, but not the transitive ones. (Hence my test case uses golang.org/x/sync/semaphore, which imports golang.org/x/net/context.)

I've tried wiping my GOPATH.

$ go version
go version go1.11.1 darwin/amd64

@atombender
Copy link
Author

I believe golang.org/x/tools/go/loader, which you use for loading Go code, has not been updated to support modules. Instead, there's a new package, golang.org/x/tools/go/packages. Discussion here. See this issue for an example of a different project struggling with the same issue.

@atombender
Copy link
Author

@BurntSushi

kujenga added a commit to kujenga/go-sumtype that referenced this issue Feb 24, 2019
This commt is the first step towards switching to Go modules,
ref: BurntSushi#8
kujenga added a commit to kujenga/go-sumtype that referenced this issue Feb 24, 2019
This commit adds Go modules support by switching to the new package that
supports them in the golang tools repository.

Closes BurntSushi#8
BurntSushi pushed a commit that referenced this issue Feb 25, 2019
This commt is the first step towards switching to Go modules,
ref: #8
BurntSushi pushed a commit that referenced this issue Feb 25, 2019
This commit adds Go modules support by switching to the new package that
supports them in the golang tools repository.

Closes #8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants