apppackio / apppack

Exit inside non-main function RVV-A0003
Anti-pattern
Major
2 months ago3 years old
calls to log.Fatal only in main() or init() functions
125func tempFilePath() string {
126	file, err := os.CreateTemp("", "")
127	if err != nil {
128		log.Fatal(err)129	}
130	os.Remove(file.Name())
131	return file.Name()
calls to os.Exit only in main() or init() functions
129	} else {
130		printError(err.Error())
131	}
132	os.Exit(1)133}
134
135func printError(text string) {
calls to os.Exit only in main() or init() functions
101	// run command
102	if err := rootCmd.Execute(); err != nil {
103		fmt.Println(err)
104		os.Exit(1)105	}
106
107	updateCancel() // if the update checker hasn't completed by now, abort it
calls to os.Exit only in main() or init() functions
133	}
134
135	waitStatus := cmd.ProcessState.Sys().(syscall.WaitStatus)
136	os.Exit(waitStatus.ExitStatus())137	return nil
138}
139