Standard library / crypto/x509

crypto/x509.OID.UnmarshalBinary()

Decodes OID content octets and replaces receiver on success. Expected stdout: '1.2.3\n'.

Formal Syntax & Structure

go syntaxgo
func (o *OID) UnmarshalBinary(b []byte) error

Parameters & Attributes

NameTypeDescription
b[]byteBinary OID content or PEM block, according to signature.

Return Value

error

Result as described above; check any returned error before use.

Working Example

Example Snippetgo
package main
import (  "crypto/x509"  "fmt")
func main() { var v x509.OID; check(v.UnmarshalBinary([]byte{0x2a, 3})); fmt.Println(v.String()) }
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