Debian Codegraph @

test/fixedbugs/issue74379.go

raw
1 // run
2
3 // Copyright 2025 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
6
7 package main
8
9 import (
10 "errors"
11 "fmt"
12 "os"
13 )
14
15 func crashOnErr(err error) bool {
16 if err != nil {
17 panic(err)
18 }
19 return false
20 }
21
22 func main() {
23 defer func() {
24 if recover() == nil {
25 fmt.Println("failed to have expected panic")
26 os.Exit(1)
27 }
28 }()
29 fmt.Println(crashOnErr(errors.New("test error")))
30 }