1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| func main() { slice := make([]byte, 1024) slice = strconv.AppendBool(slice, true) slice = strconv.AppendInt(slice, 1234, 10) slice = strconv.AppendQuote(slice, "abcgohello")
fmt.Println("slice = ", string(slice))
var str string str = strconv.FormatBool(false) fmt.Println("str = ", str) str = strconv.FormatFloat(3.14, 'f', -1, 64) fmt.Println("str = ", str)
str = strconv.Itoa(6666) fmt.Println("str = ", str)
flag, err := strconv.ParseBool("true") if err != nil { fmt.Println("err = ", err) } fmt.Println("flag = ", flag)
a, _ := strconv.Atoi("56479") fmt.Println("a = ", a)
}
|