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
Provenance
- Commit
1a0beff- Tree
5906eb3- Author
Christian Rocha <christian@rocha.is>- Committer
GitHub <noreply@github.com>- Parent
bf39962
16 files changed+33 added−26 removed
modified:examples/chat/main.go+4 added-2 removed
20 unmodified lines21 log.Fatal(err)22 }23 }24 25+type (25-type tickMsg struct{}26-type errMsg error26+ tickMsg struct{}27+ errMsg error28+)29 30 type model struct {31 viewport viewport.Model32 messages []string80 unmodified linesmodified:examples/composable-views/main.go+1 added-1 removed
118 unmodified lines119 func (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 linesmodified:examples/credit-card-form/main.go+5 added-5 removed
17 unmodified lines18 log.Fatal(err)19 }20 }21 22+type (22-type tickMsg struct{}23-type errMsg error23+ tickMsg struct{}24+ errMsg error25+)26 27 const (28 ccn = iota29 exp100 unmodified lines130 return textinput.Blink131 }132 133 func (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- )135 136 switch msg := msg.(type) {137 case tea.KeyMsg:138 switch msg.Type {65 unmodified linesmodified:examples/result/main.go-1 removed
44 unmodified lines45 if m.cursor < 0 {46 m.cursor = len(choices) - 147 }48 }49-49 }50 51 return m, nil52 }34 unmodified linesmodified:examples/send-msg/main.go+4 added-2 removed
123 unmodified lines124 }125 }126 127 func 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 lines51 var cmd tea.Cmd52 m.spinner, cmd = m.spinner.Update(msg)53 return m, cmd54 }55-55 }56 57 func (m model) View() string {58 if m.err != nil {16 unmodified linesmodified:examples/textinput/main.go+4 added-2 removed
17 unmodified lines18 log.Fatal(err)19 }20 }21 22+type (22-type tickMsg struct{}23-type errMsg error23+ tickMsg struct{}24+ errMsg error25+)26 27 type model struct {28 textInput textinput.Model29 err error46 unmodified linesmodified:examples/textinputs/main.go+2 added-1 removed
60 unmodified lines61 }62 63 return m64 }65+66 func (m model) Init() tea.Cmd {67 return textinput.Blink68 }69 64 unmodified lines134 return m, cmd135 }136 137 func (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))139 140 // 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 linesmodified:examples/views/main.go+4 added-2 removed
44 unmodified lines45 fmt.Println("could not start program:", err)46 }47 }48 49-type tickMsg struct{}50-type frameMsg struct{}49+type (50+ tickMsg struct{}51+ frameMsg struct{}52+)53 54 func tick() tea.Cmd {55 return tea.Tick(time.Second, func(time.Time) tea.Msg {56 return tickMsg{}235 unmodified linesmodified:examples/go.mod+1 added-1 removed
1 module examples2 3-go 1.133+go 1.164 5 require (6 github.com/charmbracelet/bubbles v0.13.1-0.20220815142520-649f78e1fd8b7 github.com/charmbracelet/bubbletea v0.22.010 unmodified linesmodified:tutorials/go.mod+1 added-1 removed
1 module tutorial2 3-go 1.143+go 1.164 5 require github.com/charmbracelet/bubbletea v0.21.06 7 replace github.com/charmbracelet/bubbletea => ../modified:commands_test.go+3 added-3 removed
25 unmodified lines26 }27 }28 29 func 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"32 33- var nilReturnCmd = func() Msg {33+ nilReturnCmd := func() Msg {34 return nil35 }36 37 tests := []struct {70 unmodified linesmodified:go.mod+1 added-1 removed
1 module github.com/charmbracelet/bubbletea2 3-go 1.133+go 1.164 5 require (6 github.com/containerd/console v1.0.37 github.com/mattn/go-isatty v0.0.169 unmodified linesmodified:logging.go+1 added-1 removed
17 unmodified lines18 // os.Exit(1)19 // }20 // defer f.Close()21 func 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 linesmodified:screen_test.go-1 removed
60 unmodified lines61 cursorBack(w, 15)62 }, []byte("\x1b[15D"))63 })64 })65-65 }modified:signals_windows.go+2 added-1 removed
9 unmodified lines10 11 // listenForResize is not available on windows because windows does not12 // implement syscall.SIGWINCH.13 func 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 }