Go — variadic parameter functions weirdness
Posted
by
ivanzoid
on Stack Overflow
See other posts from Stack Overflow
or by ivanzoid
Published on 2012-09-08T21:36:23Z
Indexed on
2012/09/08
21:37 UTC
Read the original article
Hit count: 384
go
I'm trying to write simple fmt.Printf wrapper which takes variable number of arguments, here is the code:
func Die(format string, args ...interface{}) {
str := fmt.Sprintf(format, args)
fmt.Fprintf(os.Stderr, "%v\n", str)
os.Exit(1)
}
But when I'm calling it:
Die("foo")
I get:
foo%!(EXTRA []interface {}=[])
Can't figure why I'm getting this text after the "foo" & what is the correct way to create wrappers around fmt.Fprintf?
© Stack Overflow or respective owner