Golang encoding/asn1.RawContent type example

package encoding/asn1

RawContent is used to signal that the undecoded, DER data needs to be preserved for a struct. To use it, the first field of the struct must have this type. It's an error for any of the other fields to have this type.

Golang encoding/asn1.RawContent type usage example ( example taken from https://code.google.com/p/go/source/browse/src/pkg/crypto/x509/x509.go )

 type certificate struct {
  Raw asn1.RawContent // <--- first field!
  TBSCertificate tbsCertificate
  SignatureAlgorithm pkix.AlgorithmIdentifier
  SignatureValue asn1.BitString
 }

Reference :

http://golang.org/pkg/encoding/asn1/#RawContent

Advertisement