config

package
v1.21.14 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: Zlib Imports: 9 Imported by: 3

Documentation

Index

Constants

View Source
const (
	EProd = "prod"
	ETest = "test"
	EDev  = "dev"
)
View Source
const (
	KForever  = "forever"
	KDaemon   = "daemon"
	KPprof    = "pprof"
	KPath     = "path"
	KEnv      = "env"
	KConf     = "conf"
	KDataPath = "dataPath"
	KAppId    = "appid"
)

Variables

View Source
var (
	Version  = "1.0.0"
	AppName  = "unknown"
	AppAlias = "" //别名,example 某某公司的某某应用
	AppId    string
	SeqId    int64 = 0
	Source   string
	Env      = EDev
	WorkDir  string
	MainConf string
	DataPath string //程序存储数据
	Daemon   bool
	Forever  bool
	Pprof    bool
)
View Source
var RegisterConfig func(ty string, handler HandlerFunc)
View Source
var UnRegisterConfig func(ty string)

Functions

func FileNameInAppDataPath added in v1.2.20

func FileNameInAppDataPath(name string) string

FileNameInAppDataPath conf/ "{workdir}/name" 或 {workdir}/app/name

func FileNameInAppDataPathV2 added in v1.2.20

func FileNameInAppDataPathV2(name string) string

FileNameInAppDataPathV2 conf/ "{workdir}/app/name"

func FileNameInConfAppPath added in v1.8.97

func FileNameInConfAppPath(name string) string

FileNameInConfAppPath conf/appName 不带env "conf/{appName}/name"

func FileNameInConfPath added in v1.1.6

func FileNameInConfPath(name string) string

FileNameInConfPath conf/ "confPath/name"

func FileNameInDataPath added in v1.6.11

func FileNameInDataPath(name string) string

FileNameInDataPath conf/ 目录下 "{DataPath}/name"

func FileNameInEnvDataPath added in v1.6.11

func FileNameInEnvDataPath(name string) string

FileNameInEnvDataPath conf/ 目录下 "{DataPath}/{Env}/name"

func FileNameInEnvPath added in v1.1.6

func FileNameInEnvPath(name string) string

FileNameInEnvPath env/{Env}/name

func FileNameInWork added in v1.20.87

func FileNameInWork(name string) string

FileNameInWork 工作目录下 "{WorkDir}/"

func FileNameWithEnvInConfAppPath added in v1.1.6

func FileNameWithEnvInConfAppPath(name string) string

FileNameWithEnvInConfAppPath conf/appName 带env "conf/{appName}/{Env}.name"

func FileNameWithEnvInDataPath added in v1.6.11

func FileNameWithEnvInDataPath(name string) string

FileNameWithEnvInDataPath conf/ 目录下 "{DataPath}/{Env}.name"

func FileNameWithEnvInWork added in v1.20.87

func FileNameWithEnvInWork(name string) string

FileNameWithEnvInWork 工作目录下 "{WorkDir}/"

func FileNameWithoutEnvInConfAppPath added in v1.1.6

func FileNameWithoutEnvInConfAppPath(name string) string

FileNameWithoutEnvInConfAppPath Deprecated: this function simply calls FileNameInConfAppPath.

func FileNameWithoutEnvInEnvPath added in v1.1.6

func FileNameWithoutEnvInEnvPath(name string) string

FileNameWithoutEnvInEnvPath env/name

func GetAppDataPath added in v1.1.6

func GetAppDataPath() string

GetAppDataPath 程序运行数据目录,如views,docs

func GetAppDataPathV2 added in v1.2.20

func GetAppDataPathV2() string

func GetAppPath added in v1.20.87

func GetAppPath() (string, error)

func GetConfAppPath added in v1.1.6

func GetConfAppPath() string

GetConfAppPath ./conf/appName

func GetConfPath added in v1.1.6

func GetConfPath() string

GetConfPath ./conf

func GetDataPath added in v1.1.6

func GetDataPath() string

GetDataPath 业务定义存储路径

func GetEnvPath added in v1.1.6

func GetEnvPath() string

func GetExecPath added in v1.3.20

func GetExecPath() string

func IsDefaultDataPath added in v1.8.83

func IsDefaultDataPath() bool

func IsDevEnvironment added in v1.0.51

func IsDevEnvironment() bool

func IsProdEnvironment added in v1.0.51

func IsProdEnvironment() bool

func IsTestEnvironment added in v1.0.51

func IsTestEnvironment() bool

func MainFileName added in v1.1.6

func MainFileName() string

MainFileName env.main.json 全路径文件名

func UseAppDataPathV2 added in v1.1.6

func UseAppDataPathV2()

func UseAppDataVersion added in v1.8.81

func UseAppDataVersion(ver int)

func WithEnv added in v1.6.11

func WithEnv(name string) string

WithEnv 与env组合

Types

type Config

type Config struct {
	Mode           string `json:"mode" yaml:"mode" xml:"mode"`
	Server         string `json:"server" yaml:"server" xml:"server"`
	PubIP          string `json:"publicIp" yaml:"publicIp" xml:"publicIp"`
	AppDataVersion int    `json:"appDataVersion" yaml:"appDataVersion" xml:"appDataVersion"`
	EnabledRedis   bool   `json:"enabledRedis" yaml:"enabledRedis" xml:"enabledRedis"`
	EnabledDb      bool   `json:"enabledDb" yaml:"enabledDb" xml:"enabledDb"`
	EnabledEs      bool   `json:"enabledEs" yaml:"enabledEs" xml:"enabledEs"`
	EnabledMQ      bool   `json:"enabledMQ" yaml:"enabledMQ" xml:"enabledMQ"`
	// contains filtered or unexported fields
}

func (*Config) Init

func (c *Config) Init(opts ...Option)

type HandlerFunc added in v1.20.15

type HandlerFunc func(ctx context.Context, cmd int, configType, config string) (any, error)

type Option added in v1.8.55

type Option func(c *Config)

func WithAppConfPath added in v1.8.55

func WithAppConfPath(p string) Option

func WithAppDataPath added in v1.8.55

func WithAppDataPath(p string) Option

func WithAppDataPathV2 added in v1.8.55

func WithAppDataPathV2(p string) Option

func WithDataPath added in v1.8.81

func WithDataPath(p string) Option

func WithEnvPath added in v1.20.70

func WithEnvPath(path string) Option

func WithWorkDir added in v1.8.55

func WithWorkDir(dir string) Option

Jump to

Keyboard shortcuts

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