From a9abbac4c86eb685661f2909d3f5ae59ab507773 Mon Sep 17 00:00:00 2001 From: cuishuang Date: Wed, 9 Oct 2024 11:56:25 +0800 Subject: [PATCH] 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 --- src/net/url/example_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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() -- 2.48.1