From aa1c8356082b421a0689721bdde5ae0a7ea7ce91 Mon Sep 17 00:00:00 2001 From: Pranshu Srivastava Date: Sat, 30 Mar 2024 23:39:29 +0530 Subject: [PATCH] fixup! util: throw if file has !digit characters Signed-off-by: Pranshu Srivastava --- internal/util/parse.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/util/parse.go b/internal/util/parse.go index 92648ed1..cb4f5257 100644 --- a/internal/util/parse.go +++ b/internal/util/parse.go @@ -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)