Documentation
¶
Index ¶
- Constants
- Variables
- func AddSyslogHook()
- func CopyFileContents(src, dst string) (err error)
- func DirectWriteJson(ctx context.Context, file string, obj interface{}) error
- func EnforcePermission(dirPath string) error
- func False() *bool
- func FileExists(path string) bool
- func FindFirstLogPath(logs []string) string
- func GetCallerName() string
- func InitLog(logLevel string, logs ...string) error
- func IsAdmin() bool
- func ListFiles(dir, pattern string) ([]string, error)
- func OpenBrowser(url string) error
- func ReadJson(file string, res interface{}) (interface{}, error)
- func ReadJsonWithEnvSub(file string, res interface{}) (interface{}, error)
- func RemoveJson(file string) error
- func Retry(attempts int, sleep time.Duration, toExec func() error, onError func(e error)) error
- func ReturnBoolWithDefaultFalse(b *bool) bool
- func ReturnBoolWithDefaultTrue(b *bool) bool
- func SliceDiff(x, y []string) []string
- func True() *bool
- func WriteBytesWithRestrictedPermission(ctx context.Context, file string, bs []byte) error
- func WriteJson(ctx context.Context, file string, obj interface{}) error
- func WriteJsonWithRestrictedPermission(ctx context.Context, file string, obj interface{}) error
- type Duration
Constants ¶
const ( LogConsole = "console" LogSyslog = "syslog" )
Variables ¶
var ( SpecialLogs = []string{ LogSyslog, LogConsole, } )
Functions ¶
func AddSyslogHook ¶
func AddSyslogHook()
func CopyFileContents ¶
CopyFileContents copies contents of the given src file to the dst file
func DirectWriteJson ¶
DirectWriteJson writes JSON config object to a file creating parent directories if required without creating a temporary file
func EnforcePermission ¶
func FileExists ¶
FileExists returns true if specified file exists
func FindFirstLogPath ¶
FindFirstLogPath returns the first logs entry that could be a log path, that is neither empty, nor a special value
func GetCallerName ¶
func GetCallerName() string
func ListFiles ¶
ListFiles returns the full paths of all files in dir that match pattern. Pattern uses shell-style globbing (e.g. "*.json").
func OpenBrowser ¶ added in v0.2.0
OpenBrowser opens the URL in a browser, respecting the BROWSER environment variable.
func ReadJsonWithEnvSub ¶
ReadJsonWithEnvSub reads JSON config file and maps to a provided interface with environment variable substitution
func RemoveJson ¶
RemoveJson removes the specified JSON file if it exists
func Retry ¶
Retry retries a given toExec function calling onError on failed attempts onError shouldn be a lightweight function and shouldn't be blocking
func ReturnBoolWithDefaultFalse ¶
Return bool representation if the bool pointer is non-nil, otherwise returns false
func ReturnBoolWithDefaultTrue ¶
Return bool representation if the bool pointer is non-nil, otherwise returns true
Types ¶
type Duration ¶
Duration is used strictly for JSON requests/responses due to duration marshalling issues