change IIdentifiable interface to use a string instead of int
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
|
||||
// TODO docstring
|
||||
type Article struct {
|
||||
Identifier uint
|
||||
SourceUrl string
|
||||
PublishDate time.Time
|
||||
FetchDate time.Time
|
||||
@@ -21,7 +20,6 @@ type Article struct {
|
||||
// Generates a hash based on the source url of the article. Can be used to
|
||||
// identify the article.
|
||||
func (article *Article) Hash() string {
|
||||
|
||||
hash := sha256.Sum256([]byte(article.SourceUrl))
|
||||
return hex.EncodeToString(hash[:])
|
||||
}
|
||||
@@ -30,6 +28,6 @@ func (article *Article) Hash() string {
|
||||
// --- implement IIdentifiable interface ---
|
||||
|
||||
// Using the Identifier attribute as the Id.
|
||||
func (article *Article) Id() uint {
|
||||
return article.Identifier
|
||||
func (article *Article) Id() string {
|
||||
return article.Hash()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user