Documentation ¶
Overview ¶
Package config for read the data form 'yaml' or 'json' file and copy the data to a struct.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Example ¶
package main import ( "fmt" "gopkg.in/orivil/config.v0" ) var configI18n = &struct { Languages map[string]string }{ // set default value Languages: map[string]string{ "简体中文": "zh-CN", "english": "en", }, } func main() { // 1. new config instance cfg := config.NewConfig("./testdata") // 2. read file data to struct cfg.ReadStruct("i18n.yml", configI18n) // 3. get config data fmt.Println(configI18n.Languages) }
Output: map[简体中文:zh-CN english:en]
func (*Config) ReadStruct ¶
try to read the data form config file to struct, if the file not exist, it will be auto generated
func (*Config) ReloadFile ¶
Click to show internal directories.
Click to hide internal directories.