...

Source file src/github.com/rs/zerolog/internal/cbor/base.go

Documentation: github.com/rs/zerolog/internal/cbor

     1  package cbor
     2  
     3  // JSONMarshalFunc is used to marshal interface to JSON encoded byte slice.
     4  // Making it package level instead of embedded in Encoder brings
     5  // some extra efforts at importing, but avoids value copy when the functions
     6  // of Encoder being invoked.
     7  // DO REMEMBER to set this variable at importing, or
     8  // you might get a nil pointer dereference panic at runtime.
     9  var JSONMarshalFunc func(v interface{}) ([]byte, error)
    10  
    11  type Encoder struct{}
    12  
    13  // AppendKey adds a key (string) to the binary encoded log message
    14  func (e Encoder) AppendKey(dst []byte, key string) []byte {
    15  	if len(dst) < 1 {
    16  		dst = e.AppendBeginMarker(dst)
    17  	}
    18  	return e.AppendString(dst, key)
    19  }
    20  

View as plain text