Golang encoding/asn1.StructuralError type examples

package encoding/asn1

A StructuralError suggests that the ASN.1 data is valid, but the Go type which is receiving it doesn't match.

Golang encoding/asn1.StructuralError type usage examples :

Example 1 :

 if !ok1 {
 err = StructuralError{fmt.Sprintf("unknown Go type: %v", fieldType)}
 return
 }

Example 2:

 func marshalObjectIdentifier(out *forkableWriter, oid []int) (err error) {
 if len(oid) < 2 || oid[0] > 6 || oid[1] >= 40 {
 return StructuralError{"invalid object identifier"}
 }
 }

References :

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

http://golang.org/src/pkg/encoding/asn1/marshal.go

Advertisement