Yes. It has to work that way, because otherwise Foo would be
ambiguous in bad.go. Does it mean mod1.Foo or mod2.Foo? One could
argue that it must mean mod1.Foo, but then the name "Foo" means
different things in different files in the same package. That is a
recipe for confusion.
> Except, not quite. Because if I
> introduce a third package that attempts to use the re-declared identifier
> through mod2, it doesn't work:
>
> ——— mod3/wtf.go ———
> package mod3
>
> import "mod2"
>
> func Bar() mod2.Foo {
> return nil
> }
>
> Here the code fails to compile:
> mod3/foo.go:5:12: undefined: mod2.Foo
>
> So then the identifiers brought in by the dot-import weren't truly
> re-declared in the file block, otherwise they would be exported in the
> package block of mod2, no? I'm probably misunderstanding something in this
> obscure corner case, so if any Go spec lawyers could shed some light on
> this, I'd appreciate it :)
I think you're right that the spec is missing a few words here.
Certainly there is no intent to re-export the identifiers imported
using `import .`, but the spec doesn't seem to state that clearly.
Ian