mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
encoding/json: fix package shadowing in MarshalIndent example
Prior to this CL, pasting the example from the website causes a compilation error for some programs because it was shadowing the "json" package. Change-Id: I39b68a66ca99468547f2027a7655cf1387b61e95 Reviewed-on: https://go-review.googlesource.com/c/go/+/301492 Reviewed-by: Joe Tsai <joetsai@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Joe Tsai <joetsai@google.com> Run-TryBot: Joe Tsai <joetsai@google.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
061a6903a2
commit
a8b59fe3cd
1 changed files with 2 additions and 2 deletions
|
|
@ -279,12 +279,12 @@ func ExampleMarshalIndent() {
|
||||||
"b": 2,
|
"b": 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
json, err := json.MarshalIndent(data, "<prefix>", "<indent>")
|
b, err := json.MarshalIndent(data, "<prefix>", "<indent>")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(string(json))
|
fmt.Println(string(b))
|
||||||
// Output:
|
// Output:
|
||||||
// {
|
// {
|
||||||
// <prefix><indent>"a": 1,
|
// <prefix><indent>"a": 1,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue