From 8e99146cc288eae2357d696c9c86b4f0786f5bdc Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Tue, 7 Mar 2023 11:58:03 +0100 Subject: [PATCH] transport/channel.go: Adding Channel.Is() --- transport/channel.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/transport/channel.go b/transport/channel.go index 78f0161..2a2a939 100644 --- a/transport/channel.go +++ b/transport/channel.go @@ -20,6 +20,21 @@ func (c Channel) String() string { return strings.Join(c, "/") } +// Check if two channels are equal +func (c Channel) Is(other Channel) bool { + if len(c) != len(other) { + return false + } + + for i, item := range c { + if item != other[i] { + return false + } + } + + return true +} + // Define channels without any variables. var ( TransactionChannel = Channel{"transaction"}