diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 0b24dca9c..768acdd83 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -12,7 +12,7 @@ jobs: build: strategy: matrix: - go-version: [1.23.x, 1.24.x, 1.25.x] + go-version: [1.24.x, 1.25.x, 1.26.x] os: [ubuntu-latest, macos-latest, windows-latest] env: CGO_ENABLED: 0 @@ -60,7 +60,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v6.2.0 with: - go-version: 1.25.x + go-version: 1.26.x - name: Checkout code uses: actions/checkout@v6.0.2 @@ -82,7 +82,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v6.2.0 with: - go-version: 1.25.x + go-version: 1.26.x - name: Checkout code uses: actions/checkout@v6.0.2 @@ -97,10 +97,10 @@ jobs: run: go build github.com/klauspost/compress/s2/cmd/s2c && go build github.com/klauspost/compress/s2/cmd/s2d&&./s2c -verify s2c &&./s2d s2c.s2&&rm ./s2c&&rm s2d&&rm s2c.s2 - name: goreleaser deprecation - run: curl -sfL https://git.io/goreleaser | VERSION=v2.3.2 sh -s -- check + run: curl -sfL https://goreleaser.com/static/run | VERSION=v2.13.3 bash -s -- check - name: goreleaser snapshot - run: curl -sL https://git.io/goreleaser | VERSION=v2.3.2 sh -s -- --snapshot --clean + run: curl -sfL https://goreleaser.com/static/run | VERSION=v2.13.3 bash -s -- --snapshot --clean - name: Test S2 GOAMD64 v3 env: @@ -125,7 +125,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v6.2.0 with: - go-version: 1.25.x + go-version: 1.26.x - name: Checkout code uses: actions/checkout@v6.0.2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 38b2ab443..422ad4ba6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,12 +21,12 @@ jobs: name: Set up Go uses: actions/setup-go@a5f9b05d2d216f63e13859e0d847461041025775 # v5.2.0 with: - go-version: 1.25.x + go-version: 1.26.x - name: Run GoReleaser uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0 with: - version: 2.11.2 + version: 2.13.3 args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml index 4528059ca..804a20181 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -31,6 +31,9 @@ builds: - mips64le goarm: - 7 + ignore: + - goos: windows + goarch: arm - id: "s2d" binary: s2d @@ -57,6 +60,9 @@ builds: - mips64le goarm: - 7 + ignore: + - goos: windows + goarch: arm - id: "s2sx" binary: s2sx @@ -84,6 +90,9 @@ builds: - mips64le goarm: - 7 + ignore: + - goos: windows + goarch: arm archives: - @@ -91,7 +100,7 @@ archives: name_template: "s2-{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" format_overrides: - goos: windows - format: zip + formats: ['zip'] files: - unpack/* - s2/LICENSE diff --git a/flate/example_test.go b/flate/example_test.go index fee027465..f82a581d0 100644 --- a/flate/example_test.go +++ b/flate/example_test.go @@ -177,7 +177,7 @@ func Example_synchronization() { } b := make([]byte, 256) - for _, m := range strings.Fields("A long time ago in a galaxy far, far away...") { + for m := range strings.FieldsSeq("A long time ago in a galaxy far, far away...") { // We use a simple framing format where the first byte is the // message length, followed the message itself. b[0] = uint8(copy(b[1:], m)) diff --git a/flate/regmask_other.go b/flate/regmask_other.go index 1b7a2cbd7..e62caf711 100644 --- a/flate/regmask_other.go +++ b/flate/regmask_other.go @@ -1,5 +1,4 @@ //go:build !amd64 -// +build !amd64 package flate diff --git a/flate/writer_test.go b/flate/writer_test.go index f05d43d10..ea4482985 100644 --- a/flate/writer_test.go +++ b/flate/writer_test.go @@ -335,7 +335,6 @@ func TestWriter_Reset(t *testing.T) { } in := buf.Bytes() for l := range 10 { - l := l if testing.Short() && l > 1 { continue } diff --git a/go.mod b/go.mod index 9b47a42c1..7ea68f5bf 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/klauspost/compress -go 1.23 +go 1.24 retract ( // https://github.com/klauspost/compress/issues/1114 diff --git a/gzhttp/asserts_test.go b/gzhttp/asserts_test.go index f8b8fa900..8d51b2bbf 100644 --- a/gzhttp/asserts_test.go +++ b/gzhttp/asserts_test.go @@ -6,6 +6,7 @@ package gzhttp import ( "reflect" + "slices" "testing" ) @@ -51,7 +52,7 @@ func isNil(object any) bool { []reflect.Kind{ reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, - reflect.Ptr, reflect.Slice}, + reflect.Pointer, reflect.Slice}, kind) if isNilableKind && value.IsNil() { @@ -63,11 +64,5 @@ func isNil(object any) bool { // containsKind checks if a specified kind in the slice of kinds. func containsKind(kinds []reflect.Kind, kind reflect.Kind) bool { - for i := range kinds { - if kind == kinds[i] { - return true - } - } - - return false + return slices.Contains(kinds, kind) } diff --git a/gzip/gzip_test.go b/gzip/gzip_test.go index 703fb0627..b9eea618e 100644 --- a/gzip/gzip_test.go +++ b/gzip/gzip_test.go @@ -361,12 +361,12 @@ func testFileWindow(i, window int, t *testing.T) { } func testBigGzip(i int, t *testing.T) { + rng := rand.New(rand.NewSource(1337)) if len(testbuf) != i { // Make results predictable - rand.Seed(1337) testbuf = make([]byte, i) for idx := range testbuf { - testbuf[idx] = byte(65 + rand.Intn(20)) + testbuf[idx] = byte(65 + rng.Intn(20)) } } c := BestCompression @@ -441,10 +441,10 @@ func testDeterm(level int, t *testing.T) { if testing.Short() { length = 100000 } - rand.Seed(1337) + rng := rand.New(rand.NewSource(1337)) t1 := make([]byte, length) for idx := range t1 { - t1[idx] = byte(65 + rand.Intn(8)) + t1[idx] = byte(65 + rng.Intn(8)) } br := bytes.NewBuffer(t1) @@ -462,10 +462,10 @@ func testDeterm(level int, t *testing.T) { // We recreate the buffer, so we have a goos chance of getting a // different memory address. - rand.Seed(1337) + rng = rand.New(rand.NewSource(1337)) t2 := make([]byte, length) for idx := range t2 { - t2[idx] = byte(65 + rand.Intn(8)) + t2[idx] = byte(65 + rng.Intn(8)) } br2 := bytes.NewBuffer(t2) @@ -538,46 +538,6 @@ func benchmarkGzipN(b *testing.B, level int) { } } -/* -func BenchmarkOldGzipL1(b *testing.B) { benchmarkOldGzipN(b, 1) } -func BenchmarkOldGzipL2(b *testing.B) { benchmarkOldGzipN(b, 2) } -func BenchmarkOldGzipL3(b *testing.B) { benchmarkOldGzipN(b, 3) } -func BenchmarkOldGzipL4(b *testing.B) { benchmarkOldGzipN(b, 4) } -func BenchmarkOldGzipL5(b *testing.B) { benchmarkOldGzipN(b, 5) } -func BenchmarkOldGzipL6(b *testing.B) { benchmarkOldGzipN(b, 6) } -func BenchmarkOldGzipL7(b *testing.B) { benchmarkOldGzipN(b, 7) } -func BenchmarkOldGzipL8(b *testing.B) { benchmarkOldGzipN(b, 8) } -func BenchmarkOldGzipL9(b *testing.B) { benchmarkOldGzipN(b, 9) } - -func benchmarkOldGzipN(b *testing.B, level int) { - dat, _ := os.ReadFile("testdata/test.json") - dat = append(dat, dat...) - dat = append(dat, dat...) - dat = append(dat, dat...) - dat = append(dat, dat...) - dat = append(dat, dat...) - - b.SetBytes(int64(len(dat))) - w, _ := oldgz.NewWriterLevel(io.Discard, level) - b.ResetTimer() - for n := 0; n < b.N; n++ { - w.Reset(io.Discard) - n, err := w.Write(dat) - if n != len(dat) { - panic("short write") - } - if err != nil { - panic(err) - } - err = w.Close() - if err != nil { - panic(err) - } - } -} - -*/ - func BenchmarkCompressAllocations(b *testing.B) { payload := []byte(strings.Repeat("Tiny payload", 20)) for j := -2; j <= 9; j++ { diff --git a/huff0/_generate/go.mod b/huff0/_generate/go.mod index 0c97e535f..942dbf98e 100644 --- a/huff0/_generate/go.mod +++ b/huff0/_generate/go.mod @@ -1,6 +1,6 @@ module github.com/klauspost/compress/huff0/_generate -go 1.23 +go 1.24 toolchain go1.24.2 diff --git a/huff0/decompress_amd64.go b/huff0/decompress_amd64.go index 99ddd4af9..2d6ef64be 100644 --- a/huff0/decompress_amd64.go +++ b/huff0/decompress_amd64.go @@ -1,5 +1,4 @@ //go:build amd64 && !appengine && !noasm && gc -// +build amd64,!appengine,!noasm,gc // This file contains the specialisation of Decoder.Decompress4X // and Decoder.Decompress1X that use an asm implementation of thir main loops. diff --git a/huff0/decompress_generic.go b/huff0/decompress_generic.go index 908c17de6..610392322 100644 --- a/huff0/decompress_generic.go +++ b/huff0/decompress_generic.go @@ -1,5 +1,4 @@ //go:build !amd64 || appengine || !gc || noasm -// +build !amd64 appengine !gc noasm // This file contains a generic implementation of Decoder.Decompress4X. package huff0 diff --git a/internal/cpuinfo/cpuinfo_amd64.go b/internal/cpuinfo/cpuinfo_amd64.go index e802579c4..b97f9056f 100644 --- a/internal/cpuinfo/cpuinfo_amd64.go +++ b/internal/cpuinfo/cpuinfo_amd64.go @@ -1,5 +1,4 @@ //go:build amd64 && !appengine && !noasm && gc -// +build amd64,!appengine,!noasm,gc package cpuinfo diff --git a/s2/cmd/_s2sx/go.mod b/s2/cmd/_s2sx/go.mod index 22459b4c8..7607a767b 100644 --- a/s2/cmd/_s2sx/go.mod +++ b/s2/cmd/_s2sx/go.mod @@ -1,8 +1,6 @@ module github.com/klauspost/compress/s2/cmd/_s2sx -go 1.23 - -toolchain go1.24.2 +go 1.24 require github.com/klauspost/compress v1.11.9 diff --git a/s2/cmd/s2d/main.go b/s2/cmd/s2d/main.go index 0ee3e7705..ddc915203 100644 --- a/s2/cmd/s2d/main.go +++ b/s2/cmd/s2d/main.go @@ -197,8 +197,8 @@ Options:`) for _, filename := range files { dstFilename := cleanFileName(filename) block := *block - if strings.HasSuffix(dstFilename, ".block") { - dstFilename = strings.TrimSuffix(dstFilename, ".block") + if before, ok := strings.CutSuffix(dstFilename, ".block"); ok { + dstFilename = before block = true } switch { diff --git a/s2/decode_other.go b/s2/decode_other.go index c99d40b69..2905ba277 100644 --- a/s2/decode_other.go +++ b/s2/decode_other.go @@ -4,7 +4,6 @@ // license that can be found in the LICENSE file. //go:build (!amd64 && !arm64) || appengine || !gc || noasm -// +build !amd64,!arm64 appengine !gc noasm package s2 diff --git a/s2/encode_amd64.go b/s2/encode_amd64.go index 7aadd255f..68d72a41d 100644 --- a/s2/encode_amd64.go +++ b/s2/encode_amd64.go @@ -1,5 +1,4 @@ //go:build !appengine && !noasm && gc -// +build !appengine,!noasm,gc package s2 diff --git a/s2/encode_go.go b/s2/encode_go.go index e25b78445..5597f3ef2 100644 --- a/s2/encode_go.go +++ b/s2/encode_go.go @@ -1,5 +1,4 @@ //go:build !amd64 || appengine || !gc || noasm -// +build !amd64 appengine !gc noasm package s2 diff --git a/s2/fuzz_test.go b/s2/fuzz_test.go index e25af84f8..5ed807418 100644 --- a/s2/fuzz_test.go +++ b/s2/fuzz_test.go @@ -1,5 +1,4 @@ //go:build go1.18 -// +build go1.18 package s2 diff --git a/zip/internal/obscuretestdata/obscuretestdata.go b/zip/internal/obscuretestdata/obscuretestdata.go index 76230d63d..7faf9adb9 100644 --- a/zip/internal/obscuretestdata/obscuretestdata.go +++ b/zip/internal/obscuretestdata/obscuretestdata.go @@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build go1.16 -// +build go1.16 // Package obscuretestdata contains functionality used by tests to more easily // work with testdata that must be obscured primarily due to diff --git a/zstd/_generate/go.mod b/zstd/_generate/go.mod index a9130036a..b1431b46c 100644 --- a/zstd/_generate/go.mod +++ b/zstd/_generate/go.mod @@ -1,6 +1,6 @@ module github.com/klauspost/compress/zstd/_generate -go 1.23 +go 1.24 toolchain go1.24.2 diff --git a/zstd/fse_decoder_amd64.go b/zstd/fse_decoder_amd64.go index d04a829b0..b8c8607b5 100644 --- a/zstd/fse_decoder_amd64.go +++ b/zstd/fse_decoder_amd64.go @@ -1,5 +1,4 @@ //go:build amd64 && !appengine && !noasm && gc -// +build amd64,!appengine,!noasm,gc package zstd diff --git a/zstd/fse_decoder_generic.go b/zstd/fse_decoder_generic.go index 8adfebb02..2138f8091 100644 --- a/zstd/fse_decoder_generic.go +++ b/zstd/fse_decoder_generic.go @@ -1,5 +1,4 @@ //go:build !amd64 || appengine || !gc || noasm -// +build !amd64 appengine !gc noasm package zstd diff --git a/zstd/fuzz_test.go b/zstd/fuzz_test.go index 2cd32bab7..78e0066a4 100644 --- a/zstd/fuzz_test.go +++ b/zstd/fuzz_test.go @@ -1,5 +1,4 @@ //go:build go1.18 -// +build go1.18 package zstd diff --git a/zstd/internal/xxhash/xxhash_other.go b/zstd/internal/xxhash/xxhash_other.go index 0be16cefc..9576426e6 100644 --- a/zstd/internal/xxhash/xxhash_other.go +++ b/zstd/internal/xxhash/xxhash_other.go @@ -1,5 +1,4 @@ //go:build (!amd64 && !arm64) || appengine || !gc || purego || noasm -// +build !amd64,!arm64 appengine !gc purego noasm package xxhash diff --git a/zstd/matchlen_amd64.go b/zstd/matchlen_amd64.go index f41932b7a..1ed18927f 100644 --- a/zstd/matchlen_amd64.go +++ b/zstd/matchlen_amd64.go @@ -1,5 +1,4 @@ //go:build amd64 && !appengine && !noasm && gc -// +build amd64,!appengine,!noasm,gc // Copyright 2019+ Klaus Post. All rights reserved. // License information can be found in the LICENSE file. diff --git a/zstd/matchlen_generic.go b/zstd/matchlen_generic.go index bea1779e9..379746c96 100644 --- a/zstd/matchlen_generic.go +++ b/zstd/matchlen_generic.go @@ -1,5 +1,4 @@ //go:build !amd64 || appengine || !gc || noasm -// +build !amd64 appengine !gc noasm // Copyright 2019+ Klaus Post. All rights reserved. // License information can be found in the LICENSE file. diff --git a/zstd/race_enabled_test.go b/zstd/race_enabled_test.go index b9a51d54b..86b846f17 100644 --- a/zstd/race_enabled_test.go +++ b/zstd/race_enabled_test.go @@ -2,7 +2,6 @@ // License information can be found in the LICENSE file. //go:build race -// +build race package zstd diff --git a/zstd/seqdec_amd64.go b/zstd/seqdec_amd64.go index 1f8c3cec2..18c3703dd 100644 --- a/zstd/seqdec_amd64.go +++ b/zstd/seqdec_amd64.go @@ -1,5 +1,4 @@ //go:build amd64 && !appengine && !noasm && gc -// +build amd64,!appengine,!noasm,gc package zstd diff --git a/zstd/seqdec_amd64_test.go b/zstd/seqdec_amd64_test.go index 1db3b5f52..7272b3b04 100644 --- a/zstd/seqdec_amd64_test.go +++ b/zstd/seqdec_amd64_test.go @@ -1,5 +1,4 @@ //go:build amd64 && !appengine && !noasm && gc -// +build amd64,!appengine,!noasm,gc package zstd diff --git a/zstd/seqdec_generic.go b/zstd/seqdec_generic.go index 7cec2197c..516cd9b07 100644 --- a/zstd/seqdec_generic.go +++ b/zstd/seqdec_generic.go @@ -1,5 +1,4 @@ //go:build !amd64 || appengine || !gc || noasm -// +build !amd64 appengine !gc noasm package zstd