Documentation ¶
Index ¶
- Constants
- func BaseFileName(path string) string
- func Colorize(color ColorCode, s string) string
- func ColorizeBlue(s string) string
- func ColorizeGreen(s string) string
- func ColorizePurple(s string) string
- func ColorizeRed(s string) string
- func ColorizeWhite(s string) string
- func ColorizeYellow(s string) string
- func CopyFile(srcPath, dstPath string) error
- func Fatal(err error, args ...any)
- func FatalIf(err error, v ...any)
- func FileExists(path string) bool
- func Filter[F any](list []F, predicate func(F) bool) []F
- func Find[F any](list []F, predicate func(F) bool) (F, bool)
- func FormatSimpleDate(ts *time.Time) string
- func FormatTimeSince(ts *time.Time) string
- func HashStrings(vals ...string) (string, error)
- func Init(level slog.Level, application string)
- func Map[F any, G any](list []F, mapper func(F) G) []G
- func Marshal(payload any) (io.Reader, error)
- func MarshalToString(payload any) (string, error)
- func Min(vals ...int) int
- func ReadAllString(rdr io.Reader) (string, error)
- func ShortID() string
- func SliceEqual[F any](first, second []F, comparator Comparator[F]) bool
- func StringSliceEqual(first, second []string) bool
- func TokenFromFile(path string) (*oauth2.Token, error)
- func Unmarshal[T any](rdr io.Reader) (*T, error)
- func UnmarshalFromString[T any](str string) (*T, error)
- func WrapError(err error) error
- type ColorCode
- type Comparator
- type LogHandler
- type RequestBuilder
- func (rb *RequestBuilder) Do(ctx context.Context) (*http.Response, error)
- func (rb *RequestBuilder) Get() *RequestBuilder
- func (rb *RequestBuilder) Post() *RequestBuilder
- func (rb *RequestBuilder) SetClient(client *http.Client) *RequestBuilder
- func (rb *RequestBuilder) SetMethod(method string) *RequestBuilder
- func (rb *RequestBuilder) SetParams(params map[string]string) *RequestBuilder
- func (rb *RequestBuilder) SetPayload(payload any) *RequestBuilder
- func (rb *RequestBuilder) SetUrl(url string) *RequestBuilder
- type Set
- type StackError
Constants ¶
const ( DurationDay = 24 * time.Hour DurationYear = 365 * DurationDay )
Variables ¶
This section is empty.
Functions ¶
func BaseFileName ¶
func ColorizeBlue ¶ added in v0.3.4
func ColorizeGreen ¶ added in v0.3.4
func ColorizePurple ¶ added in v0.3.4
func ColorizeRed ¶ added in v0.3.4
func ColorizeWhite ¶ added in v0.3.4
func ColorizeYellow ¶ added in v0.3.4
func FileExists ¶
func FormatSimpleDate ¶ added in v0.2.12
func FormatTimeSince ¶ added in v0.2.12
func HashStrings ¶
HashStrings computes the hash of the given strings by hashing the strings together into an int representation and then converting that to a string to keep the resulting string small
func Init ¶
Init creates a slog logger instance with a custom LogHandler and sets it as the default logger
func MarshalToString ¶
func SliceEqual ¶ added in v0.2.12
func SliceEqual[F any](first, second []F, comparator Comparator[F]) bool
func StringSliceEqual ¶ added in v0.2.12
func TokenFromFile ¶
TokenFromFile will attempt to parse an oauth token at the provided file path
func UnmarshalFromString ¶
Types ¶
type ColorCode ¶ added in v0.3.4
type ColorCode string
const ( ColorCodeReset ColorCode = "\033[0m" ColorCodeRed ColorCode = "\033[38;2;214;48;49m" ColorCodeGreen ColorCode = "\033[38;2;46;204;113m" ColorCodeYellow ColorCode = "\033[38;2;241;196;15m" ColorCodeBlue ColorCode = "\033[38;2;9;132;227m" ColorCodePurple ColorCode = "\033[38;2;155;89;182m" ColorCodeWhite ColorCode = "\033[37m" )
type Comparator ¶ added in v0.2.12
type LogHandler ¶ added in v0.2.13
type LogHandler struct {
// contains filtered or unexported fields
}
LogHandler is a custom slog handler that outputs to stdout
func (*LogHandler) Enabled ¶ added in v0.2.13
Enabled only records the log if the record's log level is greater than or equal to the handlers log level
func (*LogHandler) Handle ¶ added in v0.2.13
Handle outputs the log record to stdout. Since this logger is meant to be used for local applications with a small amount of output, it will not log the timestamps.
type RequestBuilder ¶
type RequestBuilder struct {
// contains filtered or unexported fields
}
func NewRequest ¶
func NewRequest() *RequestBuilder
func (*RequestBuilder) Get ¶
func (rb *RequestBuilder) Get() *RequestBuilder
func (*RequestBuilder) Post ¶
func (rb *RequestBuilder) Post() *RequestBuilder
func (*RequestBuilder) SetClient ¶
func (rb *RequestBuilder) SetClient(client *http.Client) *RequestBuilder
func (*RequestBuilder) SetMethod ¶
func (rb *RequestBuilder) SetMethod(method string) *RequestBuilder
func (*RequestBuilder) SetParams ¶
func (rb *RequestBuilder) SetParams(params map[string]string) *RequestBuilder
func (*RequestBuilder) SetPayload ¶
func (rb *RequestBuilder) SetPayload(payload any) *RequestBuilder
func (*RequestBuilder) SetUrl ¶
func (rb *RequestBuilder) SetUrl(url string) *RequestBuilder
type Set ¶
type Set[K comparable] map[K]struct{}
func NewSet ¶
func NewSet[K comparable](items ...K) Set[K]
type StackError ¶ added in v0.3.1
type StackError struct {
// contains filtered or unexported fields
}
StackError wraps an error with the stack information where the error occurred. Note that since stack is saved during creation we need to create this at the exact location where the base error is thrown and not at a higher level.
func (*StackError) Error ¶ added in v0.3.1
func (s *StackError) Error() string
func (*StackError) Unwrap ¶ added in v0.3.1
func (s *StackError) Unwrap() error