From 062af590b83cb312982b55e8eca5bf26185b1fa1 Mon Sep 17 00:00:00 2001 From: Barpfotenbaer Date: Mon, 16 Nov 2020 13:08:40 +0100 Subject: [PATCH] =?UTF-8?q?CheckSliceEquility=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ebkTools.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ebkTools.go b/ebkTools.go index c242263..f0e96a6 100755 --- a/ebkTools.go +++ b/ebkTools.go @@ -140,6 +140,17 @@ func InArray(array interface{}, value interface{}) (exists bool, index int) { return } +// All Values in Array are equal +func CheckSliceEquility(myslice interface{}) bool { + if reflect.ValueOf(myslice).Len() > 1 { + return reflect.DeepEqual( + reflect.ValueOf(myslice).Slice(1, reflect.ValueOf(myslice).Len()).Interface(), + reflect.ValueOf(myslice).Slice(0, reflect.ValueOf(myslice).Len()-1).Interface()) + } else { + return true // One single value is always equal to itself + } +} + // Check error code func Check(e error) { if e != nil {