Documentation
¶
Index ¶
- func FormatConfig(config *Config) error
- func GetAccessToken() string
- func GetCacheDir() string
- func GetConfigPath() string
- func GetDBFile() string
- func GetDefaultConfigPath() (string, error)
- func GetLogFile() string
- func Init(configFile string) error
- func InitConfig(configFile string) error
- func InitConfigByCode() error
- func ReInitConfig() error
- func SaveAccess(a Access) error
- func SaveCredential(c Credential) error
- func Set(conf *Config)
- func SetConfigPath(path string)
- func Show(hiddenFields ...string) string
- type Access
- type App
- type Config
- type Credential
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatConfig ¶ added in v0.0.3
func GetAccessToken ¶
func GetAccessToken() string
func GetConfigPath ¶
func GetConfigPath() string
func GetDefaultConfigPath ¶ added in v0.0.3
func GetLogFile ¶ added in v0.0.5
func GetLogFile() string
func Init ¶
初始化配置 功能需求: - 如果 config 变量有值,直接返回 - 初始化的过程使用 sync.Once 保证只做一次 - 先通过 configYml 加载配置 config - 如果 configFile 地址存在
- 如果内容不是 Yml 配置,则报错
- 是配置文件,则对 config 进行合并,字段值以文件中优先
- *_dir/*_file 后缀的字段,使用 homedir.Expand 做 ~/ 地址开头解析 - 如果 DataDir 为空,需要使用 utils.GetUserDataRoot 获取默认值
单元测试见本包 _test
func InitConfig ¶
func InitConfigByCode ¶
func InitConfigByCode() error
func ReInitConfig ¶ added in v0.0.3
func ReInitConfig() error
func SaveAccess ¶
func SaveCredential ¶
func SaveCredential(c Credential) error
func SetConfigPath ¶ added in v0.0.3
func SetConfigPath(path string)
Types ¶
type Access ¶
type Config ¶
type Credential ¶
type Credential struct {
AppID int `yaml:"appId" json:"appId"`
AppKey string `yaml:"appKey" json:"appKey"`
SecretKey string `yaml:"secretKey" json:"secretKey"`
SignKey string `yaml:"signKey" json:"signKey"`
}
func GetCredential ¶ added in v0.0.5
func GetCredential() (*Credential, error)
func (*Credential) IsNil ¶
func (c *Credential) IsNil() bool
Click to show internal directories.
Click to hide internal directories.