jconf

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnnotateFmtValid

func AnnotateFmtValid(fmt *AnnotateFmt) bool

func CtxWithConf

func CtxWithConf(ctx context.Context, ac *ActionConfig) context.Context

func SkipPartErr

func SkipPartErr(ctx context.Context) bool

Types

type ActionConfig

type ActionConfig struct {
	SkipPartErr *bool `json:"skip_part_err,omitempty"`

	CutterConfig   *CutterConfig   `json:"cutter_config,omitempty" json:"cutter_config,omitempty"`
	AnnotateConfig *AnnotateConfig `json:"annotate_config,omitempty" json:"annotate_config,omitempty"`
}

func LocalLoader

func LocalLoader(configStr string) (*ActionConfig, error)

func (*ActionConfig) WithSkipPartErr

func (a *ActionConfig) WithSkipPartErr() *ActionConfig

type AnnotateConfig

type AnnotateConfig struct {
	JsonStr        *JsonStrAction          `json:"json_str,omitempty"`
	NormalAnnotate map[string]*AnnotateFmt `json:"normal_annotate,omitempty"`
	EnumAnnotate   map[string]*AnnotateFmt `json:"enum_annotate,omitempty"`
	ArrayAnnotate  map[string]*AnnotateFmt `json:"array_annotate,omitempty"`
}

AnnotateConfig 支持的注释类型. 1. UnmarshalStr 对内嵌json str的处理行为 2. NormalAnnotate 直接在val上增加注释; 路径语法:a.b.c a.b.*.c 3. EnumAnnotate 根据val值进行匹配; 路径语法:a.b.c a.b.*.c 4. ArrayAnnotate val为数组,为每个数组值匹配; 路径语法:a.b.*.c.* 路径语法:a.b.c a.b.*.c a.b.*

type AnnotateFmt

type AnnotateFmt struct {
	Str string `json:"str,omitempty"` // 字符串注释

	UnitCvt *UnitCvt `json:"unit_cvt,omitempty"` // 单位换算

	EnumMap map[string]string `json:"enum_map,omitempty"` // 枚举map
}

AnnotateFmt 按照Str->EnumMap->UnitOp的优先级逐步解析

type CutterConfig

type CutterConfig struct {
	IncludeCut []string    `json:"include_cut,omitempty"`
	ExcludeCut []string    `json:"exclude_cut,omitempty"`
	DeepCut    *DeepCut    `json:"deep_cut,omitempty"`
	OverrunCut *OverrunCut `json:"overrun_cut,omitempty"`
}

type DeepCut

type DeepCut struct {
	Paths []string `json:"paths,omitempty"`
	Deep  int      `json:"deep,omitempty"`
}

type GlobalConfig

type GlobalConfig struct {
	SkipPartErr *bool `json:"skip_part_err,omitempty"`
}

func Conf

func Conf() *GlobalConfig

func (*GlobalConfig) WithSkipPartErr

func (g *GlobalConfig) WithSkipPartErr() *GlobalConfig

type JsonStrAction

type JsonStrAction struct {
	CheckAll    bool     `json:"check_all"`     // 所有字符串都检查并反序列化
	CheckByPath []string `json:"check_by_path"` // 检测指定路径下的字符串
}

type OverrunCut

type OverrunCut struct {
	Paths      []string `json:"paths,omitempty"`
	LimitBytes int      `json:"limit_bytes,omitempty"`
}

type UnitCvt

type UnitCvt struct {
	Unit   string  `json:"unit,omitempty"`   // 单位转换注释, 单位,如:元
	Factor float64 `json:"factor,omitempty"` // 单位转换注释,算法因子,如:分转成元 = val/Op
	Op     string  `json:"op,omitempty"`     // 单位转换的算法,如:+,-,*,/
}

Jump to

Keyboard shortcuts

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