> Instead, I expect that many people will do what I intend
> to and customize it, even at the cost of pulling go/printer out and
> including a tweaked version of it in the formatting tool source tree
> (opening braces at end of if/else/etc. instead of on their own lines
> drastically reduce readability for me)
I hope that when you do tweak it, you will do it by adding command
line options to gofmt, so that other people can take advantage of that
as well.
Ian
No one is or will ever be 100% happy with the output of gofmt,
but it's actually pretty good, and what's more, people adapt
surprisingly quickly to styles that at first seem foreign. Especially
in formatting, style is really just "what you're used to".
Since Go is an entirely new language, it should not be too
hard to get used to a different formatting too.
We hope that people will accept the output of gofmt precisely
because it puts an end to these kinds of style debates. How
many different brace styles are there in C? Too many.
Personally I find it liberating to let gofmt format for me,
because it means I have more neurons available for
attacking interesting programming problems. There are
things I don't like about gofmt's output, but I love not
worrying about them anymore.
But all of this misses what I think is the most exciting thing
about gofmt: the fact that we have a tool that can pick up every
source file in the Go tree, parse it into an internal representation,
and then put the exact same bytes back down. (A large part
of this is due to the amount of work that went into gofmt, and
the rest is because we have agreed to standardize on gofmt's
style.) Once you have such a tool, it becomes very easy to
insert mechanical processing in the middle, between parsing
and printing. So we have all the hard parts of a program
manipulation tool just sitting waiting to be used. I've started
writing similar tools for C before and never quite got the output
to match the input exactly. Agreeing to accept "gofmt style"
is the piece that makes it doable in a finite amount of code.
I hope that people will use gofmt, as is, for their own code.
As I said, it doesn't take more than a couple weeks to get
used to a new coding style, especially if you are in a brand
new language, and there are huge benefits to everyone using
the same style.
We certainly plan to keep formatting all the code in the
Go tree using gofmt. Like Go, it's an experiment.
Russ