Documentation ¶
Index ¶
- Constants
- Variables
- func AppData(filepaths ...string) string
- func Bye()
- func Catch(f func()) (err error)
- func CleanInitiators()
- func CleanModules()
- func CleanWarnings()
- func Config(filepaths ...string) string
- func Constants(filepaths ...string) string
- func DebugPrint(args ...interface{})
- func DebugPrintf(format string, args ...interface{})
- func DebugPrintln(args ...interface{})
- func DefaultConfig(filepaths ...string) string
- func DelWarning(module string)
- func DelayAndQuit()
- func EnvnameWithPrefix(envname string) string
- func GetHerbEnv(envname string) string
- func GetStackLines(from int, to int) []string
- func Getenv(key string) string
- func HasWarning() bool
- func InitModulesOrderByName(enabledModules ...string)
- func InitOrderByName(module string)
- func IsPathExists(path string) bool
- func LogError(err error)
- func LogIfError(err error)
- func Logs(filepaths ...string) string
- func MakeLoggerFolderIfNotExist()
- func Must(err error)
- func MustGetWD() string
- func MustLoadRegisteredFolders()
- func NewFileObjectNotWriteableError(id string) error
- func NewFileObjectSchemeError(id string) error
- func NopIDGenerator() string
- func OnQuit(handlers ...func())
- func OnQuitAndIgnoreError(handlers ...func() error)
- func OnQuitAndLogError(handlers ...func() error)
- func OnUnloadModules(f func())
- func Print(args ...interface{}) (n int, err error)
- func Printf(format string, args ...interface{}) (n int, err error)
- func Println(args ...interface{}) (n int, err error)
- func Quit()
- func QuitChan() chan int
- func Recover()
- func RecoverAndExit()
- func RegisterDataFolder(folder ...string) string
- func RegisterInitiator(module string, Name string, handler func())
- func Resources(filepaths ...string) string
- func Root(filepaths ...string) string
- func SetHerbEnv(envname string, val string)
- func SetSystemEnvNamePrefix(p string)
- func SetWarning(module string, info ...string)
- func Setenv(key string, value string) error
- func System(filepaths ...string) string
- func SystemEnvNamePrefix() string
- func UnloadModules()
- func WaitingQuit()
- func Warnings() map[string][]string
- type AppEnv
- type ErrorType
- type FileObjectError
- type Module
- type PrefixEnv
- type PresetEnv
- type RelativeFile
- func AppDataFile(filepath ...string) *RelativeFile
- func ConfigFile(filepath ...string) *RelativeFile
- func ConstantsFile(filepath ...string) *RelativeFile
- func NewRelativeFile() *RelativeFile
- func ResourcesFile(filepath ...string) *RelativeFile
- func RootFile(filepath ...string) *RelativeFile
- func SystemFile(filepath ...string) *RelativeFile
- type RelativeFileLocation
- type Stage
Constants ¶
View Source
const ( StageInit = Stage(0) StageNormal = Stage(5) StageFinish = Stage(9) )
View Source
const EnvAppDataPath = "Path.AppData"
View Source
const EnvConfigPath = "Path.Config"
View Source
const EnvConstantsPath = "Path.Constants"
View Source
const EnvForceDebugMode = "Debug"
EnvForceDebugMode env field to set force demog mode
View Source
const EnvResourcesPath = "Path.Resources"
View Source
const EnvRootPath = "Path.Root"
EnvRootPath env field to set root path
View Source
const EnvSystemPath = "Path.System"
View Source
const ErrTypeFileObjectNotWriteable = ErrorType("notwriteable")
View Source
const ErrTypeFileObjectSchemeNotavaliable = ErrorType("schemenotavaliable")
View Source
const RelativeFileLocationAppData = RelativeFileLocation("appdata")
View Source
const RelativeFileLocationConfig = RelativeFileLocation("config")
View Source
const RelativeFileLocationConstants = RelativeFileLocation("constants")
View Source
const RelativeFileLocationLogs = RelativeFileLocation("logs")
View Source
const RelativeFileLocationResources = RelativeFileLocation("resources")
View Source
const RelativeFileLocationRoot = RelativeFileLocation("")
View Source
const RelativeFileLocationSystem = RelativeFileLocation("system")
Variables ¶
View Source
var AppDataPath string
View Source
var ApplicationLock sync.Mutex
View Source
var Args []string
View Source
var AutoDetectCWD = true
View Source
var ConfigPath string
View Source
var ConstantsPath string
View Source
var Debug = false
View Source
var DebugOutput = os.Stdout
View Source
var DefaultConfigPath string
View Source
var DefaultFileMode = os.FileMode(0660)
View Source
var DefaultFolderMode = os.FileMode(0770)
View Source
var Env = OsEnv
View Source
var ErrorLogger = func(s string) { log.Println(s) }
View Source
var ForceDebug bool
ForceDebug force useing debug mode
View Source
var IDGenerator = NopIDGenerator
IDGenerator id generator
View Source
var IgnoreEnv = false
IgnoreEnv ignore os env settings.
View Source
var Initiators = map[string]modulelist{}
View Source
var IsErrorIgnored = func(err error) bool { for k := range LoggerIgnoredErrorsChecker { if LoggerIgnoredErrorsChecker[k](err) { return true } } return false }
View Source
var LeaveMessage = "Bye."
View Source
var LoggerIgnoredErrorsChecker = []func(error) bool{ func(err error) bool { if err == http.ErrHandlerTimeout || err == http.ErrAbortHandler { return true } if err == context.Canceled { return true } oe, ok := err.(*net.OpError) if ok { if oe.Err == syscall.EPIPE || oe.Err == syscall.ECONNRESET { return true } se, ok := oe.Err.(*os.SyscallError) if ok && (se.Err == syscall.EPIPE || se.Err == syscall.ECONNRESET) { return true } } return false }, }
View Source
var LoggerMaxLength = 5
View Source
var LogsPath string
View Source
var Modules = modulelist{}
View Source
var MustChRoot = func() { Must(os.Chdir(RootPath)) }
View Source
var OsEnv = NewPrefixEnv("")
View Source
var QuitDelayDuration = 500 * time.Microsecond
View Source
var RegisterLoggerIgnoredErrorsChecker = func(f func(error) bool) { LoggerIgnoredErrorsChecker = append(LoggerIgnoredErrorsChecker, f) }
View Source
var ResourcesPath string
View Source
var RootPath string
View Source
var SecretFileMode = os.FileMode(0600)
View Source
var SignalChan = make(chan os.Signal)
View Source
var Stdout io.Writer = os.Stdout
View Source
var SystemPath string
View Source
var UpdatePaths = func() error { if RootPath == "" { var execute string execute = filepath.Dir(mustPath(os.Executable())) if AutoDetectCWD && ConfigPath == "" && !IsPathExists(filepath.Join(execute, "../", "config")) { execute = MustGetWD() } RootPath = filepath.Join(execute, "../") } if ResourcesPath == "" { ResourcesPath = filepath.Join(RootPath, "resources") } if AppDataPath == "" { AppDataPath = filepath.Join(RootPath, "appdata") } if LogsPath == "" { LogsPath = filepath.Join(RootPath, "logs") } if ConfigPath == "" { ConfigPath = filepath.Join(RootPath, "config") } if SystemPath == "" { SystemPath = filepath.Join(RootPath, "system") } if ConstantsPath == "" { ConstantsPath = filepath.Join(SystemPath, "constants") } if DefaultConfigPath == "" { DefaultConfigPath = filepath.Join(SystemPath, "defaultconfig") } return nil }
Functions ¶
func CleanInitiators ¶
func CleanInitiators()
func CleanModules ¶
func CleanModules()
func CleanWarnings ¶
func CleanWarnings()
func DebugPrint ¶
func DebugPrint(args ...interface{})
func DebugPrintf ¶
func DebugPrintf(format string, args ...interface{})
func DebugPrintln ¶
func DebugPrintln(args ...interface{})
func DefaultConfig ¶
func DelWarning ¶
func DelWarning(module string)
func DelayAndQuit ¶
func DelayAndQuit()
func EnvnameWithPrefix ¶
func GetHerbEnv ¶
Getenv get env value with SystemEnvNamePrefix
func GetStackLines ¶
func HasWarning ¶
func HasWarning() bool
func InitModulesOrderByName ¶
func InitModulesOrderByName(enabledModules ...string)
func InitOrderByName ¶
func InitOrderByName(module string)
func IsPathExists ¶
func LogIfError ¶
func LogIfError(err error)
func MakeLoggerFolderIfNotExist ¶
func MakeLoggerFolderIfNotExist()
func MustLoadRegisteredFolders ¶
func MustLoadRegisteredFolders()
func NopIDGenerator ¶
func NopIDGenerator() string
NopIDGenerator nop id generator which alawys return empty string
func OnQuitAndIgnoreError ¶
func OnQuitAndIgnoreError(handlers ...func() error)
func OnQuitAndLogError ¶
func OnQuitAndLogError(handlers ...func() error)
func OnUnloadModules ¶
func OnUnloadModules(f func())
func RecoverAndExit ¶
func RecoverAndExit()
func RegisterDataFolder ¶
func RegisterInitiator ¶
func SetHerbEnv ¶
func SetSystemEnvNamePrefix ¶
func SetSystemEnvNamePrefix(p string)
SetSystemEnvNamePrefix set system env name prefix
func SetWarning ¶
func SystemEnvNamePrefix ¶
func SystemEnvNamePrefix() string
SystemEnvNamePrefix system env name prefix
func UnloadModules ¶
func UnloadModules()
func WaitingQuit ¶
func WaitingQuit()
Types ¶
type FileObjectError ¶
func (*FileObjectError) Error ¶
func (f *FileObjectError) Error() string
type Module ¶
func RegisterModule ¶
type RelativeFile ¶
type RelativeFile struct { Location RelativeFileLocation Path string }
func AppDataFile ¶
func AppDataFile(filepath ...string) *RelativeFile
func ConfigFile ¶
func ConfigFile(filepath ...string) *RelativeFile
func ConstantsFile ¶
func ConstantsFile(filepath ...string) *RelativeFile
func NewRelativeFile ¶
func NewRelativeFile() *RelativeFile
func ResourcesFile ¶
func ResourcesFile(filepath ...string) *RelativeFile
func RootFile ¶
func RootFile(filepath ...string) *RelativeFile
func SystemFile ¶
func SystemFile(filepath ...string) *RelativeFile
func (*RelativeFile) AbsolutePath ¶
func (f *RelativeFile) AbsolutePath() string
func (*RelativeFile) ID ¶
func (f *RelativeFile) ID() string
func (*RelativeFile) ReadRaw ¶
func (f *RelativeFile) ReadRaw() ([]byte, error)
type RelativeFileLocation ¶
type RelativeFileLocation string
Source Files ¶
Click to show internal directories.
Click to hide internal directories.