github.com/shakinm/xlsReader@v0.9.12/helpers/utils.go (about) 1 package helpers 2 3 import ( 4 "bytes" 5 "encoding/binary" 6 ) 7 8 func BytesToUint64(b []byte) uint64 { 9 return binary.LittleEndian.Uint64(b) 10 } 11 12 func BytesToUint32(b []byte) uint32 { 13 return binary.LittleEndian.Uint32(b) 14 } 15 16 func BytesToUint16(b []byte) uint16 { 17 return binary.LittleEndian.Uint16(b) 18 } 19 20 func BytesInSlice(a []byte, list [][]byte) bool { 21 for _, b := range list { 22 if bytes.Compare(a, b) == 0 { 23 return true 24 } 25 } 26 return false 27 } 28 29 30 func BytesToUints16(b []byte) (res []uint16) { 31 32 var section = make([]byte, 0) 33 for _, value := range b { 34 section = append(section, value) 35 if len(section) == 2 { 36 res = append(res, binary.LittleEndian.Uint16(section)) 37 38 section = make([]byte, 0) 39 } 40 } 41 return 42 }