Situation:
I'm trying to write a simple fmt.Fprintf
wrapper which takes a variable number of arguments. This is the code:
func Die(format string, args ...interface{}) {
str := fmt.Sprintf(format, args)
fmt.Fprintf(os.Stderr, "%v
", str)
os.Exit(1)
}
Problem:
When I call it with Die("foo")
, I get the following output (instead of "foo"):
foo%!(EXTRA []interface {}=[])
- Why is there "%!(EXTRA []interface {}=[])" after the "foo"?
- What is the correct way to create wrappers around
fmt.Fprintf
?