Standard library / net/url

url.Userinfo.Password()

Return the password and whether one was supplied. Expected stdout: '9 true\n'.

Formal Syntax & Structure

go syntaxgo
func (u *Userinfo) Password() (string, bool)

Return Value

(string, bool)

Operation result; check errors and validity indicators when returned.

Working Example

Example Snippetgo
package main
import (  "fmt"  "net/url")
func main() { p, ok := url.UserPassword("demo", "test-only").Password(); fmt.Println(len(p), ok) }
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)  }}
Go Reference