11 lines
284 B
Go
Raw Normal View History

2024-01-26 17:14:20 +01:00
package game
import "encoding/binary"
// AppendString appends the length of the string followed by its contents.
func AppendString(data []byte, str string) []byte {
data = binary.LittleEndian.AppendUint32(data, uint32(len(str)))
data = append(data, []byte(str)...)
return data
}