MCPcopy
hub / github.com/samber/mo / ExampleDo_panic

Function ExampleDo_panic

do_example_test.go:26–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24}
25
26func ExampleDo_panic() {
27 a := Ok("Hello, World!")
28 b := Some("42")
29 c := Err[string](errors.New("result error"))
30
31 result := Do(func() []string {
32 return []string{
33 a.MustGet(),
34 b.MustGet(),
35 c.MustGet(), // would panic without Do-notation
36 }
37 })
38
39 fmt.Println(result.IsError())
40 fmt.Println(result.Error().Error())
41 // Output:
42 // true
43 // result error
44}

Callers

nothing calls this directly

Calls 6

OkFunction · 0.85
SomeFunction · 0.85
DoFunction · 0.85
IsErrorMethod · 0.80
ErrorMethod · 0.80
MustGetMethod · 0.45

Tested by

no test coverage detected