From f2922155de01b734e3e8b3f50be8f263ec13cacd Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Fri, 6 Mar 2026 18:38:44 +0800 Subject: *: Lint --- internal/adler32/adler32_amd64.go | 1 + internal/adler32/bench_test.go | 1 + internal/bufpool/class.go | 1 + internal/bufpool/pool.go | 1 + internal/compress/zlib/reader.go | 1 + internal/compress/zlib/reader_test.go | 1 + internal/compress/zlib/writer.go | 1 + internal/compress/zlib/writer_test.go | 2 ++ internal/lru/get.go | 2 ++ internal/lru/peek.go | 2 ++ internal/lru/remove.go | 2 ++ internal/testgit/repo_tag_annotated.go | 3 +-- 12 files changed, 16 insertions(+), 2 deletions(-) (limited to 'internal') diff --git a/internal/adler32/adler32_amd64.go b/internal/adler32/adler32_amd64.go index 7dfab299..7c3d4746 100644 --- a/internal/adler32/adler32_amd64.go +++ b/internal/adler32/adler32_amd64.go @@ -14,6 +14,7 @@ import ( // Size of an Adler-32 checksum in bytes. const Size = 4 +//nolint:gochecknoglobals var hasAVX2 = cpu.X86.HasAVX2 // digest represents the partial evaluation of a checksum. diff --git a/internal/adler32/bench_test.go b/internal/adler32/bench_test.go index d2aebe8f..1161221a 100644 --- a/internal/adler32/bench_test.go +++ b/internal/adler32/bench_test.go @@ -8,6 +8,7 @@ import ( const benchmarkSize = 64 * 1024 +//nolint:gochecknoglobals var data = make([]byte, benchmarkSize) func init() { //nolint:gochecknoinits diff --git a/internal/bufpool/class.go b/internal/bufpool/class.go index 60842d5e..92b9742a 100644 --- a/internal/bufpool/class.go +++ b/internal/bufpool/class.go @@ -1,5 +1,6 @@ package bufpool +//nolint:gochecknoglobals var sizeClasses = [...]int{ DefaultBufferCap, 64 << 10, diff --git a/internal/bufpool/pool.go b/internal/bufpool/pool.go index 30a4a2fb..d776eaa8 100644 --- a/internal/bufpool/pool.go +++ b/internal/bufpool/pool.go @@ -2,6 +2,7 @@ package bufpool import "sync" +//nolint:gochecknoglobals var bufferPools = func() []sync.Pool { pools := make([]sync.Pool, len(sizeClasses)) for i, classCap := range sizeClasses { diff --git a/internal/compress/zlib/reader.go b/internal/compress/zlib/reader.go index 3cf0066e..1f6d4337 100644 --- a/internal/compress/zlib/reader.go +++ b/internal/compress/zlib/reader.go @@ -58,6 +58,7 @@ var ( ErrHeader = errors.New("zlib: invalid header") ) +//nolint:gochecknoglobals var readerPool = sync.Pool{ New: func() any { r := new(Reader) diff --git a/internal/compress/zlib/reader_test.go b/internal/compress/zlib/reader_test.go index c64bd5b0..2cfa8a97 100644 --- a/internal/compress/zlib/reader_test.go +++ b/internal/compress/zlib/reader_test.go @@ -24,6 +24,7 @@ type zlibTest struct { // Compare-to-golden test data was generated by the ZLIB example program at // https://www.zlib.net/zpipe.c +//nolint:gochecknoglobals var zlibTests = []zlibTest{ { "truncated empty", diff --git a/internal/compress/zlib/writer.go b/internal/compress/zlib/writer.go index 8a5562fb..05808eb6 100644 --- a/internal/compress/zlib/writer.go +++ b/internal/compress/zlib/writer.go @@ -37,6 +37,7 @@ type Writer struct { wroteHeader bool } +//nolint:gochecknoglobals var writerPool = sync.Pool{ New: func() any { return new(Writer) diff --git a/internal/compress/zlib/writer_test.go b/internal/compress/zlib/writer_test.go index e67a3539..541aac65 100644 --- a/internal/compress/zlib/writer_test.go +++ b/internal/compress/zlib/writer_test.go @@ -15,12 +15,14 @@ import ( "codeberg.org/lindenii/furgit/internal/compress/zlib" ) +//nolint:gochecknoglobals var filenames = []string{ "../testdata/gettysburg.txt", "../testdata/e.txt", "../testdata/pi.txt", } +//nolint:gochecknoglobals var data = []string{ "test a reasonable sized string that can be compressed", } diff --git a/internal/lru/get.go b/internal/lru/get.go index 92196003..81383945 100644 --- a/internal/lru/get.go +++ b/internal/lru/get.go @@ -1,6 +1,8 @@ package lru // Get returns value for key and marks it most-recently-used. +// +//nolint:ireturn func (cache *Cache[K, V]) Get(key K) (V, bool) { elem, ok := cache.items[key] if !ok { diff --git a/internal/lru/peek.go b/internal/lru/peek.go index 3a308394..8aced931 100644 --- a/internal/lru/peek.go +++ b/internal/lru/peek.go @@ -1,6 +1,8 @@ package lru // Peek returns value for key without changing recency. +// +//nolint:ireturn func (cache *Cache[K, V]) Peek(key K) (V, bool) { elem, ok := cache.items[key] if !ok { diff --git a/internal/lru/remove.go b/internal/lru/remove.go index 79735edf..3b1f2c93 100644 --- a/internal/lru/remove.go +++ b/internal/lru/remove.go @@ -3,6 +3,8 @@ package lru import "container/list" // Remove deletes key from the cache. +// +//nolint:ireturn func (cache *Cache[K, V]) Remove(key K) (V, bool) { elem, ok := cache.items[key] if !ok { diff --git a/internal/testgit/repo_tag_annotated.go b/internal/testgit/repo_tag_annotated.go index 7e9bfbf5..56bd6a0c 100644 --- a/internal/testgit/repo_tag_annotated.go +++ b/internal/testgit/repo_tag_annotated.go @@ -1,7 +1,6 @@ package testgit import ( - "fmt" "testing" "codeberg.org/lindenii/furgit/objectid" @@ -12,5 +11,5 @@ func (testRepo *TestRepo) TagAnnotated(tb testing.TB, name string, target object tb.Helper() testRepo.Run(tb, "tag", "-a", name, target.String(), "-m", message) - return testRepo.RevParse(tb, fmt.Sprintf("refs/tags/%s", name)) + return testRepo.RevParse(tb, "refs/tags/"+name) } -- cgit v1.3.1-10-gc9f91