For Article added a consturctor func New().
This commit is contained in:
parent
1c3f0c7b2c
commit
0695aa46b3
@ -15,6 +15,12 @@ type Article struct {
|
||||
Body []byte
|
||||
}
|
||||
|
||||
func New(body, meta []byte) (article *Article, err error) {
|
||||
article = &Article{Body: body}
|
||||
err = article.ParseMetadata(meta)
|
||||
return
|
||||
}
|
||||
|
||||
func (artcl *Article) ParseMetadata(data []byte) error {
|
||||
lines := bytes.Split(data, []byte{'\n'})
|
||||
if len(lines) != 4 {
|
||||
|
Loading…
Reference in New Issue
Block a user