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 {
return err
} else {
appendFn(value)
}
appendFn(value)
}
default:
return ErrUnsupportedValueType
}
return nil
} else {
return ErrNotSettable
}
return ErrNotSettable
default:
return ErrUnsupportedValueType
}

@ -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) {

@ -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) {

@ -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
}

@ -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:

Loading…
Cancel
Save