Re:A JavaScript parser and interpreter written in Go
by jzelinskie on Thursday November 28, 2013 @12:10AM
(#6813118)
Thank you for being one of the few gophers that put newlines between standard, third party, and local imports. I wish gofmt forced that standard on people.
[ Parent
| on HN ]
Re:A JavaScript parser and interpreter written in Go
by gyepi on Thursday November 28, 2013 @02:18AM
(#6813448)
It is a useful convention in C and C++ to group includes, but I don't see the benefit in Go.
Since gofmt sorts imports, the grouping is soon undone.
In any case, it is quite easy to distinguish the three kinds of imports if local imports share a common prefix or set of prefixes.
Am I missing something here?
Re:A JavaScript parser and interpreter written in Go
by agentS on Thursday November 28, 2013 @03:12AM
(#6813568)
Note that gofmt sorts within groups. So if you leave spaces between groups of imports, it'll sort them all separately. Presumably, this sort of grouping is the reason it does it this way.
Re:A JavaScript parser and interpreter written in Go
by codebeaker on Thursday November 28, 2013 @03:27AM
(#6813612)
It's possible that if you have packages that understand flags (config package, with flags in init(), for example) that if you include it after the testing package, or before. One of them won't accept flags. (because flag.Parse() has already been called)
Re:A JavaScript parser and interpreter written in Go
by 1631- on Thursday November 28, 2013 @12:00PM
(#6815314)
You can't rely on the order of imports initialization anyway. See http://golang.org/ref/spec#Program_execution .. I believe that's also the reason, you shouldn't call `flag.Parse()` in `init()`