42
43 duplicateAlias, val := string_handling.IsDuplicateInStringSlice(althelp)
44 if val {
45 log.Fatalf("Found duplicate alias: %s", duplicateAlias)46 }
47}
48
Packages exposing functions that can stop program execution by exiting are hard to reuse. Program exits in functions other than main() or init() are not encouraged.
func nonMainFunc() {
safelyExit := true // somehow arrive at this value
if safelyExit {
os.Exit(0)
}
}
func main() {
nonMainFunc()
}
func nonMainFunc() bool {
safelyExit := true // somehow arrive at this value
}
func main() {
safelyExit := nonMainFunc()
if safelyExit {
os.Exit(0)
}
}