gochan-org / gochan

Exit inside non-main function RVV-A0003
Anti-pattern
Major
2 months ago2 years old
calls to os.Exit only in main() or init() functions
169	if delstaff != "" {
170		if newstaff != "" {
171			flag.Usage()
172			os.Exit(1)173		}
174		fmt.Printf("Are you sure you want to delete the staff account %q? [y/N]: ", delstaff)
175
calls to os.Exit only in main() or init() functions
164			Str("username", arr[0]).
165			Msg("New staff account created")
166		fmt.Printf("New staff account created: %s\n", arr[0])
167		os.Exit(0)168	}
169	if delstaff != "" {
170		if newstaff != "" {
calls to os.Exit only in main() or init() functions
147		arr := strings.Split(newstaff, ":")
148		if len(arr) < 2 || delstaff != "" {
149			flag.Usage()
150			os.Exit(1)151		}
152		fmt.Printf("Creating new staff: %q, with password: %q and rank: %d from command line", arr[0], arr[1], rank)
153		if _, err = gcsql.NewStaff(arr[0], arr[1], rank); err != nil {
calls to os.Exit only in main() or init() functions
157	}
158	if _, err = os.Stat(cfg.LogDir); err != nil {
159		fmt.Println(err.Error())
160		os.Exit(1)161	}
162
163	cfg.LogDir = gcutil.FindResource(cfg.LogDir, "log", "/var/log/gochan/")
calls to os.Exit only in main() or init() functions
153	}
154	if _, err = os.Stat(cfg.TemplateDir); err != nil {
155		fmt.Println(err.Error())
156		os.Exit(1)157	}
158	if _, err = os.Stat(cfg.LogDir); err != nil {
159		fmt.Println(err.Error())