Like Prometheus, but for logs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
loki/pkg/util/string.go

35 lines
562 B

package util
import (
"bytes"
"fmt"
"unicode"
)
func StringRef(value string) *string {
return &value
}
func StringSliceContains(slice []string, value string) bool {
for _, item := range slice {
if item == value {
return true
}
}
return false
}
// SnakeCase converts given string `s` into `snake_case`.
func SnakeCase(s string) string {
var buf bytes.Buffer
for i, r := range s {
if unicode.IsUpper(r) && i > 0 && s[i-1] != '_' {
fmt.Fprintf(&buf, "_")
}
r = unicode.ToLower(r)
fmt.Fprintf(&buf, "%c", r)
}
return buf.String()
}