chore: use go 1.16 (#449)

* chore: use go 1.16 and gofmt accordingly

* chore: also update examples and tuts to go 1.16
This commit is contained in:
Christian Rocha 2022-09-14 19:08:36 -04:00 committed by GitHub
parent bf3996256b
commit 1a0beff868
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 33 additions and 26 deletions

View File

@ -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
}

View File

@ -22,8 +22,10 @@ func main() {
}
}
type tickMsg struct{}
type errMsg error
type (
tickMsg struct{}
errMsg error
)
type model struct {
viewport viewport.Model

View File

@ -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:

View File

@ -1,6 +1,6 @@
module examples
go 1.13
go 1.16
require (
github.com/charmbracelet/bubbles v0.13.1-0.20220815142520-649f78e1fd8b

View File

@ -46,7 +46,6 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.cursor = len(choices) - 1
}
}
}
return m, nil

View File

@ -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))])
}

View File

@ -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 {

View File

@ -19,8 +19,10 @@ func main() {
}
}
type tickMsg struct{}
type errMsg error
type (
tickMsg struct{}
errMsg error
)
type model struct {
textInput textinput.Model

View File

@ -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.

View File

@ -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 {

2
go.mod
View File

@ -1,6 +1,6 @@
module github.com/charmbracelet/bubbletea
go 1.13
go 1.16
require (
github.com/containerd/console v1.0.3

View File

@ -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
}

View File

@ -62,5 +62,4 @@ func TestScreen(t *testing.T) {
}, []byte("\x1b[15D"))
})
})
}

View File

@ -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)
}

View File

@ -1,6 +1,6 @@
module tutorial
go 1.14
go 1.16
require github.com/charmbracelet/bubbletea v0.21.0