Keyboard Shortcuts

File
u :up to issue
m :publish + mail comments
M :edit review message
j / k :jump to file after / before current file
J / K :jump to next file with a comment after / before current file
Side-by-side diff
i :toggle intra-line diffs
e :expand all comments
c :collapse all comments
s :toggle showing all comments
n / p :next / previous diff chunk or comment
N / P :next / previous comment
<Up> / <Down> :next / previous line
<Enter> :respond to / edit current comment
d :mark current comment as done
Issue
u :up to list of issues
m :publish + mail comments
j / k :jump to patch after / before current patch
o / <Enter> :open current patch in side-by-side view
i :open current patch in unified diff view
Issue List
j / k :jump to issue after / before current issue
o / <Enter> :open current issue
# : close issue
Comment/message editing
<Ctrl> + s or <Ctrl> + Enter :save comment
<Esc> :cancel edit
Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(35)
Issues Repositories Search
Open Issues | Closed Issues | All Issues | Sign in with your Google Account to create issues and add comments

Issue 97840044: code review 97840044: encoding/json: add example for Indent, clarify the docs.

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 8 months ago by smcquay
Modified:
11 years, 8 months ago
Reviewers:
adg , rh
CC:
golang-codereviews, minux1, bradfitz, aram, rh, r, adg
Visibility:
Public.
encoding/json: add example for Indent, clarify the docs. There was confusion in the behavior of json.Indent; This change attempts to clarify the behavior by providing a bit more verbiage to the documentation as well as provide an example function. Fixes issue 7821.

Patch Set 1 #

Patch Set 2 : diff -r 824f981dd4b7 https://code.google.com/p/go/ #

Patch Set 3 : diff -r 824f981dd4b7 https://code.google.com/p/go/ #

Total comments: 4

Patch Set 4 : diff -r c19d7fd53785 https://code.google.com/p/go/ #

Patch Set 5 : diff -r c19d7fd53785 https://code.google.com/p/go/ #

Patch Set 6 : diff -r c19d7fd53785 https://code.google.com/p/go/ #

Patch Set 7 : diff -r c19d7fd53785 https://code.google.com/p/go/ #

Patch Set 8 : diff -r b0443478e712 https://code.google.com/p/go/ #

Patch Set 9 : diff -r b0443478e712 https://code.google.com/p/go/ #

Total comments: 4

Patch Set 10 : diff -r 2e591e82a8c8 https://code.google.com/p/go/ #

Patch Set 11 : diff -r 2e591e82a8c8 https://code.google.com/p/go/ #

Total comments: 10

Patch Set 12 : diff -r 2a7aa0e6641d https://code.google.com/p/go/ #

Patch Set 13 : diff -r e3d533e55750 https://code.google.com/p/go/ #

Total comments: 2

Patch Set 14 : diff -r e3d533e55750 https://code.google.com/p/go/ #

Patch Set 15 : diff -r e3d533e55750 https://code.google.com/p/go/ #

Created: 11 years, 8 months ago
Download [raw] [tar.bz2]
Unified diffs Side-by-side diffs Delta from patch set Stats (+35 lines, -2 lines) Patch
M src/pkg/encoding/json/example_test.go View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 chunks +32 lines, -0 lines 0 comments Download
M src/pkg/encoding/json/indent.go View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +3 lines, -2 lines 0 comments Download
Total messages: 24
|
smcquay
Hello golang-codereviews@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go/
11 years, 8 months ago (2014年04月30日 06:20:51 UTC) #1
Hello golang-codereviews@googlegroups.com,
I'd like you to review this change to
https://code.google.com/p/go/ 
Sign in to reply to this message.
minux1
please change the first line of the description to: encoding/json: add example for Indent, clarify ...
11 years, 8 months ago (2014年04月30日 06:29:05 UTC) #2
please change the first line of the description to:
encoding/json: add example for Indent, clarify the docs.
or something like that.
no need for spaces before the first line.
Sign in to reply to this message.
bradfitz
https://codereview.appspot.com/97840044/diff/40001/src/pkg/encoding/json/example_test.go File src/pkg/encoding/json/example_test.go (right): https://codereview.appspot.com/97840044/diff/40001/src/pkg/encoding/json/example_test.go#newcode148 src/pkg/encoding/json/example_test.go:148: out.Write([]byte("ʕ◔π◔ʔ{\nʕ◔π◔ʔ\t\"destinations\": ")) We think this is too cute. Remove ...
11 years, 8 months ago (2014年04月30日 14:29:22 UTC) #3
https://codereview.appspot.com/97840044/diff/40001/src/pkg/encoding/json/exam...
File src/pkg/encoding/json/example_test.go (right):
https://codereview.appspot.com/97840044/diff/40001/src/pkg/encoding/json/exam...
src/pkg/encoding/json/example_test.go:148:
out.Write([]byte("ʕ◔π◔ʔ{\nʕ◔π◔ʔ\t\"destinations\": "))
We think this is too cute. Remove the emojicons. Just write XYX or ":" or "="
or something else.
https://codereview.appspot.com/97840044/diff/40001/src/pkg/encoding/json/exam...
src/pkg/encoding/json/example_test.go:149: // n.b. the previous write did not
end with newline, and the following does not start with the "ʕ◔π◔ʔ"
Drop the "n.b.". We avoid ie, e.g., etc in docs.
Sign in to reply to this message.
aram
> please change the first line of the description to: > encoding/json: add example for ...
11 years, 8 months ago (2014年04月30日 14:32:03 UTC) #4
> please change the first line of the description to:
> encoding/json: add example for Indent, clarify the docs.
> 
> or something like that.
> 
> no need for spaces before the first line.
Apart from what minux said, please run fmt(1) on the description.
Sign in to reply to this message.
smcquay
On 2014年04月30日 06:29:05, minux wrote: > please change the first line of the description to: ...
11 years, 8 months ago (2014年05月01日 04:48:00 UTC) #5
On 2014年04月30日 06:29:05, minux wrote:
> please change the first line of the description to:
> encoding/json: add example for Indent, clarify the docs.
Thanks for the suggested phrasing.
> no need for spaces before the first line.
There was funkiness with my vim config. Looks better above to me; please let me
know if I still didn't get it right.
Sign in to reply to this message.
smcquay
On 2014年04月30日 14:29:22, bradfitz wrote: > We think this is too cute. Remove the emojicons. ...
11 years, 8 months ago (2014年05月01日 04:50:35 UTC) #6
On 2014年04月30日 14:29:22, bradfitz wrote:
> We think this is too cute. Remove the emojicons. Just write XYX or ":" or "="
> or something else.
Addressed. I went with 'Δ'; if you still think that's too fancy, I'll change it
to something ascii.
> Drop the "n.b.". We avoid ie, e.g., etc in docs.
That makes sense.
Incidentally I wasn't sure what to do with wrapping, so I matched what was going
on elsewhere in the docs (seems to wrap 75-ish)
Sign in to reply to this message.
smcquay
On 2014年04月30日 14:32:03, aram wrote: > Apart from what minux said, please run fmt(1) on ...
11 years, 8 months ago (2014年05月01日 04:51:20 UTC) #7
On 2014年04月30日 14:32:03, aram wrote:
> Apart from what minux said, please run fmt(1) on the description.
I ran with the fmt(1) defaults of --width=75; look better?
Sign in to reply to this message.
rh
On 2014年05月01日 04:51:20, smcquay wrote: > On 2014年04月30日 14:32:03, aram wrote: > > Apart from ...
11 years, 8 months ago (2014年05月01日 12:37:54 UTC) #8
On 2014年05月01日 04:51:20, smcquay wrote:
> On 2014年04月30日 14:32:03, aram wrote:
> > Apart from what minux said, please run fmt(1) on the description.
> 
> I ran with the fmt(1) defaults of --width=75; look better?
The fmt(1) may just have been intended for the CL description (just move the
"to" to the next line)
For the Go code itself, I don't believe there are any hard-and-fast limits. 
Wrap if it feels too long to you. As Effective Go likes to say, don't worry
about overflowing a punched card. :)
Sign in to reply to this message.
aram
Yes, CL description, there are no hard limits for Go code. If it feels right, ...
11 years, 8 months ago (2014年05月01日 12:40:28 UTC) #9
Yes, CL description, there are no hard limits for Go code. If it feels right,
it's not too long. Also we never want to reformat existing code just to wrap it.
Sign in to reply to this message.
smcquay
Hello golang-codereviews@googlegroups.com, minux.ma@gmail.com, bradfitz@golang.org, aram@mgk.ro, robert.hencke@gmail.com (cc: golang-codereviews@googlegroups.com), Please take another look.
11 years, 8 months ago (2014年05月02日 04:54:46 UTC) #10
rh
LGTM - my comments here are just alternatives, not requests. https://codereview.appspot.com/97840044/diff/160001/src/pkg/encoding/json/example_test.go File src/pkg/encoding/json/example_test.go (right): https://codereview.appspot.com/97840044/diff/160001/src/pkg/encoding/json/example_test.go#newcode149 ...
11 years, 8 months ago (2014年05月02日 12:17:15 UTC) #11
LGTM - my comments here are just alternatives, not requests.
https://codereview.appspot.com/97840044/diff/160001/src/pkg/encoding/json/exa...
File src/pkg/encoding/json/example_test.go (right):
https://codereview.appspot.com/97840044/diff/160001/src/pkg/encoding/json/exa...
src/pkg/encoding/json/example_test.go:149: // the previous write did not end
with newline, and the following does
Perhaps this?
// The previous Write did not end with a new line, so Indent waits
// for the next new line before beginning to indent with "Δ\t".
https://codereview.appspot.com/97840044/diff/160001/src/pkg/encoding/json/exa...
src/pkg/encoding/json/example_test.go:156: // Δ{
Windows struggled with Unicode console output last I checked, so godoc -ex=true
might display interesting things here here. As a Windows user, I am used to the
Windows console being a constant disappointment, though. Just noting for
thought.
Sign in to reply to this message.
r
https://codereview.appspot.com/97840044/diff/160001/src/pkg/encoding/json/example_test.go File src/pkg/encoding/json/example_test.go (right): https://codereview.appspot.com/97840044/diff/160001/src/pkg/encoding/json/example_test.go#newcode149 src/pkg/encoding/json/example_test.go:149: // the previous write did not end with newline, ...
11 years, 8 months ago (2014年05月02日 14:41:37 UTC) #12
https://codereview.appspot.com/97840044/diff/160001/src/pkg/encoding/json/exa...
File src/pkg/encoding/json/example_test.go (right):
https://codereview.appspot.com/97840044/diff/160001/src/pkg/encoding/json/exa...
src/pkg/encoding/json/example_test.go:149: // the previous write did not end
with newline, and the following does
The delta character has no explanatory value here. I find it confusing. Please
replace it.
Sign in to reply to this message.
smcquay
Hello golang-codereviews@googlegroups.com, minux.ma@gmail.com, bradfitz@golang.org, aram@mgk.ro, robert.hencke@gmail.com, r@golang.org (cc: golang-codereviews@googlegroups.com), Please take another look.
11 years, 8 months ago (2014年05月03日 07:05:03 UTC) #13
smcquay
Addressed requests. https://codereview.appspot.com/97840044/diff/40001/src/pkg/encoding/json/example_test.go File src/pkg/encoding/json/example_test.go (right): https://codereview.appspot.com/97840044/diff/40001/src/pkg/encoding/json/example_test.go#newcode148 src/pkg/encoding/json/example_test.go:148: out.Write([]byte("ʕ◔π◔ʔ{\nʕ◔π◔ʔ\t\"destinations\": ")) On 2014年04月30日 14:29:22, bradfitz wrote: ...
11 years, 8 months ago (2014年05月03日 07:09:16 UTC) #14
Addressed requests.
https://codereview.appspot.com/97840044/diff/40001/src/pkg/encoding/json/exam...
File src/pkg/encoding/json/example_test.go (right):
https://codereview.appspot.com/97840044/diff/40001/src/pkg/encoding/json/exam...
src/pkg/encoding/json/example_test.go:148:
out.Write([]byte("ʕ◔π◔ʔ{\nʕ◔π◔ʔ\t\"destinations\": "))
On 2014年04月30日 14:29:22, bradfitz wrote:
> We think this is too cute. Remove the emojicons. Just write XYX or ":" or "="
> or something else.
Done.
https://codereview.appspot.com/97840044/diff/40001/src/pkg/encoding/json/exam...
src/pkg/encoding/json/example_test.go:149: // n.b. the previous write did not
end with newline, and the following does not start with the "ʕ◔π◔ʔ"
On 2014年04月30日 14:29:22, bradfitz wrote:
> Drop the "n.b.". We avoid ie, e.g., etc in docs.
Done.
https://codereview.appspot.com/97840044/diff/160001/src/pkg/encoding/json/exa...
File src/pkg/encoding/json/example_test.go (right):
https://codereview.appspot.com/97840044/diff/160001/src/pkg/encoding/json/exa...
src/pkg/encoding/json/example_test.go:149: // the previous write did not end
with newline, and the following does
On 2014年05月02日 14:41:37, r wrote:
> The delta character has no explanatory value here. I find it confusing. Please
> replace it.
Done.
Sign in to reply to this message.
rh
LGTM ʕ◔π◔ʔ
11 years, 8 months ago (2014年05月03日 12:45:22 UTC) #15
LGTM ʕ◔π◔ʔ
Sign in to reply to this message.
adg
https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/example_test.go File src/pkg/encoding/json/example_test.go (right): https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/example_test.go#newcode155 src/pkg/encoding/json/example_test.go:155: // Output: Wouldn't it be clearer to write an ...
11 years, 8 months ago (2014年05月05日 01:53:31 UTC) #16
https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/exa...
File src/pkg/encoding/json/example_test.go (right):
https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/exa...
src/pkg/encoding/json/example_test.go:155: // Output:
Wouldn't it be clearer to write an example that only demonstrates the behavior
of Indent?
Just glancing at this I would assume Indent does the whole job and no further
work is required.
https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/ind...
File src/pkg/encoding/json/indent.go (right):
https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/ind...
src/pkg/encoding/json/indent.go:69: // Each element following the first in a
JSON object or array begins
this is wrong
Each **element** in a JSON **object** or **array** begins on a new, indented
line.
That doesn't mean that the opening bracket or brace of an object or array begins
on a new, indented line.
please revert this
https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/ind...
src/pkg/encoding/json/indent.go:71: // more copies of indent according to the
indentation nesting. The
revert (including the wrapping of "The")
https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/ind...
src/pkg/encoding/json/indent.go:72: // data appended to dst does not begin with
the prefix nor any
this change is OK
Sign in to reply to this message.
smcquay
https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/example_test.go File src/pkg/encoding/json/example_test.go (right): https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/example_test.go#newcode155 src/pkg/encoding/json/example_test.go:155: // Output: On 2014年05月05日 01:53:31, adg wrote: > Wouldn't ...
11 years, 8 months ago (2014年05月07日 03:41:34 UTC) #17
https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/exa...
File src/pkg/encoding/json/example_test.go (right):
https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/exa...
src/pkg/encoding/json/example_test.go:155: // Output:
On 2014年05月05日 01:53:31, adg wrote:
> Wouldn't it be clearer to write an example that only demonstrates the behavior
> of Indent?
The behavior of Indent wasn't clear to me until I considered it in this context;
that's why I had the Indent nestled between other bits of json.
If there isn't much value having it used in context like this (perhaps the
example hides edge behavior?) I can revert it to be a simple example of the use
of the function.
Thoughts?
> Just glancing at this I would assume Indent does the whole job and no further
> work is required.
My hope was that the out.Write calls above would have given sufficient context.
Perhaps they don't?
https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/ind...
File src/pkg/encoding/json/indent.go (right):
https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/ind...
src/pkg/encoding/json/indent.go:69: // Each element following the first in a
JSON object or array begins
On 2014年05月05日 01:53:31, adg wrote:
> this is wrong
> Each **element** in a JSON **object** or **array** begins on a new, indented
> line.
> 
> That doesn't mean that the opening bracket or brace of an object or array
begins
> on a new, indented line.
> 
> please revert this
Done.
https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/ind...
src/pkg/encoding/json/indent.go:71: // more copies of indent according to the
indentation nesting. The
On 2014年05月05日 01:53:31, adg wrote:
> revert (including the wrapping of "The")
Done.
https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/ind...
src/pkg/encoding/json/indent.go:72: // data appended to dst does not begin with
the prefix nor any
On 2014年05月05日 01:53:31, adg wrote:
> this change is OK
Done.
Sign in to reply to this message.
adg
https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/example_test.go File src/pkg/encoding/json/example_test.go (right): https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/example_test.go#newcode155 src/pkg/encoding/json/example_test.go:155: // Output: On 2014年05月07日 03:41:34, smcquay wrote: > On ...
11 years, 8 months ago (2014年05月08日 04:00:50 UTC) #18
https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/exa...
File src/pkg/encoding/json/example_test.go (right):
https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/exa...
src/pkg/encoding/json/example_test.go:155: // Output:
On 2014年05月07日 03:41:34, smcquay wrote:
> On 2014年05月05日 01:53:31, adg wrote:
> > Wouldn't it be clearer to write an example that only demonstrates the
behavior
> > of Indent?
> 
> The behavior of Indent wasn't clear to me until I considered it in this
context;
> that's why I had the Indent nestled between other bits of json.
> 
> If there isn't much value having it used in context like this (perhaps the
> example hides edge behavior?) I can revert it to be a simple example of the
use
> of the function.
> 
> Thoughts?
I'd like to take a look at a stripped back example. Sorry for being picky about
this, I just think seeing the function's behavior on its own might be more
illustrative.
> > Just glancing at this I would assume Indent does the whole job and no
further
> > work is required.
> 
> My hope was that the out.Write calls above would have given sufficient
context.
> Perhaps they don't?
Yeah, but on a brief reading you might not notice them.
Sign in to reply to this message.
smcquay
Addressing adg's review. https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/example_test.go File src/pkg/encoding/json/example_test.go (right): https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/example_test.go#newcode155 src/pkg/encoding/json/example_test.go:155: // Output: On 2014年05月08日 04:00:50, adg ...
11 years, 8 months ago (2014年05月08日 06:24:26 UTC) #19
Addressing adg's review.
https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/exa...
File src/pkg/encoding/json/example_test.go (right):
https://codereview.appspot.com/97840044/diff/200001/src/pkg/encoding/json/exa...
src/pkg/encoding/json/example_test.go:155: // Output:
On 2014年05月08日 04:00:50, adg wrote:
> On 2014年05月07日 03:41:34, smcquay wrote:
> > On 2014年05月05日 01:53:31, adg wrote:
> > > Wouldn't it be clearer to write an example that only demonstrates the
> behavior
> > > of Indent?
> > 
> > The behavior of Indent wasn't clear to me until I considered it in this
> context;
> > that's why I had the Indent nestled between other bits of json.
> > 
> > If there isn't much value having it used in context like this (perhaps the
> > example hides edge behavior?) I can revert it to be a simple example of the
> use
> > of the function.
> > 
> > Thoughts?
> 
> I'd like to take a look at a stripped back example. Sorry for being picky
about
> this, I just think seeing the function's behavior on its own might be more
> illustrative.
> 
> > > Just glancing at this I would assume Indent does the whole job and no
> further
> > > work is required.
> > 
> > My hope was that the out.Write calls above would have given sufficient
> context.
> > Perhaps they don't?
> 
> Yeah, but on a brief reading you might not notice them.
Done.
Sign in to reply to this message.
adg
Yeah that's much clearer to my eyes. https://codereview.appspot.com/97840044/diff/240001/src/pkg/encoding/json/example_test.go File src/pkg/encoding/json/example_test.go (right): https://codereview.appspot.com/97840044/diff/240001/src/pkg/encoding/json/example_test.go#newcode138 src/pkg/encoding/json/example_test.go:138: Road{"Diamond Fork", ...
11 years, 8 months ago (2014年05月08日 06:26:52 UTC) #20
Yeah that's much clearer to my eyes.
https://codereview.appspot.com/97840044/diff/240001/src/pkg/encoding/json/exa...
File src/pkg/encoding/json/example_test.go (right):
https://codereview.appspot.com/97840044/diff/240001/src/pkg/encoding/json/exa...
src/pkg/encoding/json/example_test.go:138: Road{"Diamond Fork", 29},
you can drop the "Road" on each of these lines
Sign in to reply to this message.
smcquay
Hello golang-codereviews@googlegroups.com, minux.ma@gmail.com, bradfitz@golang.org, aram@mgk.ro, robert.hencke@gmail.com, r@golang.org, adg@golang.org (cc: golang-codereviews@googlegroups.com), Please take another look.
11 years, 8 months ago (2014年05月08日 06:28:05 UTC) #21
smcquay
*Actually* addressing adg's review. https://codereview.appspot.com/97840044/diff/240001/src/pkg/encoding/json/example_test.go File src/pkg/encoding/json/example_test.go (right): https://codereview.appspot.com/97840044/diff/240001/src/pkg/encoding/json/example_test.go#newcode138 src/pkg/encoding/json/example_test.go:138: Road{"Diamond Fork", 29}, On 2014年05月08日 ...
11 years, 8 months ago (2014年05月08日 06:42:15 UTC) #22
*Actually* addressing adg's review.
https://codereview.appspot.com/97840044/diff/240001/src/pkg/encoding/json/exa...
File src/pkg/encoding/json/example_test.go (right):
https://codereview.appspot.com/97840044/diff/240001/src/pkg/encoding/json/exa...
src/pkg/encoding/json/example_test.go:138: Road{"Diamond Fork", 29},
On 2014年05月08日 06:26:52, adg wrote:
> you can drop the "Road" on each of these lines
Done.
Sign in to reply to this message.
adg
LGTM Thanks for sticking with it!
11 years, 8 months ago (2014年05月08日 06:45:37 UTC) #23
LGTM
Thanks for sticking with it!
Sign in to reply to this message.
adg
*** Submitted as https://code.google.com/p/go/source/detail?r=f7e221a34ec6 *** encoding/json: add example for Indent, clarify the docs. There was ...
11 years, 8 months ago (2014年05月08日 06:52:48 UTC) #24
*** Submitted as https://code.google.com/p/go/source/detail?r=f7e221a34ec6 ***
encoding/json: add example for Indent, clarify the docs.
There was confusion in the behavior of json.Indent; This change
attempts to clarify the behavior by providing a bit more verbiage
to the documentation as well as provide an example function.
Fixes issue 7821.
LGTM=robert.hencke, adg
R=golang-codereviews, minux.ma, bradfitz, aram, robert.hencke, r, adg
CC=golang-codereviews
https://codereview.appspot.com/97840044
Committer: Andrew Gerrand <adg@golang.org>
Sign in to reply to this message.
|
This is Rietveld f62528b

AltStyle によって変換されたページ (->オリジナル) /