From 67e9015e42536024f9ffa3404b285316037a4c1f Mon Sep 17 00:00:00 2001 From: Timon Ringwald Date: Mon, 15 Aug 2022 14:52:35 +0200 Subject: [PATCH] String() method for Torrent implemented --- torrent.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/torrent.go b/torrent.go index dbe2a1f..fb0b586 100644 --- a/torrent.go +++ b/torrent.go @@ -1,6 +1,9 @@ package model -import "time" +import ( + "fmt" + "time" +) type Torrent struct { ID TorrentID @@ -14,3 +17,15 @@ type Torrent struct { } type TorrentID string + +func (t Torrent) String() string { + return fmt.Sprintf("id: %s | title: %s | seeders: %d | leechers: %d | downloads: %d | trusted: %t | upload time: %s", + t.ID, + t.Title, + t.Seeders, + t.Leechers, + t.Downloads, + t.Trusted, + t.Time, + ) +}