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:
flc1125 2025-05-21 19:17:06 +08:00
parent 3d8e4e928a
commit f1bcc093b8

View File

@ -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.
func (c *Context) GetStringSlice(key any) (ss []string) {
if val, ok := c.Get(key); ok && val != nil {
ss, _ = val.([]string)
}
return
return getTyped[[]string](c, key)
}
// GetStringMap returns the value associated with the key as a map of interfaces.