rogp...@gmail.com
unread,Nov 21, 2012, 10:01:39 AM11/21/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to g...@golang.org, r...@golang.org, brad...@golang.org, da...@cheney.net, golan...@googlegroups.com, re...@codereview-hr.appspotmail.com
nice.
https://codereview.appspot.com/6852075/diff/9001/src/pkg/go/fmt/fmt.go#newcode36
src/pkg/go/fmt/fmt.go:36: // an error. src is expected to be a
syntactically correct Go source file.
It would be more useful if this implemented the same heuristics that
gofmt does to allow formatting of more kinds of program elements.
On 2012/11/21 03:27:14, bradfitz wrote:
> Could also make src be of type interface{}, like parser.ParseFile,
which takes
> []byte, string, or io.Reader.
personally I'm not keen on that kind of thing. given that ParseFile
always reads into a []byte anyway, perhaps just:
func Write(dst io.Writer, source []byte) error
might be good enough to replace both String and Copy here.
the following doesn't seem too much worse than format.String(s)
to me:
var b bytes.Buffer
err := format.Write(&b, []byte(s))
use(b.String())
doesn't seem too much worse than using format.String
to me.
The single entry point makes it obvious what the trade-offs are
too.
https://codereview.appspot.com/6852075/