| 1 | package typesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/ |
| 2 | |
| 3 | import "sortscip-go gomod github.com/golang/go/src . sort/" |
| 4 | |
| 5 | // Field is a Key/Value pair used for extra data in log messages. |
| 6 | type Fieldscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/Field# struct { |
| 7 | Keyscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/Field#Key. string |
| 8 | Valuescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/Field#Value. string |
| 9 | } |
| 10 | |
| 11 | // FieldsFromMap creates a Fields slice from a map, optionally sorting keys. |
| 12 | func FieldsFromMapscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/FieldsFromMap().(fieldMap map[string]string, sorted bool) []Fieldscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/Field# { |
| 13 | keys := make([]string, 0, len(fieldMap)) |
| 14 | fields := make([]Fieldscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/Field#, len(fieldMap)) |
| 15 | |
| 16 | for key := range fieldMap { |
| 17 | keys = append(keys, key) |
| 18 | } |
| 19 | |
| 20 | if sorted { |
| 21 | sortscip-go gomod github.com/golang/go/src . sort/.Stringsscip-go gomod github.com/golang/go/src . sort/Strings().(keys) |
| 22 | } |
| 23 | |
| 24 | for i, key := range keys { |
| 25 | fields[i].Keyscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/Field#Key. = key |
| 26 | fields[i].Valuescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/Field#Value. = fieldMap[key] |
| 27 | } |
| 28 | |
| 29 | return fields |
| 30 | } |