Golangで文字列数値をカンマ区切りにするメモ。
カンマ区切りにするために dustin/go-humanize
を使用する。
s := "10000" i, _ := strconv.Atoi(s) // 文字列を数値にする c := humanize.Comma(int64(i)) // int64に変換して、カンマ区切りにする fmt.Println(c) // 10,000
Golangで文字列数値をカンマ区切りにするメモ。
カンマ区切りにするために dustin/go-humanize
を使用する。
s := "10000" i, _ := strconv.Atoi(s) // 文字列を数値にする c := humanize.Comma(int64(i)) // int64に変換して、カンマ区切りにする fmt.Println(c) // 10,000