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

	// field type should be
	if err = b.typeCheck(field, Uint32Field); 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(UnsignedInt8Code.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(UnsignedInt16Code.OpCode)

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

		// incr pos
		b.pos += 3

		// wrote 3 bytes
		return 3, nil
	}

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

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

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

	// incr pos
	b.pos += 5

	// wrote 5 bytes
	return 5, nil
}
func (b *TupleBuilder) PutUint32(field string, value uint32) (wrote uint64, err error) {

	// field type should be
	if err = b.typeCheck(field, Uint32Field); 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(UnsignedInt8Code.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(UnsignedInt16Code.OpCode)

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

		// incr pos
		b.pos += 3

		// wrote 3 bytes
		return 3, nil
	}

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

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

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

	// incr pos
	b.pos += 5

	// wrote 5 bytes
	return 5, nil
}
// PutUint32 sets a 32-bit unsigned value for the given field name. The field name must be a Uint32Field, 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 value is `< math.MaxUint8`, only 1 byte will be written. If the value is `< math.MaxUint16`, only 2 bytes will be written. Otherwise, the entire 32-bit value will be written.