mirror of
https://github.com/gin-gonic/gin.git
synced 2025-05-22 12:19:16 +08:00
refactor(context): simplify GetStringSlice function
- Replace manual type assertion with generic getTyped function - Reduce code duplication and improve type safety Signed-off-by: flc1125 <four_leaf_clover@foxmail.com>
This commit is contained in:
parent
3d8e4e928a
commit
f1bcc093b8
@ -441,10 +441,7 @@ func (c *Context) GetFloat64Slice(key any) (f64s []float64) {
|
|||||||
|
|
||||||
// GetStringSlice returns the value associated with the key as a slice of strings.
|
// GetStringSlice returns the value associated with the key as a slice of strings.
|
||||||
func (c *Context) GetStringSlice(key any) (ss []string) {
|
func (c *Context) GetStringSlice(key any) (ss []string) {
|
||||||
if val, ok := c.Get(key); ok && val != nil {
|
return getTyped[[]string](c, key)
|
||||||
ss, _ = val.([]string)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStringMap returns the value associated with the key as a map of interfaces.
|
// GetStringMap returns the value associated with the key as a map of interfaces.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user