fix golint issues (#458)

master
Kevin Wan 4 years ago committed by GitHub
parent 5e969cbef0
commit 03b5fd4a10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -216,18 +216,18 @@ func unmarshalRows(v interface{}, scanner rowsScanner, strict bool) error {
if err := scanner.Scan(values...); err != nil { if err := scanner.Scan(values...); err != nil {
return err return err
} else {
appendFn(value)
} }
appendFn(value)
} }
default: default:
return ErrUnsupportedValueType return ErrUnsupportedValueType
} }
return nil return nil
} else {
return ErrNotSettable
} }
return ErrNotSettable
default: default:
return ErrUnsupportedValueType return ErrUnsupportedValueType
} }

@ -30,9 +30,9 @@ func (h httpCarrier) Set(key, val string) {
func (g grpcCarrier) Get(key string) string { func (g grpcCarrier) Get(key string) string {
if vals, ok := g[strings.ToLower(key)]; ok && len(vals) > 0 { if vals, ok := g[strings.ToLower(key)]; ok && len(vals) > 0 {
return vals[0] return vals[0]
} else {
return ""
} }
return ""
} }
func (g grpcCarrier) Set(key, val string) { func (g grpcCarrier) Set(key, val string) {

@ -27,35 +27,35 @@ type (
) )
func (h httpPropagator) Extract(carrier interface{}) (Carrier, error) { func (h httpPropagator) Extract(carrier interface{}) (Carrier, error) {
if c, ok := carrier.(http.Header); !ok { if c, ok := carrier.(http.Header); ok {
return nil, ErrInvalidCarrier
} else {
return httpCarrier(c), nil return httpCarrier(c), nil
} }
return nil, ErrInvalidCarrier
} }
func (h httpPropagator) Inject(carrier interface{}) (Carrier, error) { func (h httpPropagator) Inject(carrier interface{}) (Carrier, error) {
if c, ok := carrier.(http.Header); ok { if c, ok := carrier.(http.Header); ok {
return httpCarrier(c), nil return httpCarrier(c), nil
} else {
return nil, ErrInvalidCarrier
} }
return nil, ErrInvalidCarrier
} }
func (g grpcPropagator) Extract(carrier interface{}) (Carrier, error) { func (g grpcPropagator) Extract(carrier interface{}) (Carrier, error) {
if c, ok := carrier.(metadata.MD); ok { if c, ok := carrier.(metadata.MD); ok {
return grpcCarrier(c), nil return grpcCarrier(c), nil
} else {
return nil, ErrInvalidCarrier
} }
return nil, ErrInvalidCarrier
} }
func (g grpcPropagator) Inject(carrier interface{}) (Carrier, error) { func (g grpcPropagator) Inject(carrier interface{}) (Carrier, error) {
if c, ok := carrier.(metadata.MD); ok { if c, ok := carrier.(metadata.MD); ok {
return grpcCarrier(c), nil return grpcCarrier(c), nil
} else {
return nil, ErrInvalidCarrier
} }
return nil, ErrInvalidCarrier
} }
func Extract(format, carrier interface{}) (Carrier, error) { func Extract(format, carrier interface{}) (Carrier, error) {

@ -155,15 +155,16 @@ func (s *engine) createMetrics() *stat.Metrics {
func (s *engine) getLogHandler() func(http.Handler) http.Handler { func (s *engine) getLogHandler() func(http.Handler) http.Handler {
if s.conf.Verbose { if s.conf.Verbose {
return handler.DetailedLogHandler return handler.DetailedLogHandler
} else {
return handler.LogHandler
} }
return handler.LogHandler
} }
func (s *engine) getShedder(priority bool) load.Shedder { func (s *engine) getShedder(priority bool) load.Shedder {
if priority && s.priorityShedder != nil { if priority && s.priorityShedder != nil {
return s.priorityShedder return s.priorityShedder
} }
return s.shedder return s.shedder
} }
@ -177,11 +178,11 @@ func (s *engine) signatureVerifier(signature signatureSetting) (func(chain alice
if len(signature.PrivateKeys) == 0 { if len(signature.PrivateKeys) == 0 {
if signature.Strict { if signature.Strict {
return nil, ErrSignatureConfig 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) decrypters := make(map[string]codec.RsaDecrypter)
@ -200,10 +201,10 @@ func (s *engine) signatureVerifier(signature signatureSetting) (func(chain alice
if s.unsignedCallback != nil { if s.unsignedCallback != nil {
return chain.Append(handler.ContentSecurityHandler( return chain.Append(handler.ContentSecurityHandler(
decrypters, signature.Expiry, signature.Strict, s.unsignedCallback)) 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 }, nil
} }

@ -109,10 +109,10 @@ func parseTagName(field reflect.StructField) string {
key := field.Tag.Get(tagName) key := field.Tag.Get(tagName)
if len(key) == 0 { if len(key) == 0 {
return "" 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 { func unmarshalRow(v interface{}, scanner rowsScanner, strict bool) error {
@ -138,19 +138,20 @@ func unmarshalRow(v interface{}, scanner rowsScanner, strict bool) error {
reflect.String: reflect.String:
if rve.CanSet() { if rve.CanSet() {
return scanner.Scan(v) return scanner.Scan(v)
} else {
return ErrNotSettable
} }
return ErrNotSettable
case reflect.Struct: case reflect.Struct:
columns, err := scanner.Columns() columns, err := scanner.Columns()
if err != nil { if err != nil {
return err return err
} }
if values, err := mapStructFieldsIntoSlice(rve, columns, strict); err != nil {
values, err := mapStructFieldsIntoSlice(rve, columns, strict)
if err != nil {
return err return err
} else {
return scanner.Scan(values...)
} }
return scanner.Scan(values...)
default: default:
return ErrUnsupportedValueType return ErrUnsupportedValueType
} }
@ -180,10 +181,10 @@ func unmarshalRows(v interface{}, scanner rowsScanner, strict bool) error {
if rve.CanSet() { if rve.CanSet() {
if err := scanner.Scan(value); err != nil { if err := scanner.Scan(value); err != nil {
return err return err
} else {
appendFn(reflect.ValueOf(value))
return nil
} }
appendFn(reflect.ValueOf(value))
return nil
} }
return ErrNotSettable return ErrNotSettable
} }
@ -209,14 +210,15 @@ func unmarshalRows(v interface{}, scanner rowsScanner, strict bool) error {
for scanner.Next() { for scanner.Next() {
value := reflect.New(base) 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 return err
} else { } else {
if err := scanner.Scan(values...); err != nil { appendFn(value)
return err
} else {
appendFn(value)
}
} }
} }
default: default:

Loading…
Cancel
Save