Skip to content

Commit

Permalink
Merge pull request #54 from xztaityozx/lint/resolve-#46
Browse files Browse the repository at this point in the history
Lint/resolve #46
  • Loading branch information
xztaityozx authored Dec 16, 2024
2 parents e11b4f5 + 51c1ca7 commit b4faf0c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
1 change: 0 additions & 1 deletion .tool-versions

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/xztaityozx/sel

go 1.21
go 1.23

require (
github.com/spf13/cobra v1.8.0
Expand Down
13 changes: 7 additions & 6 deletions internal/iterator/iterator.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package iterator

import (
"errors"
"fmt"
"regexp"
"strings"
Expand Down Expand Up @@ -96,7 +97,7 @@ func (i *Iterator) Reset(s string) {
// ElementAt は指定したインデックスの値を返す。1-indexed
func (i *Iterator) ElementAt(idx int) (string, error) {
if idx == 0 {
return "", fmt.Errorf(IndexOutOfRange)
return "", errors.New(IndexOutOfRange)
}

if idx < 0 {
Expand All @@ -116,7 +117,7 @@ func (i *Iterator) ElementAt(idx int) (string, error) {
return s, nil
}

return "", fmt.Errorf(IndexOutOfRange)
return "", errors.New(IndexOutOfRange)
} else {
if i.head >= idx {
return i.buf[idx], nil
Expand All @@ -136,7 +137,7 @@ func (i *Iterator) ElementAt(idx int) (string, error) {
}
}

return "", fmt.Errorf(IndexOutOfRange)
return "", errors.New(IndexOutOfRange)
}
}

Expand Down Expand Up @@ -262,7 +263,7 @@ type RegexpIterator struct {

func (r *RegexpIterator) ElementAt(idx int) (string, error) {
if idx == 0 {
return "", fmt.Errorf(IndexOutOfRange)
return "", errors.New(IndexOutOfRange)
}

if idx > 0 {
Expand All @@ -284,7 +285,7 @@ func (r *RegexpIterator) ElementAt(idx int) (string, error) {
}
}

return "", fmt.Errorf(IndexOutOfRange)
return "", errors.New(IndexOutOfRange)
} else {
// 負のインデックス指定されたとき
// rightmostなIndexの検索ができないので残りの文字列をすべて分割してしまう
Expand Down Expand Up @@ -329,7 +330,7 @@ func (r *RegexpIterator) ElementAt(idx int) (string, error) {
return s, nil
}

return "", fmt.Errorf(IndexOutOfRange)
return "", errors.New(IndexOutOfRange)
}
}

Expand Down
6 changes: 3 additions & 3 deletions internal/iterator/presplit.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package iterator

import (
"fmt"
"errors"
"regexp"
"strings"
)
Expand All @@ -18,12 +18,12 @@ type PreSplitIterator struct {

func (p *PreSplitIterator) ElementAt(idx int) (string, error) {
if p.l < idx {
return "", fmt.Errorf(IndexOutOfRange)
return "", errors.New(IndexOutOfRange)
}

if idx < 0 {
if -p.l > idx {
return "", fmt.Errorf(IndexOutOfRange)
return "", errors.New(IndexOutOfRange)
}
return p.a[p.l+idx], nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/option/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type InputFiles struct {

// Enumerate /path/to/input/files
func (ifs InputFiles) Enumerate() ([]string, error) {
if ifs.Files == nil || len(ifs.Files) == 0 {
if len(ifs.Files) == 0 {
return nil, fmt.Errorf("there are no files")
}

Expand Down

0 comments on commit b4faf0c

Please sign in to comment.