chore: clean up linter errors in examples
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Christian Muehlhaeuser · committed by Christian Muehlhaeuser · parent 8b8fd12 · Browse files · 16 files·+26 added−40 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+26 added−40 removed
- other:+26 added−40 removed
Provenance
- Commit
22d15ef- Tree
4cf37f9- Author
Christian Muehlhaeuser <muesli@gmail.com>- Committer
Christian Muehlhaeuser <muesli@gmail.com>- Parent
8b8fd12
16 files changed+26 added−40 removed
modified:examples/chat/main.go+1 added-2 removed
21 unmodified lines22 }23 }24 25 type (26- tickMsg struct{}27- errMsg error26+ errMsg error27 )28 29 type model struct {30 viewport viewport.Model79 unmodified linesmodified:examples/credit-card-form/main.go+3 added-5 removed
18 unmodified lines19 }20 }21 22 type (23- tickMsg struct{}24- errMsg error23+ errMsg error24 )25 26 const (27 ccn = iota109 unmodified lines137 switch msg.Type {138 case tea.KeyEnter:139 if m.focused == len(m.inputs)-1 {140 return m, tea.Quit142- } else {143- m.nextInput()141 }142+ m.nextInput()143 case tea.KeyCtrlC, tea.KeyEsc:144 return m, tea.Quit145 case tea.KeyShiftTab, tea.KeyCtrlP:146 m.prevInput()22 unmodified lines169 ` Total: $21.50:170 171 %s172 %s175- 173+174 %s %s175 %s %s176 177 %s24 unmodified linesmodified:examples/fullscreen/main.go+1 added-3 removed
26 unmodified lines27 }28 29 func (m model) Update(message tea.Msg) (tea.Model, tea.Cmd) {30 switch msg := message.(type) {31-31 case tea.KeyMsg:32 switch msg.String() {33 case "q", "esc", "ctrl+c":34 return m, tea.Quit35 }36 37 case tickMsg:39- m -= 138+ m--39 if m <= 0 {40 return m, tea.Quit41 }42 return m, tick()44-43 }44 45 return m, nil46 }10 unmodified linesmodified:examples/http/main.go+2 added-1 removed
35 unmodified lines36 }37 38 func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {39 switch msg := msg.(type) {40-40 case tea.KeyMsg:41 switch msg.String() {42 case "q", "ctrl+c", "esc":43 return m, tea.Quit31 unmodified lines75 res, err := c.Get(url)76 if err != nil {77 return errMsg{err}78 }79+ defer res.Body.Close()80+81 return statusMsg(res.StatusCode)82 }modified:examples/list-simple/main.go+1 added-2 removed
43 unmodified lines44 return selectedItemStyle.Render("> " + s)45 }46 }47 48- fmt.Fprintf(w, fn(str))48+ fmt.Fprint(w, fn(str))49 }50 51 type model struct {52 list list.Model53- items []item53 choice string54 quitting bool55 }56 71 unmodified linesmodified:examples/package-manager/main.go-1 removed
23 unmodified lines24 }25 26 var (27 currentPkgNameStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("211"))28- subtleStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("239"))28 doneStyle = lipgloss.NewStyle().Margin(1, 2)29 checkMark = lipgloss.NewStyle().Foreground(lipgloss.Color("42")).SetString("✓")30 )31 107 unmodified linesmodified:examples/progress-animated/main.go+3 added-3 removed
40 unmodified lines41 type model struct {42 progress progress.Model43 }44 45-func (_ model) Init() tea.Cmd {45+func (m model) Init() tea.Cmd {46 return tickCmd()47 }48 49 func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {28 unmodified lines78 return m, nil79 }80 }81 82-func (e model) View() string {82+func (m model) View() string {83 pad := strings.Repeat(" ", padding)84 return "\n" +85- pad + e.progress.View() + "\n\n" +85+ pad + m.progress.View() + "\n\n" +86 pad + helpStyle("Press any key to quit")87 }88 89 func tickCmd() tea.Cmd {4 unmodified linesmodified:examples/progress-download/tui.go+3 added-4 removed
25 unmodified lines26 })27 }28 29 type model struct {30- url, path string31- pw *progressWriter32- progress progress.Model33- err error30+ pw *progressWriter31+ progress progress.Model32+ err error33 }34 35 func (m model) Init() tea.Cmd {36 return nil49 unmodified linesmodified:examples/progress-static/main.go+3 added-4 removed
48 unmodified lines49 percent float6450 progress progress.Model51 }52 53-func (_ model) Init() tea.Cmd {53+func (m model) Init() tea.Cmd {54 return tickCmd()55 }56 57 func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {58 switch msg := msg.(type) {59-59 case tea.KeyMsg:60 return m, tea.Quit61 62 case tea.WindowSizeMsg:15 unmodified lines78 return m, nil79 }80 }81 83-func (e model) View() string {82+func (m model) View() string {83 pad := strings.Repeat(" ", padding)84 return "\n" +86- pad + e.progress.ViewAs(e.percent) + "\n\n" +85+ pad + m.progress.ViewAs(m.percent) + "\n\n" +86 pad + helpStyle("Press any key to quit")87 }88 89 func tickCmd() tea.Cmd {4 unmodified linesmodified:examples/send-msg/main.go-1 removed
17 unmodified lines18 var (19 spinnerStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("63"))20 helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("241")).Margin(1, 0)21 dotStyle = helpStyle.Copy().UnsetMargins()22- foodStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("36"))22 durationStyle = dotStyle.Copy()23 appStyle = lipgloss.NewStyle().Margin(1, 2, 0, 2)24 )25 108 unmodified linesmodified:examples/simple/main.go+1 added-1 removed
45 unmodified lines46 switch msg.(type) {47 case tea.KeyMsg:48 return m, tea.Quit49 case tickMsg:50- m -= 150+ m--51 if m <= 0 {52 return m, tea.Quit53 }54 return m, tick18 unmodified linesmodified:examples/spinner/main.go-1 removed
31 unmodified lines32 }33 34 func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {35 switch msg := msg.(type) {36-36 case tea.KeyMsg:37 switch msg.String() {38 case "q", "esc", "ctrl+c":39 m.quitting = true34 unmodified linesmodified:examples/tabs/main.go-2 removed
44 unmodified lines45 return border46 }47 48 var (49- defaultWidth = 2050-49 inactiveTabBorder = tabBorderWithBottom("┴", "─", "┴")50 activeTabBorder = tabBorderWithBottom("┘", " ", "└")51 docStyle = lipgloss.NewStyle().Padding(1, 2, 1, 2)52 highlightColor = lipgloss.AdaptiveColor{Light: "#874BFD", Dark: "#7D56F4"}62 unmodified linesmodified:examples/textinput/main.go+1 added-2 removed
18 unmodified lines19 }20 }21 22 type (23- tickMsg struct{}24- errMsg error23+ errMsg error24 )25 26 type model struct {27 textInput textinput.Model47 unmodified linesmodified:examples/views/main.go+5 added-7 removed
113 unmodified lines114 115 // Update loop for the first view where you're choosing a task.116 func updateChoices(msg tea.Msg, m model) (tea.Model, tea.Cmd) {117 switch msg := msg.(type) {118-118 case tea.KeyMsg:119 switch msg.String() {120 case "j", "down":122- m.Choice += 1121+ m.Choice++122 if m.Choice > 3 {123 m.Choice = 3124 }125 case "k", "up":127- m.Choice -= 1126+ m.Choice--127 if m.Choice < 0 {128 m.Choice = 0129 }130 case "enter":5 unmodified lines136 if m.Ticks == 0 {137 m.Quitting = true138 return m, tea.Quit139 }141- m.Ticks -= 1140+ m.Ticks--141 return m, tick()142 }143 144 return m, nil1 unmodified line146 147 // Update loop for the second view after a choice has been made148 func updateChosen(msg tea.Msg, m model) (tea.Model, tea.Cmd) {149 switch msg.(type) {151-150 case frameMsg:151 if !m.Loaded {154- m.Frames += 1152+ m.Frames++153 m.Progress = ease.OutBounce(float64(m.Frames) / float64(100))154 if m.Progress >= 1 {155 m.Progress = 1156 m.Loaded = true8 unmodified lines165 if m.Ticks == 0 {166 m.Quitting = true167 return m, tea.Quit168 }171- m.Ticks -= 1169+ m.Ticks--170 return m, tick()171 }172 }173 116 unmodified linesmodified:tutorials/commands/main.go+2 added-1 removed
20 unmodified lines21 res, err := c.Get(url)22 if err != nil {23 return errMsg{err}24 }25+ defer res.Body.Close()26+27 return statusMsg(res.StatusCode)28 }29 30 type statusMsg int9 unmodified lines40 }41 42 func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {43 switch msg := msg.(type) {42-44 case statusMsg:45 m.status = int(msg)46 return m, tea.Quit47 31 unmodified lines