improve code 'if block ends with a return statement, so drop this else and outdent its block (golint)'

This commit is contained in:
houseme 2021-11-16 00:26:10 +08:00
parent 47a4c6b58c
commit ff8633231f
7 changed files with 20 additions and 22 deletions

View File

@ -407,9 +407,8 @@ func (a *StrArray) SubSlice(offset int, length ...int) []string {
s := make([]string, size)
copy(s, a.array[offset:])
return s
} else {
return a.array[offset:end]
}
return a.array[offset:end]
}
// Append is alias of PushRight,please See PushRight.

View File

@ -27,25 +27,25 @@ func Decode(str string) (string, error) {
return url.QueryUnescape(str)
}
// URL-encode according to RFC 3986.
// RawEncode .URL-encode according to RFC 3986.
// See http://php.net/manual/en/function.rawurlencode.php.
func RawEncode(str string) string {
return strings.Replace(url.QueryEscape(str), "+", "%20", -1)
}
// Decode URL-encoded strings.
// RawDecode Decode URL-encoded strings.
// See http://php.net/manual/en/function.rawurldecode.php.
func RawDecode(str string) (string, error) {
return url.QueryUnescape(strings.Replace(str, "%20", "+", -1))
}
// Generate URL-encoded query string.
// BuildQuery Generate URL-encoded query string.
// See http://php.net/manual/en/function.http-build-query.php.
func BuildQuery(queryData url.Values) string {
return queryData.Encode()
}
// Parse a URL and return its components.
// ParseURL Parse a URL and return its components.
// -1: all; 1: scheme; 2: host; 4: port; 8: user; 16: pass; 32: path; 64: query; 128: fragment.
// See http://php.net/manual/en/function.parse-url.php.
func ParseURL(str string, component int) (map[string]string, error) {

View File

@ -6,8 +6,8 @@
// Package gerror provides simple functions to manipulate errors.
//
// Very note that, this package is quite a basic package, which SHOULD NOT import extra
// packages except standard packages and internal packages, to avoid cycle imports.
// Very note that, this package is quite a basic package, which SHOULD NOT import extra packages
// except standard packages and internal packages, to avoid cycle imports.
package gerror
import (

View File

@ -18,42 +18,42 @@ import (
// WriteTpl parses and responses given template file.
// The parameter `params` specifies the template variables for parsing.
func (r *Response) WriteTpl(tpl string, params ...gview.Params) error {
if b, err := r.ParseTpl(tpl, params...); err != nil {
b, err := r.ParseTpl(tpl, params...)
if err != nil {
if !gmode.IsProduct() {
r.Write("Template Parsing Error: " + err.Error())
}
return err
} else {
r.Write(b)
}
r.Write(b)
return nil
}
// WriteTplDefault parses and responses the default template file.
// The parameter `params` specifies the template variables for parsing.
func (r *Response) WriteTplDefault(params ...gview.Params) error {
if b, err := r.ParseTplDefault(params...); err != nil {
b, err := r.ParseTplDefault(params...)
if err != nil {
if !gmode.IsProduct() {
r.Write("Template Parsing Error: " + err.Error())
}
return err
} else {
r.Write(b)
}
r.Write(b)
return nil
}
// WriteTplContent parses and responses the template content.
// The parameter `params` specifies the template variables for parsing.
func (r *Response) WriteTplContent(content string, params ...gview.Params) error {
if b, err := r.ParseTplContent(content, params...); err != nil {
b, err := r.ParseTplContent(content, params...)
if err != nil {
if !gmode.IsProduct() {
r.Write("Template Parsing Error: " + err.Error())
}
return err
} else {
r.Write(b)
}
r.Write(b)
return nil
}

View File

@ -50,7 +50,7 @@ func (w *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
return w.writer.(http.Hijacker).Hijack()
}
// Flush OutputBuffer outputs the buffer to client and clears the buffer.
// Flush outputs the buffer to client and clears the buffer.
func (w *ResponseWriter) Flush() {
if w.hijacked {
return

View File

@ -9,7 +9,7 @@ package gres
import "github.com/gogf/gf/v2/container/gmap"
const (
// DefaultName Default group name for instance usage.
// DefaultName default group name for instance usage.
DefaultName = "default"
)

View File

@ -77,7 +77,7 @@ func (s *StorageRedis) Get(ctx context.Context, id string, key string) (value in
return nil, ErrorDisabled
}
// GetMap retrieves all key-value pairs as map from storage.
// Data retrieves all key-value pairs as map from storage.
func (s *StorageRedis) Data(ctx context.Context, id string) (data map[string]interface{}, err error) {
return nil, ErrorDisabled
}
@ -135,9 +135,8 @@ func (s *StorageRedis) GetSession(ctx context.Context, id string, ttl time.Durat
}
if data == nil {
return gmap.NewStrAnyMapFrom(m, true), nil
} else {
data.Replace(m)
}
data.Replace(m)
return data, nil
}