Is Golang contains a function to lead some string with a given prefix?
For example:
s : = "5"
prefix := "0"
// what I need is - 005, so that lenght of `s` is max 3 characters
// and if `s` is 15 then 015
// and so on
Is Golang contains a function to lead some string with a given prefix?
For example:
s : = "5"
prefix := "0"
// what I need is - 005, so that lenght of `s` is max 3 characters
// and if `s` is 15 then 015
// and so on
fmt.Sprintf("%03d", 15)
will do the magic. Go read https://gobyexample.com/string-formatting and https://golang.org/pkg/fmt/
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.