Documentation ¶
Index ¶
- func CopyDir(src string, dst string) error
- func CopyFile(src, dst string) (int64, error)
- func CreateShutdownChannel() chan os.Signal
- func Exists(fn string) bool
- func GetAPIURLFromJWT(jwtString string) (string, error)
- func GetFreePort() (port int, err error)
- func GzipFile(filepath string) error
- func IsLocalhost(url string) bool
- func IsRunningInsideDocker() bool
- func ListDir(dir string) ([]string, error)
- func LocalIP() (string, error)
- func ProcessDirWithDecoder(dir string, callback ProcessDirWithDecoderCallback) error
- func RecoverPanic(logger logger.Logger)
- func TarGz(srcDir string, outfile *os.File) error
- func Unzip(src, dest string, flatten bool) error
- func WriteJSON(filename string, v any) error
- func WriteJSONLAppend(filename string, v []interface{}) error
- type Environment
- type JSONDecoder
- type JSONEncoder
- type ProcessDirWithDecoderCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateShutdownChannel ¶
CreateShutdownChannel returns a channel which can be used to block for a termination signal (SIGTERM, SIGINT, etc)
func Exists ¶ added in v0.0.71
Exists returns true if the filename or directory specified by fn exists.
func GetAPIURLFromJWT ¶ added in v0.0.71
GetAPIURLFromJWT extracts the API URL from a JWT token
func GetFreePort ¶ added in v0.0.71
GetFreePort asks the kernel for a free open port that is ready to use.
func IsLocalhost ¶ added in v0.0.71
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
ListDir will return an array of files recursively walking into sub directories
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
RecoverPanic recovers from a panic and logs the error along with the current goroutines.
func WriteJSONLAppend ¶ added in v0.0.71
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