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

	// field type should be
	if err = b.typeCheck(field, Uint16Field); 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(UnsignedShort8Code.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
	}

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

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

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

	// incr pos
	b.pos += 3

	// wrote 3 bytes
	return 3, nil

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

	// field type should be
	if err = b.typeCheck(field, Uint16Field); 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(UnsignedShort8Code.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
	}

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

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

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

	// incr pos
	b.pos += 3

	// wrote 3 bytes
	return 3, nil

}
// PutUint16 sets a 16-bit unsigned value for the given field name.The field name must be a Uint16Field 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 writtn first. If the value is `< math.MaxUint8`, only 1 byte will be written. Otherwise, the entire 16-bit value will be written.