What it means. A file imports the same package twice under the same local name. It usually happens by editing: an import block added at the top of a file that already has one further down.
package main
import (
"strings"
)
// A second block importing the SAME package.
import (
"strings"
)
func main() {
Println(strings.Repeat("-", 3))
}
error[GALA-E0046]: package "strings" is already imported at line 4
--> main.gala:9:5
|
9 | "strings"
| ^^^^^^^^^ remove this import — a file's import blocks are merged, so a…
|
= hint: remove this import — a file's import blocks are merged, so a package listed in one block is in scope for the whole file
Remove the second import. A file may have as many import blocks as it likes — they are merged — so a package named in one is in scope for the whole file.
The same path under two different local names stays legal, as it is in Go:
import "strings"
import gostr "strings"
val a = strings.Repeat("-", 3)
val b = gostr.Repeat("+", 2)
The rejection is not new; the reporter is. A repeated path used to reach go build as two identical import lines and was reported against the generated file — strings redeclared in this block, plus a misleading "strings" imported and not used for a package used exactly as often as it was imported. Neither message pointed at the source.