Standard library / net/url

url.Userinfo.Username()

Return the unescaped username. Expected stdout: 'a b\n'.

Formal Syntax & Structure

go syntaxgo
func (u *Userinfo) Username() string

Return Value

string

Operation result; check errors and validity indicators when returned.

Working Example

Example Snippetgo
package main
import (  "fmt"  "net/url")
func main() { fmt.Println(url.User("a b").Username()) }
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