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

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

Loading…
Cancel
Save