Documentation ¶
Index ¶
- Constants
- Variables
- func AreSlicesIntersect[T comparable](slice1, slice2 []T) bool
- func CloneRequestBody(r *http.Request) (body string)
- func CloneResponseBody(r *http.Response) (body string)
- func CloserFunc(r io.Reader, close func() error) io.ReadCloser
- func DeepCopy[T any](v T) (c T, err error)
- func DurationUntilNextInterval(now time.Time, interval time.Duration) time.Duration
- func EscapeChars(str string, chars map[rune]struct{}) string
- func EscapeJSONString(str string, level int) string
- func FillEmptyIP(ipv4, ipv6 string) (string, string)
- func First[T any](arr []T) (f T)
- func FuncName() string
- func GetFirst(str string) string
- func GetRequestIP(r *http.Request) (requestIP string)
- func GetSecond(str string) string
- func IsInSlice[T comparable](i T, slice []T) bool
- func JoinIPVersions(ipv4, ipv6 string) (ip string)
- func JoinParams(first, second string) string
- func JoinQuoted(lines []string, quote, separator string) string
- func JoinQuotedInt(lines []int, quote, separator string) string
- func Last[T any](arr []T) (f T)
- func Must[T any](v T, err error) T
- func PanicOnError(err error)
- func ParseFields(structPtr any, parser TagsParser) error
- func Range[T int | int8 | int16 | int32 | int64 | float32 | float64](start, end T) []T
- func Retry(f func() error, times int)
- func RetryOverTime(f func() error, timeout time.Duration, tick time.Duration) error
- func SQLReplaceArgs(query string, args ...any) string
- func SetCORS(w http.ResponseWriter)
- func SetContentTypeHeader(w http.ResponseWriter, contentType ContentType)
- func SplitIPVersions(ip string) (ipv4, ipv6 string)
- func ToUnderscoreACII(s string) (underscored string)
- func UnGzipBody(bodyContent []byte) ([]byte, error)
- func WrapForCORS(handler http.Handler) http.Handler
- type Commission
- type ContentType
- type DeepCopier
- type Diff
- type Diffs
- type Distribution
- type ExpiringStorage
- type Percent
- type QueryDecoder
- type QueryEncoder
- type QueryMarshaller
- type QueryUnmarshaler
- type Request
- type SQLStringValue
- type Set
- type TagsParser
- type UnixTime
Constants ¶
View Source
const ( ZeroIPv4 = "0.0.0.0" ZeroIPv6 = "0000:0000:0000:0000:0000:0000:0000:0000" )
Variables ¶
Functions ¶
func AreSlicesIntersect ¶
func AreSlicesIntersect[T comparable](slice1, slice2 []T) bool
func CloneRequestBody ¶
func CloneResponseBody ¶
func CloserFunc ¶
func CloserFunc(r io.Reader, close func() error) io.ReadCloser
func EscapeChars ¶
func EscapeJSONString ¶ added in v0.0.3
func FillEmptyIP ¶
func GetRequestIP ¶
func IsInSlice ¶
func IsInSlice[T comparable](i T, slice []T) bool
func JoinIPVersions ¶
func JoinParams ¶
func JoinQuoted ¶
func JoinQuotedInt ¶
func PanicOnError ¶ added in v0.0.3
func PanicOnError(err error)
func ParseFields ¶ added in v0.0.3
func ParseFields(structPtr any, parser TagsParser) error
func RetryOverTime ¶
func SQLReplaceArgs ¶
func SetCORS ¶
func SetCORS(w http.ResponseWriter)
func SetContentTypeHeader ¶
func SetContentTypeHeader(w http.ResponseWriter, contentType ContentType)
func SplitIPVersions ¶
func ToUnderscoreACII ¶
func UnGzipBody ¶
Types ¶
type Commission ¶
type Commission Percent
func (Commission) AddTo ¶
func (e Commission) AddTo(value float64) float64
func (Commission) SubtractFrom ¶
func (e Commission) SubtractFrom(value float64) float64
type ContentType ¶
type ContentType string
const ( ContentTypeApplicationJSON ContentType = "application/json" ContentTypeTextHTML ContentType = "text/html" )
type DeepCopier ¶ added in v0.0.3
type DeepCopier interface {
DeepCopy() interface{}
}
type Distribution ¶
type Distribution []float64
func (*Distribution) GetMax ¶
func (d *Distribution) GetMax() float64
func (*Distribution) GetMin ¶
func (d *Distribution) GetMin() float64
func (*Distribution) GetQuantileValue ¶
func (d *Distribution) GetQuantileValue(quantileNumber uint) float64
func (*Distribution) TrimMax ¶
func (d *Distribution) TrimMax(difference float64)
TrimMax sorts and trims max values if difference is too big, difference 0.25 means 25% between max values
type ExpiringStorage ¶ added in v0.0.4
type ExpiringStorage[K comparable, V any] struct { // contains filtered or unexported fields }
func NewExpiringStorage ¶ added in v0.0.4
func NewExpiringStorage[K comparable, V any](expirationTimeout time.Duration, cleanupInterval time.Duration) *ExpiringStorage[K, V]
func (*ExpiringStorage[K, V]) Get ¶ added in v0.0.4
func (e *ExpiringStorage[K, V]) Get(key K) (value V)
func (*ExpiringStorage[K, V]) Keys ¶ added in v0.0.5
func (e *ExpiringStorage[K, V]) Keys() []K
func (*ExpiringStorage[K, V]) Len ¶ added in v0.0.4
func (e *ExpiringStorage[K, V]) Len() int
func (*ExpiringStorage[K, V]) Run ¶ added in v0.0.4
func (e *ExpiringStorage[K, V]) Run(ctx context.Context)
func (*ExpiringStorage[K, V]) Set ¶ added in v0.0.5
func (e *ExpiringStorage[K, V]) Set(key K, value V)
type Percent ¶
type Percent float64
const (
OnePercent Percent = 0.01
)
func PercentFrom ¶
func (*Percent) MarshalJSON ¶
func (Percent) ScaleReversed ¶
ScaleReversed returns 100% imply that val is p%
func (*Percent) UnmarshalJSON ¶
type QueryDecoder ¶ added in v0.0.3
type QueryDecoder struct {
// contains filtered or unexported fields
}
func NewQueryDecoder ¶ added in v0.0.3
func NewQueryDecoder(query url.Values) *QueryDecoder
func (*QueryDecoder) AddTypeParsing ¶ added in v0.0.3
func (qp *QueryDecoder) AddTypeParsing(typeSample any, parseFunc func(string) (any, error))
func (*QueryDecoder) DecodeQuery ¶ added in v0.0.3
func (qp *QueryDecoder) DecodeQuery(dst any) error
func (*QueryDecoder) ParseTags ¶ added in v0.0.3
func (qp *QueryDecoder) ParseTags(fieldVal reflect.Value, tags []string) error
func (*QueryDecoder) TagName ¶ added in v0.0.3
func (qp *QueryDecoder) TagName() string
type QueryEncoder ¶ added in v0.0.3
type QueryEncoder struct {
// contains filtered or unexported fields
}
func NewQueryEncoder ¶ added in v0.0.3
func NewQueryEncoder(query url.Values) *QueryEncoder
func (*QueryEncoder) EncodeQuery ¶ added in v0.0.3
func (qe *QueryEncoder) EncodeQuery(src any) error
func (*QueryEncoder) ParseTags ¶ added in v0.0.3
func (qe *QueryEncoder) ParseTags(fieldVal reflect.Value, tags []string) error
func (*QueryEncoder) TagName ¶ added in v0.0.3
func (qe *QueryEncoder) TagName() string
type QueryMarshaller ¶ added in v0.0.3
type QueryUnmarshaler ¶ added in v0.0.3
type Request ¶ added in v0.0.4
type SQLStringValue ¶
type SQLStringValue string
func ToSQLStringValue ¶
func ToSQLStringValue(lines ...string) []SQLStringValue
type Set ¶
type Set[data comparable] map[data]struct{}
func NewSet ¶
func NewSet[T comparable]() Set[T]
type TagsParser ¶ added in v0.0.3
type UnixTime ¶ added in v0.0.3
func (*UnixTime) MarshalQuery ¶ added in v0.0.3
func (*UnixTime) UnmarshalQuery ¶ added in v0.0.3
Click to show internal directories.
Click to hide internal directories.