code: func readFieldLength(valBytes []byte) (
  	length uint64,
  	remaining []byte,
  	err error) {
  
  	if len(valBytes) == 0 {
  		return 0, nil, errors.New("Empty field length input")
  	}
  
  	val := uint64(valBytes[0])
  	if val < 251 {
  		return val, valBytes[1:], nil
  	} else if val == 251 {
  		return NullLength, valBytes[1:], nil
  	}
  	size := 9
  	if val == 252 {
  		size = 3
  	} else if val == 253 {
  		size = 4
  	}
  	if len(valBytes) < size {
  		return 0, nil, errors.Newf(
  			"Invalid field length input (expected at least %d bytes)",
  			size)
  	}
  	// NOTE: mysql's net_field_length implementation is somewhat broken.
  	// In particular, when net_store_length encode a ulong using 8 bytes,
  	// net_field_length will only read the first 4 bytes, and ignore the
  	// rest ....
  	return bytesToLEUint(valBytes[1:size]), valBytes[size:], nil
  }
docs: // Note: this is equivalent to net_field_length in sql-common/pack.c