Skip to content

Commit

Permalink
chore: use go 1.16 (charmbracelet#449)
Browse files Browse the repository at this point in the history
* chore: use go 1.16 and gofmt accordingly

* chore: also update examples and tuts to go 1.16
  • Loading branch information
meowgorithm authored Sep 14, 2022
1 parent bf39962 commit 1a0beff
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 26 deletions.
6 changes: 3 additions & 3 deletions commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
6 changes: 4 additions & 2 deletions examples/chat/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ func main() {
}
}

type tickMsg struct{}
type errMsg error
type (
tickMsg struct{}
errMsg error
)

type model struct {
viewport viewport.Model
Expand Down
2 changes: 1 addition & 1 deletion examples/composable-views/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}
Expand Down
10 changes: 5 additions & 5 deletions examples/credit-card-form/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ func main() {
}
}

type tickMsg struct{}
type errMsg error
type (
tickMsg struct{}
errMsg error
)

const (
ccn = iota
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion examples/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module examples

go 1.13
go 1.16

require (
github.com/charmbracelet/bubbles v0.13.1-0.20220815142520-649f78e1fd8b
Expand Down
1 change: 0 additions & 1 deletion examples/result/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.cursor = len(choices) - 1
}
}

}

return m, nil
Expand Down
6 changes: 4 additions & 2 deletions examples/send-msg/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))])
}
1 change: 0 additions & 1 deletion examples/spinner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions examples/textinput/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ func main() {
}
}

type tickMsg struct{}
type errMsg error
type (
tickMsg struct{}
errMsg error
)

type model struct {
textInput textinput.Model
Expand Down
3 changes: 2 additions & 1 deletion examples/textinputs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func initialModel() model {

return m
}

func (m model) Init() tea.Cmd {
return textinput.Blink
}
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions examples/views/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/charmbracelet/bubbletea

go 1.13
go 1.16

require (
github.com/containerd/console v1.0.3
Expand Down
2 changes: 1 addition & 1 deletion logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 0 additions & 1 deletion screen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,4 @@ func TestScreen(t *testing.T) {
}, []byte("\x1b[15D"))
})
})

}
3 changes: 2 additions & 1 deletion signals_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion tutorials/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module tutorial

go 1.14
go 1.16

require github.com/charmbracelet/bubbletea v0.21.0

Expand Down

0 comments on commit 1a0beff

Please sign in to comment.