encode

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEncoding = errors.New("encode error")
)

Functions

func Encode

func Encode(node *ir.Node, w io.Writer, opts ...EncodeOption) error

func MustString

func MustString(node *ir.Node) string

Types

type ColorAttr

type ColorAttr int
const (
	CommentColor ColorAttr = iota
	TagColor
	FieldColor
	ValueColor
	SepColor
	LiteralSingleColor
	LiteralMultiColor
	MergeColor
	MergeRawColor
)

type Colorable

type Colorable struct {
	Type ir.Type
	Attr ColorAttr
}

type Colors

type Colors struct {
	Default func(string, ...any) string
	Map     map[Colorable]func(string, ...any) string
}

func NewColors

func NewColors() *Colors

func (*Colors) Color

func (c *Colors) Color(t ir.Type, a ColorAttr, s string) string

func (*Colors) Get

func (c *Colors) Get(t ir.Type, a ColorAttr) func(string, ...any) string

type EncState

type EncState struct {
	Color func(ir.Type, ColorAttr, string) string
	// contains filtered or unexported fields
}

type EncodeOption

type EncodeOption func(*EncState)

func Depth

func Depth(n int) EncodeOption

func EncodeBrackets

func EncodeBrackets(v bool) EncodeOption

func EncodeColors

func EncodeColors(c *Colors) EncodeOption

func EncodeComments

func EncodeComments(v bool) EncodeOption

func EncodeFormat

func EncodeFormat(f format.Format) EncodeOption

func EncodeWire

func EncodeWire(v bool) EncodeOption

func InjectRaw

func InjectRaw(v bool) EncodeOption

Jump to

Keyboard shortcuts

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