From 6094b88c4868727c855efbc66c423e228bf8b3d6 Mon Sep 17 00:00:00 2001 From: Carlos C Date: Thu, 9 Jul 2015 15:08:39 +0200 Subject: [PATCH] net/url: add example to URL.ResolveReference Change-Id: I9db1997b8dc7e06e9d124753ead6221470a1edf9 Reviewed-on: https://go-review.googlesource.com/12254 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick --- src/net/url/example_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/net/url/example_test.go b/src/net/url/example_test.go index 7f2eb2c3542..645de2e9092 100644 --- a/src/net/url/example_test.go +++ b/src/net/url/example_test.go @@ -84,3 +84,17 @@ func ExampleURL_opaque() { // Accept-Encoding: gzip // } + +func ExampleURL_ResolveReference() { + u, err := url.Parse("../../..//search?q=dotnet") + if err != nil { + log.Fatal(err) + } + base, err := url.Parse("http://example.com/directory/") + if err != nil { + log.Fatal(err) + } + fmt.Println(base.ResolveReference(u)) + // Output: + // http://example.com/search?q=dotnet +}