Speaking as someone who has written a few (albeit simple) code generators
that parse Go code, dot imports are a nightmare from my perspective because
it makes it impossible to work out from just imports alone whether an
identifier belongs to the current package or not.

Put another way, if you disallow dot imports, a reference to anything that
is outside the current package needs to be a qualified identifier, a
qualified identifier that is easily determined by reference to the
(possibly renamed) imports in the current file.

Blank imports on the other hand are only used for the side effects of their
inits; they do not alter the importing scope.

I can't quite find the link right now, but it has long been thought/said by
the authors of the Go language that dot imports should not have been
included in the language.

All that said I suspect this was a large part of the reason that golint
discourages the use of dot imports.



On 2 April 2018 at 15:26, Kaveh Shahbazian <kaveh.shahbaz...@gmail.com>
wrote:

> Why isn't it possible to justifying a dot import using a comment (like
> blank imports)?
>
> (Go 1.10.1, golint, ubuntu)
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to