The following code snippet was derived from the golang/sample_per/employee sample program in the ASN1C distribution:
package main import ( "employee/asn1gen" "encoding/hex" "fmt" "io/ioutil" "os" ) func main() { var pdu asn1gen.PersonnelRecord encoding, err := ioutil.ReadFile("message.per") if err != nil { fmt.Printf("Read message.per failed: %s\n", err) return } _, err = asn1gen.Unmarshal(encoding, &pdu) if err == nil { fmt.Printf("Decoding was successful:\n") } else { fmt.Printf("Decoding failed: %s\n", err) }