Documentation ¶
Index ¶
- Variables
- func CloseFileAndRename(fileDescriptor *os.File, sourceFilePath string, targetFilePath string) error
- func CreateTempFile(filePath string) (*os.File, string, error)
- func DirectoryEmpty(dirPath string) (bool, error)
- func EstimateRemainingTime(timeStart time.Time, current int64, total int64) (percentage float64, remaining time.Duration)
- func FolderSize(target string) (int64, error)
- func LoadEd25519PrivateKeysFromEnvironment(name string) ([]ed25519.PrivateKey, error)
- func LoadStringFromEnvironment(name string) (string, error)
- func MergeContexts(ctxPrimary context.Context, ctxSecondary context.Context) (context.Context, context.CancelFunc)
- func ParseEd25519PrivateKeyFromString(key string) (ed25519.PrivateKey, error)
- func ParseEd25519PublicKeyFromString(key string) (ed25519.PublicKey, error)
- func RandomInsecure(min int, max int) int
- func ReadFromFile(filename string, data interface{}) error
- func ReadJSONFromFile(filename string, data interface{}) error
- func ReadTOMLFromFile(filename string, data interface{}) error
- func ReturnErrIfChannelClosed(channel <-chan struct{}, err error) error
- func ReturnErrIfCtxDone(ctx context.Context, err error) error
- func Uint32Diff(newCount uint32, oldCount uint32) uint32
- func WaitForChannelClosed(ctx context.Context, ch chan struct{}) error
- func WriteJSONToFile(filename string, data interface{}, perm os.FileMode) (err error)
- func WriteTOMLToFile(filename string, data interface{}, perm os.FileMode, header ...string) (err error)
- func WriteToFile(filename string, data interface{}, perm os.FileMode) (err error)
- type SyncEvent
- type TimeHeap
- type WrappedLogger
- func (l *WrappedLogger) LogDebug(args ...interface{})
- func (l *WrappedLogger) LogDebugf(template string, args ...interface{})
- func (l *WrappedLogger) LogError(args ...interface{})
- func (l *WrappedLogger) LogErrorf(template string, args ...interface{})
- func (l *WrappedLogger) LogFatal(args ...interface{})
- func (l *WrappedLogger) LogFatalf(template string, args ...interface{})
- func (l *WrappedLogger) LogInfo(args ...interface{})
- func (l *WrappedLogger) LogInfof(template string, args ...interface{})
- func (l *WrappedLogger) LogPanic(args ...interface{})
- func (l *WrappedLogger) LogPanicf(template string, args ...interface{})
- func (l *WrappedLogger) LogWarn(args ...interface{})
- func (l *WrappedLogger) LogWarnf(template string, args ...interface{})
- func (l *WrappedLogger) Logger() *logger.Logger
- func (l *WrappedLogger) LoggerNamed(name string) *logger.Logger
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidKeyLength = errors.New("invalid key length")
)
var (
ErrMergedContextCanceled = errors.New("merged context canceled")
)
Functions ¶
func CloseFileAndRename ¶ added in v1.1.0
func CloseFileAndRename(fileDescriptor *os.File, sourceFilePath string, targetFilePath string) error
CloseFileAndRename closes the file descriptor and renames the file.
func CreateTempFile ¶ added in v1.1.0
CreateTempFile creates a file descriptor with _tmp as file extension.
func DirectoryEmpty ¶ added in v1.1.0
DirectoryEmpty returns whether the given directory is empty.
func EstimateRemainingTime ¶ added in v0.5.0
func EstimateRemainingTime(timeStart time.Time, current int64, total int64) (percentage float64, remaining time.Duration)
EstimateRemainingTime estimates the remaining time for a running operation and returns the finished percentage.
func FolderSize ¶ added in v1.0.5
FolderSize returns the size of a folder.
func LoadEd25519PrivateKeysFromEnvironment ¶ added in v1.0.0
func LoadEd25519PrivateKeysFromEnvironment(name string) ([]ed25519.PrivateKey, error)
LoadEd25519PrivateKeysFromEnvironment loads ed25519 private keys from the given environment variable.
func LoadStringFromEnvironment ¶ added in v1.0.0
LoadStringFromEnvironment loads a string from the given environment variable.
func MergeContexts ¶ added in v1.1.0
func MergeContexts(ctxPrimary context.Context, ctxSecondary context.Context) (context.Context, context.CancelFunc)
MergeContexts creates a new mergedContext based on two contexts.
func ParseEd25519PrivateKeyFromString ¶ added in v1.0.0
func ParseEd25519PrivateKeyFromString(key string) (ed25519.PrivateKey, error)
func ParseEd25519PublicKeyFromString ¶ added in v1.0.0
func RandomInsecure ¶
RandomInsecure returns a random int in the range of min to max. the result is not cryptographically secure. RandomInsecure is inclusive max value.
func ReadFromFile ¶ added in v1.0.0
ReadFromFile reads structured binary data from the file named by filename to data. A successful call returns err == nil, not err == EOF. ReadFromFile uses binary.Read to decode data. Data must be a pointer to a fixed-size value or a slice of fixed-size values.
func ReadJSONFromFile ¶ added in v1.0.0
ReadJSONFromFile reads JSON data from the file named by filename to data. ReadJSONFromFile uses json.Unmarshal to decode data. Data must be a pointer to a fixed-size value or a slice of fixed-size values.
func ReadTOMLFromFile ¶ added in v1.0.5
ReadTOMLFromFile reads TOML data from the file named by filename to data. ReadTOMLFromFile uses toml.Unmarshal to decode data. Data must be a pointer to a fixed-size value or a slice of fixed-size values.
func ReturnErrIfChannelClosed ¶ added in v1.2.0
ReturnErrIfChannelClosed returns the given error if the provided channel was closed.
func ReturnErrIfCtxDone ¶ added in v1.0.0
ReturnErrIfCtxDone returns the given error if the provided context is done.
func Uint32Diff ¶ added in v1.0.5
Uint32Diff returns the difference between newCount and oldCount and catches overflows
func WaitForChannelClosed ¶ added in v1.0.0
WaitForChannelClosed waits until the channel is closed or the context is done. If the context was done, the event should be manually deregistered afterwards to clean up memory.
func WriteJSONToFile ¶ added in v1.0.0
WriteJSONToFile writes the JSON representation of data to a file named by filename. If the file does not exist, WriteJSONToFile creates it with permissions perm (before umask); otherwise WriteJSONToFile truncates it before writing, without changing permissions. WriteJSONToFile uses json.MarshalIndent to encode data. Data must be a pointer to a fixed-size value or a slice of fixed-size values.
func WriteTOMLToFile ¶ added in v1.0.5
func WriteTOMLToFile(filename string, data interface{}, perm os.FileMode, header ...string) (err error)
WriteTOMLToFile writes the TOML representation of data to a file named by filename. If the file does not exist, WriteTOMLToFile creates it with permissions perm (before umask); otherwise WriteTOMLToFile truncates it before writing, without changing permissions. WriteTOMLToFile uses toml.Marshal to encode data. Data must be a pointer to a fixed-size value or a slice of fixed-size values. An additional header can be passed.
func WriteToFile ¶ added in v1.0.0
WriteToFile writes the binary representation of data to a file named by filename. If the file does not exist, WriteFile creates it with permissions perm (before umask); otherwise WriteFile truncates it before writing, without changing permissions. WriteToFile uses binary.Write to encode data. Data must be a pointer to a fixed-size value or a slice of fixed-size values.
Types ¶
type SyncEvent ¶ added in v1.0.0
func NewSyncEvent ¶ added in v1.0.0
func NewSyncEvent() *SyncEvent
func (*SyncEvent) DeregisterEvent ¶ added in v1.0.0
func (se *SyncEvent) DeregisterEvent(key interface{})
DeregisterEvent removes a registered event to free the memory if not used.
func (*SyncEvent) RegisterEvent ¶ added in v1.0.0
func (se *SyncEvent) RegisterEvent(key interface{}) chan struct{}
RegisterEvent creates a unique channel for the key which can be used to signal global events.
type TimeHeap ¶
type TimeHeap struct {
// contains filtered or unexported fields
}
TimeHeap implements a heap sorted by time, where older elements are popped during AveragePerSecond call.
func (*TimeHeap) AveragePerSecond ¶ added in v1.0.5
AveragePerSecond calculates the average per second of all entries in the given duration. older elements are removed from the container.
type WrappedLogger ¶ added in v1.1.0
type WrappedLogger struct {
// contains filtered or unexported fields
}
WrappedLogger is a wrapper to call logging functions in case a logger was passed.
func NewWrappedLogger ¶ added in v1.1.0
func NewWrappedLogger(logger *logger.Logger) *WrappedLogger
NewWrappedLogger creates a new WrappedLogger.
func (*WrappedLogger) LogDebug ¶ added in v1.1.0
func (l *WrappedLogger) LogDebug(args ...interface{})
LogDebug uses fmt.Sprint to construct and log a message.
func (*WrappedLogger) LogDebugf ¶ added in v1.1.0
func (l *WrappedLogger) LogDebugf(template string, args ...interface{})
LogDebugf uses fmt.Sprintf to log a templated message.
func (*WrappedLogger) LogError ¶ added in v1.1.0
func (l *WrappedLogger) LogError(args ...interface{})
LogError uses fmt.Sprint to construct and log a message.
func (*WrappedLogger) LogErrorf ¶ added in v1.1.0
func (l *WrappedLogger) LogErrorf(template string, args ...interface{})
LogErrorf uses fmt.Sprintf to log a templated message.
func (*WrappedLogger) LogFatal ¶ added in v1.1.0
func (l *WrappedLogger) LogFatal(args ...interface{})
LogFatal uses fmt.Sprint to construct and log a message, then calls os.Exit.
func (*WrappedLogger) LogFatalf ¶ added in v1.1.0
func (l *WrappedLogger) LogFatalf(template string, args ...interface{})
LogFatalf uses fmt.Sprintf to log a templated message, then calls os.Exit.
func (*WrappedLogger) LogInfo ¶ added in v1.1.0
func (l *WrappedLogger) LogInfo(args ...interface{})
LogInfo uses fmt.Sprint to construct and log a message.
func (*WrappedLogger) LogInfof ¶ added in v1.1.0
func (l *WrappedLogger) LogInfof(template string, args ...interface{})
LogInfof uses fmt.Sprintf to log a templated message.
func (*WrappedLogger) LogPanic ¶ added in v1.1.0
func (l *WrappedLogger) LogPanic(args ...interface{})
LogPanic uses fmt.Sprint to construct and log a message, then panics.
func (*WrappedLogger) LogPanicf ¶ added in v1.1.0
func (l *WrappedLogger) LogPanicf(template string, args ...interface{})
LogPanicf uses fmt.Sprintf to log a templated message, then panics.
func (*WrappedLogger) LogWarn ¶ added in v1.1.0
func (l *WrappedLogger) LogWarn(args ...interface{})
LogWarn uses fmt.Sprint to construct and log a message.
func (*WrappedLogger) LogWarnf ¶ added in v1.1.0
func (l *WrappedLogger) LogWarnf(template string, args ...interface{})
LogWarnf uses fmt.Sprintf to log a templated message.
func (*WrappedLogger) Logger ¶ added in v1.1.0
func (l *WrappedLogger) Logger() *logger.Logger
Logger return the underlying logger.
func (*WrappedLogger) LoggerNamed ¶ added in v1.1.0
func (l *WrappedLogger) LoggerNamed(name string) *logger.Logger
LoggerNamed adds a sub-scope to the logger's name. See Logger.Named for details.