...

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

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

     1  package json
     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 appends a new key to the output JSON.
    14  func (e Encoder) AppendKey(dst []byte, key string) []byte {
    15  	if dst[len(dst)-1] != '{' {
    16  		dst = append(dst, ',')
    17  	}
    18  	return append(e.AppendString(dst, key), ':')
    19  }
    20  

View as plain text