utils

package
v1.16.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package utils provides some utility functions for internal usage.

Index

Constants

View Source
const (
	StackFilterKeyForGoFrame = "github.com/gogf/gf@" // Stack filtering key for all GoFrame module paths.
)

Variables

View Source
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 v1.12.2

func EqualFoldWithoutChars(s1, s2 string) bool

EqualFoldWithoutChars checks string `s1` and `s2` equal case-insensitively, with/without chars '-'/'_'/'.'/' '.

func IsArray

func IsArray(value interface{}) bool

IsArray checks whether given value is array/slice. Note that it uses reflect internally implementing this feature.

func IsDebugEnabled added in v1.15.4

func IsDebugEnabled() bool

IsDebugEnabled checks and returns whether debug mode is enabled. The debug mode is enabled when command argument "gf.debug" or environment "GF_DEBUG" is passed.

func IsEmpty added in v1.16.5

func IsEmpty(value interface{}) bool

IsEmpty checks whether `value` is empty.

func IsFloat added in v1.16.5

func IsFloat(value interface{}) bool

IsFloat checks whether `value` is type of float.

func IsInt added in v1.16.5

func IsInt(value interface{}) bool

IsInt checks whether `value` is type of int.

func IsLetter added in v1.12.0

func IsLetter(b byte) bool

IsLetter checks whether the given byte b is a letter.

func IsLetterLower

func IsLetterLower(b byte) bool

IsLetterLower checks whether the given byte b is in lower case.

func IsLetterUpper

func IsLetterUpper(b byte) bool

IsLetterUpper checks whether the given byte b is in upper case.

func IsMap added in v1.16.5

func IsMap(value interface{}) bool

IsMap checks whether `value` is type of map.

func IsNil added in v1.16.5

func IsNil(value interface{}) bool

IsNil checks whether `value` is nil.

func IsNumeric

func IsNumeric(s string) bool

IsNumeric checks whether the given string s is numeric. Note that float string like "123.456" is also numeric.

func IsSlice added in v1.16.5

func IsSlice(value interface{}) bool

IsSlice checks whether `value` is type of slice.

func IsStruct added in v1.16.5

func IsStruct(value interface{}) bool

IsStruct checks whether `value` is type of struct.

func IsUint added in v1.16.5

func IsUint(value interface{}) bool

IsUint checks whether `value` is type of uint.

func NewReadCloser added in v1.13.1

func NewReadCloser(content []byte, repeatable bool) io.ReadCloser

NewRepeatReadCloser creates and returns a RepeatReadCloser object.

func NewReadCloserWithReadCloser added in v1.13.1

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 v1.14.3

func RemoveSymbols(s string) string

RemoveSymbols removes all symbols from string and lefts only numbers and letters.

func ReplaceByMap

func ReplaceByMap(origin string, replaces map[string]string) string

ReplaceByMap returns a copy of `origin`, which is replaced by a map in unordered way, case-sensitively.

func SplitAndTrim added in v1.15.4

func SplitAndTrim(str, delimiter string, characterMask ...string) []string

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.

func Trim added in v1.15.4

func Trim(str string, characterMask ...string) string

Trim strips whitespace (or other characters) from the beginning and end of a string. The optional parameter <characterMask> specifies the additional stripped characters.

func UcFirst

func UcFirst(s string) string

UcFirst returns a copy of the string s with the first letter mapped to its upper case.

Types

type ReadCloser added in v1.13.1

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 v1.13.1

func (b *ReadCloser) Close() error

Close implements the io.ReadCloser interface.

func (*ReadCloser) Read added in v1.13.1

func (b *ReadCloser) Read(p []byte) (n int, err error)

Read implements the io.ReadCloser interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL