fix: avoid global state (#126)

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
Carlos Alexandro Becker
2021-09-04 13:48:46 -03:00
committed by GitHub
parent 59e5d8e2c9
commit 60ddf33992
3 changed files with 34 additions and 20 deletions

View File

@@ -13,11 +13,6 @@ type model struct {
selected map[int]struct{}
}
var initialModel = model{
choices: []string{"Carrots", "Celery", "Kohlrabi"},
selected: make(map[int]struct{}),
}
func (m model) Init() tea.Cmd {
return nil
}
@@ -72,6 +67,11 @@ func (m model) View() string {
}
func main() {
initialModel := model{
choices: []string{"Carrots", "Celery", "Kohlrabi"},
selected: make(map[int]struct{}),
}
p := tea.NewProgram(initialModel)
if err := p.Start(); err != nil {
fmt.Printf("Alas, there's been an error: %v", err)