Skip to content

Instantly share code, notes, and snippets.

@jimjh
Created November 4, 2012 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimjh/4012189 to your computer and use it in GitHub Desktop.
Save jimjh/4012189 to your computer and use it in GitHub Desktop.
Padding with sprintf
package main
import "fmt"
func main() {
// make sure that printf pads digits with zeros so we can sort the strings
// without converting to them back to ints
fmt.Printf("%010d\n", 1)
fmt.Printf("%010d\n", 15)
fmt.Printf("%010d\n", 250)
fmt.Printf("%010d\n", 2560)
fmt.Printf("%010d\n", 34234)
fmt.Printf("%010d\n", 444444)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment