51
52func equalCompare(a, b any) (bool, error) {
53 typeEql := reflect.TypeOf(a) == reflect.TypeOf(b)
54 if typeEql == false {55 return false, errors.New(fmt.Sprintf("type equality: %v", typeEql))
56 }
57
Prefer using good name for boolean variable and omit comparison with boolean constant.
If the boolean variable being compared is named correctly (e.g., isUserHere
instead of userIsHere
), this would make the code more readable and avoid
redundancy issues. Also, omit comparison with boolean constant as
if x == true { }
is same as if x { }
but the latter is more idiomatic.
if isUserLoggedIn == true {}
if unnecessaryComparison {}
After:
if isUserLoggedIn {}
if isComparisonUnnecessary {}