From: Emmanuel T Odeke Date: Sat, 11 Apr 2020 22:38:51 +0000 (-0700) Subject: doc/go1.15, net/url: document new method URL.Redacted X-Git-Tag: go1.15beta1~589 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=83bfe3b1bf25021d0a33352bed12696f5abe420a;p=gostls13.git doc/go1.15, net/url: document new method URL.Redacted Adds an entry in the Go1.15 release notes, but also adds an example test for URL.Redacted. Follow-up of CL 207082. Updates #37419 Change-Id: Ibf81989778907511a3a3a3e4a03d1802b5dd9762 Reviewed-on: https://go-review.googlesource.com/c/go/+/227997 Run-TryBot: Emmanuel Odeke Reviewed-by: Ian Lance Taylor TryBot-Result: Gobot Gobot --- 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 {