Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 2 additions & 8 deletions backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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)
}
4 changes: 2 additions & 2 deletions bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module code.hybscloud.com/iox

go 1.25
go 1.26
26 changes: 4 additions & 22 deletions io_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 1 addition & 4 deletions tee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Loading