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.
package main
import "fmt"
func main() {
tmp_str := "hello %s"
str := fmt.Sprintf(tmp_str, "world")
fmt.Println(str)
}
In some cases, the program will pass a completed string like "Hello Friends", instead of a string template.. The program would panic and return:
Hello Friends%!(EXTRA string=world)
So, how to ignore the extra fields for fmt.Sprintf?