Code review - Issue 5629043: code review 5629043: strings: add Fields examplehttps://codereview.appspot.com/2012-02-03T19:39:12+00:00rietveld
Message from unknown
2012-02-03T18:55:08+00:00bradfitzurn:md5:c9ac9dd3d699d521a174453300a3484e
Message from unknown
2012-02-03T18:55:33+00:00bradfitzurn:md5:5f33d7fdb8435dfedb3f7dd75d33e9aa
Message from unknown
2012-02-03T18:55:38+00:00bradfitzurn:md5:558490e566c5f3b391382ce11adc52d8
Message from bradfitz@golang.org
2012-02-03T18:55:43+00:00bradfitzurn:md5:63894f98d3629c5824b8deadfe25619b
Hello golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com),
I'd like you to review this change to
https://go.googlecode.com/hg/
Message from rsc@golang.org
2012-02-03T18:59:58+00:00rscurn:md5:7ef7748259f35bafe5793f2331e9f031
LGTM
%#v is fine; %q is shorter and maybe more interesting. Either way.
Message from r@golang.org
2012-02-03T19:08:23+00:00rurn:md5:b41aa8915910af89990a5a515ad942bb
LGTM
http://codereview.appspot.com/5629043/diff/3001/src/pkg/strings/example_test.go
File src/pkg/strings/example_test.go (right):
http://codereview.appspot.com/5629043/diff/3001/src/pkg/strings/example_test.go#newcode14
src/pkg/strings/example_test.go:14: fmt.Printf("Fields are: %#v", strings.Fields(" foo bar baz "))
when you know it's a string, i think it's better to use a string format so the output is more predictable. in this case, i'd go with %q, but if you insist it be go-syntax output you can leave it as is, redundant and noisy though it is.
Message from bradfitz@golang.org
2012-02-03T19:15:50+00:00bradfitzurn:md5:a3b96bfa8503680c15708a5fec132474
Ah, I hadn't seen %q on a []string before. That works. %#v is just my go-to
format.
On Fri, Feb 3, 2012 at 11:08 AM, <r@golang.org> wrote:
> LGTM
>
>
> http://codereview.appspot.com/**5629043/diff/3001/src/pkg/**
> strings/example_test.go<http://codereview.appspot.com/5629043/diff/3001/src/pkg/strings/example_test.go>
> File src/pkg/strings/example_test.**go (right):
>
> http://codereview.appspot.com/**5629043/diff/3001/src/pkg/**
> strings/example_test.go#**newcode14<http://codereview.appspot.com/5629043/diff/3001/src/pkg/strings/example_test.go#newcode14>
> src/pkg/strings/example_test.**go:14: fmt.Printf("Fields are: %#v",
>
> strings.Fields(" foo bar baz "))
> when you know it's a string, i think it's better to use a string format
> so the output is more predictable. in this case, i'd go with %q, but if
> you insist it be go-syntax output you can leave it as is, redundant and
> noisy though it is.
>
> http://codereview.appspot.com/**5629043/<http://codereview.appspot.com/5629043/>
>
Message from unknown
2012-02-03T19:17:48+00:00bradfitzurn:md5:0cb4ff8ce5f093a3eec293fd5547c216
Message from bradfitz@golang.org
2012-02-03T19:17:59+00:00bradfitzurn:md5:b4fd5de5b6f6543135b3bd27c3495ff8
*** Submitted as http://code.google.com/p/go/source/detail?r=2631a7b6fb8e ***
strings: add Fields example
R=golang-dev, rsc, r
CC=golang-dev
http://codereview.appspot.com/5629043
Message from rsc@golang.org
2012-02-03T19:33:58+00:00rscurn:md5:b3e9e7472a91745f3f435bf6f03c9567
On Fri, Feb 3, 2012 at 14:15, Brad Fitzpatrick <bradfitz@golang.org> wrote:
> Ah, I hadn't seen %q on a []string before.
For aggregates like slices and maps, the format
filters down to the elements, so %q on a []string
means %q on each string; %.2f on a []float64 works too.
Message from r@google.com
2012-02-03T19:39:12+00:00r2urn:md5:f17e847904e6adde7f76b386f3ab49ac
On 04/02/2012, at 6:33 AM, Russ Cox wrote:
> On Fri, Feb 3, 2012 at 14:15, Brad Fitzpatrick <bradfitz@golang.org> wrote:
>> Ah, I hadn't seen %q on a []string before.
>
> For aggregates like slices and maps, the format
> filters down to the elements, so %q on a []string
> means %q on each string; %.2f on a []float64 works too.
This ain't your old C printf.
-rob