integers.go
func (b *TupleBuilder) PutUint64(field string, value uint64) (wrote uint64, err error) {

	// field type should be
	if err = b.typeCheck(field, Uint64Field); err != nil {
		return 0, err
	}

	if value < math.MaxUint8 {

		// minimum bytes is 2 (type code + value)
		if b.available() < 2 {
			return 0, xbinary.ErrOutOfRange
		}

		// write type code
		b.buffer[b.pos] = byte(UnsignedLong8Code.OpCode)

		// write value
		b.buffer[b.pos+1] = byte(value)

		// set field offset
		b.offsets[field] = b.pos

		// incr pos
		b.pos += 2

		return 2, nil
	} else if value < math.MaxUint16 {

		// write value
		// length check performed by xbinary
		wrote, err = xbinary.LittleEndian.PutUint16(b.buffer, b.pos+1, uint16(value))
		if err != nil {
			return 0, err
		}

		// write type code
		b.buffer[b.pos] = byte(UnsignedLong16Code.OpCode)

		// set field offset
		b.offsets[field] = b.pos

		// incr pos
		b.pos += 3

		// wrote 3 bytes
		return 3, nil
	} else if value < math.MaxUint32 {

		// write value
		// length check performed by xbinary
		wrote, err = xbinary.LittleEndian.PutUint32(b.buffer, b.pos+1, uint32(value))
		if err != nil {
			return 0, err
		}

		// write type code
		b.buffer[b.pos] = byte(UnsignedLong32Code.OpCode)

		// set field offset
		b.offsets[field] = b.pos

		// incr pos
		b.pos += 5

		// wrote 5 bytes
		return 5, nil
	}

	// write value
	// length check performed by xbinary
	wrote, err = xbinary.LittleEndian.PutUint64(b.buffer, b.pos+1, value)
	if err != nil {
		return 0, err
	}
	// write type code
	b.buffer[b.pos] = byte(UnsignedLong64Code.OpCode)

	// set field offset
	b.offsets[field] = b.pos

	// incr pos
	b.pos += 9

	// wrote 9 bytes
	return 9, nil

}
func (b *TupleBuilder) PutUint64(field string, value uint64) (wrote uint64, err error) {

	// field type should be
	if err = b.typeCheck(field, Uint64Field); err != nil {
		return 0, err
	}

	if value < math.MaxUint8 {

		// minimum bytes is 2 (type code + value)
		if b.available() < 2 {
			return 0, xbinary.ErrOutOfRange
		}

		// write type code
		b.buffer[b.pos] = byte(UnsignedLong8Code.OpCode)

		// write value
		b.buffer[b.pos+1] = byte(value)

		// set field offset
		b.offsets[field] = b.pos

		// incr pos
		b.pos += 2

		return 2, nil
	} else if value < math.MaxUint16 {

		// write value
		// length check performed by xbinary
		wrote, err = xbinary.LittleEndian.PutUint16(b.buffer, b.pos+1, uint16(value))
		if err != nil {
			return 0, err
		}

		// write type code
		b.buffer[b.pos] = byte(UnsignedLong16Code.OpCode)

		// set field offset
		b.offsets[field] = b.pos

		// incr pos
		b.pos += 3

		// wrote 3 bytes
		return 3, nil
	} else if value < math.MaxUint32 {

		// write value
		// length check performed by xbinary
		wrote, err = xbinary.LittleEndian.PutUint32(b.buffer, b.pos+1, uint32(value))
		if err != nil {
			return 0, err
		}

		// write type code
		b.buffer[b.pos] = byte(UnsignedLong32Code.OpCode)

		// set field offset
		b.offsets[field] = b.pos

		// incr pos
		b.pos += 5

		// wrote 5 bytes
		return 5, nil
	}

	// write value
	// length check performed by xbinary
	wrote, err = xbinary.LittleEndian.PutUint64(b.buffer, b.pos+1, value)
	if err != nil {
		return 0, err
	}
	// write type code
	b.buffer[b.pos] = byte(UnsignedLong64Code.OpCode)

	// set field offset
	b.offsets[field] = b.pos

	// incr pos
	b.pos += 9

	// wrote 9 bytes
	return 9, nil

}
// PutUint64 sets a 64-bit unsigned integer for the given field name. The field name must be a Uint64Field. Otherwise, an error will be returned. If the type buffer no longer has enough space to write the value, an `xbinary.ErrOutOfRange` error will be returned. Upon success, the number of bytes written as well as a nil error will be returned. The type code will be written first. If the absolute value is `< math.MaxUint8`, only 1 byte will be written. If the absolute value is `< math.MaxUint16`, only 2 bytes will be written. If the absolute value is `< math.MaxUint32`, only 4 bytes will be written. Otherwise, the entire 64-bit value will be written.