restructuring

This commit is contained in:
2024-12-27 03:25:44 +01:00
parent a711e5742d
commit ab1b709c77
5 changed files with 39 additions and 2 deletions

View File

@@ -0,0 +1,8 @@
package data
type Datastore interface {
Set(key string) error
Get(key string) string, error
GetAll(rowkey string) map[string]string, error
GetAllKeys() map[string]bool, error
}

24
internal/model/article.go Normal file
View File

@@ -0,0 +1,24 @@
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[:])
}