chore: remove else instead of return/continue (#1502)
As[ Effective Go](https://golang.org/doc/effective_go.html?#if) about `if` said, remove else statement instead of return/continue statement.
This commit is contained in:
parent
0ebd42d0a9
commit
85f3e78abc
@ -74,16 +74,16 @@ func mapForm(ptr interface{}, form map[string][]string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
val.Field(i).Set(slice)
|
val.Field(i).Set(slice)
|
||||||
} else {
|
continue
|
||||||
if _, isTime := structField.Interface().(time.Time); isTime {
|
}
|
||||||
if err := setTimeField(inputValue[0], typeField, structField); err != nil {
|
if _, isTime := structField.Interface().(time.Time); isTime {
|
||||||
return err
|
if err := setTimeField(inputValue[0], typeField, structField); err != nil {
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if err := setWithProperType(typeField.Type.Kind(), inputValue[0], structField); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err := setWithProperType(typeField.Type.Kind(), inputValue[0], structField); err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -665,9 +665,9 @@ func (c *Context) Status(code int) {
|
|||||||
func (c *Context) Header(key, value string) {
|
func (c *Context) Header(key, value string) {
|
||||||
if value == "" {
|
if value == "" {
|
||||||
c.Writer.Header().Del(key)
|
c.Writer.Header().Del(key)
|
||||||
} else {
|
return
|
||||||
c.Writer.Header().Set(key, value)
|
|
||||||
}
|
}
|
||||||
|
c.Writer.Header().Set(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetHeader returns value from request headers.
|
// GetHeader returns value from request headers.
|
||||||
@ -755,9 +755,9 @@ func (c *Context) JSONP(code int, obj interface{}) {
|
|||||||
callback := c.DefaultQuery("callback", "")
|
callback := c.DefaultQuery("callback", "")
|
||||||
if callback == "" {
|
if callback == "" {
|
||||||
c.Render(code, render.JSON{Data: obj})
|
c.Render(code, render.JSON{Data: obj})
|
||||||
} else {
|
return
|
||||||
c.Render(code, render.JsonpJSON{Callback: callback, Data: obj})
|
|
||||||
}
|
}
|
||||||
|
c.Render(code, render.JsonpJSON{Callback: callback, Data: obj})
|
||||||
}
|
}
|
||||||
|
|
||||||
// JSON serializes the given struct as JSON into the response body.
|
// JSON serializes the given struct as JSON into the response body.
|
||||||
|
@ -128,10 +128,8 @@ func (r AsciiJSON) Render(w http.ResponseWriter) (err error) {
|
|||||||
|
|
||||||
var buffer bytes.Buffer
|
var buffer bytes.Buffer
|
||||||
for _, r := range string(ret) {
|
for _, r := range string(ret) {
|
||||||
cvt := ""
|
cvt := string(r)
|
||||||
if r < 128 {
|
if r >= 128 {
|
||||||
cvt = string(r)
|
|
||||||
} else {
|
|
||||||
cvt = fmt.Sprintf("\\u%04x", int64(r))
|
cvt = fmt.Sprintf("\\u%04x", int64(r))
|
||||||
}
|
}
|
||||||
buffer.WriteString(cvt)
|
buffer.WriteString(cvt)
|
||||||
|
Loading…
Reference in New Issue
Block a user