mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
comment update;standardize const naming for package gtcp/gudp
This commit is contained in:
@ -20,7 +20,7 @@ var (
|
||||
argumentRegex = regexp.MustCompile(`^\-{1,2}([\w\?\.\-]+)(=){0,1}(.*)$`)
|
||||
)
|
||||
|
||||
// Custom initialization.
|
||||
// Init does custom initialization.
|
||||
func Init(args ...string) {
|
||||
if len(args) == 0 {
|
||||
if len(defaultParsedArgs) == 0 && len(defaultParsedOptions) == 0 {
|
||||
|
||||
@ -286,10 +286,9 @@ func IsEmpty(value interface{}) bool {
|
||||
//}
|
||||
|
||||
// IsNil checks whether given `value` is nil.
|
||||
// Parameter `traceSource` is used for tracing to the source variable if given `value` is type
|
||||
// of a pinter that also points to a pointer. It returns nil if the source is nil when `traceSource`
|
||||
// is true.
|
||||
// Note that it might use reflect feature which affects performance a little bit.
|
||||
// Parameter `traceSource` is used for tracing to the source variable if given `value` is type of pinter
|
||||
// that also points to a pointer. It returns nil if the source is nil when `traceSource` is true.
|
||||
// Note that it might use reflect feature which affects performance a little.
|
||||
func IsNil(value interface{}, traceSource ...bool) bool {
|
||||
if value == nil {
|
||||
return true
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
// Package structs provides functions for struct conversion.
|
||||
// Package structs provides functions for struct information retrieving and struct conversion.
|
||||
//
|
||||
// Inspired and improved from: https://github.com/fatih/structs
|
||||
package structs
|
||||
|
||||
@ -16,7 +16,7 @@ func (f *Field) Tag(key string) string {
|
||||
|
||||
// TagLookup returns the value associated with key in the tag string.
|
||||
// If the key is present in the tag the value (which may be empty)
|
||||
// is returned. Otherwise the returned value will be the empty string.
|
||||
// is returned. Otherwise, the returned value will be the empty string.
|
||||
// The ok return value reports whether the value was explicitly set in
|
||||
// the tag string. If the tag does not have the conventional format,
|
||||
// the value returned by Lookup is unspecified.
|
||||
|
||||
@ -53,7 +53,7 @@ func ParseTag(tag string) map[string]string {
|
||||
if i >= len(tag) {
|
||||
break
|
||||
}
|
||||
quotedValue := string(tag[:i+1])
|
||||
quotedValue := tag[:i+1]
|
||||
tag = tag[i+1:]
|
||||
value, err := strconv.Unquote(quotedValue)
|
||||
if err != nil {
|
||||
@ -137,6 +137,7 @@ func getFieldValues(value interface{}) ([]*Field, error) {
|
||||
goto exitLoop
|
||||
}
|
||||
}
|
||||
|
||||
exitLoop:
|
||||
for reflectKind == reflect.Ptr {
|
||||
reflectValue = reflectValue.Elem()
|
||||
|
||||
@ -37,13 +37,16 @@ func StructType(object interface{}) (*Type, error) {
|
||||
reflectValue = reflectValue.Elem()
|
||||
reflectKind = reflectValue.Kind()
|
||||
}
|
||||
|
||||
case reflect.Array, reflect.Slice:
|
||||
reflectValue = reflect.New(reflectValue.Type().Elem()).Elem()
|
||||
reflectKind = reflectValue.Kind()
|
||||
|
||||
default:
|
||||
goto exitLoop
|
||||
}
|
||||
}
|
||||
|
||||
exitLoop:
|
||||
for reflectKind == reflect.Ptr {
|
||||
reflectValue = reflectValue.Elem()
|
||||
@ -63,7 +66,7 @@ exitLoop:
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Signature returns an unique string as this type.
|
||||
// Signature returns a unique string as this type.
|
||||
func (t Type) Signature() string {
|
||||
return t.PkgPath() + "/" + t.String()
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ type ReadCloser struct {
|
||||
repeatable bool
|
||||
}
|
||||
|
||||
// NewRepeatReadCloser creates and returns a RepeatReadCloser object.
|
||||
// NewReadCloser creates and returns a RepeatReadCloser object.
|
||||
func NewReadCloser(content []byte, repeatable bool) io.ReadCloser {
|
||||
return &ReadCloser{
|
||||
content: content,
|
||||
@ -29,7 +29,7 @@ func NewReadCloser(content []byte, repeatable bool) io.ReadCloser {
|
||||
}
|
||||
}
|
||||
|
||||
// NewRepeatReadCloserWithReadCloser creates and returns a RepeatReadCloser object
|
||||
// NewReadCloserWithReadCloser creates and returns a RepeatReadCloser object
|
||||
// with given io.ReadCloser.
|
||||
func NewReadCloserWithReadCloser(r io.ReadCloser, repeatable bool) (io.ReadCloser, error) {
|
||||
content, err := ioutil.ReadAll(r)
|
||||
|
||||
Reference in New Issue
Block a user