1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

chore: use errors.New to replace fmt.Errorf with no parameters.

This commit is contained in:
ChengenH
2024-04-24 16:21:34 +08:00
parent 0a5e9b2d60
commit dd6bfa1680
4 changed files with 12 additions and 9 deletions

View File

@ -1,6 +1,8 @@
package utils
import "fmt"
import (
"errors"
)
type HistoryBuffer[T any] struct {
maxSize int
@ -24,10 +26,10 @@ func (self *HistoryBuffer[T]) Push(item T) {
func (self *HistoryBuffer[T]) PeekAt(index int) (T, error) {
var item T
if len(self.items) == 0 {
return item, fmt.Errorf("Buffer is empty")
return item, errors.New("Buffer is empty")
}
if len(self.items) <= index || index < -1 {
return item, fmt.Errorf("Index out of range")
return item, errors.New("Index out of range")
}
if index == -1 {
return item, nil