377func testKeysAreAvailable(t *testing.T) {
378 files, err := os.ReadDir(".")
379 if err != nil {
380 log.Fatal(err)381 }
382
383 for _, k := range []string{"cert.pem", "key.pem"} {
106// Fatal is equivalent to l.Critical(fmt.Sprint()) followed by a call to os.Exit(1).
107func (l BasicLogger) Fatal(v ...interface{}) {
108 l.prependLog("FATAL:", v...)
109 os.Exit(1)110}
111
112func (l BasicLogger) prependLog(level string, v ...interface{}) {
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)
}
}