refactor: upgrade to Go 1.26 and modernize code idioms
All checks were successful
Build Backend / build (push) Successful in 3m51s
Build Backend / build-docker (push) Successful in 1m0s

- 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:
lafay
2026-03-30 04:49:35 +08:00
parent a69b2026f4
commit b640c9a249
47 changed files with 368 additions and 352 deletions

View File

@@ -97,7 +97,7 @@ func (e ExtraData) Value() (driver.Value, error) {
}
// Scan 实现sql.Scanner接口用于数据库读取
func (e *ExtraData) Scan(value interface{}) error {
func (e *ExtraData) Scan(value any) error {
if value == nil {
return nil
}
@@ -109,7 +109,7 @@ func (e *ExtraData) Scan(value interface{}) error {
}
// MessageSegmentData 单个消息段的数据
type MessageSegmentData map[string]interface{}
type MessageSegmentData map[string]any
// MessageSegment 消息段
type MessageSegment struct {
@@ -126,7 +126,7 @@ func (s MessageSegments) Value() (driver.Value, error) {
}
// Scan 实现sql.Scanner接口用于数据库读取
func (s *MessageSegments) Scan(value interface{}) error {
func (s *MessageSegments) Scan(value any) error {
if value == nil {
*s = nil
return nil
@@ -148,11 +148,11 @@ type Message struct {
Seq int64 `gorm:"not null;index:idx_msg_conversation_seq,priority:2" json:"seq"` // 会话内序号,用于排序和增量同步
// 消息内容字段
Segments MessageSegments `gorm:"-" json:"segments"` // 消息链(内存中使用,不映射到数据库)
SegmentsEncrypted string `gorm:"column:segments;type:text" json:"-"` // 加密后的消息链(存储在数据库)
Segments MessageSegments `gorm:"-" json:"segments"` // 消息链(内存中使用,不映射到数据库)
SegmentsEncrypted string `gorm:"column:segments;type:text" json:"-"` // 加密后的消息链(存储在数据库)
SegmentsKeyVersion int `gorm:"column:segments_key_version;default:0" json:"segments_key_version"` // 密钥版本,用于密钥轮换
ReplyToID *string `json:"reply_to_id,omitempty"` // 回复的消息IDstring类型
ReplyToID *string `json:"reply_to_id,omitempty"` // 回复的消息IDstring类型
Status MessageStatus `gorm:"type:varchar(20);default:'normal'" json:"status"` // 消息状态
// 新增字段:消息分类和系统消息类型