FigmentEngine , . , . , , , .
Context. , .
type Context struct {
commands map[string]func(Context)
}
, :
var context = Context {
commands: map[string]func(Context) {
"hello": hello,
"list": list,
},
}
, , , :
func hello(ctx Context) {
fmt.Print("Hello World!")
}
func list(ctx Context) {
for key, _ := range ctx.commands {
fmt.Print(key)
}
}
, :
func main() {
for key, fn := range context.commands {
fmt.Printf("Calling %q\n", key)
fn(context)
}
}