// Create new Unmarshaller object u := xdr.NewUnmarshaller([]byte{xdr.Uint32, 0, 0, 0, 0x0A, 0x00, 0x00, 0x00}) // Unmarshal XDR encoded string var val uint32 err := u.UnmarshalStringMax(4, &val) // maximum length of 4 bytes if err != nil { panic(err) } fmt.Println(val) // Outputs: 10
// Create new Unmarshaller object u := xdr.NewUnmarshaller([]byte{xdr.Array, 0, 0, 0, 0x03, xdr.Uint32, 0, 0, 0, 0x05, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00}) // Unmarshal XDR encoded string var val []uint32 err := u.UnmarshalStringMax(16, &val) // maximum length of 16 bytes if err != nil { panic(err) } fmt.Println(val) // Outputs: [10]This example demonstrates the use of UnmarshalStringMax to unmarshal an array of uint32 values from an XDR encoded string with a maximum length of 16 bytes. Thus, the package library being used is github.com/calmh.xdr.