Help us shape the future of Go! Take the 2026 Go Developer Survey

run

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package run drives the encoder: it compiles the opcodes of a value, sets up the runtime context and runs the VM which the options choose. The v1 and the v2 json packages encode through it.

Index

Constants

View Source
const MaxReusedValueSize = 4096

MaxReusedValueSize is the size of the largest value which EncodeOf, and the decoding of a value by its type, copy to a value they reuse. Every runtime context in the pool keeps such a value, so a large one is left to the GC.

Variables

This section is empty.

Functions

func Code

func Code(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]byte, error)

Code runs the opcodes of a value, which ctx is set up for, by the VM of the options of ctx.

func Encode

func Encode(ctx *encoder.RuntimeContext, v any) ([]byte, error)

Encode appends v to the buffer of ctx as JSON, with a comma after it, by the options of ctx. On an error, it returns the output written before the error with it, which the v2 json package finds the place of the error by.

func EncodeIndent

func EncodeIndent(ctx *encoder.RuntimeContext, v any, prefix, indent string) ([]byte, error)

EncodeIndent is Encode with the indentation and the prefix of each line.

func EncodeOf

func EncodeOf[T any](ctx *encoder.RuntimeContext, v *T) ([]byte, error)

EncodeOf encodes the value at v, as Encode encodes it, without the copy of the value to the heap which an interface value of it would be: it is copied to a value in the heap which is reused ( see encoder.OpcodeSet.TakeValue ). A value which an interface value holds directly is encoded by Encode.

func IndentCode

func IndentCode(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, prefix, indent string) ([]byte, error)

IndentCode is Code with the indentation and the prefix of each line.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL