Documentation ¶
Index ¶
- Variables
- func AsError(r any) error
- func BigIntBytes(v *big.Int, bitsize int) []byte
- func BigIntBytesAutoChoose(v *big.Int) []byte
- func BytesDecodeBase64(base64Str string) string
- func BytesDecodeHex(hexStr string) string
- func BytesDeflate(uncompressed []byte) (compressed []byte)
- func BytesEncodeBase64(str string) string
- func BytesEncodeHex(str string) string
- func BytesFilter(f func(byte) bool, data []byte) []byte
- func BytesGzip(uncompressed []byte) (compressed []byte)
- func BytesHead(data []byte, numLines int) (lines []string, rest []byte)
- func BytesInflate(compressed []byte) (uncompressed []byte)
- func BytesMD5(data string) string
- func BytesMap(f func(byte) byte, data []byte) []byte
- func BytesReader(data any) io.Reader
- func BytesTail(data []byte, numLines int) (lines []string, rest []byte)
- func BytesUnGzip(compressed []byte) (uncompressed []byte)
- func BytesXor(a, b []byte) []byte
- func ConvertFloat(n interface{}) float64
- func ConvertInt(n interface{}) int
- func DecryptAES(key []byte, ciphertext []byte) []byte
- func EncryptAES(key []byte, plaintext []byte) []byte
- func EndianIsBig() bool
- func EndianIsLittle() bool
- func EndianSafeSplitUint16(value uint16) (leastSignificant, mostSignificant uint8)
- func EnvironMap() map[string]string
- func FileAppendBytes(filename string, data []byte) error
- func FileAppendPrintf(filename, format string, args ...any) error
- func FileAppendString(filename string, data string) error
- func FileBufferedReader(filenameOrURL string) (io.Reader, error)
- func FileCRC64(filenameOrURL string) (uint64, error)
- func FileCopy(source string, dest string) (err error)
- func FileCopyDir(source string, dest string) (err error)
- func FileExists(filename string) bool
- func FileFind(searchDirs []string, filenames ...string) (filePath string, found bool)
- func FileFindModified(searchDirs []string, filenames ...string) (filePath string, found bool, modified time.Time)
- func FileGetBytes(filenameOrURL string, timeout ...time.Duration) ([]byte, error)
- func FileGetCSV(filenameOrURL string, timeout ...time.Duration) ([][]string, error)
- func FileGetConfig(filenameOrURL string, timeout ...time.Duration) (map[string]string, error)
- func FileGetGz(filenameOrURL string) ([]byte, error)
- func FileGetInflate(filenameOrURL string) ([]byte, error)
- func FileGetJSON(filenameOrURL string, timeout ...time.Duration) (result any, err error)
- func FileGetLastLine(filenameOrURL string, timeout ...time.Duration) (line string, err error)
- func FileGetLines(filenameOrURL string, timeout ...time.Duration) (lines []string, err error)
- func FileGetNonEmptyLines(filenameOrURL string, timeout ...time.Duration) (lines []string, err error)
- func FileGetString(filenameOrURL string, timeout ...time.Duration) (string, error)
- func FileGetXML(filenameOrURL string, timeout ...time.Duration) (result any, err error)
- func FileIsDir(dirname string) bool
- func FileMD5Bytes(filenameOrURL string) ([]byte, error)
- func FileMD5String(filenameOrURL string) (string, error)
- func FilePrintf(filename, format string, args ...any) error
- func FileScanf(filename, format string, args ...any) error
- func FileSetBytes(filename string, data []byte) error
- func FileSetCSV(filename string, records [][]string) error
- func FileSetConfig(filename string, config map[string]string) error
- func FileSetDeflate(filename string, data []byte) error
- func FileSetGz(filename string, data []byte) error
- func FileSetJSON(filename string, data any) error
- func FileSetJSONIndent(filename string, data any, indent string) error
- func FileSetLines(filename string, lines []string) error
- func FileSetString(filename string, data string) error
- func FileSetXML(filename string, data any) error
- func FileSize(filename string) int64
- func FileTimeModified(filename string) time.Time
- func FileTouch(filename string) error
- func FileUnmarshallJSON(filenameOrURL string, result any, timeout ...time.Duration) error
- func FileUnmarshallXML(filenameOrURL string, result any, timeout ...time.Duration) error
- func FirstArg(args ...any) any
- func FirstError(errs ...error) error
- func GetError(args ...any) error
- func GetenvDefault(key, defaultValue string) string
- func HTTPCompressHandlerFunc(handlerFunc http.HandlerFunc) http.HandlerFunc
- func HTTPDelete(url string) (statusCode int, statusText string, err error)
- func HTTPPostForm(url string, data url.Values) (statusCode int, statusText string, err error)
- func HTTPPostJSON(url string, data any) error
- func HTTPPostXML(url string, data any) error
- func HTTPPutForm(url string, data url.Values) (statusCode int, statusText string, err error)
- func HTTPRespondMarshalIndentJSON(response any, prefix, indent string, responseWriter http.ResponseWriter, ...) (err error)
- func HTTPRespondMarshalIndentXML(response any, rootElement string, prefix, indent string, ...) (err error)
- func HTTPRespondMarshalJSON(response any, responseWriter http.ResponseWriter, request *http.Request) (err error)
- func HTTPRespondMarshalXML(response any, rootElement string, responseWriter http.ResponseWriter, ...) (err error)
- func HTTPRespondText(response string, responseWriter http.ResponseWriter, request *http.Request) (err error)
- func HTTPUnmarshalRequestBodyJSON(request *http.Request, result any) error
- func IsTestMode() bool
- func LastError(errs ...error) error
- func ListDir(dir string) ([]string, error)
- func ListDirDirectories(dir string) ([]string, error)
- func ListDirFiles(dir string) ([]string, error)
- func MapKeys(in any) any
- func NetHostname() string
- func NetIP() string
- func Nop(dummiesIn ...any) (dummyOut any)
- func PanicIf(condition bool, i ...any)
- func PanicIfErr(args ...any)
- func PathIsWritable(path string) bool
- func PathNearestExisting(path string) string
- func PathSplitExt(path string) (basepath, ext string)
- func PathWithoutExt(filename string) string
- func PlatformEndianess() binary.ByteOrder
- func PrettyPrintAsJSON(input any, indent ...string) error
- func RandSeedWithTime()
- func RandomBytes(size int) []byte
- func RandomChoose(items ...any) any
- func RandomChooseString(items ...string) string
- func RandomHEXString(length int) string
- func RandomHexString(length int) string
- func RangeDate(start, end time.Time) []time.Time
- func ReadBinary(r io.Reader, order binary.ByteOrder, data any) (n int, err error)
- func ReadLine(reader io.Reader) (line string, err error)
- func RealNetIP() string
- func ReflectExportedStructFields(v reflect.Value) map[string]reflect.Value
- func ReflectIsInteger(i any) bool
- func ReflectIsIntgerType(t reflect.Type) bool
- func ReflectLess(a, b interface{}) bool
- func ReflectNameIsExported(name string) bool
- func ReflectSetStructFieldString(structPtr any, name, value string) error
- func ReflectSetStructFieldsFromStringMap(structPtr any, m map[string]string, errOnMissingField bool) error
- func ReflectSort(slice, compareFunc any)
- func ReflectStructFieldIsExported(structField reflect.StructField) bool
- func ReflectTypeOfError() reflect.Type
- func SetUnify(a, b any) any
- func SetsEqual(a, b []string) bool
- func Sha1(input string) []byte
- func Sha1Byte(input []byte) []byte
- func Sha3256(text string) []byte
- func Sha3512(text string) []byte
- func Sha3512Hex(text string) string
- func SliceContains(slice, item any) bool
- func SliceCut(slice any, i, j int) any
- func SliceDeleteIndex(slice any, i int) any
- func SliceExpand(slice any, i, j int) any
- func SliceForEach(slice any, f func(index int, i any))
- func SliceIndex(slice, item any) int
- func SlicePopFunc(slice any, f func(i any) bool) (res, popped any)
- func SliceRemoveFunc(slice any, f func(i any) bool) any
- func SliceToInterfaceSlice(in any) []any
- func SliceUnique(in any) any
- func StackTrace(skipFrames int) string
- func StackTraceLine(skipFrames int) string
- func StringAddURLParam(url, name, value string) string
- func StringCSV(records [][]string) string
- func StringConvertTime(timeString, formatIn, formatOut string) (resultTime string, err error)
- func StringEndsWithNumber(s string) bool
- func StringEscapeJSON(jsonString string) string
- func StringFilter(f func(string) bool, data []string) []string
- func StringFind(s, token string) (remainder string, found bool)
- func StringFindBetween(s, start, stop string) (between, remainder string, found bool)
- func StringFormatBigInt(mem uint64) string
- func StringFormatMemory(mem uint64) string
- func StringInSlice(s string, slice []string) bool
- func StringJoin(values any, sep string) string
- func StringJoinFormat(format string, values any, sep string) string
- func StringListContains(l []string, s string) bool
- func StringListContainsCaseInsensitive(l []string, s string) bool
- func StringMD5Hex(data string) string
- func StringMap(f func(string) string, data []string) []string
- func StringMapGroupedNumberPostfixSortedKeys(m map[string]string) []string
- func StringMapGroupedNumberPostfixSortedValues(m map[string]string) []string
- func StringMapSortedKeys(m map[string]string) []string
- func StringMarshalJSON(data any, indent string) string
- func StringPrettifyJSON(compactJSON string) string
- func StringReplaceHTMLTags(text, replacement string) (plainText string)
- func StringReplaceMulti(str string, fromTo ...string) string
- func StringSHA1Base64(data string) string
- func StringSplitNumberPostfix(s string) (base, number string)
- func StringSplitOnce(s, sep string) (pre, post string)
- func StringSplitOnceChar(s string, sep byte) (pre, post string)
- func StringSplitOnceRune(s string, sep rune) (pre, post string)
- func StringStripHTMLTags(text string) (plainText string)
- func StringToBool(s string) bool
- func StringToFloat(s string) float64
- func StringToInt(s string) int
- func StringToLowerCamelCase(str string) string
- func StringToUpperCamelCase(str string) string
- func StringsCRLF(in string) string
- func StringsCommonPrefix(a, b string) string
- func TestGetCurrentPackagePath() string
- func WaitForStdin(v ...any) byte
- func WriteFull(data []byte, writer io.Writer) (n int, err error)
- type CancelableReader
- type CountingReadWriter
- type DebugMutex
- type DebugRWMutex
- type DeflatePool
- type ErrorList
- type FileCopyError
- type GzipPool
- type HTTPCompressHandler
- type ReadCounter
- type ReaderFunc
- type StringBuilder
- func (s *StringBuilder) Bool(value bool) *StringBuilder
- func (s *StringBuilder) Byte(value byte) *StringBuilder
- func (s *StringBuilder) Bytes() []byte
- func (s *StringBuilder) Float(value float64) *StringBuilder
- func (s *StringBuilder) Int(value int) *StringBuilder
- func (s *StringBuilder) Printf(format string, args ...any) *StringBuilder
- func (s *StringBuilder) String() string
- func (s *StringBuilder) Uint(value uint) *StringBuilder
- func (s *StringBuilder) Write(strings ...string) *StringBuilder
- func (s *StringBuilder) WriteBytes(bytes []byte) *StringBuilder
- func (s *StringBuilder) WriteTo(writer io.Writer) (n int64, err error)
- type StringGroupedNumberPostfixSorter
- type StringSet
- func (set StringSet) Clone() StringSet
- func (set StringSet) Delete(s string)
- func (set StringSet) Exclude(other StringSet)
- func (set StringSet) Has(s string) bool
- func (set StringSet) Join(other StringSet)
- func (set StringSet) ReverseSorted() []string
- func (set StringSet) Set(s string)
- func (set StringSet) Sorted() []string
- type SyncBool
- type SyncFloat
- type SyncInt
- type SyncMap
- func (s *SyncMap) Add(key string, value any)
- func (s *SyncMap) AddBool(key string, value bool)
- func (s *SyncMap) AddFloat(key string, value float64)
- func (s *SyncMap) AddInt(key string, value int)
- func (s *SyncMap) AddString(key string, value string)
- func (s *SyncMap) Bool(key string) *SyncBool
- func (s *SyncMap) Delete(key string)
- func (s *SyncMap) Float(key string) *SyncFloat
- func (s *SyncMap) Get(key string) any
- func (s *SyncMap) Has(key string) bool
- func (s *SyncMap) Int(key string) *SyncInt
- func (s *SyncMap) String(key string) *SyncString
- type SyncPoolMap
- type SyncString
- type SyncStringMap
- type WriteCounter
- type WriterFunc
Constants ¶
This section is empty.
Variables ¶
var ( Deflate DeflatePool Gzip GzipPool )
var (
AES = aesCipherPool{NewSyncPoolMap()}
)
Functions ¶
func BigIntBytesAutoChoose ¶
func BytesDecodeBase64 ¶
func BytesDecodeHex ¶
func BytesDeflate ¶
func BytesEncodeBase64 ¶
func BytesEncodeHex ¶
func BytesFilter ¶
BytesFilter filters out all bytes where the function does not return true.
func BytesHead ¶
BytesHead returns at most numLines from data starting at the beginning. A slice of the remaining data is returned as rest. \n is used to detect line ends, a preceding \r will be stripped away. BytesHead resembles the Unix head command.
func BytesInflate ¶
func BytesReader ¶
func BytesTail ¶
BytesTail returns at most numLines from the end of data. A slice of the remaining data before lines is returned as rest. \n is used to detect line ends, a preceding \r will be stripped away. BytesTail resembles the Unix tail command.
func BytesUnGzip ¶
func ConvertFloat ¶
func ConvertFloat(n interface{}) float64
func ConvertInt ¶
func ConvertInt(n interface{}) int
func DecryptAES ¶
DecryptAES decrypts ciphertext using AES with the given key. key should be either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.
func EncryptAES ¶
EncryptAES encrypts plaintext using AES with the given key. key should be either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256. plaintext must not be shorter than key.
func EndianIsBig ¶
func EndianIsBig() bool
func EndianIsLittle ¶
func EndianIsLittle() bool
func EndianSafeSplitUint16 ¶
func EnvironMap ¶
EnvironMap returns the current environment variables as a map.
func FileAppendBytes ¶
func FileAppendPrintf ¶
func FileAppendString ¶
func FileCopy ¶
FileCopy copies file source to destination dest. Based on Jaybill McCarthy's code which can be found at http://jayblog.jaybill.com/post/id/26
func FileCopyDir ¶
FileCopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist. Based on Jaybill McCarthy's code which can be found at http://jayblog.jaybill.com/post/id/26
func FileExists ¶
func FileFindModified ¶
func FileGetBytes ¶
func FileGetCSV ¶
func FileGetConfig ¶
func FileGetInflate ¶
func FileGetJSON ¶
func FileGetLastLine ¶
FileGetLastLine reads the last line from a file. In case of a network file, the whole file is read. In case of a local file, the last 64kb are read, so if the last line is longer than 64kb it is not returned completely. The first optional timeout is used for network files only.
func FileGetLines ¶
FileGetLines returns a string slice with the text lines of filenameOrURL. The lines can be separated by \n or \r\n.
func FileGetNonEmptyLines ¶
func FileGetNonEmptyLines(filenameOrURL string, timeout ...time.Duration) (lines []string, err error)
FileGetNonEmptyLines returns a string slice with the non empty text lines of filenameOrURL. The lines can be separated by \n or \r\n.
func FileGetString ¶
func FileGetXML ¶
func FileMD5Bytes ¶
func FileMD5String ¶
func FilePrintf ¶
func FileSetBytes ¶
func FileSetCSV ¶
func FileSetDeflate ¶
func FileSetJSON ¶
func FileSetJSONIndent ¶
func FileSetLines ¶
func FileSetString ¶
func FileSetXML ¶
func FileTimeModified ¶
FileTimeModified returns the modified time of a file, or the zero time value in case of an error.
func FileUnmarshallJSON ¶
func FileUnmarshallXML ¶
func FirstArg ¶
func FirstArg(args ...any) any
FirstArg returns the first passed argument, can be used to extract first result value from a function call to pass it on to functions like fmt.Printf
func FirstError ¶
FirstError returns the first non nil error, or nil
func GetError ¶
func GetError(args ...any) error
GetError returns the last argument that is of type error, panics if none of the passed args is of type error. Note that GetError(nil) will panic because nil is not of type error but interface{}
func GetenvDefault ¶
GetenvDefault retrieves the value of the environment variable named by the key. It returns the given defaultValue if the variable is not present.
func HTTPCompressHandlerFunc ¶
func HTTPCompressHandlerFunc(handlerFunc http.HandlerFunc) http.HandlerFunc
HTTPCompressHandlerFunc wraps a http.HandlerFunc so that the response gets gzip or deflate compressed if the Accept-Encoding header of the request allows it.
func HTTPDelete ¶
HTTPDelete performs a HTTP DELETE request
func HTTPPostForm ¶
HTTPPostForm performs a HTTP POST request with data as application/x-www-form-urlencoded
func HTTPPostJSON ¶
HTTPPostJSON marshalles data as JSON and sends it as HTTP POST request to url. If the response status code is not 200 OK, then the status is returned as an error.
func HTTPPostXML ¶
HTTPPostXML marshalles data as XML and sends it as HTTP POST request to url. If the response status code is not 200 OK, then the status is returned as an error.
func HTTPPutForm ¶
HTTPPutForm performs a HTTP PUT request with data as application/x-www-form-urlencoded
func HTTPRespondMarshalIndentJSON ¶
func HTTPRespondMarshalIndentJSON(response any, prefix, indent string, responseWriter http.ResponseWriter, request *http.Request) (err error)
HTTPRespondMarshalIndentJSON marshals response as JSON to responseWriter, sets Content-Type to application/json and compresses the response if Content-Encoding from the request allows it. The JSON will be marshalled indented according to json.MarshalIndent
func HTTPRespondMarshalIndentXML ¶
func HTTPRespondMarshalIndentXML(response any, rootElement string, prefix, indent string, responseWriter http.ResponseWriter, request *http.Request) (err error)
HTTPRespondMarshalIndentXML marshals response as XML to responseWriter, sets Content-Type to application/xml and compresses the response if Content-Encoding from the request allows it. The XML will be marshalled indented according to xml.MarshalIndent. If rootElement is not empty, then an additional root element with this name will be wrapped around the content.
func HTTPRespondMarshalJSON ¶
func HTTPRespondMarshalJSON(response any, responseWriter http.ResponseWriter, request *http.Request) (err error)
HTTPRespondMarshalJSON marshals response as JSON to responseWriter, sets Content-Type to application/json and compresses the response if Content-Encoding from the request allows it.
func HTTPRespondMarshalXML ¶
func HTTPRespondMarshalXML(response any, rootElement string, responseWriter http.ResponseWriter, request *http.Request) (err error)
HTTPRespondMarshalXML marshals response as XML to responseWriter, sets Content-Type to application/xml and compresses the response if Content-Encoding from the request allows it. If rootElement is not empty, then an additional root element with this name will be wrapped around the content.
func HTTPRespondText ¶
func HTTPRespondText(response string, responseWriter http.ResponseWriter, request *http.Request) (err error)
HTTPRespondText sets Content-Type to text/plain and compresses the response if Content-Encoding from the request allows it.
func HTTPUnmarshalRequestBodyJSON ¶
HTTPUnmarshalRequestBodyJSON reads a http.Request body and unmarshals it as JSON to result.
func IsTestMode ¶
func IsTestMode() bool
func ListDirDirectories ¶
func ListDirFiles ¶
func NetHostname ¶
func NetHostname() string
func NetIP ¶
func NetIP() string
NetIP returns the primary IP address of the system or an empty string.
func Nop ¶
func Nop(dummiesIn ...any) (dummyOut any)
Nop is a dummy function that can be called in source files where other debug functions are constantly added and removed. That way import "github.com/ungerik/go-quick" won't cause an error when no other debug function is currently used. Arbitrary objects can be passed as arguments to avoid "declared and not used" error messages when commenting code out and in. The result is a nil interface{} dummy value.
func PanicIfErr ¶
func PanicIfErr(args ...any)
PanicIfErr panics with a stack trace if any of the passed args is a non nil error
func PathIsWritable ¶
func PathNearestExisting ¶
func PathSplitExt ¶
делить название файла на само название и расширение при этом на название не влияет путь, в котором расположен файл
func PathWithoutExt ¶
func PlatformEndianess ¶
func PrettyPrintAsJSON ¶
PrettyPrintAsJSON marshalles input as indented JSON and calles fmt.Println with the result. If indent arguments are given, they are joined into a string and used as JSON line indent. If no indet argument is given, two spaces will be used to indent JSON lines.
func RandSeedWithTime ¶
func RandSeedWithTime()
RandSeedWithTime calls rand.Seed() with the current time.
func RandomBytes ¶
func RandomChoose ¶
func RandomChoose(items ...any) any
deprecated except for strings. you can copy this oneline implementation
func RandomChooseString ¶
deprecated except for strings. you can copy this oneline implementation
func RandomHEXString ¶
RandomHEXString returns a random upper case hex string with length.
func RandomHexString ¶
RandomHexString returns a random lower case hex string with length.
func ReadBinary ¶
! DEPRECATED ReadBinary wraps binary.Read with a CountingReader and returns the acutal bytes read by it.
func ReadLine ¶
! DEPRECATED ReadLine reads unbuffered until a newline '\n' byte and removes an optional carriege return '\r' at the end of the line. In case of an error, the string up to the error is returned.
func RealNetIP ¶
func RealNetIP() string
RealNetIP returns the real local IP of the system or an empty string.
func ReflectExportedStructFields ¶
ReflectExportedStructFields returns a map from exported struct field names to values, inlining anonymous sub-structs so that their field names are available at the base level. Example:
type A struct { X int } type B Struct { A Y int } // Yields X and Y instead of A and Y: ReflectExportedStructFields(reflect.ValueOf(B{}))
func ReflectIsInteger ¶
func ReflectIsInteger(i any) bool
func ReflectIsIntgerType ¶
func ReflectNameIsExported ¶
func ReflectSetStructFieldString ¶
ReflectSetStructFieldString sets the field with name to value.
func ReflectSetStructFieldsFromStringMap ¶
func ReflectSetStructFieldsFromStringMap(structPtr any, m map[string]string, errOnMissingField bool) error
ReflectSetStructFieldsFromStringMap sets the fields of a struct with the field names and values taken from a map[string]string. If errOnMissingField is true, then all fields must exist.
func ReflectSort ¶
func ReflectSort(slice, compareFunc any)
ReflectSort will sort slice according to compareFunc using reflection. slice can be a slice of any element type including interface{}. compareFunc must have two arguments that are assignable from the slice element type or pointers to such a type. The result of compareFunc must be a bool indicating if the first argument is less than the second. If the element type of slice is interface{}, then the type of the compareFunc arguments can be any type and dynamic casting from the interface value or its address will be attempted.
func ReflectStructFieldIsExported ¶
func ReflectStructFieldIsExported(structField reflect.StructField) bool
func ReflectTypeOfError ¶
ReflectTypeOfError returns the built-in error type
func Sha3512Hex ¶
func SliceContains ¶
func SliceContains(slice, item any) bool
func SliceDeleteIndex ¶
func SliceDeleteIndex(slice any, i int) any
func SliceExpand ¶
func SliceExpand(slice any, i, j int) any
func SliceForEach ¶
func SliceForEach(slice any, f func(index int, i any))
SliceForEach is special function, when you just know, that some variable is slice. try to not use this func instead, for _,_ := range _ is WAY MORE preferrable. This func is only is useful for rarest situtations
func SliceIndex ¶
func SliceIndex(slice, item any) int
индекс элемента T в []T выводит индекс найденого элемента, либо -1, если элемент не найден
func SlicePopFunc ¶
func SlicePopFunc(slice any, f func(i any) bool) (res, popped any)
if f func returns true, than slice item will pop
func SliceRemoveFunc ¶
func SliceRemoveFunc(slice any, f func(i any) bool) any
func SliceToInterfaceSlice ¶
func SliceToInterfaceSlice(in any) []any
SliceToInterfaceSlice converts a slice of any type into a slice of interface{}.
func StackTrace ¶
func StackTraceLine ¶
func StringAddURLParam ¶
func StringConvertTime ¶
func StringEndsWithNumber ¶
func StringEscapeJSON ¶
func StringFilter ¶
Filter out all strings where the function does not return true.
func StringFind ¶
StringFind returns in found if token has been found in s, and returns the remaining string afte token in remainder. The whole string s will be returned if found is false.
func StringFindBetween ¶
StringFindBetween returns the string between the first occurrences of the tokens start and stop. The remainder of the string after the stop token will be returned if found. If the tokens couldn't be found, then the whole string will be returned as remainder.
func StringFormatBigInt ¶
func StringFormatMemory ¶
func StringInSlice ¶
func StringJoin ¶
StringJoin formats every value in values according to its default formatting and joins the result with sep as separator. values must be a slice of a formatable type
func StringJoinFormat ¶
StringJoinFormat formats every value in values with format and joins the result with sep as separator. values must be a slice of a formatable type
func StringListContains ¶
func StringMD5Hex ¶
StringMD5Hex returns the hex encoded MD5 hash of data
func StringMapSortedKeys ¶
func StringMarshalJSON ¶
StringMarshalJSON marshals data to an indented string.
func StringPrettifyJSON ¶
func StringReplaceHTMLTags ¶
StringReplaceHTMLTags replaces HTML/XML tags from text with replacement.
func StringReplaceMulti ¶
func StringSHA1Base64 ¶
StringSHA1Base64 returns the base64 encoded SHA1 hash of data
func StringSplitOnce ¶
func StringSplitOnceChar ¶
func StringSplitOnceRune ¶
func StringStripHTMLTags ¶
StringStripHTMLTags strips HTML/XML tags from text.
func StringToBool ¶
func StringToFloat ¶
func StringToInt ¶
func StringToLowerCamelCase ¶
func StringToUpperCamelCase ¶
func StringsCRLF ¶
func StringsCommonPrefix ¶
func TestGetCurrentPackagePath ¶
func TestGetCurrentPackagePath() string
func WaitForStdin ¶
func WaitForStdin(v ...any) byte
! DEPRECATED WaitForStdin blocks until input is available from os.Stdin. The first byte from os.Stdin is returned as result. If there are println arguments, then fmt.Println will be called with those before reading from os.Stdin.
Types ¶
type CancelableReader ¶
type CancelableReader = dry_ioutil.CancelableReader
CancelableReader позволяет читать данные с контекстом
func NewCancelableReader ¶
func NewCancelableReader(ctx context.Context, r io.Reader) *CancelableReader
type CountingReadWriter ¶
type CountingReadWriter struct { ReadWriter io.ReadWriter BytesRead int BytesWritten int }
TODO: принцип интересный, но не входит в рамки io
type DebugMutex ¶
type DebugMutex struct {
// contains filtered or unexported fields
}
DebugMutex wraps a sync.Mutex and adds debug output
func (*DebugMutex) Lock ¶
func (d *DebugMutex) Lock()
func (*DebugMutex) Unlock ¶
func (d *DebugMutex) Unlock()
type DebugRWMutex ¶
type DebugRWMutex struct {
// contains filtered or unexported fields
}
DebugRWMutex wraps a sync.RWMutex and adds debug output
func (*DebugRWMutex) Lock ¶
func (d *DebugRWMutex) Lock()
func (*DebugRWMutex) RLock ¶
func (d *DebugRWMutex) RLock()
func (*DebugRWMutex) RLocker ¶
func (d *DebugRWMutex) RLocker() sync.Locker
func (*DebugRWMutex) RUnlock ¶
func (d *DebugRWMutex) RUnlock()
func (*DebugRWMutex) Unlock ¶
func (d *DebugRWMutex) Unlock()
type DeflatePool ¶
type DeflatePool struct {
// contains filtered or unexported fields
}
DeflatePool manages a pool of flate.Writer flate.NewWriter allocates a lot of memory, so if flate.Writer are needed frequently, it's more efficient to use a pool of them. The pool uses sync.Pool internally.
func (*DeflatePool) GetWriter ¶
func (pool *DeflatePool) GetWriter(dst io.Writer) (writer *flate.Writer)
GetWriter returns flate.Writer from the pool, or creates a new one with flate.BestCompression if the pool is empty.
func (*DeflatePool) ReturnWriter ¶
func (pool *DeflatePool) ReturnWriter(writer *flate.Writer)
ReturnWriter returns a flate.Writer to the pool that can late be reused via GetWriter. Don't close the writer, Flush will be called before returning it to the pool.
type ErrorList ¶
type ErrorList []error
ErrorList holds a slice of errors.
Usage example:
func maybeError() (int, error) { return } func main() { e := NewErrorList(maybeError()) e.Collect(maybeError()) e.Collect(maybeError()) if e.Err() != nil { fmt.Println("Some calls of maybeError() returned errors:", e) } else { fmt.Println("No call of maybeError() returned an error") } }
func AsErrorList ¶
AsErrorList checks if err is already an ErrorList and returns it if this is the case. Else an ErrorList with err as element is created. Useful if a function potentially returns an ErrorList as error and you want to avoid creating nested ErrorLists.
func NewErrorList ¶
func NewErrorList(args ...any) (list ErrorList)
NewErrorList returns an ErrorList where Collect has been called for args. The returned list will be nil if there was no non nil error in args. Note that alle methods of ErrorList can be called with a nil ErrorList.
func (*ErrorList) Collect ¶
func (list *ErrorList) Collect(args ...any)
Collect adds any non nil errors in args to the list.
func (ErrorList) Err ¶
Err returns the list if it is not empty, or nil if it is empty. Can be called for a nil ErrorList.
func (ErrorList) Error ¶
Error calls fmt.Println for of every error in the list and returns the concernated text. Can be called for a nil ErrorList.
type FileCopyError ¶
type FileCopyError struct {
What string
}
FileCopyError is a struct for returning file copy error messages
func (*FileCopyError) Error ¶
func (e *FileCopyError) Error() string
type GzipPool ¶
type GzipPool struct {
// contains filtered or unexported fields
}
GzipPool manages a pool of gzip.Writer. The pool uses sync.Pool internally.
func (*GzipPool) GetWriter ¶
GetWriter returns gzip.Writer from the pool, or creates a new one with gzip.BestCompression if the pool is empty.
func (*GzipPool) ReturnWriter ¶
ReturnWriter returns a gzip.Writer to the pool that can late be reused via GetWriter. Don't close the writer, Flush will be called before returning it to the pool.
type HTTPCompressHandler ¶
HTTPCompressHandler wraps a http.Handler so that the response gets gzip or deflate compressed if the Accept-Encoding header of the request allows it.
func NewHTTPCompressHandler ¶
func NewHTTPCompressHandler(handler http.Handler) *HTTPCompressHandler
func NewHTTPCompressHandlerFromFunc ¶
func NewHTTPCompressHandlerFromFunc(handler http.HandlerFunc) *HTTPCompressHandler
func (*HTTPCompressHandler) ServeHTTP ¶
func (h *HTTPCompressHandler) ServeHTTP(response http.ResponseWriter, request *http.Request)
type ReadCounter ¶
type ReadCounter = dry_ioutil.ReadCounter
func CountingReader ¶
func CountingReader(r io.Reader) ReadCounter
type ReaderFunc ¶
type ReaderFunc = dry_ioutil.ReaderFunc
ReaderFunc implements io.Reader as function type with a Read method.
type StringBuilder ¶
type StringBuilder struct {
// contains filtered or unexported fields
}
func (*StringBuilder) Bool ¶
func (s *StringBuilder) Bool(value bool) *StringBuilder
func (*StringBuilder) Byte ¶
func (s *StringBuilder) Byte(value byte) *StringBuilder
func (*StringBuilder) Bytes ¶
func (s *StringBuilder) Bytes() []byte
func (*StringBuilder) Float ¶
func (s *StringBuilder) Float(value float64) *StringBuilder
func (*StringBuilder) Int ¶
func (s *StringBuilder) Int(value int) *StringBuilder
func (*StringBuilder) Printf ¶
func (s *StringBuilder) Printf(format string, args ...any) *StringBuilder
func (*StringBuilder) String ¶
func (s *StringBuilder) String() string
func (*StringBuilder) Uint ¶
func (s *StringBuilder) Uint(value uint) *StringBuilder
func (*StringBuilder) Write ¶
func (s *StringBuilder) Write(strings ...string) *StringBuilder
func (*StringBuilder) WriteBytes ¶
func (s *StringBuilder) WriteBytes(bytes []byte) *StringBuilder
type StringGroupedNumberPostfixSorter ¶
type StringGroupedNumberPostfixSorter []string
func (StringGroupedNumberPostfixSorter) Len ¶
func (s StringGroupedNumberPostfixSorter) Len() int
Len is the number of elements in the collection.
func (StringGroupedNumberPostfixSorter) Less ¶
func (s StringGroupedNumberPostfixSorter) Less(i, j int) bool
Less reports whether the element with index i should sort before the element with index j.
func (StringGroupedNumberPostfixSorter) Swap ¶
func (s StringGroupedNumberPostfixSorter) Swap(i, j int)
Swap swaps the elements with indexes i and j.
type StringSet ¶
type StringSet map[string]null
StringSet wraps map[string]struct{} with some useful methods.
func (StringSet) ReverseSorted ¶
type SyncBool ¶
type SyncBool struct {
// contains filtered or unexported fields
}
func NewSyncBool ¶
type SyncFloat ¶
type SyncFloat struct {
// contains filtered or unexported fields
}
func NewSyncFloat ¶
type SyncMap ¶
type SyncMap struct {
// contains filtered or unexported fields
}
func NewSyncMap ¶
func NewSyncMap() *SyncMap
func (*SyncMap) String ¶
func (s *SyncMap) String(key string) *SyncString
type SyncPoolMap ¶
type SyncPoolMap struct {
// contains filtered or unexported fields
}
func NewSyncPoolMap ¶
func NewSyncPoolMap() *SyncPoolMap
func (*SyncPoolMap) Delete ¶
func (s *SyncPoolMap) Delete(key string)
func (*SyncPoolMap) GetOrAddNew ¶
func (s *SyncPoolMap) GetOrAddNew(key string, newFunc func() any) *sync.Pool
func (*SyncPoolMap) Has ¶
func (s *SyncPoolMap) Has(key string) bool
type SyncString ¶
type SyncString struct {
// contains filtered or unexported fields
}
func NewSyncString ¶
func NewSyncString(value string) *SyncString
func (*SyncString) Append ¶
func (s *SyncString) Append(value string) string
func (*SyncString) Get ¶
func (s *SyncString) Get() string
func (*SyncString) Set ¶
func (s *SyncString) Set(value string)
func (*SyncString) Swap ¶
func (s *SyncString) Swap(value string) string
type SyncStringMap ¶
type SyncStringMap struct {
// contains filtered or unexported fields
}
func NewSyncStringMap ¶
func NewSyncStringMap() *SyncStringMap
func (*SyncStringMap) Add ¶
func (s *SyncStringMap) Add(key string, value string)
func (*SyncStringMap) Delete ¶
func (s *SyncStringMap) Delete(key string)
func (*SyncStringMap) Get ¶
func (s *SyncStringMap) Get(key string) string
func (*SyncStringMap) Has ¶
func (s *SyncStringMap) Has(key string) bool
type WriteCounter ¶
type WriteCounter = dry_ioutil.WriteCounter
func CountingWriter ¶
func CountingWriter(w io.Writer) WriteCounter
type WriterFunc ¶
type WriterFunc = dry_ioutil.WriterFunc
WriterFunc implements io.Writer as function type with a Write method.