MCPcopy Create free account
hub / github.com/Go-Learning-Land/Go-Learning-Archive / main

Function main

GolangBasics/GoByExample/022Error.go:35–57  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33}
34
35func main() {
36
37 for _, i := range []int{7, 42} {
38 if r, e := f1(i); e != nil {
39 fmt.Println("f1 failed:", e)
40 } else {
41 fmt.Println("f1 worked:", r)
42 }
43 }
44 for _, i := range []int{7, 42} {
45 if r, e := f2(i); e != nil {
46 fmt.Println("f2 failed:", e)
47 } else {
48 fmt.Println("f2 worked:", r)
49 }
50 }
51
52 _, e := f2(42)
53 if ae, ok := e.(*argError); ok {
54 fmt.Println(ae.arg)
55 fmt.Println(ae.prob)
56 }
57}

Callers

nothing calls this directly

Calls 3

PrintlnMethod · 0.80
f1Function · 0.70
f2Function · 0.70

Tested by

no test coverage detected