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