comment update;standardize const naming for package gtcp/gudp

This commit is contained in:
John Guo
2021-08-08 13:10:21 +08:00
parent dc407bf293
commit fc1dfb7ff9
17 changed files with 114 additions and 112 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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()

View File

@ -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()
}

View File

@ -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)