props

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPropertyNotFound        = errors.New("property not found")
	ErrMalformedPathExpressoin = errors.New("malformed path expression")
	ErrUnsupportedFileFormat   = errors.New("unsupported file format")
)

Functions

func GetPropertyFromFile

func GetPropertyFromFile(fileName string, propertyPath string) (string, error)

Types

type FileParser

type FileParser interface {
	GetProperty(fileBytes []byte, pp *ParsedPath) (*ParsedProperty, error)
}

FileParser is a base interface that works with file content and returns a property based on provided path

type JsonFileParser

type JsonFileParser struct {
}

func (*JsonFileParser) GetProperty

func (j *JsonFileParser) GetProperty(fileBytes []byte, pp *ParsedPath) (*ParsedProperty, error)

type ParsedPath

type ParsedPath struct {
	Elements []string
}

ParsedPath describes steps of searching for a property in a file content

func ParsePath

func ParsePath(propertyPath string) (*ParsedPath, error)

func (*ParsedPath) String

func (p *ParsedPath) String() string

type ParsedProperty

type ParsedProperty struct {
	// Start cursor position of the first character of the value. Starts from 0
	Start int
	// End cursor position of the next character after the last one of the value
	End int
	// Text text representation of the value
	Text string
	// Type describes type of the value
	Type PropertyType
	// QuotesType describes used type of quotes
	QuotesType QuotesType
}

ParsedProperty describes a found property

type PropertyType

type PropertyType int
const (
	PropertyTypeString PropertyType = 1 << iota
	PropertyTypeNumber
	PropertyTypeBool
	PropertyTypeNull
)

type QuotesType

type QuotesType int
const (
	QuotesTypeNone QuotesType = 1 << iota
	QuotesTypeSingular
	QuotesTypeDouble
)

type XmlFileParser

type XmlFileParser struct {
}

func (*XmlFileParser) GetProperty

func (j *XmlFileParser) GetProperty(fileBytes []byte, pp *ParsedPath) (*ParsedProperty, error)

type YamlFileParser

type YamlFileParser struct {
}

func (*YamlFileParser) GetProperty

func (p *YamlFileParser) GetProperty(fileBytes []byte, pp *ParsedPath) (*ParsedProperty, error)

Jump to

Keyboard shortcuts

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