parse

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

README

PARSE

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

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func Init

func 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)

	// IsLegal whether the format meets the specifications
	Format(source []byte) (string, error)
}

TargetText: 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

func NewTomlParse

func NewTomlParse() Parse

func NewYanmlParse

func NewYanmlParse() Parse

type TomlParse

type TomlParse struct {
}

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)

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)

Fusion ...

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)

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)

解析成kv

Jump to

Keyboard shortcuts

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