Generated Go Function Format and Calling Parameters

The primary interface to encode data in Go is through the use of the generated Marshal function. This function has the same signature as that found in the Go encoding/asn1 package:

func Marshal(val interface{}) ([]byte, error)

The val argument holds a value of the type to be encoded. Note that the Marshal function only encodes types determined to be Protocol Data Unit (PDU) types. By default, a PDU type in a schema is a type not found to be referenced by any other type. This behavior can be overridden by using the -pdu command-line option to explicitly select types as PDU types.

The Marshal function returns the encoded message in memory as a byte slice. If any errors occur during encoding, the error result is returned in the error return value. The encoded value byte slice will be nil in this case.