Skip to content

Commit 83bfe3b

Browse files
committed
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 <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent b10849f commit 83bfe3b

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

doc/go1.15.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,16 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
134134
</dd>
135135
</dl>
136136

137+
<dl id="net/url"><dt><a href="/pkg/net/url/">net/url</a></dt>
138+
<dd>
139+
<p><!-- CL 207082 -->
140+
The new <a href="/pkg/net/url/#URL"><code>URL</code></a>
141+
method <a href="/pkg/net/url/#URL.Redacted"><code>Redacted</code></a>
142+
returns the URL in string form with any password replaced with <code>xxxxx</code>.
143+
</p>
144+
</dd>
145+
</dl>
146+
137147
<dl id="pkg-runtime"><dt><a href="/pkg/runtime/">runtime</a></dt>
138148
<dd>
139149
<p><!-- CL 221779 -->

src/net/url/example_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,21 @@ func ExampleURL_UnmarshalBinary() {
205205
// https://example.org/foo
206206
}
207207

208+
func ExampleURL_Redacted() {
209+
u := &url.URL{
210+
Scheme: "https",
211+
User: url.UserPassword("user", "password"),
212+
Host: "example.com",
213+
Path: "foo/bar",
214+
}
215+
fmt.Println(u.Redacted())
216+
u.User = url.UserPassword("me", "newerPassword")
217+
fmt.Println(u.Redacted())
218+
// Output:
219+
// https://user:[email protected]/foo/bar
220+
// https://me:[email protected]/foo/bar
221+
}
222+
208223
func ExampleURL_RequestURI() {
209224
u, err := url.Parse("https://example.org/path?foo=bar")
210225
if err != nil {

0 commit comments

Comments
 (0)