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

Method MustGet

context.go:296–301  ·  view source on GitHub ↗

MustGet returns the value for the given key if it exists, otherwise it panics.

(key any)

Source from the content-addressed store, hash-verified

294
295// MustGet returns the value for the given key if it exists, otherwise it panics.
296func (c *Context) MustGet(key any) any {
297 if value, exists := c.Get(key); exists {
298 return value
299 }
300 panic(fmt.Sprintf("key %v does not exist", key))
301}
302
303func getTyped[T any](c *Context, key any) (res T) {
304 if val, ok := c.Get(key); ok && val != nil {

Callers 8

TestContextSetGetFunction · 0.80
TestContextSetGetValuesFunction · 0.80
TestBindMiddlewareFunction · 0.80
TestBasicAuthSucceedFunction · 0.80
TestBasicAuth401Function · 0.80
TestBasicAuthForProxy407Function · 0.80

Calls 1

GetMethod · 0.95

Tested by 8

TestContextSetGetFunction · 0.64
TestContextSetGetValuesFunction · 0.64
TestBindMiddlewareFunction · 0.64
TestBasicAuthSucceedFunction · 0.64
TestBasicAuth401Function · 0.64
TestBasicAuthForProxy407Function · 0.64