Adds a fallback ID function.

This commit is contained in:
Harm Aarts 2013-12-05 16:18:13 +01:00
parent 6b6086e389
commit b4a80d771a
1 changed files with 10 additions and 1 deletions

11
item.go
View File

@ -1,5 +1,10 @@
package feeder
import (
"crypto/md5"
"io"
)
type Item struct {
// RSS and Shared fields
Title string
@ -26,7 +31,11 @@ func (i *Item) Key() string {
return *i.Guid
case len(i.Id) != 0:
return i.Id
default:
case len(i.Title) > 0 && len(i.PubDate) > 0:
return i.Title + i.PubDate
default:
h := md5.New()
io.WriteString(h, i.Description)
return string(h.Sum(nil))
}
}