Skip to content

Commit

Permalink
doc/go1.15, net/url: document new method URL.Redacted
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
  • Loading branch information
odeke-em committed Apr 12, 2020
1 parent b10849f commit 83bfe3b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions doc/go1.15.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
</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 -->
Expand Down
15 changes: 15 additions & 0 deletions src/net/url/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:[email protected]/foo/bar
// https://me:[email protected]/foo/bar
}

func ExampleURL_RequestURI() {
u, err := url.Parse("https://example.org/path?foo=bar")
if err != nil {
Expand Down

0 comments on commit 83bfe3b

Please sign in to comment.