From 0695aa46b385d7db7f7cb6704faa33688c4d824c Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sun, 24 Sep 2023 19:02:43 +0400 Subject: [PATCH] For Article added a consturctor func New(). --- pkg/article/article.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/article/article.go b/pkg/article/article.go index a22fb0d..9dc6bbd 100644 --- a/pkg/article/article.go +++ b/pkg/article/article.go @@ -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 {