MCPcopy
hub / github.com/gin-gonic/gin / Set

Method Set

context.go:276–284  ·  context.go::Context.Set

************************************/ ******** METADATA MANAGEMENT********/ ************************************/ Set is used to store a new key/value pair exclusively for this context. It also lazy initializes c.Keys if it was not used previously.

(key any, value any)

Source from the content-addressed store, hash-verified

274// Set is used to store a new key/value pair exclusively for this context.
275// It also lazy initializes c.Keys if it was not used previously.
276func (c *Context) Set(key any, value any) {
277 c.mu.Lock()
278 defer c.mu.Unlock()
279 if c.Keys == nil {
280 c.Keys = make(map[any]any)
281 }
282
283 c.Keys[key] = value
284}
285
286// Get returns the value for the given key, ie: (value, true).
287// If the value does not exist it returns (nil, false)

Callers 15

TestContextWithKeysMutexFunction · 0.95
ShouldBindBodyWithMethod · 0.95
TestSecureRequestDumpFunction · 0.80
createMultipartRequestFunction · 0.80
TestContextFileFunction · 0.80
TestContextFormFileFunction · 0.80
TestContextMultipartFormFunction · 0.80

Calls

no outgoing calls

Tested by 15

TestContextWithKeysMutexFunction · 0.76
TestSecureRequestDumpFunction · 0.64
createMultipartRequestFunction · 0.64
TestContextFileFunction · 0.64
TestContextFormFileFunction · 0.64
TestContextMultipartFormFunction · 0.64
TestContextResetFunction · 0.64