Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions files/glob.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"os"
"path/filepath"
"sort"
"slices"
"strings"

"github.com/bmatcuk/doublestar"
Expand Down Expand Up @@ -56,10 +56,8 @@ func ignore(path string) bool {
for _, e := range excludes {
chunks := strings.Split(slash, "/")

for _, c := range chunks {
if c == e {
return true
}
if slices.Contains(chunks, e) {
return true
}
}

Expand All @@ -77,9 +75,7 @@ func Glob(d string) []string {
panic("malformed path pattern")
}

sort.Slice(paths, func(i, j int) bool {
return paths[i] < paths[j]
})
slices.Sort(paths)

outs := []string{}

Expand Down
4 changes: 2 additions & 2 deletions files/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package files

import (
"errors"
"io/ioutil"
"os"
)

// Read file content of given path.
Expand All @@ -11,7 +11,7 @@ func Read(path string) (string, error) {
return "", errors.New("given path is empty")
}

byt, err := ioutil.ReadFile(path)
byt, err := os.ReadFile(path)

if err != nil {
return "", err
Expand Down
3 changes: 1 addition & 2 deletions files/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package files

import (
"errors"
"io/ioutil"
"os"
)

Expand All @@ -19,7 +18,7 @@ func Update(path, doc string) error {
return nil
}

if err := ioutil.WriteFile(path, []byte(doc), info.Mode()); err != nil {
if err := os.WriteFile(path, []byte(doc), info.Mode()); err != nil {
return err
}

Expand Down
6 changes: 3 additions & 3 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func Show(doc string, ver string) ([]string, error) {

found := false

for _, line := range strings.Split(doc, "\n") {
for line := range strings.SplitSeq(doc, "\n") {
p := fmt.Sprintf("## %s", v)

if !found && !strings.HasPrefix(line, p) {
Expand Down Expand Up @@ -148,7 +148,7 @@ func Latest(doc string) (string, error) {

re := regexp.MustCompile(`## \[([v]?\d*\.\d*\.\d*)\]`)

for _, line := range strings.Split(doc, "\n") {
for line := range strings.SplitSeq(doc, "\n") {
got := re.FindStringSubmatch(line)

if len(got) != 2 {
Expand All @@ -169,7 +169,7 @@ func LatestAny(doc string) (string, error) {

re := regexp.MustCompile(`## \[(.*)\]`)

for _, line := range strings.Split(doc, "\n") {
for line := range strings.SplitSeq(doc, "\n") {
got := re.FindStringSubmatch(line)

if len(got) != 2 {
Expand Down