Let's say I want to pad out a number in Go:
4 => "004"
23 => "023"
How can I do it?
Let's say I want to pad out a number in Go:
4 => "004"
23 => "023"
How can I do it?
Use the "%0xd"
flag to fmt.Printf
from the fmt package, where x
is the number of leading zeros to pad.
import "fmt"
fmt.Printf("%03d", 4) // will print "004"
The interface is the same as in C.