type encType … const _ … const name … const scalar … const messageOpen … const messageClose … type Encoder … type encoderState … // NewEncoder returns an Encoder. // // If indent is a non-empty string, it causes every entry in a List or Message // to be preceded by the indent and trailed by a newline. // // If delims is not the zero value, it controls the delimiter characters used // for messages (e.g., "{}" vs "<>"). // // If outputASCII is true, strings will be serialized in such a way that // multi-byte UTF-8 sequences are escaped. This property ensures that the // overall output is ASCII (as opposed to UTF-8). func NewEncoder(buf []byte, indent string, delims [2]byte, outputASCII bool) (*Encoder, error) { … } // Bytes returns the content of the written bytes. func (e *Encoder) Bytes() []byte { … } // StartMessage writes out the '{' or '<' symbol. func (e *Encoder) StartMessage() { … } // EndMessage writes out the '}' or '>' symbol. func (e *Encoder) EndMessage() { … } // WriteName writes out the field name and the separator ':'. func (e *Encoder) WriteName(s string) { … } // WriteBool writes out the given boolean value. func (e *Encoder) WriteBool(b bool) { … } // WriteString writes out the given string value. func (e *Encoder) WriteString(s string) { … } func appendString(out []byte, in string, outputASCII bool) []byte { … } // 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 value for given bitSize. func (e *Encoder) WriteFloat(n float64, bitSize int) { … } func appendFloat(out []byte, n float64, bitSize int) []byte { … } // WriteInt writes out the given signed integer value. func (e *Encoder) WriteInt(n int64) { … } // WriteUint writes out the given unsigned integer value. func (e *Encoder) WriteUint(n uint64) { … } // WriteLiteral writes out the given string as a literal value without quotes. // This is used for writing enum literal strings. func (e *Encoder) WriteLiteral(s string) { … } // prepareNext adds possible space and indentation for the next value based // on last encType and indent option. It also updates e.lastType to next. func (e *Encoder) prepareNext(next encType) { … } // Snapshot returns the current snapshot for use in Reset. func (e *Encoder) Snapshot() encoderState { … } // Reset resets the Encoder to the given encoderState from a Snapshot. func (e *Encoder) Reset(es encoderState) { … } // AppendString appends the escaped form of the input string to b. func AppendString(b []byte, s string) []byte { … }