package ui import ( "image" "os" ) type ImageSource interface { CreateImage() (image.Image, error) } type ImageFileSource string var _ ImageSource = ImageFileSource("") func (s ImageFileSource) CreateImage() (image.Image, error) { f, err := os.Open(string(s)) if err != nil { return nil, err } defer f.Close() m, _, err := image.Decode(f) if err != nil { return nil, err } return m, nil } type ImageGoSource struct { image.Image } var _ ImageSource = ImageGoSource{} func (s ImageGoSource) CreateImage() (image.Image, error) { return s.Image, nil }