如何在Go中传递可变长度参数?例如,我想打电话
func MyPrint(format string,args ...interface{}) { fmt.Printf("[MY PREFIX] " + format,???) } // to be called as: MyPrint("yay %d",213) // or MyPrint("yay") // or MyPrint("yay %d %d",123,234)
啊发现了..
原文链接:https://www.f2er.com/go/187494.htmlpackage main import "fmt" func MyPrint(format string,args...) } func main() { MyPrint("yay %d %d\n",234); MyPrint("yay %d\n ",123); MyPrint("yay %d\n"); }