编写UtilsToU64, UtilsToU32函数

This commit is contained in:
chenxinquan 2022-11-07 11:20:46 +08:00
parent d8b6e2cc47
commit 1700692398
1 changed files with 15 additions and 0 deletions

View File

@ -47,3 +47,18 @@ func UtilsToS32(i int) string {
/* */
return string(bytes)
}
func UtilsToU64(s sting) int {
bytes := make([]byte, 8)
copy(bytes, []byte(s))
/* */
return int(binary.LittleEndian.Uint64(bytes))
}
func UtilsToU32(s string) int {
bytes := make([]byte, 4)
copy(bytes, []byte(s))
/* */
return int(binary.LittleEndian.Uint32(bytes))
}