package imageprocessor import ( "encoding/json" "fmt" "github.com/google/uuid" ) const ( IMAGE_TYPE = "image" LIST_TYPE = "list" ) type ImageNotification struct { Type string ImageID uuid.UUID ImageName string Status string } func getImageNotification(image ImageNotification) Notification { return Notification{ image: &image, } } type ListNotification struct { Type string ListID uuid.UUID Name string Status string } type Notification struct { image *ImageNotification list *ListNotification } func GetListNotification(list ListNotification) Notification { return Notification{ list: &list, } } func (n Notification) MarshalJSON() ([]byte, error) { if n.image != nil { return json.Marshal(n.image) } if n.list != nil { return json.Marshal(n.list) } return nil, fmt.Errorf("no image or list present") } func (n *Notification) UnmarshalJSON(data []byte) error { return fmt.Errorf("unimplemented") }