Skip to content

Instantly share code, notes, and snippets.

@holys
Created August 15, 2014 03:25
Show Gist options
  • Save holys/defa0b41c5534fd36bb1 to your computer and use it in GitHub Desktop.
Save holys/defa0b41c5534fd36bb1 to your computer and use it in GitHub Desktop.
package main
import "fmt"
func f(p string) {
fmt.Println("function f parameter:", p)
}
func g(p string, q int) {
fmt.Println("function g parameters:", p, q)
}
func main() {
m := map[string]interface{}{
"f": f,
"g": g,
}
for k, v := range m {
switch k {
case "f":
v.(func(string))("astring")
case "g":
v.(func(string, int))("astring", 42)
}
}
}
//from http://stackoverflow.com/a/6770333/1297203
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment