Documentation ¶
Index ¶
- Constants
- func Default(filed interface{}, def interface{})
- func Err(e string, args ...string) error
- func MakeTemplate(tpl string, w io.Writer, data interface{}) error
- func MakeTemplateGunicorn(tpl, file string, data interface{}) error
- func MakeTemplateGunicornString(tpl, file string, data interface{}) error
- func MakeTemplateGunicornTest(tpl string, data interface{}) error
- func MakeTemplateNginx(tpl, file string, data interface{}) error
- func MakeTemplateNginxString(tpl, file string, data interface{}) error
- func MakeTemplateNginxTest(tpl string, data interface{}) error
- func MakeTemplateRaw(w io.Writer, data []string) error
- func MakeTemplateString(tpl string, w io.Writer, data interface{}) error
- func ParseConfig(c interface{}, t, file string) error
- func ParseConfigMap(t, file string) (*map[string]interface{}, error)
- func RegToConfig(v interface{})
- func SaveConfig(c interface{}, t, file string) error
- func ValidateTags(v interface{}, env string, f HandleEnv) error
- type HandleEnv
Constants ¶
View Source
const ( ErrIni = "failed to parse ini" ErrJson = "failed to parse json" ErrYaml = "failed to parse yaml" ErrGdx = "failed to parse gdx" ErrSaveIni = "failed to save ini" ErrSaveJson = "failed to save json" ErrSaveYaml = "failed to save yaml" ErrSaveGdx = "failed to save gdx" ErrSuffix = "file type not support" ErrLoad = "failed to load file" ErrSave = "failed to save file" ErrGenTemp = "failed to generate template" ErrNotPointer = "input is not a pointer" ErrNotStruct = "input is not a struct" ErrValidate = "failed to reflect type" )
errors
View Source
const ( INI = "ini" JSON = "json" Pig = "pig" // pig is an alias of json Config = "config" // config is an alias of json Yaml = "yaml" Gdx = "gdx" )
infos
View Source
const ( INIType = iota JSONType YamlType GdxType )
类型枚举
View Source
const ( TpName = "ConfigenTpl" TpRaw = `# config generate by configen # copyright github.com/landers1037/configen {{range $r := . -}} {{print $r}} {{end}}` )
配置文件模板生成 支持py的gunicorn和nginx
Variables ¶
This section is empty.
Functions ¶
func Default ¶
func Default(filed interface{}, def interface{})
Default 修改默认值 field must be a pointer
func MakeTemplate ¶ added in v1.0.1
MakeTemplate 生成模板
func MakeTemplateGunicorn ¶ added in v1.0.1
MakeTemplateGunicorn 生成nginx配置文件 支持端口
func MakeTemplateGunicornString ¶ added in v1.0.1
func MakeTemplateGunicornTest ¶ added in v1.0.1
func MakeTemplateNginx ¶ added in v1.0.1
MakeTemplateNginx 生成nginx配置文件 支持自定义域名 服务名 端口 IP 代理转发
func MakeTemplateNginxString ¶ added in v1.0.1
func MakeTemplateNginxTest ¶ added in v1.0.1
func MakeTemplateRaw ¶ added in v1.0.1
MakeTemplateRaw 按照字符串数组生成配置文件 需要传入[]string
func MakeTemplateString ¶ added in v1.0.1
MakeTemplateString 使用字符串生成模板
func ParseConfig ¶
ParseConfig 指定配置文件类型解析 c must be a pointer t only support messages INI, Json, Yaml, Gdx
func ParseConfigMap ¶
ParseConfigMap 指定配置文件类型解析为字典 t only support messages INI, Json, Yaml, Gdx
func SaveConfig ¶
SaveConfig 保存数据到文件中 c must be a pointer t is type must be in supports file is the output file
func ValidateTags ¶
ValidateTags 自定义标签的解析 用于配置默认值 eg: `config:"env"` 默认为0值时从环境变量key: env读取 env 需要读取的环境变量 f 处理环境变量的函数,返回最终处理后需要更改的值
Types ¶
Click to show internal directories.
Click to hide internal directories.