on main help sign in
bugfix: fixup panic for oob range
76fc7e7Tai Groot
cmd/logs.go+4−12
@@ -77,17 +77,13 @@ func followLogs(ctx context.Context, logsFile string, tailLines int) error {
77 }
77 }
78
78
79 var lines []string
79 var lines []string
80− lineCount := 0
81 for line := range t.Lines {
80 for line := range t.Lines {
82 if line.Err != nil {
81 if line.Err != nil {
83 continue
82 continue
84 }
83 }
85 lines = append(lines, line.Text)
84 lines = append(lines, line.Text)
86− lineCount++
87− if lineCount >= tailLines {
88− if len(lines) > tailLines {
85+ if len(lines) > tailLines {
89− lines = lines[len(lines)-tailLines:]
86+ lines = lines[len(lines)-tailLines:]
90− }
91 }
87 }
92 }
88 }
93 t.Stop()
89 t.Stop()
@@ -138,17 +134,13 @@ func showLogs(logsFile string, tailLines int) error {
138 defer t.Stop()
134 defer t.Stop()
139
135
140 var lines []string
136 var lines []string
141− lineCount := 0
142 for line := range t.Lines {
137 for line := range t.Lines {
143 if line.Err != nil {
138 if line.Err != nil {
144 continue
139 continue
145 }
140 }
146 lines = append(lines, line.Text)
141 lines = append(lines, line.Text)
147− lineCount++
148− if lineCount >= tailLines {
149− if len(lines) > tailLines {
142+ if len(lines) > tailLines {
150− lines = lines[len(lines)-tailLines:]
143+ lines = lines[len(lines)-tailLines:]
151− }
152 }
144 }
153 }
145 }
154
146