From 4a03a820b3ad35d3e56060882d48a4ab356cd3a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ecl=C3=A9sio=20Junior?= Date: Mon, 21 Mar 2022 01:35:19 -0400 Subject: [PATCH] chore: add `String()` method to `IDSlice` type (#238) --- peer/peer.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/peer/peer.go b/peer/peer.go index b88ae05..2ab22fe 100644 --- a/peer/peer.go +++ b/peer/peer.go @@ -209,3 +209,11 @@ type IDSlice []ID func (es IDSlice) Len() int { return len(es) } func (es IDSlice) Swap(i, j int) { es[i], es[j] = es[j], es[i] } func (es IDSlice) Less(i, j int) bool { return string(es[i]) < string(es[j]) } + +func (es IDSlice) String() string { + peersStrings := make([]string, len(es)) + for i, id := range es { + peersStrings[i] = id.String() + } + return strings.Join(peersStrings, ", ") +}