util

package
v0.0.0-...-b579be4 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2019 License: MIT, MIT, MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const EnvForceDebugMode = "HerbDebug"

EnvForceDebugMode env field to set force demog mode

View Source
const EnvRootPath = "HerbRoot"

EnvRootPath env field to set root path

Variables

View Source
var AppDataPath string
View Source
var ConfigPath string
View Source
var ConstantsPath string
View Source
var Debug = false
View Source
var DefaultFolderMode = os.FileMode(0700)
View Source
var ForceDebug bool

ForceDebug force useing debug mode

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 {
		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 Modules = modulelist{}
View Source
var MustChRoot = func() {
	Must(os.Chdir(RootPath))
}
View Source
var QuitChan = make(chan int)
View Source
var RegisterLoggerIgnoredErrorsChecker = func(f func(error) bool) {
	LoggerIgnoredErrorsChecker = append(LoggerIgnoredErrorsChecker, f)
}
View Source
var ResouresPath string
View Source
var RootPath string
View Source
var SignalChan = make(chan os.Signal)
View Source
var SystemPath string
View Source
var UpdatePaths = func() error {
	if RootPath == "" {
		RootPath = filepath.Join(filepath.Dir(mustPath(os.Executable())), "../")
	}
	ResouresPath = path.Join(RootPath, "resources")
	AppDataPath = path.Join(RootPath, "appdata")
	ConfigPath = path.Join(RootPath, "config")
	SystemPath = path.Join(RootPath, "system")
	ConstantsPath = path.Join(RootPath, "system", "constants")
	return nil
}

Functions

func AppData

func AppData(filepaths ...string) string

func Bye

func Bye()

func Config

func Config(filepaths ...string) string

func Constants

func Constants(filepaths ...string) string

func DebugPrintln

func DebugPrintln(args ...interface{})

func DelWarning

func DelWarning(module string)

func GetStackLines

func GetStackLines(from int, to int) []string

func HasWarning

func HasWarning() bool

func InitModulesOrderByName

func InitModulesOrderByName()

func InitOrderByName

func InitOrderByName(module string)

func LogError

func LogError(err error)

func Must

func Must(err error)

func MustGetWD

func MustGetWD() string

func MustLoadRegisteredFolders

func MustLoadRegisteredFolders()

func Quit

func Quit()

func Recover

func Recover(args ...interface{})

func RegisterDataFolder

func RegisterDataFolder(folder ...string) string

func RegisterInitiator

func RegisterInitiator(module string, Name string, handler func())

func Resource

func Resource(filepaths ...string) string

func SetConfigPath

func SetConfigPath(paths ...string)

func SetWarning

func SetWarning(module string, info ...string)

func System

func System(filepaths ...string) string

func WaitingQuit

func WaitingQuit()

func Warnings

func Warnings() map[string][]string

Types

type Module

type Module struct {
	Name     string
	Handler  func()
	Position string
}

func RegisterModule

func RegisterModule(Name string, handler func()) Module

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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