MCPcopy
hub / github.com/uber-go/zap / UnmarshalText

Method UnmarshalText

zapcore/encoder.go:259–271  ·  view source on GitHub ↗

UnmarshalText unmarshals text to a DurationEncoder. "string" is unmarshaled to StringDurationEncoder, and anything else is unmarshaled to NanosDurationEncoder.

(text []byte)

Source from the content-addressed store, hash-verified

257// to StringDurationEncoder, and anything else is unmarshaled to
258// NanosDurationEncoder.
259func (e *DurationEncoder) UnmarshalText(text []byte) error {
260 switch string(text) {
261 case "string":
262 *e = StringDurationEncoder
263 case "nanos":
264 *e = NanosDurationEncoder
265 case "ms":
266 *e = MillisDurationEncoder
267 default:
268 *e = SecondsDurationEncoder
269 }
270 return nil
271}
272
273// A CallerEncoder serializes an EntryCaller to a primitive type.
274//

Callers 1

TestDurationEncodersFunction · 0.95

Calls

no outgoing calls

Tested by 1

TestDurationEncodersFunction · 0.76