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 <emm.odeke@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
</dd>
</dl>
+<dl id="net/url"><dt><a href="/pkg/net/url/">net/url</a></dt>
+ <dd>
+ <p><!-- CL 207082 -->
+ The new <a href="/pkg/net/url/#URL"><code>URL</code></a>
+ method <a href="/pkg/net/url/#URL.Redacted"><code>Redacted</code></a>
+ returns the URL in string form with any password replaced with <code>xxxxx</code>.
+ </p>
+ </dd>
+</dl>
+
<dl id="pkg-runtime"><dt><a href="/pkg/runtime/">runtime</a></dt>
<dd>
<p><!-- CL 221779 -->
// 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 {