func (enc *Encoder) EncodeEnum(v int32, validEnums map[int32]bool) (err error) {
	if !validEnums[v] {
		err = marshalError("EncodeEnum", ErrBadEnumValue, "invalid enum", v)
		return
	}
	return enc.EncodeInt(v)
}
EncodeEnum treats the passed 32-bit signed integer as an enumeration value
and, if it is in the list of passed valid enumeration values, appends the XDR
encoded representation of it to the Encoder's data.

A MarshalError is returned if the enumeration value is not one of the provided
valid values or appending the data would overflow the internal data slice.

Reference:
RFC Section 4.3 - Enumeration
Represented as an XDR encoded signed integer
package xdr
import (
	"fmt"
	"math"
	"reflect"
	"time"
)
var errMaxXdr = "data exceeds max xdr size limit"
func Marshal(v interface{}) (rv []byte, err error) {
	if v == nil {
		msg := "can't marshal nil interface"
		err = marshalError("Marshal", ErrNilInterface, msg, nil)
		return nil, err
	}
	vv := reflect.ValueOf(v)
	vve := vv
	for vve.Kind() == reflect.Ptr {
		if vve.IsNil() {
			msg := fmt.Sprintf("can't marshal nil pointer '%v'",
				vv.Type().String())
			err = marshalError("Marshal", ErrBadArguments, msg, nil)
			return nil, err
		}
		vve = vve.Elem()
	}
	enc := Encoder{}
	err = enc.encode(vve)
	return enc.data, err
}
type Encoder struct {
	data []byte
	off  int
}
func (enc *Encoder) EncodeInt(v int32) (err error) {
	b := make([]byte, 4, 4)
	b[0] = byte(v >> 24)
	b[1] = byte(v >> 16)
	b[2] = byte(v >> 8)
	b[3] = byte(v)
	if len(enc.data) > maxInt-4 {
		err = marshalError("EncodeInt", ErrOverflow, errMaxSlice, b)
		return
	}
	enc.data = append(enc.data, b...)
	return
}
func (enc *Encoder) EncodeUint(v uint32) (err error) {
	b := make([]byte, 4, 4)
	b[0] = byte(v >> 24)
	b[1] = byte(v >> 16)
	b[2] = byte(v >> 8)
	b[3] = byte(v)
	if len(enc.data) > maxInt-4 {
		err = marshalError("EncodeUint", ErrOverflow, errMaxSlice, b)
		return
	}
	enc.data = append(enc.data, b...)
	return
}