Ver Fonte

工具类 int 2 bytes

zzf há 1 ano atrás
pai
commit
c02daef99d
1 ficheiros alterados com 12 adições e 0 exclusões
  1. 12 0
      common/utils.go

+ 12 - 0
common/utils.go

@@ -40,3 +40,15 @@ func GetCurrentAbPathByExecutable() string {
 	res, _ := filepath.EvalSymlinks(filepath.Dir(exePath))
 	return res
 }
+
+func Int2Bytes(i int) [4]byte {
+	var result [4]byte
+	result[0] = byte(i >> 24 & 0xFF)
+	result[1] = byte(i >> 16 & 0xFF)
+	result[2] = byte(i >> 8 & 0xFF)
+	result[3] = byte(i & 0xFF)
+	return result
+}
+func Bytes2HexStr(bytes [4]byte) {
+
+}