Files
postmoogle/utils/list.go
2022-08-24 12:02:41 +03:00

28 lines
423 B
Go

package utils
// ListItem with key and value
type ListItem struct {
K string
V string
}
// List slice
type List []ListItem
// Get item's value
func (l List) Get(key string) (string, bool) {
for _, item := range l {
if item.K == key {
return item.V, true
}
}
return "", false
}
// ForEach item
func (l List) ForEach(handler func(key, value string)) {
for _, item := range l {
handler(item.K, item.V)
}
}