util

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatErrorList added in v0.0.7

func FormatErrorList(errList []error) error

FormatErrorList() is a wrapper function that unifies error list formatting and makes printing error lists consistent.

NOTE: The error returned IS NOT an error in itself and may be a bit misleading. Instead, it is a single condensed error composed of all of the errors included in the errList argument.

func GetNextIP

func GetNextIP(ip *net.IP, inc uint) *net.IP

GetNextIP() returns the next IP address, but does not account for net masks.

func HasErrors added in v0.0.7

func HasErrors(errList []error) bool

HasErrors() is a simple wrapper function to check if an error list contains errors. Having a function that clearly states its purpose helps to improve readibility although it may seem pointless.

func MakeOutputDirectory

func MakeOutputDirectory(path string) (string, error)

MakeOutputDirectory() creates a new directory at the path argument if the path does not exist

TODO: Refactor this function for hive partitioning or possibly move into the logging package. TODO: Add an option to force overwriting the path.

func MakeRequest

func MakeRequest(client *http.Client, url string, httpMethod string, body []byte, headers map[string]string) (*http.Response, []byte, error)

MakeRequest() is a wrapper function that condenses simple HTTP requests done to a single call. It expects an optional HTTP client, URL, HTTP method, request body, and request headers. This function is useful when making many requests where only these few arguments are changing.

Returns a HTTP response object, response body as byte array, and any error that may have occurred with making the request.

func PathExists

func PathExists(path string) (bool, error)

PathExists() is a wrapper function that simplifies checking if a file or directory already exists at the provided path.

Returns whether the path exists and no error if successful, otherwise, it returns false with an error.

func SplitPathForViper added in v0.0.7

func SplitPathForViper(path string) (string, string, string)

SplitPathForViper() is an utility function to split a path into 3 parts: - directory - filename - extension The intent was to break a path into a format that's more easily consumable by spf13/viper's API. See the "LoadConfig()" function in internal/config.go for more details.

TODO: Rename function to something more generalized.

Types

This section is empty.

Jump to

Keyboard shortcuts

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