package domain import ( "encoding/json" "time" ) type Message struct { ID string `json:"id"` ChatID string `json:"chat_id"` SenderID string `json:"sender_id"` Text string `json:"text"` CreatedAt time.Time `json:"created_at"` // AttachmentIDs — в порядке отправки; всегда массив (пустой, если вложений нет). AttachmentIDs []string `json:"attachment_ids"` } func (m Message) MarshalJSON() ([]byte, error) { type Alias Message if m.AttachmentIDs == nil { m.AttachmentIDs = []string{} } return json.Marshal(&struct { Alias CreatedAt string `json:"created_at"` }{ Alias: Alias(m), CreatedAt: m.CreatedAt.UTC().Truncate(time.Second).Format(time.RFC3339), }) }