Documentation ¶
Index ¶
- Constants
- Variables
- func GenConfigTemplate(format encoding.Format, config Config, dao Dao)
- func GetConfig[T any]() *T
- func Parse(commandLine *pflag.FlagSet)
- func ParseTagSetting(str string, sep string, settings any)
- func Start(conf Config, dao Dao) func()
- func Unmarshal(v reflect.Value) errordeprecated
- type BasicConfig
- type CloseFunc
- type Config
- type ConfigTagSettings
- type Dao
- type DaoConfig
- type DaoEntity
- type DaoField
- type DaoFieldCloser
- type DaoFieldCloserWithError
- type DaoTagSettings
- type Env
- type EnvConfig
- type FileConfig
- type FlagTagSettings
- type Generate
- type InitAfterInject
- type InitAfterInjectConfig
- type InitBeforeInject
Constants ¶
View Source
const ( EntityField = "ENTITY" ConfigField = "CONFIG" )
View Source
const (
InitKey = "initialize"
)
Variables ¶
View Source
var DaoFieldType = reflect.TypeOf((*DaoField)(nil)).Elem()
View Source
var ( GlobalConfig = &globalConfig{ BasicConfig: BasicConfig{ConfUrl: "./config.toml"}, EnvConfig: EnvConfig{Debug: true}, confMap: map[string]interface{}{}, lock: sync.RWMutex{}, } )
约定大于配置
Functions ¶
func GenConfigTemplate ¶ added in v1.6.0
func ParseTagSetting ¶
ParseTagSetting default sep ;
Types ¶
type BasicConfig ¶
type BasicConfig struct { // 配置文件路径 ConfUrl string `` /* 152-byte string literal not displayed */ // 模块名 Module string `flag:"name:mod;short:m;default:tiga-app;usage:模块名;env:MODULE" json:"module,omitempty"` // environment Env string `flag:"name:env;short:e;default:dev;usage:环境;env:ENV" json:"env,omitempty"` }
BasicConfig zh: 基本配置,包含模块名
type Config ¶
type Config interface { // 注入之前设置默认值 InitBeforeInject // 注入之后初始化 InitAfterInject }
type ConfigTagSettings ¶
func ParseConfigTagSettings
deprecated
func ParseConfigTagSettings(str string) *ConfigTagSettings
Deprecated: 使用独立的tag
type Dao ¶
type Dao interface { InitBeforeInject // 注入config后执行 InitAfterInjectConfig() // 注入dao后执行 InitAfterInject }
type DaoEntity ¶
type DaoFieldCloser ¶
type DaoFieldCloser interface {
Close()
}
type DaoFieldCloserWithError ¶
type DaoTagSettings ¶
func ParseDaoTagSettings ¶
func ParseDaoTagSettings(str string) *DaoTagSettings
type EnvConfig ¶ added in v1.6.0
type EnvConfig struct { Debug bool `flag:"name:debug;short:d;default:debug;usage:是否测试;env:DEBUG" json:"debug,omitempty"` ConfigTemplate bool `` /* 132-byte string literal not displayed */ // 代理, socks5://localhost:1080 Proxy string `flag:"name:proxy;short:p;default:'socks5://localhost:1080';usage:代理;env:HTTP_PROXY" json:"proxy,omitempty"` NoInject []string ConfigCenter conf_center.Config }
type FileConfig ¶
FileConfig 配置文件映射结构体,每个启动都有一个必要的配置文件,用于初始化基本配置及配置中心配置, ```toml Module = "user" Env = "dev" // 支持自定义
[dev] Debug = true configType = "local" Watch = true NoInject = ["Apollo","Etcd", "Es"]
[dev.local] 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 FlagTagSettings ¶
type InitAfterInject ¶ added in v1.6.0
type InitAfterInject interface {
InitAfterInject()
}
type InitAfterInjectConfig ¶ added in v1.6.0
type InitAfterInjectConfig interface {
InitAfterInjectConfig()
}
type InitBeforeInject ¶ added in v1.6.0
type InitBeforeInject interface {
InitBeforeInject()
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.