Update to support Go 1.11 modules
atombender opened this issue · 4 comments
atombender commented
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 commented
Can you provide a reproducible example on which to run?
atombender commented
@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 commented
atombender commented