From e542fa0c97afd12db17e239f338ae2a03c5a3415 Mon Sep 17 00:00:00 2001 From: milarin Date: Fri, 3 Mar 2023 15:08:21 +0100 Subject: [PATCH] added String() methods for various types --- types.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/types.go b/types.go index f60bfc7..8edb2b0 100644 --- a/types.go +++ b/types.go @@ -15,12 +15,22 @@ type ReadingList struct { Entries []ReadingListEntry `json:"entries"` } +func (l ReadingList) String() string { + data, _ := json.MarshalIndent(l, "", "\t") + return string(data) +} + type ReadingListEntry struct { Novel NovelEntry `json:"novel"` CurrentChapter ReadingListChapterEntry `json:"current_chapter"` LatestChapter ReadingListChapterEntry `json:"latest_chapter"` } +func (e ReadingListEntry) String() string { + data, _ := json.MarshalIndent(e, "", "\t") + return string(data) +} + func (e ReadingListEntry) NewChapterAvailable() bool { return e.CurrentChapter.ID != e.LatestChapter.ID } @@ -31,11 +41,21 @@ type ReadingListChapterEntry struct { Link string `json:"link"` } +func (e ReadingListChapterEntry) String() string { + data, _ := json.MarshalIndent(e, "", "\t") + return string(data) +} + type NovelEntry struct { NovelID NovelID `json:"id"` Name string `json:"name"` } +func (e NovelEntry) String() string { + data, _ := json.MarshalIndent(e, "", "\t") + return string(data) +} + type Novel struct { ID NovelID `json:"id"` Name string `json:"name"` @@ -48,6 +68,11 @@ type Novel struct { Tags []TagID `json:"tags"` } +func (n Novel) String() string { + data, _ := json.MarshalIndent(n, "", "\t") + return string(data) +} + type NovelType string const (