浏览代码

工具类 int 2 bytes

zzf 1 年之前
父节点
当前提交
c02daef99d
共有 1 个文件被更改,包括 12 次插入0 次删除
  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) {
+
+}