net/url: fix example of Values.Encode

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>
This commit is contained in:
José Joaquín Atria 2025-11-24 19:52:22 +00:00 committed by Gopher Robot
parent bd9222b525
commit 657b331ff5

View 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]