github.com/git-amp/amp-sdk-go@v0.7.5/stdlib/log/fields.go (about) 1 package log 2 3 type Fields map[string]interface{} 4 5 func (f Fields) With(xs ...interface{}) Fields { 6 f2 := make(Fields, len(f)+(len(xs)/2)) 7 for k, v := range f { 8 f2[k] = v 9 } 10 for i := 0; i < len(xs)/2; i++ { 11 key, is := xs[i*2].(string) 12 if !is { 13 continue 14 } 15 val := xs[i*2+1] 16 f2[key] = val 17 } 18 return f2 19 } 20 21 func (f Fields) Merge(f2 Fields) Fields { 22 f3 := make(Fields, len(f)+len(f2)) 23 for k, v := range f { 24 f3[k] = v 25 } 26 for k, v := range f2 { 27 f3[k] = v 28 } 29 return f3 30 } 31 32 func (f Fields) Slice() []interface{} { 33 s := make([]interface{}, len(f)*2) 34 for k, v := range f { 35 s = append(s, k, v) 36 } 37 return s 38 }