//菜農[email protected] 2019.6.21於西安雁塔菜地 func inttohex(val, size int) string { //size必須int
fmts := "%0" + strconv.Itoa(size) + "X"//%#輸出0X1234
return fmt.Sprintf(fmts, val)
} func hextoint(str string, size int) int {
var result int = 0
fmts := "%0" + strconv.Itoa(size) + "X" //%#輸入0X1234
fmt.Sscanf(str, fmts, &result)
return result
}