Standard library / net/url

url.URL.UnmarshalBinary()

Parse a binary URL representation into the receiver. Expected stdout: '/new\n'.

Formal Syntax & Structure

go syntaxgo
func (u *URL) UnmarshalBinary(text []byte) error

Parameters & Attributes

NameTypeDescription
text[]byteText encoding of the address, endpoint or prefix.

Return Value

error

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"))  check(u.UnmarshalBinary([]byte("https://example.invalid/new")))  fmt.Println(u.Path)}
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