Documentation ¶
Overview ¶
Cfgo from the YAML document, bi-directional synchronous multi-module configuration.
The structure of the generated document will reflect the structure of the value itself. Maps and pointers (to struct, string, int, etc) are accepted as the in value.
Struct fields are only unmarshalled if they are exported (have an upper case first letter), and are unmarshalled using the field name lowercased as the default key. Custom keys may be defined via the "yaml" name in the field tag: the content preceding the first comma is used as the key, and the following comma-separated options are used to tweak the marshalling process. Conflicting names result in a runtime error.
The field tag format accepted is:
`(...) yaml:"[<key>][,<flag1>[,<flag2>]]" (...)`
The following flags are currently supported:
omitempty Only include the field if it's not set to the zero value for the type or to empty slices or maps. Does not apply to zero valued structs. flow Marshal using a flow style (useful for structs, sequences and maps). inline Inline the field, which must be a struct or a map, causing all of its fields or keys to be processed as if they were part of the outer struct. For maps, keys must not conflict with the yaml keys of other struct fields.
In addition, if the key is `-`, the field is ignored.
Index ¶
- func AllowAppsShare(allow bool)
- func BindSection(section string, v interface{}) error
- func Content() []byte
- func Filename() string
- func GetSection(section string) (interface{}, bool)
- func IsReg(section string) bool
- func MustReg(section string, structPtr Config)
- func Reg(section string, structPtr Config) error
- func Reload() error
- func ReloadAll() error
- type BindFunc
- type Cfgo
- func (c *Cfgo) AllowAppsShare(allow bool)
- func (c *Cfgo) BindSection(section string, v interface{}) error
- func (c *Cfgo) Content() []byte
- func (c *Cfgo) Filename() string
- func (c *Cfgo) GetSection(section string) (interface{}, bool)
- func (c *Cfgo) IsReg(section string) bool
- func (c *Cfgo) MustReg(section string, structPtr Config)
- func (c *Cfgo) Reg(section string, structPtr Config) error
- func (c *Cfgo) Reload() error
- type Config
- type Section
- type Sections
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllowAppsShare ¶
func AllowAppsShare(allow bool)
AllowAppsShare allows other applications to share the configuration file.
func BindSection ¶
BindSection returns default config section copy.
func GetSection ¶
GetSection returns default config section.
Types ¶
type Cfgo ¶
type Cfgo struct {
// contains filtered or unexported fields
}
Cfgo a whole config
func (*Cfgo) AllowAppsShare ¶
AllowAppsShare allows other applications to share the configuration file.
func (*Cfgo) BindSection ¶
BindSection returns yaml config section copy.
func (*Cfgo) GetSection ¶
GetSection returns yaml config section.