Exit inside non-main function RVV-A0003
Anti-pattern
Major
6 months ago3 years old
calls to os.Exit only in main() or init() functions
 67	if cmd, ok := commands[name]; ok {
 68		cmd.Parse(os.Args[3:])
 69		cmd.Run()
 70		os.Exit(0) 71	} else {
 72		if name == "" {
 73			printHelp()
calls to os.Exit only in main() or init() functions
 46		fmt.Println(errs[0])
 47	}
 48	fmt.Println(content)
 49	os.Exit(2) 50}
 51
 52// RunCommand listens for orm command and runs if command arguments have been passed.
calls to log.Panicf only in main() or init() functions
800		log.Panicf("Failed to parse int from %s: %s", expr, err)
801	}
802	if num < 0 {
803		log.Panicf("Negative number (%d) not allowed: %s", num, expr)804	}
805
806	return uint(num)
calls to log.Panicf only in main() or init() functions
797func mustParseInt(expr string) uint {
798	num, err := strconv.Atoi(expr)
799	if err != nil {
800		log.Panicf("Failed to parse int from %s: %s", expr, err)801	}
802	if num < 0 {
803		log.Panicf("Negative number (%d) not allowed: %s", num, expr)
calls to log.Panicf only in main() or init() functions
777		log.Panicf("End of range (%d) above maximum (%d): %s", end, r.max, expr)
778	}
779	if start > end {
780		log.Panicf("Beginning of range (%d) beyond end of range (%d): %s", start, end, expr)781	}
782
783	return getBits(start, end, step) | extrastar