mango

package module
v0.2.11 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 17 Imported by: 0

README

mango

a smattering of helper utilities for golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseFileName

func BaseFileName(path string) string

func CopyFile

func CopyFile(srcPath, dstPath string) error

func Debug

func Debug(v ...any)

func Debugf

func Debugf(format string, v ...any)

func Error

func Error(v ...any)

func Errorf

func Errorf(v ...any)

func Fatal

func Fatal(v ...any)

func FatalIf

func FatalIf(err error, v ...any)

func FileExists

func FileExists(path string) bool

func Filter

func Filter[F any](list []F, predicate func(F) bool) []F

func HashStrings

func HashStrings(vals ...string) (string, error)

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 Info

func Info(v ...any)

func Infof

func Infof(format string, v ...any)

func Init

func Init(level LogLevel, prefix string)

func Map

func Map[F any, G any](list []F, mapper func(F) G) []G

func Marshal

func Marshal(payload any) (io.Reader, error)

func MarshalToString

func MarshalToString(payload any) (string, error)

func ReadAllString

func ReadAllString(rdr io.Reader) (string, error)

func ShortID

func ShortID() string

func TokenFromFile

func TokenFromFile(path string) (*oauth2.Token, error)

TokenFromFile will attempt to parse an oauth token at the provided file path

func Unmarshal

func Unmarshal[T any](rdr io.Reader) (*T, error)

func UnmarshalFromString

func UnmarshalFromString[T any](str string) (*T, error)

func Warning

func Warning(v ...any)

func Warningf

func Warningf(format string, v ...any)

Types

type LogLevel

type LogLevel int8
const (
	LogLevelDebug LogLevel = iota
	LogLevelInfo
	LogLevelWarning
	LogLevelError
)

func (LogLevel) String

func (l LogLevel) String() string

type RequestBuilder

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

func NewRequest

func NewRequest() *RequestBuilder

func (*RequestBuilder) Do

func (rb *RequestBuilder) Do(ctx context.Context) (*http.Response, error)

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]

func (Set[K]) Add

func (s Set[K]) Add(item K)

func (Set[K]) Delete

func (s Set[K]) Delete(item K) bool

func (Set[K]) Has

func (s Set[K]) Has(item K) bool

func (Set[K]) Size

func (s Set[K]) Size() int

Jump to

Keyboard shortcuts

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