package main import ( "fmt" "log" "github.com/dixonwille/wmenu/v5" ) func main() { type program struct { name string launchFunction func() } programs := []program{ { name: "Pass or Fail", launchFunction: func() { passFail() }, }, { name: "Guessing Game", launchFunction: func() { guess() }, }, { name: "Shopping List", launchFunction: func() { shopping() }, }, { name: "Commandline Test", launchFunction: func() { terminalTest() }, }, { name: "Wall Area", launchFunction: func() { wallArea() }, }, { name: "myIntPointer", launchFunction: func() { myIntPointer() }, }, { name: "Double", launchFunction: func() { double() }, }, { name: "Convert To Celsius", launchFunction: func() { toCelsius() }, }, { name: "Get the Average My Solution", launchFunction: func() { averageMySolution() }, }, { name: "Get the Average Head First Solution", launchFunction: func() { averageHeadFirstSolution() }, }, { name: "Get the Average Variadic", launchFunction: func() { averageVariadic() }, }, { name: "Slices", launchFunction: func() { slices() }, }, { name: "Variadic Functions", launchFunction: func() { variadic() }, }, { name: "Count Votes", launchFunction: func() { countVotes() }, }, { name: "Magazine Subscribers", launchFunction: func() { magazineSubscribers() }, }, { name: "Fuel", launchFunction: func() { fuel() }, }, { name: "Calendar", launchFunction: func() { companyCalendar() }, }, } menu := wmenu.NewMenu("Choose a program.") menu.Action(func(opts []wmenu.Opt) error { fmt.Printf("You chose " + opts[0].Text + ". Launching...\n") for _, v := range programs { if v.name == opts[0].Text { v.launchFunction() } } return nil }) menu.PadOptionID() for _, option := range programs { menu.Option(option.name, nil, false, nil) } err := menu.Run() if err != nil { log.Fatal(err) } }