我想做这样的事情,但显然这是不可能的,我认为我想念一些东西。
type command struct {
help string
handler func (params ...interface{})
}
func showHelp( commands map[string]command ) {
fmt.Println( "Help:" )
for c, h := range commands {
fmt.Println( c,"->" ,h.help )
}
}
func main() {
// Map to store commands
commands := make( map[string]command )
// Adding help command
commands["help"] = command{ "show this information", showHelp }
}
四季花海
潇湘沐
相关分类