From 770bc88b88dee1e525da7c997f6322a23e0f6f1d Mon Sep 17 00:00:00 2001 From: dudaodong Date: Wed, 15 Feb 2023 10:14:26 +0800 Subject: [PATCH] doc: update doc for xerror package --- docs/xerror.md | 12 ++++++------ docs/xerror_zh-CN.md | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/xerror.md b/docs/xerror.md index c760bb9..1a1dc54 100644 --- a/docs/xerror.md +++ b/docs/xerror.md @@ -22,20 +22,20 @@ import ( ## Index -- [Unwrap](#Unwrap) +- [TryUnwrap](#TryUnwrap)
## Documentation -### Unwrap +### TryUnwrap -

Unwrap if err is nil then it returns a valid value. If err is not nil, Unwrap panics with err.

+

TryUnwrap if err is nil then it returns a valid value. If err is not nil, Unwrap panics with err.

Signature: ```go -func Unwrap[T any](val T, err error) T +func TryUnwrap[T any](val T, err error) T ``` Example: @@ -49,7 +49,7 @@ import ( ) func main() { - result1 := xerror.Unwrap(strconv.Atoi("42")) + result1 := xerror.TryUnwrap(strconv.Atoi("42")) fmt.Println(result1) _, err := strconv.Atoi("4o2") @@ -59,7 +59,7 @@ func main() { fmt.Println(result2) }() - xerror.Unwrap(strconv.Atoi("4o2")) + xerror.TryUnwrap(strconv.Atoi("4o2")) // Output: // 42 diff --git a/docs/xerror_zh-CN.md b/docs/xerror_zh-CN.md index 0a466df..8ebc0da 100644 --- a/docs/xerror_zh-CN.md +++ b/docs/xerror_zh-CN.md @@ -22,20 +22,20 @@ import ( ## 目录 -- [Unwrap](#Unwrap) +- [TryUnwrap](#TryUnwrap)
## 文档 -### Unwrap +### TryUnwrap -

检查error, 如果err为nil则展开,则它返回一个有效值,如果err不是nil则Unwrap使用err发生panic。

+

检查error, 如果err为nil则展开,则它返回一个有效值,如果err不是nil则TryUnwrap使用err发生panic。

函数签名: ```go -func Unwrap[T any](val T, err error) T +func TryUnwrap[T any](val T, err error) T ``` 示例: @@ -49,7 +49,7 @@ import ( ) func main() { - result1 := xerror.Unwrap(strconv.Atoi("42")) + result1 := xerror.TryUnwrap(strconv.Atoi("42")) fmt.Println(result1) _, err := strconv.Atoi("4o2") @@ -59,7 +59,7 @@ func main() { fmt.Println(result2) }() - xerror.Unwrap(strconv.Atoi("4o2")) + xerror.TryUnwrap(strconv.Atoi("4o2")) // Output: // 42