in src/message/messageparser.go [377:396]
func putString(log log.T, byteArray []byte, offsetStart int, offsetEnd int, inputString string) (err error) {
byteArrayLength := len(byteArray)
if offsetStart > byteArrayLength-1 || offsetEnd > byteArrayLength-1 || offsetStart > offsetEnd || offsetStart < 0 {
log.Error("putString failed: Offset is invalid.")
return errors.New("Offset is outside the byte array.")
}
if offsetEnd-offsetStart+1 < len(inputString) {
log.Error("putString failed: Not enough space to save the string.")
return errors.New("Not enough space to save the string.")
}
// wipe out the array location first and then insert the new value.
for i := offsetStart; i <= offsetEnd; i++ {
byteArray[i] = ' '
}
copy(byteArray[offsetStart:offsetEnd+1], inputString)
return nil
}