Standard library / net/url
url.URL.Redacted()
Return a URL string with its password replaced; other secrets in paths or queries are not hidden. Expected stdout: 'https://demo:xxxxx@example.invalid/a%2Fb?q=go#x%20y\n'.
Formal Syntax & Structure
go syntaxgo
func (u *URL) Redacted() stringReturn Value
string
Operation result; check errors and validity indicators when returned.
Working Example
Example Snippetgo
package main
import ( "fmt" "net/url")
func main() { u := must(url.Parse("https://example.invalid/a%2Fb?q=go#x%20y")) u.User = url.UserPassword("demo", "test-only") fmt.Println(u.Redacted())}
func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}