mirror of
https://github.com/gin-gonic/gin.git
synced 2026-09-07 08:52:04 +08:00
test(context): use named context key in multipart cleanup test
staticcheck SA1029 forbids empty anonymous struct as context.WithValue keys; use a local named type instead.
This commit is contained in:
parent
2c86eae948
commit
433700d545
@ -302,8 +302,10 @@ func TestServeHTTPCleansMultipartFormAfterWithContext(t *testing.T) {
|
||||
router := New()
|
||||
router.MaxMultipartMemory = 32 // force temp file
|
||||
|
||||
// Named key type required by staticcheck SA1029 (avoid empty anonymous struct keys).
|
||||
type withContextMarker struct{}
|
||||
router.Use(func(c *Context) {
|
||||
c.Request = c.Request.WithContext(context.WithValue(c.Request.Context(), struct{}{}, 1))
|
||||
c.Request = c.Request.WithContext(context.WithValue(c.Request.Context(), withContextMarker{}, 1))
|
||||
c.Next()
|
||||
})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user