Initial QSfera import

This commit is contained in:
Курнат Андрей
2026-06-07 10:20:04 +03:00
commit 2315f25754
16485 changed files with 4826827 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
package slogcommon
import "log/slog"
func FindAttrByKey(attrs []slog.Attr, key string) (slog.Attr, bool) {
for i := range attrs {
if attrs[i].Key == key {
return attrs[i], true
}
}
return slog.Attr{}, false
}
func FindAttrByGroupAndKey(attrs []slog.Attr, groups []string, key string) (slog.Attr, bool) {
if len(groups) == 0 {
return FindAttrByKey(attrs, key)
}
for i := range attrs {
if attrs[i].Key == groups[0] && attrs[i].Value.Kind() == slog.KindGroup {
attr, found := FindAttrByGroupAndKey(attrs[i].Value.Group(), groups[1:], key)
if found {
return attr, true
}
}
}
return slog.Attr{}, false
}