Doesn't go offer an out of the box solution to format thousands?

Hi, please correct me if I’m wrong, but I’m surprised to see that it seems Golang doesn’t have a built-in formatter for Sprintf / Printf to deal with thousands, as found in this stackoverflow discussion

Since the question above is quite old (2012), how is this today? Do we actually have to code a method or add custom package to format 1000 as 1,000.00?

Hi, the code you posted doesn’t format number in thousands like 1,000 out-of-the-box.

package main

import "fmt"

func main() {
	v := 1000
	fmt.Printf("print %d as %0.2f\n", v, float64(v))


print 1000 as 1000.00

I have found some packages that does that formatting, but I’m wondering if we have a built-in formatter:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.