diff --git a/doc/go1.15.html b/doc/go1.15.html index e75132bfa7..8d74c9a5c1 100644 --- a/doc/go1.15.html +++ b/doc/go1.15.html @@ -134,6 +134,16 @@ TODO +
net/url
+
+

+ The new URL + method Redacted + returns the URL in string form with any password replaced with xxxxx. +

+
+
+
runtime

diff --git a/src/net/url/example_test.go b/src/net/url/example_test.go index ad67f5328a..f0d3d2bf45 100644 --- a/src/net/url/example_test.go +++ b/src/net/url/example_test.go @@ -205,6 +205,21 @@ func ExampleURL_UnmarshalBinary() { // https://example.org/foo } +func ExampleURL_Redacted() { + u := &url.URL{ + Scheme: "https", + User: url.UserPassword("user", "password"), + Host: "example.com", + Path: "foo/bar", + } + fmt.Println(u.Redacted()) + u.User = url.UserPassword("me", "newerPassword") + fmt.Println(u.Redacted()) + // Output: + // https://user:xxxxx@example.com/foo/bar + // https://me:xxxxx@example.com/foo/bar +} + func ExampleURL_RequestURI() { u, err := url.Parse("https://example.org/path?foo=bar") if err != nil {