xdr/main.go
func SafeUnmarshalBase64(data string, dest interface{}) error {
	count := &countWriter{}
	l := len(data)

	b64 := io.TeeReader(strings.NewReader(data), count)
	raw := base64.NewDecoder(base64.StdEncoding, b64)
	_, err := Unmarshal(raw, dest)

	if err != nil {
		return err
	}

	if count.Count != l {
		return fmt.Errorf("input not fully consumed. expected to read: %d, actual: %d", l, count.Count)
	}

	return nil
}
func SafeUnmarshalBase64(data string, dest interface{}) error {
	count := &countWriter{}
	l := len(data)

	b64 := io.TeeReader(strings.NewReader(data), count)
	raw := base64.NewDecoder(base64.StdEncoding, b64)
	_, err := Unmarshal(raw, dest)

	if err != nil {
		return err
	}

	if count.Count != l {
		return fmt.Errorf("input not fully consumed. expected to read: %d, actual: %d", l, count.Count)
	}

	return nil
}
// SafeUnmarshalBase64 first decodes the provided reader from base64 before decoding the xdr
// into the provided destination.  Also ensures that the reader is fully consumed.