NewEncoder creates a new encoder with the following default conversions: - float NaN/Inf are converted to nil - zero time.Time are converted to nil - durations are converted to seconds using WithDuration() - fmt.Stringer are converted to string - time.Time are converted to RFC3339 string
(opt ...EncoderOption)
| 23 | // - fmt.Stringer are converted to string |
| 24 | // - time.Time are converted to RFC3339 string |
| 25 | func NewEncoder(opt ...EncoderOption) Encoder { |
| 26 | res := new(encoder) |
| 27 | for _, o := range opt { |
| 28 | o(res) |
| 29 | } |
| 30 | return res |
| 31 | } |
| 32 | |
| 33 | func WithDuration() EncoderOption { |
| 34 | return func(e *encoder) { |
no outgoing calls