package pg import ( "database/sql/driver" "encoding/json" "errors" ) // swagger:enum MediaType // ENUM( // Video = "video", // Audio = "audio", // Pdf = "pdf", // ) type MediaType string type MediaSource struct { Duration int64 `json:"duration"` Items []MediaSourceItem `json:"items"` } func (x MediaSource) Scan(value interface{}) (err error) { switch v := value.(type) { case string: return json.Unmarshal([]byte(v), &x) case []byte: return json.Unmarshal(v, &x) case *string: return json.Unmarshal([]byte(*v), &x) } return errors.New("Unknown type for ") } func (x MediaSource) Value() (driver.Value, error) { return json.Marshal(x) } type MediaSourceItem struct { Source string `json:"source"` Size int64 `json:"size"` Duration int64 `json:"duration"` }