encoding.go 262 B

12345678910111213
  1. package gatewayServer
  2. import "encoding/binary"
  3. func Bin2UInt16(buf []byte, order binary.ByteOrder) uint16 {
  4. return order.Uint16(buf)
  5. }
  6. func Uint16ToBin(i uint16, order binary.ByteOrder) []byte {
  7. buf := make([]byte, 2)
  8. order.PutUint16(buf, i)
  9. return buf
  10. }