()
| 24 | } |
| 25 | |
| 26 | func 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 | } |