1
有什麼方法可以使Warn函數起作用?如何將可變參數傳遞給其他函數
func Warn(s string, args ...interface{}) {
log.Printf("warn: "+s, args)
}
func main() {
Warn("%d apples, %s ", 10, "good") //it should output the same as below
log.Printf("%d apples, %s ", 10, "good")
}
輸出:
2009/11/10 23:00:00 warn: [10 %!d(string=good)] apples, %s(MISSING)
2009/11/10 23:00:00 10 apples, good
我試圖使這項工作:http://play.golang.org/p/W62f2NGDUe