18 ln := portless.NewTunnel()
19 conn0, err := Dial(addr, from)
20 if err != nil {
21 log.Fatalln(err)22 }
23
24 go func() {
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}
362
363func errorExit(message string) {
364 fmt.Fprintln(os.Stderr, message)
365 os.Exit(2)366}
367
368func init() {
39 }
40 }
41 fmt.Fprintln(os.Stderr, "Failed to open "+consoleDevice)
42 os.Exit(2) 43 }
44 return in
45}
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):
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)
}
}