MCPcopy
hub / github.com/grpc-ecosystem/go-grpc-middleware / AppendUnique

Method AppendUnique

interceptors/logging/logging.go:140–159  ·  view source on GitHub ↗

AppendUnique appends (can reuse array!) fields which does not occur in existing fields slice.

(add Fields)

Source from the content-addressed store, hash-verified

138
139// AppendUnique appends (can reuse array!) fields which does not occur in existing fields slice.
140func (f Fields) AppendUnique(add Fields) Fields {
141 if len(add) == 0 {
142 return f
143 }
144
145 a := add.Iterator()
146NextAddField:
147 for a.Next() {
148 k, v := a.At()
149 i := f.Iterator()
150 for i.Next() {
151 fk, _ := i.At()
152 if fk == k {
153 continue NextAddField
154 }
155 }
156 f = append(f, k, v)
157 }
158 return f
159}
160
161// ExtractFields returns logging fields from the context.
162// Fields can be added from the context using InjectFields. For example logging interceptor adds some (base) fields

Callers 6

reportableFunction · 0.95
AddFieldsFunction · 0.80
PostCallMethod · 0.80
PostMsgSendMethod · 0.80
PostMsgReceiveMethod · 0.80

Calls 3

IteratorMethod · 0.95
NextMethod · 0.80
AtMethod · 0.80

Tested by 1