Skip to content
Myr

chore: remove else instead of return/continue (#1502)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

As[ Effective Go](https://golang.org/doc/effective_go.html?#if) about `if` said, remove else statement instead of return/continue statement.

authored by 田欧 · committed by Bo-Yi Wu · parent 0ebd42d · Browse files · 3 files+14 added−16 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+14 added−16 removed

  • other:+14 added−16 removed

3 files+14 added−16 removed

modified:binding/form_mapping.go+8 added-8 removed
72 unmodified lines
73 return err74 }75 }76 val.Field(i).Set(slice)77 } else {78 if _, isTime := structField.Interface().(time.Time); isTime {79 if err := setTimeField(inputValue[0], typeField, structField); err != nil {80 return err81 }82 continue83 }84 if err := setWithProperType(typeField.Type.Kind(), inputValue[0], structField); err != nil {77 continue78 }79 if _, isTime := structField.Interface().(time.Time); isTime {80 if err := setTimeField(inputValue[0], typeField, structField); err != nil {81 return err82 }83 continue84 }85 if err := setWithProperType(typeField.Type.Kind(), inputValue[0], structField); err != nil {86 return err87 }88 }89 return nil90}91
118 unmodified lines
modified:render/json.go+2 added-4 removed
126 unmodified lines
127 }128129 var buffer bytes.Buffer130 for _, r := range string(ret) {131 cvt := ""132 if r < 128 {133 cvt = string(r)134 } else {131 cvt := string(r)132 if r >= 128 {133 cvt = fmt.Sprintf("\\u%04x", int64(r))134 }135 buffer.WriteString(cvt)136 }
8 unmodified lines
modified:context.go+4 added-4 removed
663 unmodified lines
664// If value == "", this method removes the header `c.Writer.Header().Del(key)`665func (c *Context) Header(key, value string) {666 if value == "" {667 c.Writer.Header().Del(key)668 } else {669 c.Writer.Header().Set(key, value)668 return669 }670 c.Writer.Header().Set(key, value)671}672673// GetHeader returns value from request headers.674func (c *Context) GetHeader(key string) string {
79 unmodified lines
754func (c *Context) JSONP(code int, obj interface{}) {755 callback := c.DefaultQuery("callback", "")756 if callback == "" {757 c.Render(code, render.JSON{Data: obj})758 } else {759 c.Render(code, render.JsonpJSON{Callback: callback, Data: obj})758 return759 }760 c.Render(code, render.JsonpJSON{Callback: callback, Data: obj})761}762763// JSON serializes the given struct as JSON into the response body.764// It also sets the Content-Type as "application/json".
184 unmodified lines