25 lines
475 B
Go
25 lines
475 B
Go
|
|
package model
|
||
|
|
|
||
|
|
import (
|
||
|
|
"time"
|
||
|
|
"crypto/sha256"
|
||
|
|
"encoding/hex"
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
type Article struct {
|
||
|
|
SourceUrl string
|
||
|
|
PublishDate time.Time
|
||
|
|
FetchDate time.Time
|
||
|
|
Title string
|
||
|
|
Content string
|
||
|
|
}
|
||
|
|
|
||
|
|
func (article *Article) Hash() string {
|
||
|
|
/* Generates a hash based on the source url of the article. Can be used to
|
||
|
|
* identify the article. */
|
||
|
|
|
||
|
|
hash := sha256.Sum256([]byte(article.SourceUrl))
|
||
|
|
return hex.EncodeToString(hash[:])
|
||
|
|
}
|