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

unconvert doesn't work in certain scenarios with Go modules #34

Closed
nmiyake opened this issue Jan 9, 2019 · 2 comments
Closed

unconvert doesn't work in certain scenarios with Go modules #34

nmiyake opened this issue Jan 9, 2019 · 2 comments

Comments

@nmiyake
Copy link

nmiyake commented Jan 9, 2019

To repro, perform the following outside of the $GOPATH:

➜  mkdir test-mod
➜  cd test-mod
➜  go mod init github.com/test/mod
go: creating new go.mod: module github.com/test/mod
➜  echo 'package foo; import _ "gopkg.in/AlecAivazis/survey.v1"; func foo() { v := 5; _ = int(v);  }' > main.go
➜  go build .
➜  unconvert .
/Volumes/git/go/pkg/mod/gopkg.in/!alec!aivazis/[email protected]/confirm.go:7:2: could not import gopkg.in/AlecAivazis/survey.v1/core (cannot find package "gopkg.in/AlecAivazis/survey.v1/core" in any of:
	/usr/local/go/src/gopkg.in/AlecAivazis/survey.v1/core (from $GOROOT)
	/Volumes/git/go/src/gopkg.in/AlecAivazis/survey.v1/core (from $GOPATH))
/Volumes/git/go/pkg/mod/gopkg.in/!alec!aivazis/[email protected]/editor.go:10:13: could not import github.com/kballard/go-shellquote (cannot find package "github.com/kballard/go-shellquote" in any of:
	/usr/local/go/src/github.com/kballard/go-shellquote (from $GOROOT)
...

This is tracked on the Go side as golang/go#24661.

Using the new "golang.org/x/tools/go/packages" API seems to resolve this issue.

nmiyake added a commit to nmiyake/unconvert that referenced this issue Jan 9, 2019
Use golang.org/x/tools/go/packages to load packages.
Fixes mdempsky#34.
@mdempsky
Copy link
Owner

I think this was fixed by #32. Please let me know if I'm mistaken.

@nmiyake
Copy link
Author

nmiyake commented Jan 10, 2019

Yes, #32 resolves this, and verified that this now works on master -- thanks!

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

No branches or pull requests

2 participants