parse

package
v0.5.9 Latest Latest
Warning

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

Go to latest
Published: May 5, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

README

PARSE

配置文件多格式解析功能代码块。

Documentation

Index

Constants

View Source
const (
	// TypToml ..
	TypToml = "toml"
	// TypYaml ..
	TypYaml = "yaml"
)

Variables

This section is empty.

Functions

func Init

func Init()

Init ..

Types

type Item

type Item struct {
	Key       string
	Val       interface{}
	Typ       reflect.Kind
	Comment   string
	SourceTyp int
	Id        uint64
	DiffKey   string
}

type Parse

type Parse interface {
	// Convert the json data stored in the template to the target format
	Convert(text string) ([]byte, error)

	// Fusion Multi-configuration data fusion
	Fusion(sources []string) (string, error)

	// FusionWithTpl Config combine with json
	FusionWithTpl(sources string, texts []string) (string, error)

	// Format
	Format(source []byte) (string, error)

	// IsLegal whether the format meets the specifications
	IsLegal(source []byte) (bool, error)

	// FormatStrict Custom strict analysis
	FormatStrict(source []byte) (string, error)
}

Parse toml、yaml、ini, Configuration files stored in the database Different types of configurations have their own parser Json -> typ, merge with the original configuration file, and then return

func GetParseManage

func GetParseManage(typ string) Parse

GetParseManage ..

func NewTomlParse

func NewTomlParse() Parse

NewTomlParse ..

func NewYanmlParse

func NewYanmlParse() Parse

type TomlParse

type TomlParse struct {
}

TomlParse ..

func (*TomlParse) Convert

func (tp *TomlParse) Convert(text string) (res []byte, err error)

Convert ...

func (*TomlParse) Format

func (tp *TomlParse) Format(source []byte) (out string, err error)

Format ..

func (*TomlParse) FormatStrict

func (tp *TomlParse) FormatStrict(source []byte) (out string, err error)

FormatStrict ..

func (*TomlParse) Fusion

func (tp *TomlParse) Fusion(sources []string) (out string, err error)

Fusion only useful with configuration format

func (*TomlParse) FusionWithTpl

func (tp *TomlParse) FusionWithTpl(source string, texts []string) (out string, err error)

FusionWithTpl ...

func (*TomlParse) IsLegal

func (tp *TomlParse) IsLegal(source []byte) (res bool, err error)

IsLegal ...

type YamlParse

type YamlParse struct {
}

func (*YamlParse) Convert

func (tp *YamlParse) Convert(text string) (res []byte, err error)

Convert ...

func (*YamlParse) Format

func (tp *YamlParse) Format(source []byte) (out string, err error)

Format ..

func (*YamlParse) FormatStrict

func (tp *YamlParse) FormatStrict(source []byte) (out string, err error)

FormatStrict ..

func (*YamlParse) Fusion

func (tp *YamlParse) Fusion(sources []string) (out string, err error)

Fusion only useful with configuration format 组合两个配置

func (*YamlParse) FusionWithTpl

func (tp *YamlParse) FusionWithTpl(source string, texts []string) (out string, err error)

Fusion ...

func (*YamlParse) IsLegal

func (tp *YamlParse) IsLegal(source []byte) (res bool, err error)

IsLegal ... 是否合法

func (*YamlParse) ParseItem

func (tp *YamlParse) ParseItem(source []byte) (res []*Item, err error)

ParseItem 解析成kv

Jump to

Keyboard shortcuts

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