diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 6ff073a..db2bc74 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -27,6 +27,7 @@ jobs: - '1.20' - '1.21' - '1.22' + - '1.23' steps: - uses: actions/checkout@v2 @@ -62,10 +63,10 @@ jobs: run: go vet -unsafeptr=false ./... - name: 'Staticcheck' - # staticcheck requires go1.19. - if: ${{ matrix.arch == 'x64' && matrix.go >= '1.19' }} + # staticcheck requires go1.22. + if: ${{ matrix.arch == 'x64' && matrix.go >= '1.22' }} run: | - go install honnef.co/go/tools/cmd/staticcheck@v0.4.3 + go install honnef.co/go/tools/cmd/staticcheck@v0.5.0 staticcheck ./... - name: 'GCAssert' diff --git a/bigint_go1.15_test.go b/bigint_go1.15_test.go index fd04115..83a16bf 100644 --- a/bigint_go1.15_test.go +++ b/bigint_go1.15_test.go @@ -65,7 +65,7 @@ func TestBigIntFillBytes(t *testing.T) { "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", } { t.Run(n, func(t *testing.T) { - t.Logf(n) + t.Log(n) x, ok := new(BigInt).SetString(n, 0) if !ok { panic("invalid test entry") diff --git a/decimal_test.go b/decimal_test.go index ef6a475..bc00e04 100644 --- a/decimal_test.go +++ b/decimal_test.go @@ -491,6 +491,22 @@ func TestFormat(t *testing.T) { } } +// fmtAllowsPaddingAndMinusFlags is set to true if the %-0 flag combination is +// allowed. This combination was not allowed before Go 1.23, but it is allowed +// in Go 1.23 and later. See https://github.com/golang/go/issues/61784 for +// details. +var fmtAllowsPaddingAndMinusFlags bool + +// The following type definition, customer formatter implementation, and init +// function are used to test for fmtAllowsPaddingAndMinusFlags. +type fmtAllowsPaddingAndMinusFlagsHelper struct{} + +func (fmtAllowsPaddingAndMinusFlagsHelper) Format(s fmt.State, format rune) { + fmtAllowsPaddingAndMinusFlags = s.Flag('-') && s.Flag('0') +} + +func init() { fmt.Printf("%-0s", fmtAllowsPaddingAndMinusFlagsHelper{}) } + func TestFormatFlags(t *testing.T) { const stdD = "1.23E+56" tests := []struct { @@ -531,7 +547,22 @@ func TestFormatFlags(t *testing.T) { { d: stdD, fmt: "%-010G", - out: "1.23E+56 ", + out: func() string { + if !fmtAllowsPaddingAndMinusFlags { + return "1.23E+56 " + } + return "001.23E+56" + }(), + }, + { + d: stdD, + fmt: "%0-10G", + out: func() string { + if !fmtAllowsPaddingAndMinusFlags { + return "1.23E+56 " + } + return "001.23E+56" + }(), }, { d: "nan",