]> Cypherpunks repositories - gostls13.git/commitdiff
net/url: fix example of Values.Encode
authorJosé Joaquín Atria <jjatria@gmail.com>
Mon, 24 Nov 2025 19:52:22 +0000 (19:52 +0000)
committerGopher Robot <gobot@golang.org>
Tue, 25 Nov 2025 18:41:33 +0000 (10:41 -0800)
Calling url.Values.Encode generates a query string with the
values sorted by key. However, in the example in the documentation
this behaviour is not reflected. This change corrects this.

Change-Id: Id95a5d79b57dc20c3bff1f0c6975c76dcd8412b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/723960
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Florian Lehner <lehner.florian86@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Sean Liao <sean@liao.dev>

src/net/url/example_test.go

index 311ba5c329b442459434526ffffeebcbeff94942..bae83ab1d05646239e0a0a611ee86e09bbaf747c 100644 (file)
@@ -58,11 +58,12 @@ func ExampleValues() {
        v.Add("friend", "Jess")
        v.Add("friend", "Sarah")
        v.Add("friend", "Zoe")
-       // v.Encode() == "name=Ava&friend=Jess&friend=Sarah&friend=Zoe"
+       fmt.Println(v.Encode())
        fmt.Println(v.Get("name"))
        fmt.Println(v.Get("friend"))
        fmt.Println(v["friend"])
        // Output:
+       // friend=Jess&friend=Sarah&friend=Zoe&name=Ava
        // Ava
        // Jess
        // [Jess Sarah Zoe]