chore: apply some linter recommendations.

This commit is contained in:
Alexandre Pujol 2025-04-04 23:45:24 +02:00
parent 3b6b50cf63
commit 984cf28e61
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
37 changed files with 125 additions and 126 deletions

View file

@ -521,7 +521,7 @@ func (p *Path) ReadFileAsLines() ([]string, error) {
return nil, err
}
txt := string(data)
txt = strings.Replace(txt, "\r\n", "\n", -1)
txt = strings.ReplaceAll(txt, "\r\n", "\n")
return strings.Split(txt, "\n"), nil
}
@ -542,7 +542,7 @@ func (p *Path) MustReadFilteredFileAsLines() []string {
panic(err)
}
txt := string(data)
txt = strings.Replace(txt, "\r\n", "\n", -1)
txt = strings.ReplaceAll(txt, "\r\n", "\n")
txt = util.Filter(txt)
res := strings.Split(txt, "\n")
if slices.Contains(res, "") {
@ -636,7 +636,9 @@ func (p *Path) String() string {
func (p *Path) Canonical() *Path {
canonical := p.Clone()
// https://github.com/golang/go/issues/17084#issuecomment-246645354
canonical.FollowSymLink()
if err := canonical.FollowSymLink(); err != nil {
return nil
}
if absPath, err := canonical.Abs(); err == nil {
canonical = absPath
}