On Sun, May 8, 2016 at 5:20 AM, Carl Mastrangelo wrote:
I ended up copying protobuf's approach
of using a tab writer, which makes for a more visually pleasing generated
indentation, but uglier generator.
I'm not sure which protobuf you're referring to, but I wouldn't use a
tabwriter. Instead, as Jan suggested, just let go/format auto-format
your generated source code. For example,

One of the reasons I was looking at go/ast in the first place is that it is
hard to tell if an import is used or not until the whole source is
generated. Writing code out with fmt has problems too, since now I have
strconv.Quote all over the place.
I'm not sure what you're trying to do exactly, but you might not need
strconv.Quote all over the place if you use the %q verb instead:

Using "fmt" also has problems when used
with bytes.Buffer as the temporary destination since you can't really
"unwrite" a rune or set of bytes.
Can you give an example where you need to unwrite a rune?

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

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 6 of 7 | next ›
Discussion Overview
groupgolang-nuts @
postedMay 7, '16 at 5:30p
activeMay 9, '16 at 9:34a



site design / logo © 2021 Grokbase