From 9c8460fc44358f28a2c5cfee439d7fef56720ace Mon Sep 17 00:00:00 2001 From: zhaoyupeng Date: Fri, 4 Jul 2025 13:57:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20MustWithData?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- opt/opt.go | 4 ++++ resp/resp.go | 5 +++++ tool/must.go | 5 +++++ 3 files changed, 14 insertions(+) create mode 100644 opt/opt.go diff --git a/opt/opt.go b/opt/opt.go new file mode 100644 index 0000000..eaf0a63 --- /dev/null +++ b/opt/opt.go @@ -0,0 +1,4 @@ +package opt + +type Config struct { +} diff --git a/resp/resp.go b/resp/resp.go index a961dc6..f44db83 100644 --- a/resp/resp.go +++ b/resp/resp.go @@ -70,6 +70,7 @@ func _r(c *gin.Context, r *res, args ...any) { func R400(c *gin.Context, args ...any) { r := &res{ Status: 400, + Code: -1, } _r(c, r, args...) @@ -78,6 +79,7 @@ func R400(c *gin.Context, args ...any) { func R401(c *gin.Context, args ...any) { r := &res{ Status: 401, + Code: -1, } _r(c, r, args...) @@ -86,6 +88,7 @@ func R401(c *gin.Context, args ...any) { func R403(c *gin.Context, args ...any) { r := &res{ Status: 403, + Code: -1, } _r(c, r, args...) @@ -94,6 +97,7 @@ func R403(c *gin.Context, args ...any) { func R500(c *gin.Context, args ...any) { r := &res{ Status: 500, + Code: -1, } _r(c, r, args...) @@ -102,6 +106,7 @@ func R500(c *gin.Context, args ...any) { func R501(c *gin.Context, args ...any) { r := &res{ Status: 501, + Code: -1, } _r(c, r, args...) diff --git a/tool/must.go b/tool/must.go index 3b70062..20154a0 100644 --- a/tool/must.go +++ b/tool/must.go @@ -11,3 +11,8 @@ func Must(errs ...error) { } } } + +func MustWithData[T any](data T, err error) T { + Must(err) + return data +}