Documentation ¶
Index ¶
- Constants
- Variables
- func GetConfig[T any]() *T
- func Parse(commandLine *pflag.FlagSet)
- func ParseTagSetting(str string, sep string, settings any)
- func Start(conf Config, dao Dao, notinit ...string) func(deferCalls ...func())
- func Unmarshal(v reflect.Value) errordeprecated
- type BasicConfig
- type CloseFunc
- type Config
- type ConfigCenterConfig
- type ConfigTagSettings
- type Dao
- type DaoConfig
- type DaoEntity
- type DaoField
- type DaoFieldCloser
- type DaoFieldCloser1
- type DaoTagSettings
- type Env
- type EnvConfig
- type EnvTagSettings
- type FileConfig
- type FlagConfig
- type FlagTagSettings
- type Generate
- type NeedInit
- type NeedInitPlaceholder
Constants ¶
const ( DEVELOPMENT = "dev" TEST = "test" PRODUCT = "prod" InitKey = "initialize" )
const ( EntityField = "ENTITY" ConfigField = "CONFIG" )
Variables ¶
var ( GlobalConfig = &globalConfig{ Env: DEVELOPMENT, ConfUrl: "./config.toml", confMap: map[string]interface{}{}, } )
约定大于配置
Functions ¶
func ParseTagSetting ¶
ParseTagSetting default sep ;
Types ¶
type BasicConfig ¶
type BasicConfig struct { Module string // 代理, socks5://localhost:1080 Proxy string `flag:"name:proxy;short:p;default:'socks5://localhost:1080';usage:代理"` }
BasicConfig zh: 基本配置,包含模块名
type ConfigCenterConfig ¶
type ConfigCenterConfig struct { NoInject []string conf_center.ConfigCenterConfig }
ConfigCenterConfig zh:配置中心的配置 en:
type ConfigTagSettings ¶
func ParseConfigTagSettings
deprecated
func ParseConfigTagSettings(str string) *ConfigTagSettings
Deprecated: 使用独立的tag
type DaoEntity ¶
type DaoFieldCloser ¶
type DaoFieldCloser1 ¶
type DaoFieldCloser1 interface {
Close()
}
type DaoTagSettings ¶
func ParseDaoTagSettings ¶
func ParseDaoTagSettings(str string) *DaoTagSettings
type EnvConfig ¶ added in v1.1.0
type EnvConfig struct {
Proxy string `env:"name:HTTP_PROXY"`
}
example
type EnvTagSettings ¶ added in v1.1.0
type FileConfig ¶
type FileConfig struct { BasicConfig Dev, Test, Prod *ConfigCenterConfig }
FileConfig 配置文件映射结构体,每个启动都有一个必要的配置文件,用于初始化基本配置及配置中心配置, ```toml Module = "user"
[dev] configType = "local" Watch = true NoInject = ["Apollo","Etcd", "Es"]
[dev.local] Debug = true ConfigPath = "local.toml" ReloadType = "fsnotify"
[dev.http] Interval = 100 Url = "http://localhost:6666/local.toml"
[dev.nacos] DataId = "pro" Group = "DEFAULT_GROUP"
[[dev.nacos.ServerConfigs]] Scheme = "http" IpAddr = "nacos" Port = 9000 GrpcPort = 10000
[dev.nacos.ClientConfig] NamespaceId = "" username = "nacos" password = "nacos" LogLevel = "debug" ```
type FlagConfig ¶
type FlagConfig struct { // environment Env string `flag:"name:env;short:e;default:dev;usage:环境"` // 配置文件路径 ConfUrl string `flag:"name:conf;short:c;default:config.toml;usage:配置文件路径,默认./config.toml或./config/config.toml"` // 是否监听配置文件 Watch bool `flag:"name:watch;short:w;default:false;usage:是否监听配置文件"` // 代理, socks5://localhost:1080 Proxy string `flag:"name:proxy;short:p;default:'socks5://localhost:1080';usage:代理"` }
TODO: 优先级高于其他Config,覆盖环境变量及配置中心的配置 example
type FlagTagSettings ¶ added in v1.1.0
type NeedInitPlaceholder ¶
type NeedInitPlaceholder struct { }