Exit inside non-main function RVV-A0003
Anti-pattern
Major
6 months agoa year old
calls to log.Fatalln only in main() or init() functions
18	ln := portless.NewTunnel()
19	conn0, err := Dial(addr, from)
20	if err != nil {
21		log.Fatalln(err)22	}
23
24	go func() {
calls to log.Fatalln only in main() or init() functions
10func listener(p string) net.Listener {
11	ln, err := net.Listen("tcp", p)
12	if err != nil {
13		log.Fatalln(err)14	}
15	return ln
16}
calls to os.Exit only in main() or init() functions
362
363func errorExit(message string) {
364	fmt.Fprintln(os.Stderr, message)
365	os.Exit(2)366}
367
368func init() {
calls to os.Exit only in main() or init() functions
 39			}
 40		}
 41		fmt.Fprintln(os.Stderr, "Failed to open "+consoleDevice)
 42		os.Exit(2) 43	}
 44	return in
 45}
calls to os.Exit only in main() or init() functions
1593						case code := <-t.killChan:
1594							if code != exitCancel {
1595								util.KillCommand(cmd)
1596								os.Exit(code)1597							} else {
1598								select {
1599								case <-time.After(previewCancelWait):