1package feeder 2 3import ( 4 "crypto/md5" 5 "io" 6 "time" 7) 8 9type Item struct { 10 // RSS and Shared fields 11 Title string 12 Links []*Link 13 Description string 14 Author Author 15 Categories []*Category 16 Comments string 17 Enclosures []*Enclosure 18 Guid *string 19 PubDate string 20 Source *Source 21 22 // Atom specific fields 23 Id string 24 Generator *Generator 25 Contributors []string 26 Content *Content 27 Updated string 28 29 Extensions map[string]map[string][]Extension 30} 31 32func (i *Item) ParsedPubDate() (time.Time, error) { 33 return parseTime(i.PubDate) 34} 35 36func (i *Item) Key() string { 37 switch { 38 case i.Guid != nil && len(*i.Guid) != 0: 39 return *i.Guid 40 case len(i.Id) != 0: 41 return i.Id 42 case len(i.Title) > 0 && len(i.PubDate) > 0: 43 return i.Title + i.PubDate 44 default: 45 h := md5.New() 46 io.WriteString(h, i.Description) 47 return string(h.Sum(nil)) 48 } 49} 50