1
0
mirror of https://github.com/golang/go synced 2024-11-23 05:20:11 -07:00

net/url: add example to URL.ResolveReference

Change-Id: I9db1997b8dc7e06e9d124753ead6221470a1edf9
Reviewed-on: https://go-review.googlesource.com/12254
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Carlos C 2015-07-09 15:08:39 +02:00 committed by Brad Fitzpatrick
parent 6163cf87c8
commit 6094b88c48

View File

@ -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
}