package main
import "fmt"
func main() {
res := fmt.Sprintf("Number: %10d", 123)
fmt.Println(res)
}
package main
- default package declarationimport "fmt"
- loadsfmt
package to operate on strings (and print them)fmt.Sprintf(
- formats given string based on a given template and return result%10d
- sample number formatting placeholder, will pad number to 10 spaces on the left123
- sample integer value to formatres
- variable will contain formatted value
group: int_format
package main
import "fmt"
func main() {
res := fmt.Sprintf("Number: %10d", 123)
fmt.Println(res)
}
Number: 123