parser

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package parser exposes the koanf-style Parser slot used at the Manager call site (WithSource(file.New(path), yaml.Parser())).

A Parser is contracts.Codec plus a list of canonical content-types ("yaml", ".yaml", ".yml", "application/yaml"). The built-in yaml / json / toml parsers are registered in this package's init so that Bind can auto-select a parser from a Source.Read content-type hint when the caller passes nil.

Parsers are thin wrappers over pkg/decoder Codecs; the registry here is a content-type index on top of that flat map.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSON

func JSON() contracts.Parser

JSON returns the built-in JSON parser. It claims "json", ".json", "application/json", "text/json".

func Lookup

func Lookup(contentType string) (contracts.Parser, bool)

Lookup returns the Parser registered for the given content-type, or (nil, false) if none matches. Lookup is case-insensitive and accepts both the bare extension ("yaml"), the dotted form (".yaml"), and the MIME type ("application/yaml"). The empty string is never a hit.

func New

func New(c contracts.Codec, contentTypes ...string) contracts.Parser

New constructs a Parser from an existing Codec plus the content-types this Parser claims. The content-types are stored case-folded; lookup is case-insensitive.

func Register

func Register(p contracts.Parser)

Register installs p under every content-type it claims. Subsequent calls override prior registrations for the same content-type, which makes test helpers and feature toggles ergonomic.

func TOML

func TOML() contracts.Parser

TOML returns the built-in TOML parser. It claims "toml", ".toml", "application/toml", "text/toml".

func YAML

func YAML() contracts.Parser

YAML returns the built-in YAML parser. It claims "yaml", ".yaml", ".yml", "application/yaml", "application/x-yaml", "text/yaml".

Types

This section is empty.

Jump to

Keyboard shortcuts

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