From 890caddfb3b4528e0656847b20e69c53375df19d Mon Sep 17 00:00:00 2001 From: alingse Date: Sun, 10 Jul 2022 14:39:46 +0800 Subject: [PATCH] fix pass []any as any in variadic function by asasalint (#5012) * fix pass []any as any in variadic function * add change log --- CHANGELOG.md | 1 + adapter/app.go | 2 +- adapter/context/context.go | 4 ++-- adapter/context/output.go | 2 +- adapter/orm/db_alias.go | 2 +- adapter/router.go | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa3f20f0..2fad31ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - [Fix 4984: random expire cache](https://github.com/beego/beego/pull/4984) - [Fix 4907: make admin serve HTTP only](https://github.com/beego/beego/pull/5005) - [Feat 4999: add get all tasks function](https://github.com/beego/beego/pull/4999) +- [Fix 5012: fix some bug, pass []any as any in variadic function](https://github.com/beego/beego/pull/5012) # v2.0.4 diff --git a/adapter/app.go b/adapter/app.go index 35570616..aaf85a17 100644 --- a/adapter/app.go +++ b/adapter/app.go @@ -245,7 +245,7 @@ func Any(rootpath string, f FilterFunc) *App { // fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path)) // })) func Handler(rootpath string, h http.Handler, options ...interface{}) *App { - return (*App)(web.Handler(rootpath, h, options)) + return (*App)(web.Handler(rootpath, h, options...)) } // InsertFilter adds a FilterFunc with pattern condition and action constant. diff --git a/adapter/context/context.go b/adapter/context/context.go index c0259139..77a0aa05 100644 --- a/adapter/context/context.go +++ b/adapter/context/context.go @@ -78,7 +78,7 @@ func (ctx *Context) GetCookie(key string) string { // SetCookie Set cookie for response. // It's alias of BeegoOutput.Cookie. func (ctx *Context) SetCookie(name string, value string, others ...interface{}) { - (*context.Context)(ctx).SetCookie(name, value, others) + (*context.Context)(ctx).SetCookie(name, value, others...) } // GetSecureCookie Get secure cookie from request by a given key. @@ -88,7 +88,7 @@ func (ctx *Context) GetSecureCookie(Secret, key string) (string, bool) { // SetSecureCookie Set Secure cookie for response. func (ctx *Context) SetSecureCookie(Secret, name, value string, others ...interface{}) { - (*context.Context)(ctx).SetSecureCookie(Secret, name, value, others) + (*context.Context)(ctx).SetSecureCookie(Secret, name, value, others...) } // XSRFToken creates a xsrf token string and returns. diff --git a/adapter/context/output.go b/adapter/context/output.go index 5152ccf5..46edd343 100644 --- a/adapter/context/output.go +++ b/adapter/context/output.go @@ -47,7 +47,7 @@ func (output *BeegoOutput) Body(content []byte) error { // Cookie sets cookie value via given key. // others are ordered as cookie's max age time, path,domain, secure and httponly. func (output *BeegoOutput) Cookie(name string, value string, others ...interface{}) { - (*context.BeegoOutput)(output).Cookie(name, value, others) + (*context.BeegoOutput)(output).Cookie(name, value, others...) } // JSON writes json to response body. diff --git a/adapter/orm/db_alias.go b/adapter/orm/db_alias.go index f910c3f9..a196ca23 100644 --- a/adapter/orm/db_alias.go +++ b/adapter/orm/db_alias.go @@ -69,7 +69,7 @@ func (d *DB) QueryContext(ctx context.Context, query string, args ...interface{} } func (d *DB) QueryRow(query string, args ...interface{}) *sql.Row { - return (*orm.DB)(d).QueryRow(query, args) + return (*orm.DB)(d).QueryRow(query, args...) } func (d *DB) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row { diff --git a/adapter/router.go b/adapter/router.go index a0add1fe..23f08e1e 100644 --- a/adapter/router.go +++ b/adapter/router.go @@ -212,7 +212,7 @@ func (p *ControllerRegister) AddMethod(method, pattern string, f FilterFunc) { // Handler add user defined Handler func (p *ControllerRegister) Handler(pattern string, h http.Handler, options ...interface{}) { - (*web.ControllerRegister)(p).Handler(pattern, h, options) + (*web.ControllerRegister)(p).Handler(pattern, h, options...) } // AddAuto router to ControllerRegister.