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()
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.
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)
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)
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
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)
}
}