type kind … const _ … const name … const scalar … const objectOpen … const objectClose … const arrayOpen … const arrayClose … type Encoder … // NewEncoder returns an Encoder. // // If indent is a non-empty string, it causes every entry for an Array or Object // to be preceded by the indent and trailed by a newline. func NewEncoder(buf []byte, indent string) (*Encoder, error) { … } // Bytes returns the content of the written bytes. func (e *Encoder) Bytes() []byte { … } // WriteNull writes out the null value. func (e *Encoder) WriteNull() { … } // WriteBool writes out the given boolean value. func (e *Encoder) WriteBool(b bool) { … } // WriteString writes out the given string in JSON string value. Returns error // if input string contains invalid UTF-8. func (e *Encoder) WriteString(s string) error { … } var errInvalidUTF8 … func appendString(out []byte, in string) ([]byte, error) { … } // indexNeedEscapeInString returns the index of the character that needs // escaping. If no characters need escaping, this returns the input length. func indexNeedEscapeInString(s string) int { … } // WriteFloat writes out the given float and bitSize in JSON number value. func (e *Encoder) WriteFloat(n float64, bitSize int) { … } // appendFloat formats given float in bitSize, and appends to the given []byte. func appendFloat(out []byte, n float64, bitSize int) []byte { … } // WriteInt writes out the given signed integer in JSON number value. func (e *Encoder) WriteInt(n int64) { … } // WriteUint writes out the given unsigned integer in JSON number value. func (e *Encoder) WriteUint(n uint64) { … } // StartObject writes out the '{' symbol. func (e *Encoder) StartObject() { … } // EndObject writes out the '}' symbol. func (e *Encoder) EndObject() { … } // WriteName writes out the given string in JSON string value and the name // separator ':'. Returns error if input string contains invalid UTF-8, which // should not be likely as protobuf field names should be valid. func (e *Encoder) WriteName(s string) error { … } // StartArray writes out the '[' symbol. func (e *Encoder) StartArray() { … } // EndArray writes out the ']' symbol. func (e *Encoder) EndArray() { … } // prepareNext adds possible comma and indentation for the next value based // on last type and indent option. It also updates lastKind to next. func (e *Encoder) prepareNext(next kind) { … }