I have a Golang program that reads a string parameter from command line and passes it to the fmt.Sprintf function. Let\'s say tmp_str is the target string from command line.
I agree with Volker's answer, but you could check your input string:
package main import ( "fmt" "strings" ) func main() { tmp_str := "hello %s" res := tmp_str if strings.Count(tmp_str, "%s") == 1 { res = fmt.Sprintf(tmp_str, "world") } fmt.Println(res) }