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

cmd/go2go: build fails to recognize imports that should be resolved relatively (but not always) #39766

Closed
firelizzard18 opened this issue Jun 23, 2020 · 5 comments

Comments

@firelizzard18
Copy link

@firelizzard18 firelizzard18 commented Jun 23, 2020

If I have a directory that contains a go.mod file that defines the directory as module gitlab.com/firelizzard/go-iter, and in a subdirectory ./assert I import iter "gitlab.com/firelizzard/go-iter", go tool go2go build should recognize that iter should be resolved relatively, and should successfully build. However, it instead attempts to fetch iter. Other times, I have been able to make this work, but I don't know why it worked then (nor do I have an example of it working).

What version of Go are you using (go version)?

$ go version
go version devel +da7932368b Mon Jun 22 19:06:44 2020 +0000 linux/amd64

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"

What did you do?

  • git clone https://gitlab.com/firelizzard/go-iter -b assert-pkg
  • cd go-iter/assert
  • go tool go2go build

What did you expect to see?

A successful build

What did you see instead?

type checking failed for assert
assert.go2:6:7: could not import gitlab.com/firelizzard/go-iter (cannot find module providing package gitlab.com/firelizzard/go-iter: unrecognized import path "gitlab.com/firelizzard": parse https://gitlab.com/firelizzard?go-get=1: no go-import meta tags ())
@firelizzard18
Copy link
Author

@firelizzard18 firelizzard18 commented Jun 23, 2020

It seems like go2go is eliding the last part of the import. On this branch, import "gitlab.com/firelizzard/go-iter/iterator" fails with undeclared name: iterator. It mostly works if I use import iterator "gitlab.com/firelizzard/go-iter/iterator". But as of the last change (moving Iterable into its own package), I am getting package iter is not in GOROOT (/usr/lib/go-tip/src/iter), even with GO111MODULE=on.

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jun 23, 2020

The go2go tool does not support modules. Have you set the GO2PATH environment variable?

@firelizzard18
Copy link
Author

@firelizzard18 firelizzard18 commented Jun 23, 2020

I had not. I moved to a GO2PATH directory structure and I see less errors, but I'm still getting package iterable is not in GOROOT (/usr/lib/go-tip/src/iterable) (on the packages branch). I don't have import "iterable" anywhere, so I don't know where that error is coming from.

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jun 24, 2020

Can you provide exact instructions showing how we can reproduce the problem?

The go-iter package builds successfully for me.

@firelizzard18
Copy link
Author

@firelizzard18 firelizzard18 commented Jun 24, 2020

I was working on a branch, which is why I added -b assert-pkg to the clone command.

I created #39797 with a more complete description of the error mode and a reproduction. I'm not sure if package XXX is not in GOROOT is the same error as the one I initially reported here, so I'm closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.