cast
cast copied to clipboard
ToInt have bad case
for example,string is "00011",handle ToInt("00011"),want to get int value is 11,now return 9;
need exchange caste.go trimZeroDecimal method,first trimleft zero
func trimZeroDecimal(s string) string { s = strings.TrimLeft(s, "0") var foundZero bool for i := len(s); i > 0; i-- { switch s[i-1] { case '.': if foundZero { return s[:i-1] } case '0': foundZero = true default: return s } } return s }
Cast package treats this value as an octal number.