From e134c1d57eec494ba2e887a8a747cae19195c761 Mon Sep 17 00:00:00 2001 From: Radu Berinde Date: Sat, 22 Nov 2025 17:19:44 -0800 Subject: [PATCH] use base 10 to parse integers The new parsing code passes base 0 to strconv which causes it to interpret leading 0 as indicating an octal number. This is not what we want; in particular Pebble has a lot of tests which use file numbers with leading 0s. --- datadriven.go | 4 ++-- datadriven_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/datadriven.go b/datadriven.go index 7437cca..905cb1a 100644 --- a/datadriven.go +++ b/datadriven.go @@ -879,14 +879,14 @@ func parseArgVal(s string, dest reflect.Value) error { dest.SetBool(b) case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - n, err := strconv.ParseInt(s, 0, int(t.Bits())) + n, err := strconv.ParseInt(s, 10, int(t.Bits())) if err != nil { return fmt.Errorf("parse %q as %s: %w", s, t, err) } dest.SetInt(n) case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - n, err := strconv.ParseUint(s, 0, int(t.Bits())) + n, err := strconv.ParseUint(s, 10, int(t.Bits())) if err != nil { return fmt.Errorf("parse %q as %s: %w", s, t, err) } diff --git a/datadriven_test.go b/datadriven_test.go index 75eba8b..da1e344 100644 --- a/datadriven_test.go +++ b/datadriven_test.go @@ -326,7 +326,7 @@ func TestScanArgsSingle(t *testing.T) { ---- []uint64{0x1, 0x2, 0x3, 0x4} -[]int64 vals=(0xA, 0x10) +[]int64 vals=(10, 000016) ---- []int64{10, 16}