Skip to content

Commit

Permalink
fix golint issues (zeromicro#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan authored Feb 9, 2021
1 parent 5e969cb commit 03b5fd4
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 41 deletions.
8 changes: 4 additions & 4 deletions core/stores/sqlx/orm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions core/trace/carrier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
18 changes: 9 additions & 9 deletions core/trace/propagator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
19 changes: 10 additions & 9 deletions rest/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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)
Expand All @@ -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
}

Expand Down
36 changes: 19 additions & 17 deletions tools/goctl/model/sql/test/orm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Expand All @@ -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:
Expand Down

0 comments on commit 03b5fd4

Please sign in to comment.