Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linting: do not capitalize errors #75

Merged
merged 3 commits into from
Aug 12, 2021
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
2 changes: 1 addition & 1 deletion mountinfo/mountinfo_bsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func parseMountTable(filter FilterFunc) ([]*Info, error) {

count := int(C.getmntinfo(&rawEntries, C.MNT_WAIT))
if count == 0 {
return nil, fmt.Errorf("Failed to call getmntinfo")
return nil, fmt.Errorf("failed to call getmntinfo")
}

var entries []C.struct_statfs
Expand Down
14 changes: 7 additions & 7 deletions mountinfo/mountinfo_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) {
numFields := len(fields)
if numFields < 10 {
// should be at least 10 fields
return nil, fmt.Errorf("Parsing '%s' failed: not enough fields (%d)", text, numFields)
return nil, fmt.Errorf("parsing '%s' failed: not enough fields (%d)", text, numFields)
}

// separator field
Expand All @@ -67,23 +67,23 @@ func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) {
for fields[sepIdx] != "-" {
sepIdx--
if sepIdx == 5 {
return nil, fmt.Errorf("Parsing '%s' failed: missing - separator", text)
return nil, fmt.Errorf("parsing '%s' failed: missing - separator", text)
}
}

p := &Info{}

p.Mountpoint, err = unescape(fields[4])
if err != nil {
return nil, fmt.Errorf("Parsing '%s' failed: mount point: %w", fields[4], err)
return nil, fmt.Errorf("parsing '%s' failed: mount point: %w", fields[4], err)
}
p.FSType, err = unescape(fields[sepIdx+1])
if err != nil {
return nil, fmt.Errorf("Parsing '%s' failed: fstype: %w", fields[sepIdx+1], err)
return nil, fmt.Errorf("parsing '%s' failed: fstype: %w", fields[sepIdx+1], err)
}
p.Source, err = unescape(fields[sepIdx+2])
if err != nil {
return nil, fmt.Errorf("Parsing '%s' failed: source: %w", fields[sepIdx+2], err)
return nil, fmt.Errorf("parsing '%s' failed: source: %w", fields[sepIdx+2], err)
}
p.VFSOptions = fields[sepIdx+3]

Expand All @@ -92,14 +92,14 @@ func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) {
p.Parent, _ = strconv.Atoi(fields[1])
mm := strings.Split(fields[2], ":")
if len(mm) != 2 {
return nil, fmt.Errorf("Parsing '%s' failed: unexpected minor:major pair %s", text, mm)
return nil, fmt.Errorf("parsing '%s' failed: unexpected major:minor pair %s", text, mm)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also fixed the error message here, which had "major" and "minor" swapped

}
p.Major, _ = strconv.Atoi(mm[0])
p.Minor, _ = strconv.Atoi(mm[1])

p.Root, err = unescape(fields[3])
if err != nil {
return nil, fmt.Errorf("Parsing '%s' failed: root: %w", fields[3], err)
return nil, fmt.Errorf("parsing '%s' failed: root: %w", fields[3], err)
}

p.Options = fields[5]
Expand Down
4 changes: 2 additions & 2 deletions signal/signal.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ func ParseSignal(rawSignal string) (syscall.Signal, error) {
s, err := strconv.Atoi(rawSignal)
if err == nil {
if s == 0 {
return -1, fmt.Errorf("Invalid signal: %s", rawSignal)
return -1, fmt.Errorf("invalid signal: %s", rawSignal)
}
return syscall.Signal(s), nil
}
signal, ok := SignalMap[strings.TrimPrefix(strings.ToUpper(rawSignal), "SIG")]
if !ok {
return -1, fmt.Errorf("Invalid signal: %s", rawSignal)
return -1, fmt.Errorf("invalid signal: %s", rawSignal)
}
return signal, nil
}
Expand Down
4 changes: 2 additions & 2 deletions signal/signal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import (

func TestParseSignal(t *testing.T) {
_, err := ParseSignal("0")
expectedErr := "Invalid signal: 0"
expectedErr := "invalid signal: 0"
if err == nil || err.Error() != expectedErr {
t.Errorf("expected %q, but got %v", expectedErr, err)
}

_, err = ParseSignal("SIG")
expectedErr = "Invalid signal: SIG"
expectedErr = "invalid signal: SIG"
if err == nil || err.Error() != expectedErr {
t.Errorf("expected %q, but got %v", expectedErr, err)
}
Expand Down
2 changes: 1 addition & 1 deletion symlink/fs_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func testSymlink(tmpdir, path, expected, scope string) error {
return err
}
if expected != rewrite {
return fmt.Errorf("Expected %q got %q", expected, rewrite)
return fmt.Errorf("expected %q got %q", expected, rewrite)
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion symlink/fs_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func walkSymlinks(path string) (string, error) {
var b bytes.Buffer
for n := 0; path != ""; n++ {
if n > maxIter {
return "", errors.New("EvalSymlinks: too many links in " + originalPath)
return "", errors.New("too many links in " + originalPath)
}

// A path beginning with `\\?\` represents the root, so automatically
Expand Down