]> Cypherpunks repositories - gostls13.git/commitdiff
doc/go1.15, net/url: document new method URL.Redacted
authorEmmanuel T Odeke <emmanuel@orijtech.com>
Sat, 11 Apr 2020 22:38:51 +0000 (15:38 -0700)
committerEmmanuel Odeke <emm.odeke@gmail.com>
Sun, 12 Apr 2020 00:19:41 +0000 (00:19 +0000)
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>

doc/go1.15.html
src/net/url/example_test.go

index e75132bfa74c2535950a42722d7b628afa64a524..8d74c9a5c14f85c6b2d8ccf896158c6aeb4af606 100644 (file)
@@ -134,6 +134,16 @@ TODO
   </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 -->
index ad67f5328a8688cd5104d2067098c14e2eb51bf8..f0d3d2bf45df83099bb3cf84928c51446b67ebdc 100644 (file)
@@ -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 {