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: compilation fails if mutiple packages with the same name are imported #40318

Closed
DeedleFake opened this issue Jul 20, 2020 · 2 comments
Closed

Comments

@DeedleFake
Copy link

@DeedleFake DeedleFake commented Jul 20, 2020

Playground

package main

import (
	crand "crypto/rand"
	"math/rand"
)

func main() {
	_ = crand.Reader
	_ = rand.Source(nil)
}

Output:

./prog.go2:4: rand redeclared as imported package name
	previous declaration at ./prog.go2:4
@toothrot toothrot added this to the Unreleased milestone Jul 21, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Jul 23, 2020

Change https://golang.org/cl/244621 mentions this issue: [dev.go2go] go/go2go: don't import renamed package twice

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jul 23, 2020

Thanks. Fixed on go2go branch.

I'm sure there are cases using local import aliases that will fail with the translation tool. But we can fix this one, at least.

gopherbot pushed a commit that referenced this issue Jul 23, 2020
We keep an import spec if it uses a local alias. Avoid importing it
again, unless it is required by something else.

Fixes #40318

Change-Id: If90de3bf30412645c9144083372e6b07df3c6a0b
Reviewed-on: https://go-review.googlesource.com/c/go/+/244621
Reviewed-by: Ian Lance Taylor <iant@golang.org>
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
4 participants
You can’t perform that action at this time.