Skip to content
Myr

chore: use go 1.16 (#449)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* chore: use go 1.16 and gofmt accordingly * chore: also update examples and tuts to go 1.16

authored by Christian Rocha · committed by GitHub · parent bf39962 · Browse files · 16 files+33 added−26 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

16 files+33 added−26 removed

  • other:+33 added−26 removed

16 files+33 added−26 removed

modified:examples/chat/main.go+4 added-2 removed
20 unmodified lines
21 log.Fatal(err)22 }23}2425type (25type tickMsg struct{}26type errMsg error26 tickMsg struct{}27 errMsg error28)2930type model struct {31 viewport viewport.Model32 messages []string
80 unmodified lines
modified:examples/composable-views/main.go+1 added-1 removed
118 unmodified lines
119func (m mainModel) View() string {120 var s string121 model := m.currentFocusedModel()122 if m.state == timerView {123 s += lipgloss.JoinHorizontal(lipgloss.Top, focusedModelStyle.Render(fmt.Sprintf("%4s", m.timer.View())), modelStyle.Render( m.spinner.View()))123 s += lipgloss.JoinHorizontal(lipgloss.Top, focusedModelStyle.Render(fmt.Sprintf("%4s", m.timer.View())), modelStyle.Render(m.spinner.View()))124 } else {125 s += lipgloss.JoinHorizontal(lipgloss.Top, modelStyle.Render(fmt.Sprintf("%4s", m.timer.View())), focusedModelStyle.Render(m.spinner.View()))126 }127 s += helpStyle.Render(fmt.Sprintf("\ntab: change focused model • n: new %s • q: exit\n", model))
31 unmodified lines
modified:examples/credit-card-form/main.go+5 added-5 removed
17 unmodified lines
18 log.Fatal(err)19 }20}2122type (22type tickMsg struct{}23type errMsg error23 tickMsg struct{}24 errMsg error25)2627const (28 ccn = iota29 exp
100 unmodified lines
130 return textinput.Blink131}132133func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {132 var (133 cmds []tea.Cmd = make([]tea.Cmd, len(m.inputs))134 var cmds []tea.Cmd = make([]tea.Cmd, len(m.inputs))134 )135136 switch msg := msg.(type) {137 case tea.KeyMsg:138 switch msg.Type {
65 unmodified lines
modified:examples/result/main.go-1 removed
44 unmodified lines
45 if m.cursor < 0 {46 m.cursor = len(choices) - 147 }48 }4949 }5051 return m, nil52}
34 unmodified lines
modified:examples/send-msg/main.go+4 added-2 removed
123 unmodified lines
124 }125}126127func randomFood() string {128 food := []string{"an apple", "a pear", "a gherkin", "a party gherkin",128 food := []string{129 "an apple", "a pear", "a gherkin", "a party gherkin",130 "a kohlrabi", "some spaghetti", "tacos", "a currywurst", "some curry",130 "a sandwich", "some peanut butter", "some cashews", "some ramen"}131 "a sandwich", "some peanut butter", "some cashews", "some ramen",132 }133 return string(food[rand.Intn(len(food))])134}
modified:examples/spinner/main.go-1 removed
50 unmodified lines
51 var cmd tea.Cmd52 m.spinner, cmd = m.spinner.Update(msg)53 return m, cmd54 }5555}5657func (m model) View() string {58 if m.err != nil {
16 unmodified lines
modified:examples/textinput/main.go+4 added-2 removed
17 unmodified lines
18 log.Fatal(err)19 }20}2122type (22type tickMsg struct{}23type errMsg error23 tickMsg struct{}24 errMsg error25)2627type model struct {28 textInput textinput.Model29 err error
46 unmodified lines
modified:examples/textinputs/main.go+2 added-1 removed
60 unmodified lines
61 }6263 return m64}6566func (m model) Init() tea.Cmd {67 return textinput.Blink68}69
64 unmodified lines
134 return m, cmd135}136137func (m *model) updateInputs(msg tea.Msg) tea.Cmd {137 var cmds = make([]tea.Cmd, len(m.inputs))138 cmds := make([]tea.Cmd, len(m.inputs))139140 // Only text inputs with Focus() set will respond, so it's safe to simply141 // update all of them here without any further logic.142 for i := range m.inputs {
35 unmodified lines
modified:examples/views/main.go+4 added-2 removed
44 unmodified lines
45 fmt.Println("could not start program:", err)46 }47}4849type tickMsg struct{}50type frameMsg struct{}49type (50 tickMsg struct{}51 frameMsg struct{}52)5354func tick() tea.Cmd {55 return tea.Tick(time.Second, func(time.Time) tea.Msg {56 return tickMsg{}
235 unmodified lines
modified:examples/go.mod+1 added-1 removed
1module examples23go 1.133go 1.1645require (6 github.com/charmbracelet/bubbles v0.13.1-0.20220815142520-649f78e1fd8b7 github.com/charmbracelet/bubbletea v0.22.0
10 unmodified lines
modified:tutorials/go.mod+1 added-1 removed
1module tutorial23go 1.143go 1.1645require github.com/charmbracelet/bubbletea v0.21.067replace github.com/charmbracelet/bubbletea => ../
modified:commands_test.go+3 added-3 removed
25 unmodified lines
26 }27}2829func TestSequentially(t *testing.T) {30 var expectedErrMsg = fmt.Errorf("some err")31 var expectedStrMsg = "some msg"30 expectedErrMsg := fmt.Errorf("some err")31 expectedStrMsg := "some msg"3233 var nilReturnCmd = func() Msg {33 nilReturnCmd := func() Msg {34 return nil35 }3637 tests := []struct {
70 unmodified lines
modified:go.mod+1 added-1 removed
1module github.com/charmbracelet/bubbletea23go 1.133go 1.1645require (6 github.com/containerd/console v1.0.37 github.com/mattn/go-isatty v0.0.16
9 unmodified lines
modified:logging.go+1 added-1 removed
17 unmodified lines
18// os.Exit(1)19// }20// defer f.Close()21func LogToFile(path string, prefix string) (*os.File, error) {22 f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)22 f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o644)23 if err != nil {24 return nil, err25 }26 log.SetOutput(f)
13 unmodified lines
modified:screen_test.go-1 removed
60 unmodified lines
61 cursorBack(w, 15)62 }, []byte("\x1b[15D"))63 })64 })6565}
modified:signals_windows.go+2 added-1 removed
9 unmodified lines
1011// listenForResize is not available on windows because windows does not12// implement syscall.SIGWINCH.13func listenForResize(ctx context.Context, output *os.File, msgs chan Msg,14 errs chan error, done chan struct{}) {14 errs chan error, done chan struct{},15) {16 close(done)17}