5 ms·
> I get the sense that most Go programmers use "goimports" to work around the annoyance. I have my Emacs configured to use it automatically. I never even think
by buro9 10y ago
> I get the sense that most Go programmers use "goimports" to work around the annoyance. I have my Emacs configured to use it automatically. I never even think about imports anymore.
You haven't yet encountered clashing names?
https://golang.org/pkg/crypto/rand/ https://golang.org/pkg/crypto/rand/
https://golang.org/pkg/math/rand/ https://golang.org/pkg/math/rand/
Or?
https://golang.org/pkg/text/template/ https://golang.org/pkg/text/template/
https://golang.org/pkg/html/template/ https://golang.org/pkg/html/template/
goimports is wonderful, but some care is needed to make sure it has added the one you intended to add.
NB: Only an issue when new imports are added, not an issue if the correct package is already referenced.
- zenlikethat 10y agoThe minor inconvenience of occasionally having to fix a path when goimports picked the wrong one is far outweighed by the massive convenience it brings me every day.
- donatj 10y agoI have been using it since I switched to VSCode about 4 months ago and thus far, knock on wood, it's always found the one I intend. I however do think it considers what public members/methods you are calling.
- buro9 10y ago"considers"? It just finds a match and goes with it, and that does cause issue. Both of the above have potential security implications. Filippo suggests preferring crypto/rand over math/rand as a softfix in this twitter conversation: https://twitter.com/filosottile/status/752210041709719552 https://twitter.com/filosottile/status/752210041709719552 I'd probably prefer html/template over text/template as it's better to have someone ask why their output was HTML escaped than to have someone render HTML in plain text without explicitly wanting to do so.