Standard library / crypto/x509

crypto/x509.OID.EqualASN1OID()

Compares an OID to an ASN.1 object identifier. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func (oid OID) EqualASN1OID(other asn1.ObjectIdentifier) bool

Parameters & Attributes

NameTypeDescription
otherasn1.ObjectIdentifierOther value to compare.

Return Value

bool

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

Working Example

Example Snippetgo
package main
import (  "crypto/x509"  "encoding/asn1"  "fmt")
func main() {  v := must(x509.ParseOID("1.2.3"))  fmt.Println(v.EqualASN1OID(asn1.ObjectIdentifier{1, 2, 3}))}
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