golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.68k stars 17.49k forks source link

cmd/go2go: compilation fails if mutiple packages with the same name are imported #40318

Closed DeedleFake closed 4 years ago

DeedleFake commented 4 years ago

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
gopherbot commented 4 years ago

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

ianlancetaylor commented 4 years ago

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.