refactor: upgrade to Go 1.26 and modernize code idioms
- Replace `interface{}` with `any` type alias across all packages
- Use built-in `min()`/`max()` for parameter clamping
- Use `slices.SortFunc`, `slices.Min`, `slices.Max` for cleaner code
- Use `strings.Cut()` for simpler string parsing in auth middleware
- Use `errors.Is()` for proper error comparison in handlers
- Update dependencies: golang.org/x/image 0.37.0 -> 0.38.0
- Add Wire code generation guidelines to ARCHITECTURE.md
- Disable Go cache in CI build workflow
This commit is contained in:
@@ -73,7 +73,7 @@ func (c *Client) Get(ctx context.Context, key string) (string, error) {
|
||||
}
|
||||
|
||||
// Set 设置值
|
||||
func (c *Client) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error {
|
||||
func (c *Client) Set(ctx context.Context, key string, value any, expiration time.Duration) error {
|
||||
return c.rdb.Set(ctx, key, value, expiration).Err()
|
||||
}
|
||||
|
||||
@@ -121,12 +121,12 @@ func (c *Client) IsMiniRedis() bool {
|
||||
// ==================== Hash 操作 ====================
|
||||
|
||||
// HSet 设置 Hash 字段
|
||||
func (c *Client) HSet(ctx context.Context, key string, field string, value interface{}) error {
|
||||
func (c *Client) HSet(ctx context.Context, key string, field string, value any) error {
|
||||
return c.rdb.HSet(ctx, key, field, value).Err()
|
||||
}
|
||||
|
||||
// HMSet 批量设置 Hash 字段
|
||||
func (c *Client) HMSet(ctx context.Context, key string, values map[string]interface{}) error {
|
||||
func (c *Client) HMSet(ctx context.Context, key string, values map[string]any) error {
|
||||
return c.rdb.HMSet(ctx, key, values).Err()
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ func (c *Client) HGet(ctx context.Context, key string, field string) (string, er
|
||||
}
|
||||
|
||||
// HMGet 批量获取 Hash 字段值
|
||||
func (c *Client) HMGet(ctx context.Context, key string, fields ...string) ([]interface{}, error) {
|
||||
func (c *Client) HMGet(ctx context.Context, key string, fields ...string) ([]any, error) {
|
||||
return c.rdb.HMGet(ctx, key, fields...).Result()
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ func (c *Client) ZRevRange(ctx context.Context, key string, start, stop int64) (
|
||||
}
|
||||
|
||||
// ZRem 删除 Sorted Set 成员
|
||||
func (c *Client) ZRem(ctx context.Context, key string, members ...interface{}) error {
|
||||
func (c *Client) ZRem(ctx context.Context, key string, members ...any) error {
|
||||
return c.rdb.ZRem(ctx, key, members...).Err()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user