From 164e30b37d2fa93aecc60f9e9005e02f301a93af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorben=20G=C3=BCnther?= Date: Fri, 11 Aug 2023 13:39:19 +0200 Subject: [PATCH] Use slices.Contains from the standard library --- functions.go | 10 ---------- main.go | 5 +++-- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/functions.go b/functions.go index 642195d..2c6c291 100644 --- a/functions.go +++ b/functions.go @@ -2,16 +2,6 @@ package main import "sort" -func sliceContains(s []string, e string) bool { - for _, v := range s { - if e == v { - return true - } - } - - return false -} - func sortKeys(m map[string]string) []string { var s []string for key := range m { diff --git a/main.go b/main.go index 74be861..6ef1541 100644 --- a/main.go +++ b/main.go @@ -13,6 +13,7 @@ import ( "net/http" "os" "os/signal" + "slices" "strings" "syscall" "time" @@ -141,7 +142,7 @@ func (br *bridge) singleAlertNotifications(p *payload) []*notification { } for _, val := range labelConfig.Tags { - if !sliceContains(tags, val) { + if !slices.Contains(tags, val) { tags = append(tags, val) } } @@ -249,7 +250,7 @@ func (br *bridge) multiAlertNotification(p *payload) *notification { } for _, val := range labelConfig.Tags { - if !sliceContains(tags, val) { + if !slices.Contains(tags, val) { tags = append(tags, val) } }