-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage.go
31 lines (28 loc) · 816 Bytes
/
image.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package rss2
import (
"encoding/xml"
"fmt"
)
// Image represents a Channel's image. URL, Title and Link must be
// present. Width must not exceed 144. Height must not exceed 400.
type Image struct {
XMLName xml.Name `xml:"image"`
URL string `xml:"url"`
Title string `xml:"title"`
Link string `xml:"link"`
Width int `xml:"width,omitempty"`
Height int `xml:"height,omitempty"`
Description string `xml:"description,omitempty"`
}
// NewImage creates new Image.
func NewImage(url, title, link string) (*Image, error) {
if len(url) == 0 || len(title) == 0 || len(link) == 0 {
return nil, fmt.Errorf(`empty string passed to NewImage()`)
}
return &Image{
XMLName: xml.Name{Local: `image`},
URL: url,
Title: title,
Link: link,
}, nil
}