Documentation ¶
Overview ¶
Index ¶
- Constants
- func ChunkString(s string, size int) []string
- func CleanString(in string) string
- func ContainsString(s string, a []string) bool
- func ContentTypeFromFileName(filename string) (string, error)
- func CreateDirectoryIfNotExists(path string) (bool, error)
- func DayStr(t time.Time) string
- func DotProductDistance(a, b []float64) (float64, error)
- func DotProductSimilarity(a, b []float64) (float64, error)
- func DotX(a []float64, b float64) []float64
- func DotXX(a [][]float64, b float64) [][]float64
- func ExistsOnDisk(path string) (bool, error)
- func FancyRandStr(length int) string
- func FastFail(failure string, args ...int)
- func FileExists(filename string) bool
- func FiveCharPrefix(s string) string
- func FliterFloat64Array(a []float64, filter func(f float64) bool) []float64
- func Folderify(filename string) string
- func GzipHandler(h http.Handler) http.Handler
- func Mapify(thing interface{}) (map[string]interface{}, error)
- func MaxInt(a, b int) int
- func MaxInt64(a, b int64) int64
- func MeanFloat64(a []float64) float64
- func MeanInt64(a []int64) float64
- func MedianFloat64(input []float64) (median float64)
- func MedianInt64(input []int64) (median float64)
- func MergeMaps[T comparable, U any](a map[T]U, b map[T]U) map[T]U
- func MinInt(a, b int) int
- func MinInt64(a, b int64) int64
- func MustNewGzipLevelHandler(level int) func(http.Handler) http.Handler
- func NewGzipLevelHandler(level int) (func(http.Handler) http.Handler, error)
- func NextID() string
- func NextId() string
- func ParseDuration(durationStr string) (time.Duration, error)
- func PrettyPrint[T any](r *T) string
- func RandStr100(length int) string
- func RandomString(length int, includeUpperCase bool, includeDigits bool) string
- func Reverse(input string) string
- func RunCommand(pwd string, name string, args ...string) (stdout, stderr string, err error)
- func SafeMarshal(s interface{}) (string, error)
- func SafeMarshalBytes(s interface{}) ([]byte, error)
- func SafeUnmarshal(encoded string, out interface{}) error
- func SafeUnmarshalBytes(compressedData []byte, out interface{}) error
- func Shuffle[K comparable](a []K) []K
- func SleepItOff(d time.Duration)
- func Spinner() string
- func StoragePathFromURL(url *url.URL) (string, error)
- func StringArrayContains(a []string, s string) bool
- func StringArraysHaveSameElements(a, b []string) bool
- func TruncFloat(f float64, prec int) (float64, error)
- func UniqueArray[K comparable](a []K) []K
- func UniqueIDForBlob(blob []byte, PrependFolder bool) string
- func Unzipb64(s string) (string, error)
- func Zipb64(s string) string
- type GzipResponseWriter
- type SortableFloat64Array
- type SortableInt64Array
- type SortableStringArray
Constants ¶
const DEFAULT_QVALUE = 1.0
The default qvalue to assign to an encoding if no explicit qvalue is set. This is actually kind of ambiguous in RFC 2616, so hopefully it's correct. The examples seem to indicate that it is.
Variables ¶
This section is empty.
Functions ¶
func ChunkString ¶ added in v0.2.4
ChunkString splits a string into chunks of the given size or smaller
func CleanString ¶ added in v0.3.13
func ContainsString ¶
func ContentTypeFromFileName ¶
func CreateDirectoryIfNotExists ¶ added in v0.3.7
func DotProductDistance ¶ added in v0.3.8
func DotProductSimilarity ¶ added in v0.3.8
func ExistsOnDisk ¶
func FancyRandStr ¶
func FastFail ¶ added in v0.2.2
FastFail is a GomegaFailHandler that, when run with `go test -failfast` , fails immidiately and halts other long running tests prints the line number of the test that failed from conversation with @onsi https://github.com/onsi/gomega/issues/660 this makes it possible to fail fast and not wait for all the tests to finish if they are going to fail usage: in your test, as the first line of the test, add this:
RegisterFailHandler(aliU.FastFail)
func FileExists ¶ added in v0.3.7
fileExists checks if a file exists and is not a directory
func FiveCharPrefix ¶
func FliterFloat64Array ¶
func GzipHandler ¶ added in v0.3.3
GzipHandler wraps an HTTP handler, to transparently gzip the response body if the client supports it (via the Accept-Encoding header). This will compress at the default compression level.
func Mapify ¶
Mapify converts any struct to a json friendly map of string to interface it expects the thing to have autogenerated json tags float64 are supported while ints are not Damn and embedded strucs are not flattened by default :p
func MeanFloat64 ¶
func MedianFloat64 ¶
func MedianInt64 ¶ added in v0.2.1
it returns the median of a slice of int64 it returns float64 because sometimes the median is not an int
func MergeMaps ¶ added in v0.3.5
func MergeMaps[T comparable, U any](a map[T]U, b map[T]U) map[T]U
func MustNewGzipLevelHandler ¶ added in v0.3.3
MustNewGzipLevelHandler behaves just like NewGzipLevelHandler except that in an error case it panics rather than returning an error.
func NewGzipLevelHandler ¶ added in v0.3.3
NewGzipLevelHandler returns a wrapper function (often known as middleware) which can be used to wrap an HTTP handler to transparently gzip the response body if the client supports it (via the Accept-Encoding header). Responses will be encoded at the given gzip compression level. An error will be returned only if an invalid gzip compression level is given, so if one can ensure the level is valid, the returned error can be safely ignored.
func NextID ¶
func NextID() string
NextID is used to generate sessionid s uses the time reverses it, to avoid problems like "hot hashes" and busy shards an overkill but a good practice
func NextId ¶
func NextId() string
used to generate sessionid s uses the time reverses it, to avoid problems like "hot hashes" and busy shards and over kill but a good practice
func ParseDuration ¶ added in v0.2.9
ParseDuration gets a string in the format of 01:03:04 and returns a time.Duration assuming this is hour:minutes:seconds
func PrettyPrint ¶ added in v0.3.12
func RandStr100 ¶
func RunCommand ¶ added in v0.3.7
func SafeMarshal ¶ added in v0.2.7
func SafeMarshalBytes ¶ added in v0.2.8
func SafeUnmarshal ¶ added in v0.2.6
func SafeUnmarshalBytes ¶ added in v0.2.8
func Shuffle ¶ added in v0.3.10
func Shuffle[K comparable](a []K) []K
func SleepItOff ¶
func StringArrayContains ¶
func TruncFloat ¶ added in v0.3.11
from https://stackoverflow.com/a/77009270/487855 prec controls the number of digits (excluding the exponent) prec of -1 uses the smallest number of digits
func UniqueArray ¶
func UniqueArray[K comparable](a []K) []K
func UniqueIDForBlob ¶
Types ¶
type GzipResponseWriter ¶ added in v0.3.3
type GzipResponseWriter struct { http.ResponseWriter // contains filtered or unexported fields }
GzipResponseWriter provides an http.ResponseWriter interface, which gzips bytes before writing them to the underlying response. This doesn't close the writers, so don't forget to do that.
func (*GzipResponseWriter) Close ¶ added in v0.3.3
func (w *GzipResponseWriter) Close() error
Close will close the gzip.Writer and will put it back in the gzipWriterPool.
func (*GzipResponseWriter) Flush ¶ added in v0.3.3
func (w *GzipResponseWriter) Flush()
Flush flushes the underlying *gzip.Writer and then the underlying http.ResponseWriter if it is an http.Flusher. This makes GzipResponseWriter an http.Flusher.
func (*GzipResponseWriter) Write ¶ added in v0.3.3
func (w *GzipResponseWriter) Write(b []byte) (int, error)
Write appends data to the gzip writer.
func (*GzipResponseWriter) WriteHeader ¶ added in v0.3.3
func (w *GzipResponseWriter) WriteHeader(code int)
WriteHeader will check if the gzip writer needs to be lazily initiated and then pass the code along to the underlying ResponseWriter.
type SortableFloat64Array ¶
type SortableFloat64Array []float64
func (SortableFloat64Array) Len ¶
func (a SortableFloat64Array) Len() int
func (SortableFloat64Array) Less ¶
func (a SortableFloat64Array) Less(i, j int) bool
func (SortableFloat64Array) Swap ¶
func (a SortableFloat64Array) Swap(i, j int)
type SortableInt64Array ¶ added in v0.2.1
type SortableInt64Array []int64
func (SortableInt64Array) Len ¶ added in v0.2.1
func (a SortableInt64Array) Len() int
func (SortableInt64Array) Less ¶ added in v0.2.1
func (a SortableInt64Array) Less(i, j int) bool
func (SortableInt64Array) Swap ¶ added in v0.2.1
func (a SortableInt64Array) Swap(i, j int)
type SortableStringArray ¶
type SortableStringArray []string
func (SortableStringArray) Len ¶
func (a SortableStringArray) Len() int
func (SortableStringArray) Less ¶
func (a SortableStringArray) Less(i, j int) bool
func (SortableStringArray) Swap ¶
func (a SortableStringArray) Swap(i, j int)