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

router

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package router classifies a filing's raw bytes into one of the EDGAR format eras. It is the single seam where "what is this byte stream?" is decided; parsers downstream receive a Decision and trust it. In v1.0 only IXBRL and PartialIXBRL are parsed — the other formats are classified so the CLI can refuse them cleanly rather than crash a parser on unexpected bytes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decision

type Decision struct {
	// Format is the classified era.
	Format FilingFormat
	// PrimaryDocument is the classified bytes — post-index-resolution when the
	// input was a filing-index page.
	PrimaryDocument []byte
	// SectionFormats holds per-section formats for PartialIXBRL filings. It is
	// nil until section detection (Phase 8) is wired in.
	SectionFormats map[string]FilingFormat
	// ResolvedFromIndex is true when the input was a filing-index page and the
	// router followed it to the real primary document.
	ResolvedFromIndex bool
	// Warnings are non-fatal observations a parser should know about.
	Warnings []string
}

Decision is the router's verdict on a filing's bytes.

func Detect

func Detect(ctx context.Context, raw []byte, fetch Fetcher) (*Decision, error)

Detect classifies raw filing bytes. When the bytes are a filing-index page it follows the index to the primary document (via fetch) and classifies that. Index resolution recurses at most once — a primary document should never itself be an index.

type Fetcher

type Fetcher func(ctx context.Context, ref string) ([]byte, error)

Fetcher resolves a filing-index document reference to the bytes it points at. The router calls it at most once, to follow an index page to the real primary document. It is a plain function (not an interface) so tests pass a fake.

type FilingFormat

type FilingFormat int

FilingFormat is the era a filing's bytes belong to.

const (
	// IXBRL is a fully inline-XBRL filing (≥ 80% of numeric cells fact-tagged).
	// Supported in v1.0.
	IXBRL FilingFormat = iota
	// PartialIXBRL tags only part of the document (10–80% of numeric cells).
	// Supported in v1.0 via a mixed parser path.
	PartialIXBRL
	// PlainHTML is a pre-iXBRL HTML filing (~2010–2018, small filers later).
	// Refused in v1.0; targeted for v1.1.
	PlainHTML
	// PlainText is a pre-2010 ASCII filing. Refused in v1.0; deferred to v1.2.
	PlainText
	// Unknown does not fit any recognized pattern. Always refused.
	Unknown
)

func (FilingFormat) String

func (f FilingFormat) String() string

func (FilingFormat) Supported

func (f FilingFormat) Supported() bool

Supported reports whether the format is parseable in v1.0.

Jump to

Keyboard shortcuts

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