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:
@@ -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"` // 回复的消息ID(string类型)
|
||||
ReplyToID *string `json:"reply_to_id,omitempty"` // 回复的消息ID(string类型)
|
||||
Status MessageStatus `gorm:"type:varchar(20);default:'normal'" json:"status"` // 消息状态
|
||||
|
||||
// 新增字段:消息分类和系统消息类型
|
||||
|
||||
Reference in New Issue
Block a user