Documentation ¶
Overview ¶
Package config 类ini的配置文件库,支持注释信息
Index ¶
- Variables
- type File
- func (f *File) Clean()
- func (f *File) DelItem(key string)
- func (f *File) ForEach(do func(key string, value *Value) bool)
- func (f *File) FromFile(configfile string) error
- func (f *File) GetAll() string
- func (f *File) GetDefault(item *Item) *Value
- func (f *File) GetItem(key string) *Value
- func (f *File) Has(key string) bool
- func (f *File) Keys() []string
- func (f *File) Len() int
- func (f *File) Print() string
- func (f *File) PrintJSON() string
- func (f *File) PutItem(item *Item)
- func (f *File) Save() error
- func (f *File) SaveTo(filename string) error
- func (f *File) ToFile() error
- func (f *File) ToJSON() error
- func (f *File) ToYAML() error
- type FormatType
- type Formatted
- func (f *Formatted[ITEM]) Clone() map[string]*ITEM
- func (f *Formatted[ITEM]) DelItem(key string)
- func (f *Formatted[ITEM]) ForEach(do func(key string, value *ITEM) bool)
- func (f *Formatted[ITEM]) FromFile(configfile string) error
- func (f *Formatted[ITEM]) GetItem(key string) (*ITEM, bool)
- func (f *Formatted[ITEM]) Has(key string) bool
- func (f *Formatted[ITEM]) Len() int
- func (f *Formatted[ITEM]) Print() string
- func (f *Formatted[ITEM]) PrintFormat(fmt FormatType) string
- func (f *Formatted[ITEM]) PutItem(key string, value *ITEM)
- func (f *Formatted[ITEM]) ToFile() error
- type Item
- type PwdString
- type VString
- func (rs VString) Bytes() []byte
- func (rs VString) String() string
- func (rs VString) TryBool() bool
- func (rs VString) TryDecode() string
- func (rs VString) TryFloat32() float32
- func (rs VString) TryFloat64() float64
- func (rs VString) TryInt() int
- func (rs VString) TryInt32() int32
- func (rs VString) TryInt64() int64
- func (rs VString) TryTimestamp(f string) int64
- func (rs VString) TryUint64() uint64
- type Value
- func (v *Value) Bytes() []byte
- func (v *Value) MarshalJSON() ([]byte, error)
- func (v *Value) MarshalYAML() (any, error)
- func (v *Value) String() string
- func (v *Value) TryBool() bool
- func (v *Value) TryDecode() string
- func (v *Value) TryFloat32(dec ...int) float32
- func (v *Value) TryFloat64(dec ...int) float64
- func (v *Value) TryInt() int
- func (v *Value) TryInt32() int32
- func (v *Value) TryInt64() int64
- func (v *Value) TryTimestamp(f string) int64
- func (v *Value) TryUint64() uint64
- func (v *Value) UnmarshalJSON(data []byte) error
- func (v *Value) UnmarshalYAML(unmarshal func(interface{}) error) error
Constants ¶
This section is empty.
Variables ¶
View Source
var EmptyValue = &Value{t: tstr}
EmptyValue an empty value
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File 配置文件
func (*File) GetDefault ¶
GetDefault 读取一个配置,若不存在,则添加这个配置
type Formatted ¶
type Formatted[ITEM any] struct { // contains filtered or unexported fields }
Formatted yaml/json 格式化配置文件
func NewFormatFile ¶
func NewFormatFile[ITEM any](configfile string, ft FormatType) *Formatted[ITEM]
NewFormatFile 创建一个新的自定义结构的yaml/json配置文件
func (*Formatted[ITEM]) PrintFormat ¶
func (f *Formatted[ITEM]) PrintFormat(fmt FormatType) string
PrintFormat 返回所有配置项
type Item ¶
type Item struct { Value *Value `json:"value" yaml:"value"` Comment string `json:"comment" yaml:"comment"` Key string `json:"-" yaml:"-"` }
Item 配置内容,包含注释,key,value,是否加密value
type PwdString ¶
type PwdString string
PwdString 序列化反序列化时可自动加密解密字符串,用于敏感字段
func (*PwdString) MarshalJSON ¶
func (PwdString) MarshalYAML ¶
func (*PwdString) UnmarshalJSON ¶
func (*PwdString) UnmarshalYAML ¶
type VString ¶
type VString string
VString value string, can parse to bool int64 float64
func (VString) TryTimestamp ¶
TryTimestamp try turn time string to timestamp
f: datetime format string,default is 2006-01-02 15:04:05, use timezone +8.0
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value config value
func NewCodeValue ¶
NewCodeValue return a value after code the data
func (*Value) MarshalJSON ¶
func (*Value) MarshalYAML ¶
func (*Value) TryFloat32 ¶
TryFloat32 reutrn float32 dec: 设置小数位数,仅第一个值有效
func (*Value) TryFloat64 ¶
TryFloat64 reutrn float64 dec: 设置小数位数,仅第一个值有效
func (*Value) TryTimestamp ¶
func (*Value) UnmarshalJSON ¶
func (*Value) UnmarshalYAML ¶
Click to show internal directories.
Click to hide internal directories.