parser

package
v0.56.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: Apache-2.0 Imports: 31 Imported by: 5

Documentation

Index

Constants

View Source
const (
	CUE        = "cue"
	CYCLONEDX  = "cyclonedx"
	Dockerfile = "dockerfile"
	EDN        = "edn"
	HCL1       = "hcl1"
	HCL2       = "hcl2"
	HOCON      = "hocon"
	IGNORE     = "ignore"
	INI        = "ini"
	JSON       = "json"
	JSONC      = "jsonc"
	JSONNET    = "jsonnet"
	PROPERTIES = "properties"
	SPDX       = "spdx"
	TEXTPROTO  = "textproto"
	TOML       = "toml"
	VCL        = "vcl"
	XML        = "xml"
	YAML       = "yaml"
	DOTENV     = "dotenv"
)

The defined parsers are the parsers that are valid for parsing files.

Variables

This section is empty.

Functions

func CombineConfigurations added in v0.22.0

func CombineConfigurations(configs map[string]interface{}) map[string]interface{}

CombineConfigurations takes the given configurations and combines them into a single configuration. The result will be a map that contains a single key with a value of Combined.

func FileSupported added in v0.22.0

func FileSupported(path string) bool

FileSupported returns true if the file at the given path is a file that can be parsed.

func Format added in v0.22.0

func Format(configurations map[string]interface{}) (string, error)

Format takes in multiple configurations input and formats the configuration to be more human readable. The key of each configuration should be its filepath.

func FormatCombined added in v0.22.0

func FormatCombined(configurations map[string]interface{}) (string, error)

FormatCombined takes in multiple configurations, combines them, and formats the configuration to be more human readable. The key of each configuration should be its filepath.

func FormatJSON added in v0.31.0

func FormatJSON(configurations map[string]interface{}) (string, error)

FormatJSON takes in multiple configurations and formats them as a JSON object where each key is the path to the file and the contents are the parsed configurations.

func ParseConfigurations added in v0.22.0

func ParseConfigurations(files []string) (map[string]interface{}, error)

ParseConfigurations parses and returns the configurations from the given list of files. The result will be a map where the key is the file name of the configuration.

func ParseConfigurationsAs added in v0.22.0

func ParseConfigurationsAs(files []string, parser string) (map[string]interface{}, error)

ParseConfigurationsAs parses the files as the given file type and returns the configurations given in the file list. The result will be a map where the key is the file name of the configuration.

func Parsers added in v0.22.0

func Parsers() []string

Parsers returns a list of the supported Parsers.

Types

type Parser

type Parser interface {
	Unmarshal(p []byte, v interface{}) error
}

Parser defines all of the methods that every parser definition must implement.

func New added in v0.22.0

func New(parser string) (Parser, error)

New returns a new Parser.

func NewFromPath added in v0.22.0

func NewFromPath(path string) (Parser, error)

NewFromPath returns a file parser based on the file type that exists at the given path.

Directories

Path Synopsis
Package textproto provides an interface to parse Protocol Buffers in their textual format.
Package textproto provides an interface to parse Protocol Buffers in their textual format.

Jump to

Keyboard shortcuts

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