1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00

test&doc: add example and update doc for xerror package

This commit is contained in:
dudaodong
2023-01-08 20:36:32 +08:00
parent 7380721ccc
commit a930511054

View File

@@ -0,0 +1,25 @@
package xerror
import (
"fmt"
"reflect"
"strconv"
)
func ExampleUnwrap() {
result1 := Unwrap(strconv.Atoi("42"))
fmt.Println(result1)
_, err := strconv.Atoi("4o2")
defer func() {
v := recover()
result2 := reflect.DeepEqual(err.Error(), v.(*strconv.NumError).Error())
fmt.Println(result2)
}()
Unwrap(strconv.Atoi("4o2"))
// Output:
// 42
// true
}