build: modernize with "go fix -minmax": use min and max builtins

This commit is contained in:
Nick Craig-Wood
2026-08-21 12:23:31 +01:00
parent bfd0e3f3c2
commit b5bea683c5
4 changed files with 12 additions and 26 deletions
+8 -14
View File
@@ -125,13 +125,10 @@ func (o *RangeOption) Decode(size int64) (offset, limit int64) {
}
} else {
if o.End >= 0 {
offset = size - o.End
if offset < 0 {
// RFC 7233 section 2.1: if the suffix-length is
// larger than the representation, use the entire
// representation.
offset = 0
}
// RFC 7233 section 2.1: if the suffix-length is
// larger than the representation, use the entire
// representation.
offset = max(size-o.End, 0)
} else {
offset = 0
}
@@ -168,13 +165,10 @@ func FixRangeOption(options []OpenOption, size int64) {
case *RangeOption:
// If start is < 0 then fetch from the end
if x.Start < 0 {
start := size - x.End
if start < 0 {
// RFC 7233 section 2.1: if the suffix-length is
// larger than the representation, use the entire
// representation (#6310).
start = 0
}
// RFC 7233 section 2.1: if the suffix-length is
// larger than the representation, use the entire
// representation (#6310).
start := max(size-x.End, 0)
x = &RangeOption{Start: start, End: -1}
options[i] = x
}