sys

package
v0.0.76 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDir added in v0.0.6

func CopyDir(src string, dst string) error

CopyDir will copy all files recursively from src to dst

func CopyFile added in v0.0.6

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

CopyFile will copy src to dst

func CreateShutdownChannel

func CreateShutdownChannel() chan os.Signal

CreateShutdownChannel returns a channel which can be used to block for a termination signal (SIGTERM, SIGINT, etc)

func Exists added in v0.0.71

func Exists(fn string) bool

Exists returns true if the filename or directory specified by fn exists.

func GetAPIURLFromJWT added in v0.0.71

func GetAPIURLFromJWT(jwtString string) (string, error)

GetAPIURLFromJWT extracts the API URL from a JWT token

func GetFreePort added in v0.0.71

func GetFreePort() (port int, err error)

GetFreePort asks the kernel for a free open port that is ready to use.

func GzipFile added in v0.0.71

func GzipFile(filepath string) error

GzipFile compresses a file using gzip.

func IsLocalhost added in v0.0.71

func IsLocalhost(url string) bool

IsLocalhost returns true if the URL is localhost or 127.0.0.1 or 0.0.0.0.

func IsRunningInsideDocker added in v0.0.71

func IsRunningInsideDocker() bool

IsRunningInsideDocker returns true if the process is running inside a docker container.

func ListDir added in v0.0.71

func ListDir(dir string) ([]string, error)

ListDir will return an array of files recursively walking into sub directories

func LocalIP added in v0.0.6

func LocalIP() (string, error)

LocalIP will return the local ipaddress for the machine

func ProcessDirWithDecoder added in v0.0.71

func ProcessDirWithDecoder(dir string, callback ProcessDirWithDecoderCallback) error

ProcessDirWithDecoder will process all the JSON files in directory and call the callback

func RecoverPanic added in v0.0.71

func RecoverPanic(logger logger.Logger)

RecoverPanic recovers from a panic and logs the error along with the current goroutines.

func TarGz added in v0.0.71

func TarGz(srcDir string, outfile *os.File) error

func Unzip added in v0.0.71

func Unzip(src, dest string, flatten bool) error

Unzip a file to a directory

func WriteJSON added in v0.0.71

func WriteJSON(filename string, v any) error

func WriteJSONLAppend added in v0.0.71

func WriteJSONLAppend(filename string, v []interface{}) error

Types

type Environment added in v0.0.49

type Environment string
const (
	Stable  Environment = "stable"
	Sandbox Environment = "sandbox"
	Edge    Environment = "edge"
	Dev     Environment = "dev"
)

func GetEnvironment added in v0.0.49

func GetEnvironment() (Environment, error)

func MustGetEnvironment added in v0.0.49

func MustGetEnvironment() Environment

func NewEnvironment added in v0.0.49

func NewEnvironment(env string) (Environment, error)

func (Environment) String added in v0.0.50

func (e Environment) String() string

type JSONDecoder added in v0.0.71

type JSONDecoder interface {
	Decode(v any) error
	// More returns true if there are more items in the stream
	More() bool
	// Count returns the number of records read
	Count() int
	// Close a stream
	Close() error
}

func NewNDJSONDecoder added in v0.0.71

func NewNDJSONDecoder(fn string) (JSONDecoder, error)

NewNDJSONDecoder returns a decoder which can be used to read JSON new line delimited files

type JSONEncoder added in v0.0.71

type JSONEncoder interface {
	// Encode will encode v as a new line delimited JSON encoded string
	Encode(v any) error
	// Close a stream
	Close() error
	// Count returns the number of records written
	Count() int
}

JSONEncoder is an encoder that will allow you to encode one or more objects as JSON newline delimited output

func NewNDJSONEncoder added in v0.0.71

func NewNDJSONEncoder(fn string) (JSONEncoder, error)

NewNDJSONEncoder will return a JSONEncoder which allows you to stream json as new line delimited JSON

func NewNDJSONEncoderAppend added in v0.0.71

func NewNDJSONEncoderAppend(fn string) (JSONEncoder, error)

type ProcessDirWithDecoderCallback added in v0.0.71

type ProcessDirWithDecoderCallback func(decoder JSONDecoder, filename string) error

Jump to

Keyboard shortcuts

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