z1cnf

package module
v1.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

z1cnf

介绍

轻量配置库,开箱即用,使用 yaml 做为配置文件,可以设置配置模版。若设置了配置模版,若没有给配置文件,会根据配置模版生成配置文件。

软件架构
1 自动读取config/config.yaml
2 若config/config.yaml不存在,会从用户配置的模版(z1cnf.SetCnf(z1cnfContent))生成config/config.yaml,并提醒修改重启

安装教程
  1. go get gitee.com/z1gotool/z1cnf
  2. xxxx
  3. xxxx
使用说明
1 常用函数
z1cnf.GetString(`db.host`)
z1cnf.GetInt(`db.port`)
z1cnf.GetString(`db.dbs.2`)

2 添加配置模版
第一步
import (
	...
	_ "embed"
	...
}

第二步
//go:embed config.yaml
var z1cnfContent []byte
var z1cnfPlaceholder = z1cnf.SetCnf(z1cnfContent)

参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenConfigTemplate added in v1.2.4

func GenConfigTemplate() error

func Get added in v1.2.0

func Get(key string) interface{}

func GetBool added in v1.2.0

func GetBool(key string) bool

func GetInt added in v1.2.0

func GetInt(key string) int

func GetSlice added in v1.2.0

func GetSlice(key string) []interface{}

func GetSliceBool added in v1.2.0

func GetSliceBool(key string) []bool

func GetSliceInt added in v1.2.0

func GetSliceInt(key string) []int

func GetSliceString added in v1.2.0

func GetSliceString(key string) []string

func GetString added in v1.2.0

func GetString(key string) string

func GetStringMap added in v1.2.0

func GetStringMap(key string) map[string]interface{}

func GetStringMapBool added in v1.2.0

func GetStringMapBool(key string) map[string]bool

func GetStringMapInt added in v1.2.0

func GetStringMapInt(key string) map[string]int

func GetStringMapString added in v1.2.0

func GetStringMapString(key string) map[string]string

func SetConfigTemplate added in v1.2.2

func SetConfigTemplate(newYamlFileContent []byte) error

Types

This section is empty.

Directories

Path Synopsis
test
rs

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL