From 9ce439a217a8f2f5c48317bb5fb37e65d2f11ede Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 27 Apr 2026 08:38:37 +0300 Subject: Move post.Load constructor before methods in post.go --- internal/post/post.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'internal/post') diff --git a/internal/post/post.go b/internal/post/post.go index cdef546..38dff03 100644 --- a/internal/post/post.go +++ b/internal/post/post.go @@ -40,21 +40,6 @@ type Post struct { Assets []string `json:"assets,omitempty"` } -// Save writes the post as post.json into dir. -func (p *Post) Save(dir string) error { - data, err := json.MarshalIndent(p, "", " ") - if err != nil { - return fmt.Errorf("marshal post %s: %w", p.ID, err) - } - - path := filepath.Join(dir, "post.json") - if err := os.WriteFile(path, data, 0o644); err != nil { - return fmt.Errorf("write post.json for %s: %w", p.ID, err) - } - - return nil -} - // Load reads and parses post.json from dir. func Load(dir string) (*Post, error) { path := filepath.Join(dir, "post.json") @@ -82,3 +67,18 @@ func NewID(t time.Time, suffix int) string { return fmt.Sprintf("%s-%d", base, suffix) } + +// Save writes the post as post.json into dir. +func (p *Post) Save(dir string) error { + data, err := json.MarshalIndent(p, "", " ") + if err != nil { + return fmt.Errorf("marshal post %s: %w", p.ID, err) + } + + path := filepath.Join(dir, "post.json") + if err := os.WriteFile(path, data, 0o644); err != nil { + return fmt.Errorf("write post.json for %s: %w", p.ID, err) + } + + return nil +} -- cgit v1.2.3