Skip to content
Myr

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

16 files+26 added−40 removed

modified:examples/chat/main.go+1 added-2 removed
21 unmodified lines
22 }23}2425type (26 tickMsg struct{}27 errMsg error26 errMsg error27)2829type model struct {30 viewport viewport.Model
79 unmodified lines
modified:examples/credit-card-form/main.go+3 added-5 removed
18 unmodified lines
19 }20}2122type (23 tickMsg struct{}24 errMsg error23 errMsg error24)2526const (27 ccn = iota
109 unmodified lines
137 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 lines
169 ` Total: $21.50:170171 %s172 %s175 173174 %s %s175 %s %s176177 %s
24 unmodified lines
modified:examples/fullscreen/main.go+1 added-3 removed
26 unmodified lines
27}2829func (m model) Update(message tea.Msg) (tea.Model, tea.Cmd) {30 switch msg := message.(type) {3131 case tea.KeyMsg:32 switch msg.String() {33 case "q", "esc", "ctrl+c":34 return m, tea.Quit35 }3637 case tickMsg:39 m -= 138 m--39 if m <= 0 {40 return m, tea.Quit41 }42 return m, tick()4443 }4445 return m, nil46}
10 unmodified lines
modified:examples/http/main.go+2 added-1 removed
35 unmodified lines
36}3738func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {39 switch msg := msg.(type) {4040 case tea.KeyMsg:41 switch msg.String() {42 case "q", "ctrl+c", "esc":43 return m, tea.Quit
31 unmodified lines
75 res, err := c.Get(url)76 if err != nil {77 return errMsg{err}78 }79 defer res.Body.Close()8081 return statusMsg(res.StatusCode)82}
modified:examples/list-simple/main.go+1 added-2 removed
43 unmodified lines
44 return selectedItemStyle.Render("> " + s)45 }46 }4748 fmt.Fprintf(w, fn(str))48 fmt.Fprint(w, fn(str))49}5051type model struct {52 list list.Model53 items []item53 choice string54 quitting bool55}56
71 unmodified lines
modified:examples/package-manager/main.go-1 removed
23 unmodified lines
24}2526var (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 lines
modified:examples/progress-animated/main.go+3 added-3 removed
40 unmodified lines
41type model struct {42 progress progress.Model43}4445func (_ model) Init() tea.Cmd {45func (m model) Init() tea.Cmd {46 return tickCmd()47}4849func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
28 unmodified lines
78 return m, nil79 }80}8182func (e model) View() string {82func (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}8889func tickCmd() tea.Cmd {
4 unmodified lines
modified:examples/progress-download/tui.go+3 added-4 removed
25 unmodified lines
26 })27}2829type model struct {30 url, path string31 pw *progressWriter32 progress progress.Model33 err error30 pw *progressWriter31 progress progress.Model32 err error33}3435func (m model) Init() tea.Cmd {36 return nil
49 unmodified lines
modified:examples/progress-static/main.go+3 added-4 removed
48 unmodified lines
49 percent float6450 progress progress.Model51}5253func (_ model) Init() tea.Cmd {53func (m model) Init() tea.Cmd {54 return tickCmd()55}5657func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {58 switch msg := msg.(type) {5959 case tea.KeyMsg:60 return m, tea.Quit6162 case tea.WindowSizeMsg:
15 unmodified lines
78 return m, nil79 }80}8183func (e model) View() string {82func (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}8889func tickCmd() tea.Cmd {
4 unmodified lines
modified:examples/send-msg/main.go-1 removed
17 unmodified lines
18var (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 lines
modified:examples/simple/main.go+1 added-1 removed
45 unmodified lines
46 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, tick
18 unmodified lines
modified:examples/spinner/main.go-1 removed
31 unmodified lines
32}3334func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {35 switch msg := msg.(type) {3636 case tea.KeyMsg:37 switch msg.String() {38 case "q", "esc", "ctrl+c":39 m.quitting = true
34 unmodified lines
modified:examples/tabs/main.go-2 removed
44 unmodified lines
45 return border46}4748var (49 defaultWidth = 205049 inactiveTabBorder = tabBorderWithBottom("┴", "─", "┴")50 activeTabBorder = tabBorderWithBottom("┘", " ", "└")51 docStyle = lipgloss.NewStyle().Padding(1, 2, 1, 2)52 highlightColor = lipgloss.AdaptiveColor{Light: "#874BFD", Dark: "#7D56F4"}
62 unmodified lines
modified:examples/textinput/main.go+1 added-2 removed
18 unmodified lines
19 }20}2122type (23 tickMsg struct{}24 errMsg error23 errMsg error24)2526type model struct {27 textInput textinput.Model
47 unmodified lines
modified:examples/views/main.go+5 added-7 removed
113 unmodified lines
114115// Update loop for the first view where you're choosing a task.116func updateChoices(msg tea.Msg, m model) (tea.Model, tea.Cmd) {117 switch msg := msg.(type) {118118 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 lines
136 if m.Ticks == 0 {137 m.Quitting = true138 return m, tea.Quit139 }141 m.Ticks -= 1140 m.Ticks--141 return m, tick()142 }143144 return m, nil
1 unmodified line
146147// Update loop for the second view after a choice has been made148func updateChosen(msg tea.Msg, m model) (tea.Model, tea.Cmd) {149 switch msg.(type) {151150 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 = true
8 unmodified lines
165 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 lines
modified:tutorials/commands/main.go+2 added-1 removed
20 unmodified lines
21 res, err := c.Get(url)22 if err != nil {23 return errMsg{err}24 }25 defer res.Body.Close()2627 return statusMsg(res.StatusCode)28}2930type statusMsg int
9 unmodified lines
40}4142func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {43 switch msg := msg.(type) {4244 case statusMsg:45 m.status = int(msg)46 return m, tea.Quit47
31 unmodified lines