adding basic data storage

This commit is contained in:
2024-12-27 22:34:43 +01:00
parent ab1b709c77
commit aeb9de71a1
9 changed files with 259 additions and 15 deletions

View File

@@ -6,15 +6,16 @@ import (
"encoding/hex"
)
type Article struct {
SourceUrl string
PublishDate time.Time
FetchDate time.Time
Title string
Content string
Identifier uint
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. */
@@ -22,3 +23,10 @@ func (article *Article) Hash() string {
hash := sha256.Sum256([]byte(article.SourceUrl))
return hex.EncodeToString(hash[:])
}
// --- implementation of the IIdentifiable interface ---
func (article *Article) Id() uint {
return article.Identifier
}