Documentation ¶
Overview ¶
Package command provides console operations, like options/arguments reading.
Package utils provides some utility functions for internal usage.
Index ¶
- Variables
- func ContainsOpt(name string) bool
- func EqualFoldWithoutChars(s1, s2 string) bool
- func FormatCmdKey(s string) string
- func FormatEnvKey(s string) string
- func GetArg(index int, def ...string) string
- func GetArgAll() []string
- func GetOpt(name string, def ...string) string
- func GetOptAll() map[string]string
- func GetOptWithEnv(key string, def ...string) string
- func Init(args ...string)
- 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 ListToMapByKey(list []map[string]interface{}, key string) map[string]interface{}
- func MapContainsPossibleKey(data map[string]interface{}, key string) bool
- func MapPossibleItemByKey(data map[string]interface{}, key string) (foundKey string, foundValue interface{})
- func NewReadCloser(content []byte, repeatable bool) io.ReadCloser
- func NewReadCloserWithReadCloser(r io.ReadCloser, repeatable bool) (io.ReadCloser, error)
- func ParseUsingDefaultAlgorithm(args ...string) (parsedArgs []string, parsedOptions map[string]string)
- func RemoveSymbols(s string) string
- func ReplaceByMap(origin string, replaces map[string]string) string
- func SetDebugEnabled(enabled bool)
- func SplitAndTrim(str, delimiter string, characterMask ...string) []string
- func StripSlashes(str string) string
- func Trim(str string, characterMask ...string) string
- func UcFirst(s string) string
- type ReadCloser
Constants ¶
This section is empty.
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 ContainsOpt ¶ added in v0.2.72
ContainsOpt checks whether option named `name` exist in the arguments.
func EqualFoldWithoutChars ¶
EqualFoldWithoutChars checks string `s1` and `s2` equal case-insensitively, with/without chars '-'/'_'/'.'/' '.
func FormatCmdKey ¶
FormatCmdKey formats string `s` as command key using uniformed format.
func FormatEnvKey ¶
FormatEnvKey formats string `s` as environment key using uniformed format.
func GetOptWithEnv ¶ added in v0.2.72
GetOptWithEnv returns the command line argument of the specified `key`. If the argument does not exist, then it returns the environment variable with specified `key`. It returns the default value `def` if none of them exists.
Fetching Rules: 1. Command line arguments are in lowercase format, eg: gf.package.variable; 2. Environment arguments are in uppercase format, eg: GF_PACKAGE_VARIABLE;
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 ¶
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 IsFloat ¶
func IsFloat(value interface{}) bool
IsFloat checks whether `value` is type of float.
func IsLetterLower ¶
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 IsNil ¶
func IsNil(value interface{}) bool
IsNil checks whether `value` is nil, especially for interface{} type value.
func IsNumeric ¶
IsNumeric checks whether the given string s is numeric. Note that float string like "123.456" is also numeric.
func IsSlice ¶
func IsSlice(value interface{}) bool
IsSlice checks whether `value` is type of slice.
func IsStruct ¶
func IsStruct(value interface{}) bool
IsStruct checks whether `value` is type of struct.
func ListToMapByKey ¶
ListToMapByKey converts `list` to a map[string]interface{} of which key is specified by `key`. Note that the item value may be type of slice.
func MapContainsPossibleKey ¶
MapContainsPossibleKey checks if the given `key` is contained in given map `data`. It checks the key ignoring cases and symbols.
Note that this function might be of low performance.
func MapPossibleItemByKey ¶
func MapPossibleItemByKey(data map[string]interface{}, key string) (foundKey string, foundValue interface{})
MapPossibleItemByKey tries to find the possible key-value pair for given key ignoring cases and symbols.
Note that this function might be of low performance.
func NewReadCloser ¶
func NewReadCloser(content []byte, repeatable bool) io.ReadCloser
NewReadCloser creates and returns a RepeatReadCloser object.
func NewReadCloserWithReadCloser ¶
func NewReadCloserWithReadCloser(r io.ReadCloser, repeatable bool) (io.ReadCloser, error)
NewReadCloserWithReadCloser creates and returns a RepeatReadCloser object with given io.ReadCloser.
func ParseUsingDefaultAlgorithm ¶ added in v0.2.72
func ParseUsingDefaultAlgorithm(args ...string) (parsedArgs []string, parsedOptions map[string]string)
ParseUsingDefaultAlgorithm parses arguments using default algorithm.
func RemoveSymbols ¶
RemoveSymbols removes all symbols from string and lefts only numbers and letters.
func ReplaceByMap ¶
ReplaceByMap returns a copy of `origin`, which is replaced by a map in unordered way, case-sensitively.
func SetDebugEnabled ¶
func SetDebugEnabled(enabled bool)
SetDebugEnabled enables/disables the internal debug info.
func SplitAndTrim ¶
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 StripSlashes ¶
StripSlashes un-quotes a quoted string by AddSlashes.
Types ¶
type ReadCloser ¶
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 ¶
func (b *ReadCloser) Close() error
Close implements the io.ReadCloser interface.