func EncodeTo(term interface{}, buf *bytes.Buffer) error {
	buf.Write([]byte{TagETFVersion})
	if err := encodePayloadTo(term, buf); err != nil {
		return err
	}
	return nil
}
Use Erlang External Term Format
Reference: http://erlang.org/doc/apps/erts/erl_ext_dist.html
package bertrpc  
import (
	"bytes"
	"encoding/binary"
	"fmt"
	"reflect"
)
func Encode(term interface{}) ([]byte, error) {
	var buf bytes.Buffer
	if err := EncodeTo(term, &buf); err != nil {
		return []byte{}, err
	}
	return buf.Bytes(), nil
}