From: cuishuang Date: Wed, 9 Oct 2024 03:56:25 +0000 (+0800) Subject: net/url: add example for JoinPath X-Git-Tag: go1.24rc1~711 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a9abbac4c86eb685661f2909d3f5ae59ab507773;p=gostls13.git net/url: add example for JoinPath Change-Id: Ibbd2bda7ff2ea3c782ad41f6f00ad62849a4f066 Reviewed-on: https://go-review.googlesource.com/c/go/+/618756 LUCI-TryBot-Result: Go LUCI Reviewed-by: Ian Lance Taylor Reviewed-by: Cherry Mui Auto-Submit: Ian Lance Taylor --- diff --git a/src/net/url/example_test.go b/src/net/url/example_test.go index a1913508f7..311ba5c329 100644 --- a/src/net/url/example_test.go +++ b/src/net/url/example_test.go @@ -253,6 +253,18 @@ func ExampleURL_IsAbs() { // true } +func ExampleURL_JoinPath() { + u, err := url.Parse("https://example.com/foo/bar") + if err != nil { + log.Fatal(err) + } + + fmt.Println(u.JoinPath("baz", "qux")) + + // Output: + // https://example.com/foo/bar/baz/qux +} + func ExampleURL_MarshalBinary() { u, _ := url.Parse("https://example.org") b, err := u.MarshalBinary()