decode

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package decode is the second pipeline stage: it decodes base64, URL, JSON-escaped and env-file encodings and expands archives in memory within configured size, depth and entry limits.

Index

Constants

View Source
const (
	// PassThrough is the adapter that emits each chunk unchanged.
	PassThrough = "passthrough"
	// Standard is the adapter that also decodes base64, percent-encoding, JSON
	// escapes and env-file values, recursively.
	Standard = "standard"
)

Adapter names.

View Source
const (
	// DetailMaxDepth: a span nested deeper than MaxDepth was not decoded.
	DetailMaxDepth = "max_depth"
	// DetailSizeBudget: the decoded bytes of one chunk reached their budget.
	DetailSizeBudget = "size_budget"
)

Detail codes of decode_depth_limit warnings.

View Source
const DefaultMaxDepth = 3

DefaultMaxDepth is the decoding depth used when Options.MaxDepth is 0 or less.

Variables

This section is empty.

Functions

func Register

func Register(name string, f Factory)

Register adds a decode adapter. Adapters call it from init().

Types

type Decoder

type Decoder interface {
	Decode(ctx context.Context, c candidate.Chunk, emit func(candidate.Chunk) bool, warn func(model.Warning))
}

Decoder is the decode stage interface. Decode emits the chunk itself first and then every chunk decoded from it; emit returns false when the scan is stopping, and Decode then returns early. warn receives decode warnings (codes only, never content). Decode never errors, never panics and never logs: input that does not decode is simply not decoded.

func NewStandard

func NewStandard(o Options) Decoder

NewStandard returns the standard decoder.

type Factory

type Factory func(Options) (Decoder, error)

Factory builds a Decoder.

func Lookup

func Lookup(name string) (Factory, bool)

Lookup returns the decode adapter registered under name.

type Options

type Options struct {
	// MaxDepth bounds nested decoding (limits.decode_max_depth); 0 or less means
	// DefaultMaxDepth.
	MaxDepth int
}

Options configures a decoder.

Jump to

Keyboard shortcuts

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