gocomma like go imports?

162 views
Skip to first unread message

Timothy Bone

unread,
Jun 2, 2015, 5:17:40 PM6/2/15
to golan...@googlegroups.com
not sure how reasonable an idea this is, but it would be nice if a tool could auto add missing commas, as that happens to me enough that it would be useful. i'm thinking something like goreturns or goimports. any thoughts?

Chris Manghane

unread,
Jun 2, 2015, 5:21:59 PM6/2/15
to Timothy Bone, golan...@googlegroups.com
Add missing commas where? Between entries in a composite literal initialization? Seems like something gofmt could do.

On Tue, Jun 2, 2015 at 2:17 PM Timothy Bone <timot...@gmail.com> wrote:
not sure how reasonable an idea this is, but it would be nice if a tool could auto add missing commas, as that happens to me enough that it would be useful. i'm thinking something like goreturns or goimports. any thoughts?

--
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...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Timothy Bone

unread,
Jun 2, 2015, 6:51:31 PM6/2/15
to golan...@googlegroups.com
also multiple variable initializiation, multiple func parameters,.,.,,.but mostly i've thought for composite literals


and func(a b string) (a,c,d e int)

Volker Dobler

unread,
Jun 3, 2015, 1:41:12 AM6/3/15
to golan...@googlegroups.com
There is a fundamental difference between inserting import
statements and inserting commas: goimports works on
syntactically *correct* code and tries to make it semantically
meaningful by inserting appropriate import statements so that
the syntactical correct time.Second becomes semantically
sensible.
Inserting commas would have to work on a *syntactically*
*malformed* code which cannot be parsed by standard means.
Such stuff is tricky to impossible. Your example looks innocent,
but where would you insert commas in this parameter list:
  func f(foo bar waz det zup) int
If waz and zup are types than this might be f(foo, bar waz, det zup)
if only zup is a type it presumably means f(foo, bar, waz, det zup).
Now what if both bar and waz are types? Applying some heuristics
her will produce more confusion than requiring everybody to type
some commas.

V.
Reply all
Reply to author
Forward
0 new messages