Skip to content

Commit

Permalink
fixup! util: throw if file has !digit characters
Browse files Browse the repository at this point in the history
Signed-off-by: Pranshu Srivastava <[email protected]>
  • Loading branch information
rexagod committed Mar 30, 2024
1 parent e6bdd98 commit aa1c835
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/util/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ func ReadUintFromFile(path string) (uint64, error) {
return 0, err
}
for _, c := range data {
if string(c) == "\n" {
continue
}
if !unicode.IsDigit(rune(c)) {
return 0, fmt.Errorf("%w: %s", strconv.ErrSyntax, path)
return 0, fmt.Errorf("%w ('%s'): %s", strconv.ErrSyntax, string(c), path)
}
}
return strconv.ParseUint(strings.TrimSpace(string(data)), 10, 64)
Expand Down

0 comments on commit aa1c835

Please sign in to comment.