chore(lint): unify formatting on golangci-lint fmt (gofumpt), uncap issue reporting, fix gofumpt drift

- make format 现在与 code-check 使用同一格式化器(golangci-lint fmt),消除 goimports -local 与 gofumpt 的格式拉锯
- .golangci.yml 关闭默认 50/3 截断,完整上报所有问题(只增强不弱化)
- 全库 gofumpt 规范化(203 files, 纯格式无行为变更)
This commit is contained in:
ryan
2026-08-28 16:31:53 +08:00
parent 078ad9b2f3
commit 528240026d
204 changed files with 572 additions and 718 deletions
+3 -4
View File
@@ -4,13 +4,12 @@
package cap
import (
"net/http"
"github.com/gin-gonic/gin"
"Wavelet/pkg/logger"
"Wavelet/pkg/response"
"Wavelet/plugins/domain/cap/pow"
"net/http"
"github.com/gin-gonic/gin"
)
// ChallengeResponse is a local type alias for the pow.ChallengeResponse struct
+3 -4
View File
@@ -5,6 +5,8 @@
package cap
import (
"Wavelet/pkg/config"
"Wavelet/plugins/domain/cap/pow"
"context"
"crypto/sha256"
"encoding/hex"
@@ -12,9 +14,6 @@ import (
"strings"
"sync"
"time"
"Wavelet/pkg/config"
"Wavelet/plugins/domain/cap/pow"
)
const (
@@ -116,7 +115,7 @@ func (m *Manager) Redeem(ctx context.Context, token string, solutions []int, sco
}
// VerifyToken validates and consumes the redeem token (single-use).
func (m *Manager) VerifyToken(ctx context.Context, token string, expectedScope string) (bool, error) {
func (m *Manager) VerifyToken(ctx context.Context, token, expectedScope string) (bool, error) {
if token == "" {
return false, nil
}
+2 -2
View File
@@ -4,9 +4,9 @@
package cap
import (
"github.com/gin-gonic/gin"
"Wavelet/pkg/response"
"github.com/gin-gonic/gin"
)
// VerifyMiddleware returns a Gin middleware that checks and consumes the X-Cap-Token header.
+1 -2
View File
@@ -5,11 +5,10 @@
package cap
import (
"reflect"
"Wavelet/core"
"Wavelet/core/contracts"
"Wavelet/core/extpoints"
"reflect"
)
// Plugin implements core.Plugin to provide CAPTCHA generation, validation, and route protection.
+1 -1
View File
@@ -88,7 +88,7 @@ func RandomHex(byteLen int) string {
return hex.EncodeToString(bytes)
}
func jwtSign(payload []byte, secret []byte) string {
func jwtSign(payload, secret []byte) string {
body := b64urlEncode(payload)
sigInput := jwtHeaderB64 + "." + body
+6 -6
View File
@@ -14,12 +14,12 @@ import (
// Store defines the storage interface for challenge nonces and verification tokens
type Store interface {
Get(ctx context.Context, key string) (string, bool, error)
Set(ctx context.Context, key string, val string, ttl time.Duration) error
Set(ctx context.Context, key, val string, ttl time.Duration) error
Delete(ctx context.Context, key string) error
// SetNX atomically sets key=val with the given TTL only when the key does not
// exist yet. It returns true when the key was actually written (i.e. this
// caller "won" the race), and false when the key already existed.
SetNX(ctx context.Context, key string, val string, ttl time.Duration) (bool, error)
SetNX(ctx context.Context, key, val string, ttl time.Duration) (bool, error)
// GetAndDelete atomically retrieves the value of key and removes it in a
// single operation. Returns ("", false, nil) when the key does not exist.
GetAndDelete(ctx context.Context, key string) (string, bool, error)
@@ -68,7 +68,7 @@ func (s *MemoryStore) getLocked(key string) (string, bool, error) {
}
// Set 向 MemoryStore 写入指定 key 的值
func (s *MemoryStore) Set(_ context.Context, key string, val string, ttl time.Duration) error {
func (s *MemoryStore) Set(_ context.Context, key, val string, ttl time.Duration) error {
s.mu.Lock()
defer s.mu.Unlock()
s.items[key] = memoryItem{
@@ -88,7 +88,7 @@ func (s *MemoryStore) Delete(_ context.Context, key string) error {
// SetNX atomically sets key only when it is absent (or expired).
// Returns true if the key was written by this call.
func (s *MemoryStore) SetNX(_ context.Context, key string, val string, ttl time.Duration) (bool, error) {
func (s *MemoryStore) SetNX(_ context.Context, key, val string, ttl time.Duration) (bool, error) {
s.mu.Lock()
defer s.mu.Unlock()
@@ -159,7 +159,7 @@ func (s *RedisStore) Get(ctx context.Context, key string) (string, bool, error)
}
// Set 向 RedisStore 写入指定 key 的值
func (s *RedisStore) Set(ctx context.Context, key string, val string, ttl time.Duration) error {
func (s *RedisStore) Set(ctx context.Context, key, val string, ttl time.Duration) error {
return s.client.Set(ctx, key, val, ttl).Err()
}
@@ -169,7 +169,7 @@ func (s *RedisStore) Delete(ctx context.Context, key string) error {
}
// SetNX wraps Redis SET NX – returns true only when the key was newly created.
func (s *RedisStore) SetNX(ctx context.Context, key string, val string, ttl time.Duration) (bool, error) {
func (s *RedisStore) SetNX(ctx context.Context, key, val string, ttl time.Duration) (bool, error) {
return s.client.SetNX(ctx, key, val, ttl).Result()
}
@@ -4,6 +4,8 @@
package cap
import (
"Wavelet/core"
"Wavelet/core/contracts"
"context"
"errors"
"strconv"
@@ -13,9 +15,6 @@ import (
"golang.org/x/sync/singleflight"
"gorm.io/gorm"
"Wavelet/core"
"Wavelet/core/contracts"
)
var (