diff --git a/core/stores/sqlx/orm.go b/core/stores/sqlx/orm.go index 2f17fe4f..edba340a 100644 --- a/core/stores/sqlx/orm.go +++ b/core/stores/sqlx/orm.go @@ -216,18 +216,18 @@ func unmarshalRows(v interface{}, scanner rowsScanner, strict bool) error { if err := scanner.Scan(values...); err != nil { return err - } else { - appendFn(value) } + + appendFn(value) } default: return ErrUnsupportedValueType } return nil - } else { - return ErrNotSettable } + + return ErrNotSettable default: return ErrUnsupportedValueType } diff --git a/core/trace/carrier.go b/core/trace/carrier.go index 0970656b..004ace7f 100644 --- a/core/trace/carrier.go +++ b/core/trace/carrier.go @@ -30,9 +30,9 @@ func (h httpCarrier) Set(key, val string) { func (g grpcCarrier) Get(key string) string { if vals, ok := g[strings.ToLower(key)]; ok && len(vals) > 0 { return vals[0] - } else { - return "" } + + return "" } func (g grpcCarrier) Set(key, val string) { diff --git a/core/trace/propagator.go b/core/trace/propagator.go index 39b18479..32ebf727 100644 --- a/core/trace/propagator.go +++ b/core/trace/propagator.go @@ -27,35 +27,35 @@ type ( ) func (h httpPropagator) Extract(carrier interface{}) (Carrier, error) { - if c, ok := carrier.(http.Header); !ok { - return nil, ErrInvalidCarrier - } else { + if c, ok := carrier.(http.Header); ok { return httpCarrier(c), nil } + + return nil, ErrInvalidCarrier } func (h httpPropagator) Inject(carrier interface{}) (Carrier, error) { if c, ok := carrier.(http.Header); ok { return httpCarrier(c), nil - } else { - return nil, ErrInvalidCarrier } + + return nil, ErrInvalidCarrier } func (g grpcPropagator) Extract(carrier interface{}) (Carrier, error) { if c, ok := carrier.(metadata.MD); ok { return grpcCarrier(c), nil - } else { - return nil, ErrInvalidCarrier } + + return nil, ErrInvalidCarrier } func (g grpcPropagator) Inject(carrier interface{}) (Carrier, error) { if c, ok := carrier.(metadata.MD); ok { return grpcCarrier(c), nil - } else { - return nil, ErrInvalidCarrier } + + return nil, ErrInvalidCarrier } func Extract(format, carrier interface{}) (Carrier, error) { diff --git a/rest/engine.go b/rest/engine.go index a39547f1..b022e10e 100644 --- a/rest/engine.go +++ b/rest/engine.go @@ -155,15 +155,16 @@ func (s *engine) createMetrics() *stat.Metrics { func (s *engine) getLogHandler() func(http.Handler) http.Handler { if s.conf.Verbose { return handler.DetailedLogHandler - } else { - return handler.LogHandler } + + return handler.LogHandler } func (s *engine) getShedder(priority bool) load.Shedder { if priority && s.priorityShedder != nil { return s.priorityShedder } + return s.shedder } @@ -177,11 +178,11 @@ func (s *engine) signatureVerifier(signature signatureSetting) (func(chain alice if len(signature.PrivateKeys) == 0 { if signature.Strict { return nil, ErrSignatureConfig - } else { - return func(chain alice.Chain) alice.Chain { - return chain - }, nil } + + return func(chain alice.Chain) alice.Chain { + return chain + }, nil } decrypters := make(map[string]codec.RsaDecrypter) @@ -200,10 +201,10 @@ func (s *engine) signatureVerifier(signature signatureSetting) (func(chain alice if s.unsignedCallback != nil { return chain.Append(handler.ContentSecurityHandler( decrypters, signature.Expiry, signature.Strict, s.unsignedCallback)) - } else { - return chain.Append(handler.ContentSecurityHandler( - decrypters, signature.Expiry, signature.Strict)) } + + return chain.Append(handler.ContentSecurityHandler( + decrypters, signature.Expiry, signature.Strict)) }, nil } diff --git a/tools/goctl/model/sql/test/orm.go b/tools/goctl/model/sql/test/orm.go index 022120a0..6cb35a7e 100644 --- a/tools/goctl/model/sql/test/orm.go +++ b/tools/goctl/model/sql/test/orm.go @@ -109,10 +109,10 @@ func parseTagName(field reflect.StructField) string { key := field.Tag.Get(tagName) if len(key) == 0 { return "" - } else { - options := strings.Split(key, ",") - return options[0] } + + options := strings.Split(key, ",") + return options[0] } func unmarshalRow(v interface{}, scanner rowsScanner, strict bool) error { @@ -138,19 +138,20 @@ func unmarshalRow(v interface{}, scanner rowsScanner, strict bool) error { reflect.String: if rve.CanSet() { return scanner.Scan(v) - } else { - return ErrNotSettable } + + return ErrNotSettable case reflect.Struct: columns, err := scanner.Columns() if err != nil { return err } - if values, err := mapStructFieldsIntoSlice(rve, columns, strict); err != nil { + + values, err := mapStructFieldsIntoSlice(rve, columns, strict) + if err != nil { return err - } else { - return scanner.Scan(values...) } + return scanner.Scan(values...) default: return ErrUnsupportedValueType } @@ -180,10 +181,10 @@ func unmarshalRows(v interface{}, scanner rowsScanner, strict bool) error { if rve.CanSet() { if err := scanner.Scan(value); err != nil { return err - } else { - appendFn(reflect.ValueOf(value)) - return nil } + + appendFn(reflect.ValueOf(value)) + return nil } return ErrNotSettable } @@ -209,14 +210,15 @@ func unmarshalRows(v interface{}, scanner rowsScanner, strict bool) error { for scanner.Next() { value := reflect.New(base) - if values, err := mapStructFieldsIntoSlice(value, columns, strict); err != nil { + values, err := mapStructFieldsIntoSlice(value, columns, strict) + if err != nil { + return err + } + + if err := scanner.Scan(values...); err != nil { return err } else { - if err := scanner.Scan(values...); err != nil { - return err - } else { - appendFn(value) - } + appendFn(value) } } default: