From f1bcc093b82dc36bff296df11cc9d310062c6a2d Mon Sep 17 00:00:00 2001 From: flc1125 Date: Wed, 21 May 2025 19:17:06 +0800 Subject: [PATCH] refactor(context): simplify GetStringSlice function - Replace manual type assertion with generic getTyped function - Reduce code duplication and improve type safety Signed-off-by: flc1125 --- context.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/context.go b/context.go index 12423186..2ed41c1f 100644 --- a/context.go +++ b/context.go @@ -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.