lib

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2021 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ConfBase     *BaseConf
	DBMapPool    map[string]*sql.DB
	GORMMapPool  map[string]*gorm.DB
	ConfRedis    *RedisConf
	ConfRedisMap *RedisMapConf
	ViperConfMap map[string]*viper.Viper
	TimeLocation *time.Location
	TimeFormat   = "2006-01-02 15:04:05"
	DateFormat   = "2006-01-02"
	LocalIP      = net.ParseIP("127.0.0.1")
	ConfEnvPath  string
	ConfEnv      string
	ZLog         *ddlog.DiLogHandle
)

Functions

func AddGetDataToUrl

func AddGetDataToUrl(urlString string, data url.Values) string

func Black

func Black(str string) string

func Blue

func Blue(str string) string

func CloseDB

func CloseDB() error

func CmdExecute

func CmdExecute() error

func Cyan

func Cyan(str string) string

func DestroyConf

func DestroyConf()

func Encode

func Encode(data string) (string, error)

func GetBoolConf

func GetBoolConf(key string) bool

func GetCmdConfPath

func GetCmdConfPath() string

func GetCmdPanelType

func GetCmdPanelType() string

func GetConf

func GetConf(key string) interface{}

func GetConfEnv

func GetConfEnv() string

func GetConfFilePath

func GetConfFilePath(fileName string) string

func GetConfPath

func GetConfPath(fileName string) string

func GetDBPool

func GetDBPool(name string) (*sql.DB, error)

func GetDurationConf

func GetDurationConf(key string) time.Duration

func GetFloat64Conf

func GetFloat64Conf(key string) float64

func GetGormPool

func GetGormPool(name string) (*gorm.DB, error)

func GetIntConf

func GetIntConf(key string) int

func GetLocalIPs

func GetLocalIPs() (ips []net.IP)

func GetMd5Hash

func GetMd5Hash(text string) string

func GetStringConf

func GetStringConf(key string) string

func GetStringMapConf

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

func GetStringMapStringConf

func GetStringMapStringConf(key string) map[string]string

func GetStringSliceConf

func GetStringSliceConf(key string) []string

func GetTimeConf

func GetTimeConf(key string) time.Time

func Green

func Green(str string) string

func HttpGET

func HttpGET(traceContext *trace.Trace, urlString string, urlParams url.Values, msTimeout int, header http.Header) (*http.Response, []byte, error)

func HttpJSON

func HttpJSON(traceContext *trace.Trace, urlString string, jsonContent string, msTimeout int, header http.Header) (*http.Response, []byte, error)

func HttpPOST

func HttpPOST(traceContext *trace.Trace, urlString string, urlParams url.Values, msTimeout int, header http.Header, contextType string) (*http.Response, []byte, error)

func InArrayString

func InArrayString(s string, arr []string) bool

func InitBaseConf

func InitBaseConf(path string) error

func InitConf

func InitConf(configPath string) error

func InitDBPool

func InitDBPool(path string) error

func InitRedisConf

func InitRedisConf(path string) error

func InitViperConf

func InitViperConf() error

func IsSetConf

func IsSetConf(key string) bool

func ParseConfPath

func ParseConfPath(config string) error

func ParseConfig

func ParseConfig(path string, conf interface{}) error

func ParseLocalConfig

func ParseLocalConfig(fileName string, st interface{}) error

func PathExists

func PathExists(path string) (bool, error)

func Purple

func Purple(str string) string

func Red

func Red(str string) string

func RedisConfDo

func RedisConfDo(traceContext *trace.Trace, name string, commandName string, args ...interface{}) (interface{}, error)

func RedisConnFactory

func RedisConnFactory(name string) (redis.Conn, error)

func RedisLogDo

func RedisLogDo(traceContext *trace.Trace, c redis.Conn, commandName string, args ...interface{}) (interface{}, error)

func SetCmdConfPath

func SetCmdConfPath(path string)

func SetCmdPanelType

func SetCmdPanelType(paneltype string)

func Substr

func Substr(str string, start int64, end int64) string

func White

func White(str string) string

func Yellow

func Yellow(str string) string

Types

type BaseConf

type BaseConf struct {
	TimeLocation string        `toml:"time_location"`
	Log          ZeroLogConfig `toml:"log"`
	Base         struct {
		DebugMode    string `toml:"debug_mode"`
		TimeLocation string `toml:"time_location"`
		SerName      string `toml:"ser_name"`
	} `toml:"base"`
}

type LogConfConsoleWriter

type LogConfConsoleWriter struct {
	On    bool `toml:"on"`
	Color bool `toml:"color"`
}

type LogConfFileWriter

type LogConfFileWriter struct {
	On              bool   `toml:"on"`
	LogPath         string `toml:"log_path"`
	RotateLogPath   string `toml:"rotate_log_path"`
	WfLogPath       string `toml:"wf_log_path"`
	RotateWfLogPath string `toml:"rotate_wf_log_path"`
}

type LogConfig

type LogConfig struct {
	Level string               `toml:"log_level"`
	FW    LogConfFileWriter    `toml:"file_writer"`
	CW    LogConfConsoleWriter `toml:"console_writer"`
}

type Logger

type Logger struct {
}
var Log *Logger

func (*Logger) TagError

func (l *Logger) TagError(traceContext *trace.Trace, dltag string, m map[string]interface{})

func (*Logger) TagInfo

func (l *Logger) TagInfo(traceContext *trace.Trace, dltag string, m map[string]interface{})

func (*Logger) TagWarn

func (l *Logger) TagWarn(traceContext *trace.Trace, dltag string, m map[string]interface{})

type MySQLConf

type MySQLConf struct {
	DriverName      string `toml:"driver_name"`
	DataSourceName  string `toml:"data_source_name"`
	MaxOpenConn     int    `toml:"max_open_conn"`
	MaxIdleConn     int    `toml:"max_idle_conn"`
	MaxConnLifeTime int    `toml:"max_conn_life_time"`
}

type MysqlGormLogger

type MysqlGormLogger struct {
	gorm.Logger
	Trace *trace.Trace
}

func (*MysqlGormLogger) CtxPrint

func (logger *MysqlGormLogger) CtxPrint(s *gorm.DB, values ...interface{})

func (*MysqlGormLogger) LogFormatter

func (logger *MysqlGormLogger) LogFormatter(values ...interface{}) (messages map[string]interface{})

func (*MysqlGormLogger) NowFunc

func (logger *MysqlGormLogger) NowFunc() time.Time

type MysqlMapConf

type MysqlMapConf struct {
	List map[string]*MySQLConf `toml:"list"`
}

type RedisConf

type RedisConf struct {
	ProxyList    []string `toml:"proxy_list"`
	Password     string   `toml:"password"`
	Db           int      `toml:"db"`
	ConnTimeout  int      `toml:"conn_timeout"`
	ReadTimeout  int      `toml:"read_timeout"`
	WriteTimeout int      `toml:"write_timeout"`
}

type RedisMapConf

type RedisMapConf struct {
	List map[string]*RedisConf `toml:"list"`
}

type ZeroLogConfig

type ZeroLogConfig struct {
	On          bool   `toml:"on"`
	Level       string `toml:"level"`
	FilePrefix  string `toml:"file_prefix"`
	FileDir     string `toml:"file_dir"`
	AutoClear   bool   `toml:"auto_clear"`
	ClearHours  int32  `toml:"clear_hours"`
	ClearStep   int32  `toml:"clear_step"`
	Separate    bool   `toml:"separate"`
	DisableLink bool   `toml:"disable_link"`
}

Jump to

Keyboard shortcuts

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