github.com/serversong/goreporter@v0.0.0-20200325104552-3cfaf44fd178/linters/staticcheck/testdata/CheckFlagUsage.go (about) 1 package pkg 2 3 import ( 4 "flag" 5 "os" 6 ) 7 8 type T struct { 9 Usage func() 10 } 11 12 func fn1() { 13 f := flag.NewFlagSet("", 0) 14 f.Usage = func() { 15 println("") 16 } 17 f.Usage = func() { // MATCH /the function assigned to Usage shouldn't call os.Exit/ 18 println("") 19 os.Exit(1) 20 } 21 f.Usage = func() { // MATCH /the function assigned to Usage shouldn't call os.Exit/ 22 println("") 23 if true { 24 os.Exit(1) 25 } 26 } 27 28 f = &flag.FlagSet{} 29 f.Usage = func() { // MATCH /the function assigned to Usage shouldn't call os.Exit/ 30 os.Exit(1) 31 } 32 33 f2 := flag.FlagSet{} 34 f2.Usage = func() { // MATCH /the function assigned to Usage shouldn't call os.Exit/ 35 os.Exit(1) 36 } 37 38 flag.Usage = func() { // MATCH /the function assigned to Usage shouldn't call os.Exit/ 39 os.Exit(1) 40 } 41 42 t := &T{} 43 t.Usage = func() { 44 os.Exit(1) 45 } 46 } 47 48 func fn2(arg func()) { 49 flag.Usage = arg 50 }