Use slices.Contains from the standard library
This commit is contained in:
parent
1d08b724da
commit
164e30b37d
2 changed files with 3 additions and 12 deletions
10
functions.go
10
functions.go
|
@ -2,16 +2,6 @@ package main
|
||||||
|
|
||||||
import "sort"
|
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 {
|
func sortKeys(m map[string]string) []string {
|
||||||
var s []string
|
var s []string
|
||||||
for key := range m {
|
for key := range m {
|
||||||
|
|
5
main.go
5
main.go
|
@ -13,6 +13,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
@ -141,7 +142,7 @@ func (br *bridge) singleAlertNotifications(p *payload) []*notification {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, val := range labelConfig.Tags {
|
for _, val := range labelConfig.Tags {
|
||||||
if !sliceContains(tags, val) {
|
if !slices.Contains(tags, val) {
|
||||||
tags = append(tags, val)
|
tags = append(tags, val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,7 +250,7 @@ func (br *bridge) multiAlertNotification(p *payload) *notification {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, val := range labelConfig.Tags {
|
for _, val := range labelConfig.Tags {
|
||||||
if !sliceContains(tags, val) {
|
if !slices.Contains(tags, val) {
|
||||||
tags = append(tags, val)
|
tags = append(tags, val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue