restructuring
This commit is contained in:
8
internal/data/datastore.go
Normal file
8
internal/data/datastore.go
Normal 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
24
internal/model/article.go
Normal 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[:])
|
||||
}
|
||||
Reference in New Issue
Block a user