mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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 <emm.odeke@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
b10849fbb9
commit
83bfe3b1bf
2 changed files with 25 additions and 0 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue