sysutil

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 9 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTemplate

func CreateTemplate(templatePath string) (*template.Template, error)

CreateTemplate takes in a path to a template file and parses the file to create a Template instance.

func GetEnvIntOrDefault

func GetEnvIntOrDefault(key string, def int) int

func GetEnvStringOrDefault

func GetEnvStringOrDefault(key, def string) string

func GetRequiredEnvInt

func GetRequiredEnvInt(key string) int

func GetRequiredEnvString

func GetRequiredEnvString(key string) string

func WaitForDir

func WaitForDir(path string, clock ClockInterface, interval time.Duration) error

WaitForDir returns when the specified directory is located in the filesystem, or if there is an error opening the directory once it is found.

Types

type Clock

type Clock struct{}

Clock implements ClockInterface with the standard time library functions.

func (*Clock) Now

func (c *Clock) Now() time.Time

func (*Clock) Sleep

func (c *Clock) Sleep(d time.Duration)

type ClockInterface

type ClockInterface interface {
	Now() time.Time
	Sleep(time.Duration)
}

ClockInterface allows for mocking out the functionality of the standard time library when testing.

type FileSystem

type FileSystem struct{}

FileSystem provides utility functions for interacting with the file system.

func (*FileSystem) ReadLines

func (fs *FileSystem) ReadLines(filePath string) ([]string, error)

ReadLines opens the file located at the path and reads each line into a []string.

type FileSystemInterface

type FileSystemInterface interface {
	ReadLines(filePath string) ([]string, error)
}

FileSystemInterface allows for mocking out the functionality of FileSystem to avoid calls to the actual file system during testing.

type MockClockInterface

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

Mock of ClockInterface interface

func NewMockClockInterface

func NewMockClockInterface(ctrl *gomock.Controller) *MockClockInterface

func (*MockClockInterface) EXPECT

func (_m *MockClockInterface) EXPECT() *_MockClockInterfaceRecorder

func (*MockClockInterface) Now

func (_m *MockClockInterface) Now() time.Time

func (*MockClockInterface) Since

func (_m *MockClockInterface) Since(_param0 time.Time) time.Duration

func (*MockClockInterface) Sleep

func (_m *MockClockInterface) Sleep(_param0 time.Duration)

type MockFileSystemInterface

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

Mock of FileSystemInterface interface

func NewMockFileSystemInterface

func NewMockFileSystemInterface(ctrl *gomock.Controller) *MockFileSystemInterface

func (*MockFileSystemInterface) EXPECT

func (_m *MockFileSystemInterface) EXPECT() *_MockFileSystemInterfaceRecorder

func (*MockFileSystemInterface) ListAllFiles

func (_m *MockFileSystemInterface) ListAllFiles(_param0 string) ([]string, error)

func (*MockFileSystemInterface) ReadLines

func (_m *MockFileSystemInterface) ReadLines(_param0 string) ([]string, error)

Jump to

Keyboard shortcuts

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