config

package
v0.0.0-...-9a27a15 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCommandName = "go-template-cli"
	DefaultBaseDir     = constant.CurrentDir
	// daemon
	DefaultDaemon  = false
	DaemonArg      = "--daemon"
	DaemonArgTrue  = "--daemon=true"
	DaemonArgFalse = "--daemon=false"
	// log
	DefaultLogDir          = "./log"
	MinLogMaxSize          = 1
	MaxLogMaxSize          = constant.MaxInt
	MinLogMaxDays          = 1
	MaxLogMaxDays          = constant.MaxInt
	MinLogMaxBackups       = 1
	MaxLogMaxBackups       = constant.MaxInt
	DefaultRotateOnStartup = false
	DefaultLogStdout       = false
	// server
	DefaultServerAddr         = "0.0.0.0:80"
	DefaultServerReadTimeout  = 5
	DefaultServerWriteTimeout = 10
	MinServerReadTimeout      = 0
	MaxServerReadTimeout      = 60
	MinServerWriteTimeout     = 1
	MaxServerWriteTimeout     = 60
)

global constant

View Source
const (
	// config
	ConfKey = "config"
	// daemon
	DaemonKey = "daemon"
	// log
	LogFileNameKey        = "log.fileName"
	LogLevelKey           = "log.level"
	LogFormatKey          = "log.format"
	LogMaxSizeKey         = "log.maxSize"
	LogMaxDaysKey         = "log.maxDays"
	LogMaxBackupsKey      = "log.maxBackups"
	LogRotateOnStartupKey = "log.rotateOnStartup"
	LogStdoutKey          = "log.stdout"
	// server
	ServerAddrKey         = "server.addr"
	ServerPidFileKey      = "server.pidFile"
	ServerReadTimeoutKey  = "server.readTimeout"
	ServerWriteTimeoutKey = "server.writeTimeout"
)

configuration constant

Variables

View Source
var (
	ValidLogLevels  = []string{"debug", "info", "warn", "warning", "error", "fatal"}
	ValidLogFormats = []string{"text", "json"}
)
View Source
var (
	AppName    string
	Version    string
	BuildTime  string
	FullCommit string
	Branch     string
)

Functions

func FullInfo

func FullInfo() string

func SetDefaultConfig

func SetDefaultConfig(baseDir string)

SetDefaultConfig set default configuration, it is the lowest priority

func SetDefaultDaemon

func SetDefaultDaemon()

SetDefaultDaemon sets the default value of daemon

func SetDefaultLog

func SetDefaultLog(baseDir string)

SetDefaultLog sets the default value of log

func SetDefaultServer

func SetDefaultServer(baseDir string)

SetDefaultServer sets the default value of server

func ShortInfo

func ShortInfo() string

func TrimSpaceOfArg

func TrimSpaceOfArg(arg string) string

TrimSpaceOfArg trims spaces of given argument

func ValidateConfig

func ValidateConfig() (err error)

ValidateConfig validates if the configuration is valid

func ValidateDaemon

func ValidateDaemon() error

ValidateDaemon validates if daemon section is valid

func ValidateLog

func ValidateLog() error

ValidateLog validates if log section is valid.

func ValidateServer

func ValidateServer() error

ValidateServer validates if server section is valid

Types

This section is empty.

Jump to

Keyboard shortcuts

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