Documentation ¶
Overview ¶
Package utils provides some utility functions for internal usage.
Index ¶
- Constants
- Variables
- func EqualFoldWithoutChars(s1, s2 string) bool
- func IsArray(value interface{}) bool
- func IsDebugEnabled() bool
- func IsEmpty(value interface{}) bool
- func IsFloat(value interface{}) bool
- func IsInt(value interface{}) bool
- func IsLetter(b byte) bool
- func IsLetterLower(b byte) bool
- func IsLetterUpper(b byte) bool
- func IsMap(value interface{}) bool
- func IsNil(value interface{}) bool
- func IsNumeric(s string) bool
- func IsSlice(value interface{}) bool
- func IsStruct(value interface{}) bool
- func IsUint(value interface{}) bool
- func NewReadCloser(content []byte, repeatable bool) io.ReadCloser
- func NewReadCloserWithReadCloser(r io.ReadCloser, repeatable bool) (io.ReadCloser, error)
- func RemoveSymbols(s string) string
- func ReplaceByMap(origin string, replaces map[string]string) string
- func SplitAndTrim(str, delimiter string, characterMask ...string) []string
- func Trim(str string, characterMask ...string) string
- func UcFirst(s string) string
- type ReadCloser
Constants ¶
const (
StackFilterKeyForGoFrame = "/github.com/osgochina/donkeygo/" // Stack filtering key for all GoFrame module paths.
)
Variables ¶
var ( // DefaultTrimChars are the characters which are stripped by Trim* functions in default. DefaultTrimChars = string([]byte{ '\t', '\v', '\n', '\r', '\f', ' ', 0x00, 0x85, 0xA0, }) )
Functions ¶
func EqualFoldWithoutChars ¶ added in v0.0.3
EqualFoldWithoutChars checks string `s1` and `s2` equal case-insensitively, with/without chars '-'/'_'/'.'/' '.
func IsArray ¶ added in v0.1.9
func IsArray(value interface{}) bool
IsArray checks whether given value is array/slice. Note that it uses reflect internally implementing this feature.
func IsDebugEnabled ¶
func IsDebugEnabled() bool
IsDebugEnabled checks and returns whether debug mode is enabled. The debug mode is enabled when command argument "dk.debug" or environment "DK_DEBUG" is passed.
func IsEmpty ¶ added in v0.1.9
func IsEmpty(value interface{}) bool
IsEmpty checks whether `value` is empty.
func IsFloat ¶ added in v0.1.9
func IsFloat(value interface{}) bool
IsFloat checks whether `value` is type of float.
func IsInt ¶ added in v0.1.9
func IsInt(value interface{}) bool
IsInt checks whether `value` is type of int.
func IsLetterLower ¶ added in v0.0.10
IsLetterLower checks whether the given byte b is in lower case.
func IsLetterUpper ¶
IsLetterUpper checks whether the given byte b is in upper case.
func IsMap ¶ added in v0.1.9
func IsMap(value interface{}) bool
IsMap checks whether `value` is type of map.
func IsNil ¶ added in v0.1.9
func IsNil(value interface{}) bool
IsNil checks whether `value` is nil.
func IsNumeric ¶ added in v0.0.3
IsNumeric checks whether the given string s is numeric. Note that float string like "123.456" is also numeric.
func IsSlice ¶ added in v0.1.9
func IsSlice(value interface{}) bool
IsSlice checks whether `value` is type of slice.
func IsStruct ¶ added in v0.1.9
func IsStruct(value interface{}) bool
IsStruct checks whether `value` is type of struct.
func IsUint ¶ added in v0.1.9
func IsUint(value interface{}) bool
IsUint checks whether `value` is type of uint.
func NewReadCloser ¶ added in v0.1.9
func NewReadCloser(content []byte, repeatable bool) io.ReadCloser
NewRepeatReadCloser creates and returns a RepeatReadCloser object.
func NewReadCloserWithReadCloser ¶ added in v0.1.9
func NewReadCloserWithReadCloser(r io.ReadCloser, repeatable bool) (io.ReadCloser, error)
NewRepeatReadCloserWithReadCloser creates and returns a RepeatReadCloser object with given io.ReadCloser.
func RemoveSymbols ¶ added in v0.0.3
RemoveSymbols removes all symbols from string and lefts only numbers and letters.
func ReplaceByMap ¶ added in v0.0.10
ReplaceByMap returns a copy of `origin`, which is replaced by a map in unordered way, case-sensitively.
func SplitAndTrim ¶ added in v0.0.3
SplitAndTrim splits string <str> by a string <delimiter> to an array, and calls Trim to every element of this array. It ignores the elements which are empty after Trim.
Types ¶
type ReadCloser ¶ added in v0.1.9
type ReadCloser struct {
// contains filtered or unexported fields
}
ReadCloser implements the io.ReadCloser interface which is used for reading request body content multiple times.
Note that it cannot be closed.
func (*ReadCloser) Close ¶ added in v0.1.9
func (b *ReadCloser) Close() error
Close implements the io.ReadCloser interface.