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: translation considers package x_test to be part of package x #39801

Open
firelizzard18 opened this issue Jun 24, 2020 · 1 comment
Open

Comments

@firelizzard18
Copy link

@firelizzard18 firelizzard18 commented Jun 24, 2020

Go 1 allows package a_test to reference package b and package b to reference package a. go2go considers this to be an import cycle.

go test will succeed with the following, but go tool go2go test will issue a circular import error (if .go is changed to .go2)

--- a/a.go ---
package a

func F() {}

--- b/b.go
package b

import "./a"

func F() { a.F() }

--- b/b_test.go ---
package b_test

import "testing"
import "./b"

func Test(*testing.T) { b.F() }

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
  • cd go-iter/issues/i4
  • go tool go2go build

What did you expect to see?

A successful build

What did you see instead?

type checking failed for i4_test
i4_test.go2:6:2: could not import gitlab.com/firelizzard/go-iter/issues/i4/a (type checking failed for a
/tmp/go2go529617879/src/gitlab.com/firelizzard/go-iter/issues/i4/a/a.go2:3:8: could not import gitlab.com/firelizzard/go-iter/issues/i4 (type checking failed for i4_test
/tmp/go2go529617879/src/gitlab.com/firelizzard/go-iter/issues/i4/i4_test.go2:6:2: could not import gitlab.com/firelizzard/go-iter/issues/i4/a (circular import when processing "gitlab.com/firelizzard/go-iter/issues/i4/a")
)
)
@firelizzard18 firelizzard18 changed the title cmd/go2go: Translation considers package x to be part of package x_test cmd/go2go: Translation considers package x_test to be part of package x Jun 24, 2020
@cagedmantis cagedmantis changed the title cmd/go2go: Translation considers package x_test to be part of package x cmd/go2go: translation considers package x_test to be part of package x Jun 24, 2020
@cagedmantis cagedmantis added this to the Unreleased milestone Jun 24, 2020
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jun 25, 2020

Thanks. Yes, this is a known deficiency in the translation tool. I'll leave this issue open but I have no plans to fix this. If anyone else wants to tackle it, that would be fine.

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
3 participants
You can’t perform that action at this time.