fix golint issues (#584)

master
Kevin Wan 4 years ago committed by GitHub
parent 888551627c
commit bbb4ce586f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -170,6 +170,28 @@ func implicitValueRequiredStruct(tag string, tp reflect.Type) (bool, error) {
return false, nil
}
func isLeftInclude(b byte) (bool, error) {
switch b {
case '[':
return true, nil
case '(':
return false, nil
default:
return false, errNumberRange
}
}
func isRightInclude(b byte) (bool, error) {
switch b {
case ']':
return true, nil
case ')':
return false, nil
default:
return false, errNumberRange
}
}
func maybeNewValue(field reflect.StructField, value reflect.Value) {
if field.Type.Kind() == reflect.Ptr && value.IsNil() {
value.Set(reflect.New(value.Type().Elem()))
@ -211,14 +233,9 @@ func parseNumberRange(str string) (*numberRange, error) {
return nil, errNumberRange
}
var leftInclude bool
switch str[0] {
case '[':
leftInclude = true
case '(':
leftInclude = false
default:
return nil, errNumberRange
leftInclude, err := isLeftInclude(str[0])
if err != nil {
return nil, err
}
str = str[1:]
@ -226,14 +243,9 @@ func parseNumberRange(str string) (*numberRange, error) {
return nil, errNumberRange
}
var rightInclude bool
switch str[len(str)-1] {
case ']':
rightInclude = true
case ')':
rightInclude = false
default:
return nil, errNumberRange
rightInclude, err := isRightInclude(str[len(str)-1])
if err != nil {
return nil, err
}
str = str[:len(str)-1]

@ -7,9 +7,11 @@ import (
"google.golang.org/grpc/status"
)
// DespositServer is used for mocking.
type DepositServer struct {
}
// Deposit handles the deposit requests.
func (*DepositServer) Deposit(ctx context.Context, req *DepositRequest) (*DepositResponse, error) {
if req.GetAmount() < 0 {
return nil, status.Errorf(codes.InvalidArgument, "cannot deposit %v", req.GetAmount())

Loading…
Cancel
Save