go - How to pass variable length arguments as arguments on another function in Golang? -


how pass variable length arguments in go? example, want call

func myprint(format string, args ...interface{}) {   fmt.printf("[my prefix] " + format, ???) }  // called as: myprint("yay %d", 213)  //              or  myprint("yay") //              or  myprint("yay %d %d",123,234) 

ah found it..

package main  import "fmt"  func myprint(format string, args ...interface{}) {   fmt.printf("[my prefix] " + format, args...) }  func main() {  myprint("yay %d %d\n",123,234);  myprint("yay %d\n ",123);  myprint("yay %d\n"); } 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -