19 lines
366 B
Go
19 lines
366 B
Go
package lib
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/binary"
|
|
)
|
|
|
|
func IntToBytes(n int32) []byte {
|
|
data := int32(n)
|
|
bytebuf := bytes.NewBuffer([]byte{})
|
|
binary.Write(bytebuf, binary.BigEndian, data)
|
|
return bytebuf.Bytes()
|
|
}
|
|
func Int16ToBytes(data int16) []byte {
|
|
bytebuf := bytes.NewBuffer([]byte{})
|
|
binary.Write(bytebuf, binary.BigEndian, data)
|
|
return bytebuf.Bytes()
|
|
}
|