Jelajahi Sumber

工具类 int 2 bytes

zzf 1 tahun lalu
induk
melakukan
c02daef99d
1 mengubah file dengan 12 tambahan dan 0 penghapusan
  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) {
+
+}