should omit comparison to bool constant, can be simplified to !readKeys(os.Args[1])
115 fmt.Println("Not enough arguments")
116 os.Exit(-1)
117 }
118 if readKeys(os.Args[1]) == false {119 os.Exit(-2)
120 }
121 encryptedFileRaw = readDataFile(os.Args[3], &encryptedPackets, &sizeEncryptedFile)
Description
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.
Bad practice
if isUserLoggedIn == true {}
if unnecessaryComparison {}
Recommended
After:
if isUserLoggedIn {}
if isComparisonUnnecessary {}