distroidparser

package
v0.44.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultParser = NewDefaultParser()

Functions

This section is empty.

Types

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser is a list of distro-specific idStr parsers.

func New

func New(parsers ...ParserFunc) *Parser

func NewDefaultParser

func NewDefaultParser() *Parser

func (*Parser) Parse

func (p *Parser) Parse(idStr string) (*distro.ID, error)

Parse returns the distro.ID that matches the given distro ID string. If no distro.ID matches the given distro ID string, it returns nil. If multiple distro.IDs match the given distro ID string, it panics. If no distro-specific parser matches the given distro ID string, it falls back to the default parser.

The fact that the Parser returns a distro.ID does not mean that the distro is actually supported or implemented. This functionality is provided as an easy and consistent way to parse distro IDs, while allowing distro-specific parsers.

func (*Parser) Standardize

func (p *Parser) Standardize(idStr string) (string, error)

Standardize returns the standardized distro ID string for the given distro ID string. If the given distro ID string is not valid, it returns an error.

type ParserFunc

type ParserFunc func(idStr string) (*distro.ID, error)

Jump to

Keyboard shortcuts

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