From 8dc8ec4acbd67333f32f3af30e8884dfa88aee0f Mon Sep 17 00:00:00 2001 From: hayabusa-cloud Date: Mon, 16 Feb 2026 22:05:39 +0900 Subject: [PATCH 1/2] build: bump minimum Go version to 1.26 --- .github/workflows/ci.yml | 2 +- go.mod | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7c83d2..e727f60 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go-version: [ 'stable', '1.25.x' ] + go-version: [ 'stable', '1.26.x' ] steps: - name: Checkout uses: actions/checkout@v4 diff --git a/go.mod b/go.mod index 5ede7a2..d228b21 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module code.hybscloud.com/iox -go 1.25 +go 1.26 From ea21b624419db860e4177f1fe5b9003024ffc265 Mon Sep 17 00:00:00 2001 From: hayabusa-cloud Date: Mon, 16 Feb 2026 22:07:05 +0900 Subject: [PATCH 2/2] style: apply go fix modernizers --- backoff.go | 10 ++-------- bench_test.go | 4 ++-- io_test.go | 26 ++++---------------------- tee_test.go | 5 +---- 4 files changed, 9 insertions(+), 36 deletions(-) diff --git a/backoff.go b/backoff.go index 2338144..784fe72 100644 --- a/backoff.go +++ b/backoff.go @@ -56,10 +56,7 @@ func (b *Backoff) Wait() { } // Linear duration: base * n - d := time.Duration(b.n) * b.base - if d > b.max { - d = b.max - } + d := min(time.Duration(b.n)*b.base, b.max) time.Sleep(b.applyJitter(d)) @@ -112,8 +109,5 @@ func (b *Backoff) Duration() time.Duration { if max <= 0 { max = DefaultBackoffMax } - if d > max { - return max - } - return d + return min(d, max) } diff --git a/bench_test.go b/bench_test.go index 6ec69b3..809fddd 100644 --- a/bench_test.go +++ b/bench_test.go @@ -651,7 +651,7 @@ func BenchmarkTeeWriter_Chained(b *testing.B) { func BenchmarkClassify_DeepWrapped(b *testing.B) { // Create a deeply wrapped error chain err := iox.ErrMore - for i := 0; i < 5; i++ { + for range 5 { err = errors.Join(err) } b.ReportAllocs() @@ -662,7 +662,7 @@ func BenchmarkClassify_DeepWrapped(b *testing.B) { func BenchmarkIsSemantic_DeepWrapped(b *testing.B) { err := iox.ErrWouldBlock - for i := 0; i < 5; i++ { + for range 5 { err = errors.Join(err) } var sink bool diff --git a/io_test.go b/io_test.go index d4a3adb..cabde7e 100644 --- a/io_test.go +++ b/io_test.go @@ -59,13 +59,7 @@ func (w shortWriter) Write(p []byte) (int, error) { if len(p) == 0 { return 0, nil } - n := w.limit - if n > len(p) { - n = len(p) - } - if n < 0 { - n = 0 - } + n := max(min(w.limit, len(p)), 0) return n, nil } @@ -75,13 +69,7 @@ type errWriter struct { } func (w errWriter) Write(p []byte) (int, error) { - n := w.n - if n > len(p) { - n = len(p) - } - if n < 0 { - n = 0 - } + n := max(min(w.n, len(p)), 0) return n, w.err } @@ -994,10 +982,7 @@ func (w *partialWBWriter) Write(p []byte) (int, error) { if w.partial <= 0 { return 0, iox.ErrWouldBlock } - n := w.partial - if n > len(p) { - n = len(p) - } + n := min(w.partial, len(p)) w.buf = append(w.buf, p[:n]...) w.partial = 0 return n, iox.ErrWouldBlock @@ -1013,10 +998,7 @@ func (w *partialMoreWriter) Write(p []byte) (int, error) { if w.partial <= 0 { return 0, iox.ErrMore } - n := w.partial - if n > len(p) { - n = len(p) - } + n := min(w.partial, len(p)) w.buf = append(w.buf, p[:n]...) w.partial = 0 return n, iox.ErrMore diff --git a/tee_test.go b/tee_test.go index 8c1d3ef..1b1feac 100644 --- a/tee_test.go +++ b/tee_test.go @@ -29,10 +29,7 @@ func (w *failAfterWriter) Write(p []byte) (int, error) { if w.k <= 0 { return 0, w.err } - n := w.k - if n > len(p) { - n = len(p) - } + n := min(w.k, len(p)) w.k -= n return n, w.err }