util

package
v0.0.0-...-76c1feb Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWatchdogStreamReaderReaderReachedDataLimit = fmt.Errorf("watchdog stream reader reached data limit")

ErrWatchdogStreamReaderReaderReachedDataLimit is returned when watchdogStreamReader was asked to read beyond the designated data limits

View Source
var ErrWatchdogStreamReaderTimerElapsed = fmt.Errorf("watchdog stream reader timer elapsed")

ErrWatchdogStreamReaderTimerElapsed is returned when the watchdogStreamReader was not reset in the past readaheadDuration and read was attempted

Functions

func CopyFile

func CopyFile(src, dst string) (int64, error)

CopyFile uses io.Copy() to copy a file to another location This was copied from https://opensource.com/article/18/6/copying-files-go

func CopyFolder

func CopyFolder(source, dest string) error

CopyFolder recursively copies an entire directory to another location (ignoring symlinks)

func CopyFolderWithFilter

func CopyFolderWithFilter(source, dest string, includeFilter IncludeFilter) (err error)

CopyFolderWithFilter recursively copies an entire directory to another location (ignoring symlinks) with an optional filter function to include/exclude folders or files

func ExeDir

func ExeDir() (string, error)

ExeDir returns the absolute path to the current executing binary (not including the filename)

func ExecAndCaptureOutput

func ExecAndCaptureOutput(command string, args ...string) (string, string, error)

ExecAndCaptureOutput runs the specified command and args and captures stdout into a string, returning the string or an error upon completion.

func FileExists

func FileExists(filePath string) bool

FileExists checks to see if the specified file (or directory) exists

func FindProcess

func FindProcess(pid int) (*os.Process, error)

FindProcess looks for a running process by its pid

func GetCurrentProcessTimes

func GetCurrentProcessTimes() (utime int64, stime int64, err error)

GetCurrentProcessTimes gets current process kernel and usermode times

func GetFirstLineFromFile

func GetFirstLineFromFile(netFile string) (string, error)

GetFirstLineFromFile retrieves the first line of the specified file.

func Getrusage

func Getrusage(who int, rusage *syscall.Rusage) (err error)

Getrusage gets file descriptors usage statistics

func IsDir

func IsDir(path string) bool

IsDir returns true if the specified directory is valid

func KillProcess

func KillProcess(pid int, sig syscall.Signal) error

KillProcess kills a running OS process

func RaiseRlimit

func RaiseRlimit(amount uint64) error

RaiseRlimit increases the number of file descriptors we can have

Types

type IncludeFilter

type IncludeFilter func(name string, info os.FileInfo) bool

IncludeFilter is a callback for filtering files and folders encountered while copying with CopyFileWithFilter()

type WatchdogStreamReader

type WatchdogStreamReader interface {
	Reset() error
	Read(p []byte) (n int, err error)
	Close()
}

WatchdogStreamReader is the public interface for the watchdogStreamReader implementation.

func MakeWatchdogStreamReader

func MakeWatchdogStreamReader(underlayingReader io.Reader, readSize uint64, readaheadSize uint64, readaheadDuration time.Duration) WatchdogStreamReader

MakeWatchdogStreamReader creates a watchdogStreamReader and initializes it.

Directories

Path Synopsis
Package bloom implements Bloom filters.
Package bloom implements Bloom filters.
Package db defines database utility functions.
Package db defines database utility functions.
Package metrics provides a metric logging wrappers for Prometheus server.
Package metrics provides a metric logging wrappers for Prometheus server.
Package timers provides a Clock abstraction useful for simulating timeouts.
Package timers provides a Clock abstraction useful for simulating timeouts.

Jump to

Keyboard shortcuts

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