]> Cypherpunks repositories - gostls13.git/commitdiff
encoding/json: fix package shadowing in MarshalIndent example
authorAriel Mashraki <ariel@mashraki.co.il>
Sun, 14 Mar 2021 16:12:59 +0000 (18:12 +0200)
committerIan Lance Taylor <iant@golang.org>
Sun, 14 Mar 2021 19:58:14 +0000 (19:58 +0000)
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>

src/encoding/json/example_test.go

index 2088c3429749d3477f4dbde5540d79cf857952ee..fbecf1b59397bff0ea1028f3d7a80715150cb43b 100644 (file)
@@ -279,12 +279,12 @@ func ExampleMarshalIndent() {
                "b": 2,
        }
 
-       json, err := json.MarshalIndent(data, "<prefix>", "<indent>")
+       b, err := json.MarshalIndent(data, "<prefix>", "<indent>")
        if err != nil {
                log.Fatal(err)
        }
 
-       fmt.Println(string(json))
+       fmt.Println(string(b))
        // Output:
        // {
        // <prefix><indent>"a": 1,