modulepackage
0.0.0-20240701125551-843bc5e3be55
Repository: https://github.com/programmfabrik/golib.git
Documentation: pkg.go.dev
# README
go-lib
# Functions
AbsPathExecutable prefixes p with the path to the currently running executable if p is not absolute.
AddToQuery adds qv (key, value) to query.
AnyToStrSlice converts a slice of string to slice of interface.
ArrayContainsStrs returns true if arr contains any of the passed strings.
No description provided by the author
BoolRef.
No description provided by the author
CutRunes works like CutStr but counts runes not bytes.
CutStr cuts s if is longer than "len" When a string is cut, the suffix is added.
CutStrInArray cuts each string inside the given array to the given length and adds the suffix is the string was cut.
DebugValues takes a slice of T and returns and ordered list each item rendered in a comma separated list.
DecryptAES takes a base64 encoded cryptedText and decrypt it to text using provided secretKey.
No description provided by the author
DurationRef returns a refernece to the given Duration.
EncryptAES encrypts text to cryptedText using the secretKey.
No description provided by the author
FileMimeType returns the content-type of a file.
FilepathAbs returns the file's absolute path, relative to the startDir.
Float64Ref returns a refernce to the given float64.
No description provided by the author
FoldStr uses ICU folding on s.
No description provided by the author
No description provided by the author
No description provided by the author
GenerateOTP creates a random string from the given chars.
GetBool returns bool from a string.
GetEnv returns the os environment.
GetInt returns int64 from a string, default to the given default if 0 or empty.
Uses stdlib http.Redirect but sets cache header.
No description provided by the author
No description provided by the author
Int64Intersect intersects a and b.
Int64Merge returns a new slice with all items from a and b merged together, duplicates removed.
Int64OrString checks if data is an int or any of the accepted strings.
Int64Ref returns a refernce to the given string.
No description provided by the author
Int64SliceToInterfaceSlice converts a slice of int64 to slice of interface.
Max returns the larger of x or y.
Min returns the smaller of x or y.
IntRef returns a refernece to the given string.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
IsUUID returns true if id is the same format as NewUUID provides.
No description provided by the author
No description provided by the author
No description provided by the author
Reads the given file into the given value If the filename ends in ".gz", it is opened using the gzip library.
No description provided by the author
No description provided by the author
JsonUnmarshal marshals the source into json and unmarshals it into target.
JsonUnmarshalObject marshals the source into json and unmarshals it into target.
JsonUnmarshalQuery unmarshals a query string into target Every query parameter needs to be unmarshalled separately Otherwise they'll be considered json strings and unable to unmarshal in top struct In the case of raw strings (no object/array/number etc), it will not unmarshall For this one, we just directly assign the raw value.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Write the given object into file.
LangShort cuts the lang returns the first part
.
No description provided by the author
Keys returns all map keys.
MapValues returns the full set of variables optionally starting with matching regexp "re".
No description provided by the author
MatchBasicAuth checks if a request contains credentials matched in basicAuth map.
MD5 JSONMarshals i and return the MD5 of the marshaled bytes.
MimeTypeReader returns the MIME type of input and a new reader containing the whole data from input.
MustBuildURL uses "u" as basis and adds given query values Query values must be given as key1, value1, [key2, value2[, ...]] Panics if the URL is not parsable.
No description provided by the author
No description provided by the author
NewLineWriter encodes each newline as JSON followed by a ",".
NewJsonUnmarshalError returns a new JsonUnmarshalError The original error is stored together with the source type and target type If no property name is available it is given as an empty string.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewUUID returns a randomly generated UUID.
NewWriterCounter function create new WriterCounter.
PackZipFile packs all files from sourceDir as ZIP to writeTo.
PadStr returns string s filled to a length of padWidth.
ParseAccept parses the given string as an Accept header as defined in https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1.
ParseForm works like http.Request.ParseForm but additionally adds values received in json format to request.Form.
No description provided by the author
parseRange parses a Range header string as per RFC 7233.
No description provided by the author
No description provided by the author
PrintMem dumps some mem info to the console.
PushOntoStringArray adds str(s) to arr if missing.
RandStr creates a random string containg of n chars seed with rand.Seed(time.Now().UnixNano()).
ReadGzipFile opens file fn and returns its unpacked bytes.
Recover can be used in defer to execute "f" on recover.
RegexpMatch uses regexp to match the first key found in m.
No description provided by the author
RenderTemplate takes bytes and executes it and returns the rendered bytes.
ReplaceEndless replaces old to new in s as long as the string is getting shorter.
Route returns the route from a Gorilla Mux.
SetInStruct uses setMap to set value in passed data.
SliceApply applies all functions Fs against all items in t and returns t2.
No description provided by the author
Snippet returns lines from lineNo-plusMinus to lineNo+plusMinus, prefixed with the line number.
SortStr returns a sortable hex string for s in language lang.
No description provided by the author
Split string s into byte chunks of a max size of chunkSize Each string returned has a maximum length of byteChunkSize The split is UTF-8 safe.
StringRef returns a refernce to the given string.
Subroute returns the subroute form a Gorilla Mux Subrouter.
TimeRef returns a refernece to the given Time.
ToAnySlice converts a slice of []T to []any.
No description provided by the author
ToValidUTF8 checks and converts a string to valid UTF-8, replacing invalid characters.
UniqueInt64s returns all unique strings.
UniqueStrings returns all unique strings.
No description provided by the author
UnpackZipFile reads zipData and unpacks the contents of the zip into targetDir.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
Accept is a structure to represent a clause in an HTTP Accept Header.
No description provided by the author
No description provided by the author
HttpRange specifies the byte range to be sent to the client.
No description provided by the author
No description provided by the author
JsonLineWriter implements io.Writer and send the data to an Encoder whenever a newline is written After each newline a "," is send to the underlying Writer.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
WriterCounter is counter for io.Writer.
# Type aliases
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author