diff --git a/commands_test.go b/commands_test.go index e0d5ff3..9caf18e 100644 --- a/commands_test.go +++ b/commands_test.go @@ -27,10 +27,10 @@ func TestTick(t *testing.T) { } func TestSequentially(t *testing.T) { - var expectedErrMsg = fmt.Errorf("some err") - var expectedStrMsg = "some msg" + expectedErrMsg := fmt.Errorf("some err") + expectedStrMsg := "some msg" - var nilReturnCmd = func() Msg { + nilReturnCmd := func() Msg { return nil } diff --git a/examples/chat/main.go b/examples/chat/main.go index 99fd0c6..bbf3b3a 100644 --- a/examples/chat/main.go +++ b/examples/chat/main.go @@ -22,8 +22,10 @@ func main() { } } -type tickMsg struct{} -type errMsg error +type ( + tickMsg struct{} + errMsg error +) type model struct { viewport viewport.Model diff --git a/examples/composable-views/main.go b/examples/composable-views/main.go index 9a876c2..2167d53 100644 --- a/examples/composable-views/main.go +++ b/examples/composable-views/main.go @@ -120,7 +120,7 @@ func (m mainModel) View() string { var s string model := m.currentFocusedModel() if m.state == timerView { - s += lipgloss.JoinHorizontal(lipgloss.Top, focusedModelStyle.Render(fmt.Sprintf("%4s", m.timer.View())), modelStyle.Render( m.spinner.View())) + s += lipgloss.JoinHorizontal(lipgloss.Top, focusedModelStyle.Render(fmt.Sprintf("%4s", m.timer.View())), modelStyle.Render(m.spinner.View())) } else { s += lipgloss.JoinHorizontal(lipgloss.Top, modelStyle.Render(fmt.Sprintf("%4s", m.timer.View())), focusedModelStyle.Render(m.spinner.View())) } diff --git a/examples/credit-card-form/main.go b/examples/credit-card-form/main.go index f4a9293..9128524 100644 --- a/examples/credit-card-form/main.go +++ b/examples/credit-card-form/main.go @@ -19,8 +19,10 @@ func main() { } } -type tickMsg struct{} -type errMsg error +type ( + tickMsg struct{} + errMsg error +) const ( ccn = iota @@ -129,9 +131,7 @@ func (m model) Init() tea.Cmd { } func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { - var ( - cmds []tea.Cmd = make([]tea.Cmd, len(m.inputs)) - ) + var cmds []tea.Cmd = make([]tea.Cmd, len(m.inputs)) switch msg := msg.(type) { case tea.KeyMsg: diff --git a/examples/go.mod b/examples/go.mod index 7abca4d..4e68c8b 100644 --- a/examples/go.mod +++ b/examples/go.mod @@ -1,6 +1,6 @@ module examples -go 1.13 +go 1.16 require ( github.com/charmbracelet/bubbles v0.13.1-0.20220815142520-649f78e1fd8b diff --git a/examples/result/main.go b/examples/result/main.go index a73b17d..60d55a3 100644 --- a/examples/result/main.go +++ b/examples/result/main.go @@ -46,7 +46,6 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.cursor = len(choices) - 1 } } - } return m, nil diff --git a/examples/send-msg/main.go b/examples/send-msg/main.go index 2146387..b1b40a5 100644 --- a/examples/send-msg/main.go +++ b/examples/send-msg/main.go @@ -125,8 +125,10 @@ func main() { } func randomFood() string { - food := []string{"an apple", "a pear", "a gherkin", "a party gherkin", + food := []string{ + "an apple", "a pear", "a gherkin", "a party gherkin", "a kohlrabi", "some spaghetti", "tacos", "a currywurst", "some curry", - "a sandwich", "some peanut butter", "some cashews", "some ramen"} + "a sandwich", "some peanut butter", "some cashews", "some ramen", + } return string(food[rand.Intn(len(food))]) } diff --git a/examples/spinner/main.go b/examples/spinner/main.go index 229542d..c1095f6 100644 --- a/examples/spinner/main.go +++ b/examples/spinner/main.go @@ -52,7 +52,6 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.spinner, cmd = m.spinner.Update(msg) return m, cmd } - } func (m model) View() string { diff --git a/examples/textinput/main.go b/examples/textinput/main.go index eac1c8a..af90208 100644 --- a/examples/textinput/main.go +++ b/examples/textinput/main.go @@ -19,8 +19,10 @@ func main() { } } -type tickMsg struct{} -type errMsg error +type ( + tickMsg struct{} + errMsg error +) type model struct { textInput textinput.Model diff --git a/examples/textinputs/main.go b/examples/textinputs/main.go index 1bd5594..587b8df 100644 --- a/examples/textinputs/main.go +++ b/examples/textinputs/main.go @@ -62,6 +62,7 @@ func initialModel() model { return m } + func (m model) Init() tea.Cmd { return textinput.Blink } @@ -134,7 +135,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } func (m *model) updateInputs(msg tea.Msg) tea.Cmd { - var cmds = make([]tea.Cmd, len(m.inputs)) + cmds := make([]tea.Cmd, len(m.inputs)) // Only text inputs with Focus() set will respond, so it's safe to simply // update all of them here without any further logic. diff --git a/examples/views/main.go b/examples/views/main.go index 1a934be..f27d699 100644 --- a/examples/views/main.go +++ b/examples/views/main.go @@ -46,8 +46,10 @@ func main() { } } -type tickMsg struct{} -type frameMsg struct{} +type ( + tickMsg struct{} + frameMsg struct{} +) func tick() tea.Cmd { return tea.Tick(time.Second, func(time.Time) tea.Msg { diff --git a/go.mod b/go.mod index 628391f..fedb6b0 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/charmbracelet/bubbletea -go 1.13 +go 1.16 require ( github.com/containerd/console v1.0.3 diff --git a/logging.go b/logging.go index 54a4350..97ffcb7 100644 --- a/logging.go +++ b/logging.go @@ -19,7 +19,7 @@ import ( // } // defer f.Close() func LogToFile(path string, prefix string) (*os.File, error) { - f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644) + f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o644) if err != nil { return nil, err } diff --git a/screen_test.go b/screen_test.go index 7bfdf2e..93cb50d 100644 --- a/screen_test.go +++ b/screen_test.go @@ -62,5 +62,4 @@ func TestScreen(t *testing.T) { }, []byte("\x1b[15D")) }) }) - } diff --git a/signals_windows.go b/signals_windows.go index 71da4f0..c60ca57 100644 --- a/signals_windows.go +++ b/signals_windows.go @@ -11,6 +11,7 @@ import ( // listenForResize is not available on windows because windows does not // implement syscall.SIGWINCH. func listenForResize(ctx context.Context, output *os.File, msgs chan Msg, - errs chan error, done chan struct{}) { + errs chan error, done chan struct{}, +) { close(done) } diff --git a/tutorials/go.mod b/tutorials/go.mod index 6d00a45..9f0713f 100644 --- a/tutorials/go.mod +++ b/tutorials/go.mod @@ -1,6 +1,6 @@ module tutorial -go 1.14 +go 1.16 require github.com/charmbracelet/bubbletea v0.21.0