Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize: remove unnecessary codes #208

Merged
merged 1 commit into from
Aug 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions pkg/rm/two_phase.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,9 @@ func ParseTwoPhaseActionByInterface(v interface{}) (*TwoPhaseAction, error) {
typeOf := valueOfElem.Type()
k := typeOf.Kind()
if k != reflect.Struct {
return nil, errors.New("invalid type kind")
}
numField := typeOf.NumField()
if typeOf.Kind() != reflect.Struct {
return nil, errors.New("param should be a struct, instead of a pointer")
}
numField := typeOf.NumField()

var (
hasPrepareMethodName bool
Expand Down Expand Up @@ -213,7 +210,7 @@ func getPrepareAction(t reflect.StructField, f reflect.Value) (string, *reflect.
if f.Kind() != reflect.Func || !f.IsValid() {
return "", nil, false
}
// prepare has 2 retuen error value
// prepare has 2 return error value
if outNum := t.Type.NumOut(); outNum != 2 {
return "", nil, false
}
Expand All @@ -240,7 +237,7 @@ func getCommitMethod(t reflect.StructField, f reflect.Value) (string, *reflect.V
if f.Kind() != reflect.Func || !f.IsValid() {
return "", nil, false
}
// commit method has 2 retuen error value
// commit method has 2 return error value
if outNum := t.Type.NumOut(); outNum != 2 {
return "", nil, false
}
Expand Down Expand Up @@ -271,7 +268,7 @@ func getRollbackMethod(t reflect.StructField, f reflect.Value) (string, *reflect
if f.Kind() != reflect.Func || !f.IsValid() {
return "", nil, false
}
// rollback method has 2 retuen value
// rollback method has 2 return value
if outNum := t.Type.NumOut(); outNum != 2 {
return "", nil, false
}
Expand Down