util

package
v0.0.0-...-cb3ca1d Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2019 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogDebug   = iota
	LogInfo    = iota
	LogWarning = iota
	LogError   = iota
	LogFatal   = iota
)

Log levels.

Variables

This section is empty.

Functions

func Caller

func Caller() string

Caller returns a caller's call location. If F1 calls F2 which in its turn calls Caller, then this function will return a location within F1 where it calls F2.

func ExeDirJoin

func ExeDirJoin(elem ...string) string

ExeDirJoin composes a file name relative to a running executable.

func IsHostname

func IsHostname(s string) bool

IsHostname checks if this is a hostname

func IsIPv4

func IsIPv4(s string) bool

IsIPv4 checks if this is a valid IPv4

func IsNetPort

func IsNetPort(str string) bool

IsNetPort checks if this is a valid net port

func IsTLSCert

func IsTLSCert(block string) bool

IsTLSCert if block is one or more TLS certificates then function returns true

func IsUUID

func IsUUID(s string) bool

IsUUID checks if a given string is a UUID.

func NewUUID

func NewUUID() string

NewUUID generates a new UUID.

func ReadJSONFile

func ReadJSONFile(name string, data interface{}) error

ReadJSONFile reads and parses a JSON file filling a given data instance.

func ReadTestConfig

func ReadTestConfig(conf interface{})

ReadTestConfig parses command line and reads configuration.

func RootPath

func RootPath() string

RootPath returns a path of the root package.

func TestExpectResult

func TestExpectResult(t *testing.T, op string, expected, actual error)

TestExpectResult compares two errors and fails a test if they don't match.

func ValidateMethod

func ValidateMethod(f http.HandlerFunc, method string) http.HandlerFunc

ValidateMethod returns not acceptable for methods other then given.

func WriteJSONFile

func WriteJSONFile(name, prefix, indent string, data interface{}) error

WriteJSONFile converts a given data instance to JSON and writes it to file.

Types

type LogConfig

type LogConfig struct {
	Level string
}

LogConfig is a logger configuration.

func NewLogConfig

func NewLogConfig() *LogConfig

NewLogConfig creates a default log configuration.

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger to log internal events.

func NewLogger

func NewLogger(conf *LogConfig) (*Logger, error)

NewLogger creates a new logger.

func NewTestLogger

func NewTestLogger(conf *LogConfig) *Logger

NewTestLogger creates a new logger.

func (*Logger) Debug

func (l *Logger) Debug(fmt string, v ...interface{})

Debug emits a debugging message.

func (*Logger) Error

func (l *Logger) Error(fmt string, v ...interface{})

Error emits an error message.

func (*Logger) Fatal

func (l *Logger) Fatal(fmt string, v ...interface{})

Fatal emits a fatal message and exits with failure.

func (*Logger) Info

func (l *Logger) Info(fmt string, v ...interface{})

Info emits an information message.

func (*Logger) Log

func (l *Logger) Log(lvl int, fmt string, v ...interface{})

Log emits a log message.

func (*Logger) Warn

func (l *Logger) Warn(fmt string, v ...interface{})

Warn emits an warning message.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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