Documentation ¶
Index ¶
- func ApplyOnType[T any](t *T, tFuncs []func(*T))
- func FTWSTHf(formatString string, vals ...interface{}) string
- func IsNonNilPointer(v interface{}) bool
- func JSONResponse(w http.ResponseWriter, out any, optfuncs ...jSONRespOptFunc)
- func Line(x float64) float64
- func LogOnError(err error, msg string)
- func Map[T Numeric](input, inputStart, inputEnd, outputStart, outputEnd T) T
- func Must(err error, msgs ...string)
- func NewImageReaderFromUrl(endpoint string) (io.ReadCloser, error)
- func OptimisticAtoi(inp string) int
- func RandNegOneOne() float64
- func ReadBodyAsString(r *http.Request) string
- func Sample[T any](slice []T) T
- func Sigmoid(x float64) float64
- func Sign[T Numeric](inp T) T
- func WithStatusCode(statusCode int) jSONRespOptFunc
- type GenericMap
- type Numeric
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyOnType ¶
func ApplyOnType[T any](t *T, tFuncs []func(*T))
ApplyOnType takes the address of type `t` and an array of functions that do something with this type, and applies the functions to the type.
func FTWSTHf ¶
FTWSTHf adds a message at the end of the given string, indicating the developer's frustration. It takes a format string as its main input so go nuts.
func IsNonNilPointer ¶
func IsNonNilPointer(v interface{}) bool
func JSONResponse ¶
func JSONResponse(w http.ResponseWriter, out any, optfuncs ...jSONRespOptFunc)
JSONResponse marshalls the argument `out` into JSON and response on the provided ResponseWriter. Options can be provided to further modidy the response.
func LogOnError ¶
func Must ¶
Must is a quick way to panic in programs if an error exists with a helpful message being printed. It helps avoid having check for errors at every step of a top-level program.
func NewImageReaderFromUrl ¶
func NewImageReaderFromUrl(endpoint string) (io.ReadCloser, error)
func OptimisticAtoi ¶
OptimisticAtoi is the, well, optimistic version of the stdlib's Atoi function. It assumes the conversion will succeed for sure. Don't use in production.
func RandNegOneOne ¶
func RandNegOneOne() float64
func ReadBodyAsString ¶
func WithStatusCode ¶
func WithStatusCode(statusCode int) jSONRespOptFunc
WithStatusCode allows modifying the status code of the JSON response. The default is 200 OK.
Types ¶
type GenericMap ¶
type GenericMap map[string]interface{}
type Numeric ¶
type Numeric interface { constraints.Signed | constraints.Float }