type Builder … // NewBuilder creates a Builder that appends its output to the given buffer. // Like append(), the slice will be reallocated if its capacity is exceeded. // Use Bytes to get the final buffer. func NewBuilder(buffer []byte) *Builder { … } // NewFixedBuilder creates a Builder that appends its output into the given // buffer. This builder does not reallocate the output buffer. Writes that // would exceed the buffer's capacity are treated as an error. func NewFixedBuilder(buffer []byte) *Builder { … } // SetError sets the value to be returned as the error from Bytes. Writes // performed after calling SetError are ignored. func (b *Builder) SetError(err error) { … } // Bytes returns the bytes written by the builder or an error if one has // occurred during building. func (b *Builder) Bytes() ([]byte, error) { … } // BytesOrPanic returns the bytes written by the builder or panics if an error // has occurred during building. func (b *Builder) BytesOrPanic() []byte { … } // AddUint8 appends an 8-bit value to the byte string. func (b *Builder) AddUint8(v uint8) { … } // AddUint16 appends a big-endian, 16-bit value to the byte string. func (b *Builder) AddUint16(v uint16) { … } // AddUint24 appends a big-endian, 24-bit value to the byte string. The highest // byte of the 32-bit input value is silently truncated. func (b *Builder) AddUint24(v uint32) { … } // AddUint32 appends a big-endian, 32-bit value to the byte string. func (b *Builder) AddUint32(v uint32) { … } // AddUint48 appends a big-endian, 48-bit value to the byte string. func (b *Builder) AddUint48(v uint64) { … } // AddUint64 appends a big-endian, 64-bit value to the byte string. func (b *Builder) AddUint64(v uint64) { … } // AddBytes appends a sequence of bytes to the byte string. func (b *Builder) AddBytes(v []byte) { … } type BuilderContinuation … type BuildError … // AddUint8LengthPrefixed adds a 8-bit length-prefixed byte sequence. func (b *Builder) AddUint8LengthPrefixed(f BuilderContinuation) { … } // AddUint16LengthPrefixed adds a big-endian, 16-bit length-prefixed byte sequence. func (b *Builder) AddUint16LengthPrefixed(f BuilderContinuation) { … } // AddUint24LengthPrefixed adds a big-endian, 24-bit length-prefixed byte sequence. func (b *Builder) AddUint24LengthPrefixed(f BuilderContinuation) { … } // AddUint32LengthPrefixed adds a big-endian, 32-bit length-prefixed byte sequence. func (b *Builder) AddUint32LengthPrefixed(f BuilderContinuation) { … } func (b *Builder) callContinuation(f BuilderContinuation, arg *Builder) { … } func (b *Builder) addLengthPrefixed(lenLen int, isASN1 bool, f BuilderContinuation) { … } func (b *Builder) flushChild() { … } func (b *Builder) add(bytes ...byte) { … } // Unwrite rolls back non-negative n bytes written directly to the Builder. // An attempt by a child builder passed to a continuation to unwrite bytes // from its parent will panic. func (b *Builder) Unwrite(n int) { … } type MarshalingValue … // AddValue calls Marshal on v, passing a pointer to the builder to append to. // If Marshal returns an error, it is set on the Builder so that subsequent // appends don't have an effect. func (b *Builder) AddValue(v MarshalingValue) { … }