code: func readHexLength(r io.Reader) (int, error) {
  	lengthHex := make([]byte, 4)
  	n, err := io.ReadFull(r, lengthHex)
  	if err != nil {
  		return 0, errIncompleteMessage("length", n, 4)
  	}
  
  	length, err := strconv.ParseInt(string(lengthHex), 16, 64)
  	if err != nil {
  		return 0, errors.WrapErrorf(err, errors.NetworkError, "could not parse hex length %v", lengthHex)
  	}
  
  	// Clip the length to 255, as per the Google implementation.
  	if length > MaxMessageLength {
  		length = MaxMessageLength
  	}
  
  	return int(length), nil
  }
docs: // readHexLength reads the next 4 bytes from r as an ASCII hex-encoded length and parses them into an int.