Documentation ¶
Index ¶
- Constants
- Variables
- func IntCase2Str(i int) string
- func Str2IntCase(s string) int
- type Condition
- type Config
- func (cnf *Config) HasExistKeys(ks *Keys) bool
- func (cnf *Config) HasNotExistKeys(ks *Keys) bool
- func (cnf *Config) HasTypeCondition(t *TypeCondition) bool
- func (cnf *Config) SetExist(c *ConfigLine, isExist bool) error
- func (cnf *Config) SetTypeCondition(c *ConfigLine, t types.BasicKind) error
- func (c Config) Validate() error
- type ConfigLine
- type Keys
- type TypeCondition
Constants ¶
View Source
const ( CaseInvalid = iota CaseGt // > CaseGe // >= CaseLt // < CaseLe // <= CaseEq // == CaseNe // != CaseContains // for string. CaseNotContains // for string. )
View Source
const ConfigBoolKeyName = "key_bool"
View Source
const ConfigDoubleKeyName = "key_double"
View Source
const ConfigExistKeyName = "key_exists"
View Source
const ConfigIntKeyName = "key_int"
View Source
const ConfigNotExistKeyName = "key_not_exists"
View Source
const ConfigStrKeyName = "key_str"
View Source
const ConfigUintKeyName = "key_uint"
View Source
const ParamNumMax = 16
Variables ¶
View Source
var ErrInvalidCondition = errors.New("Invalid condition")
Functions ¶
Types ¶
type Condition ¶
type Condition struct {
// contains filtered or unexported fields
}
func NewBoolCondition ¶
NewBoolCondition returns Condition c of boolean.
c must be CaseEq or CaseNe.
func NewDoubleCondition ¶
NewDoubleCondition returns Condition c of double
c must be CaseEq, CaseNe CaseGt, CaseGe, CaseLt or CaseLe.
func NewIntCondition ¶
NewIntCondition returns Condition c of int.
c must be CaseEq, CaseNe CaseGt, CaseGe, CaseLt or CaseLe.
func NewStringCondition ¶
NewStringCondition returns Condition c of string.
c must be CaseEq, CaseNe CaseContains or CaseNotContains.
func NewUintCondition ¶
NewUintCondition returns Condition c of uint.
c must be CaseEq, CaseNe CaseGt, CaseGe, CaseLt or CaseLe.
type Config ¶
type Config struct { Exists []Keys NotExists []Keys TypeConditions []TypeCondition }
Config represents context of this plugin.
func (*Config) HasExistKeys ¶
HasExistKeys check if ExistKeys of cnf has ks keys or not.
func (*Config) HasNotExistKeys ¶
HasNotExistKeys check if NotExistKeys of cnf has ks keys or not.
func (*Config) HasTypeCondition ¶
func (cnf *Config) HasTypeCondition(t *TypeCondition) bool
HasTypeCondition check if TypeConditions of cnf has t or not.
func (*Config) SetExist ¶
func (cnf *Config) SetExist(c *ConfigLine, isExist bool) error
SetKey set member variable via c.
If isExist is true, c is treated as ExistKey. If isExist is false, c is treated as NotExistKey.
func (*Config) SetTypeCondition ¶
func (cnf *Config) SetTypeCondition(c *ConfigLine, t types.BasicKind) error
type ConfigLine ¶
type ConfigLine struct { ClKey interface{} `json:"key"` // string or []string ClValue interface{} `json:"value,omitempty"` ClCondition string `json:"condition,omitempty"` }
ConfigLine represents each line of config file.
func NewConfigLineFromJson ¶
func NewConfigLineFromJson(s string) (*ConfigLine, error)
NewConfigLineFromJson returns ConfigLine pointer via Json s.
type Keys ¶
func (Keys) GetValueFromMap ¶
GetValueFromMap returns the value from map m.
If the value is not found, it returns nil, false.
type TypeCondition ¶
func (TypeCondition) String ¶
func (tc TypeCondition) String() string
Click to show internal directories.
Click to hide internal directories.