@@ -21,10 +21,18 @@ func MigrateGenericHelpers(cmd *cobra.Command, cwd string, _, _ *semver.Version)
2121 reQueryFloat := regexp .MustCompile (`(\w+)\.QueryFloat\(` )
2222 reQueryBool := regexp .MustCompile (`(\w+)\.QueryBool\(` )
2323 changed , err := internal .ChangeFileContent (cwd , func (content string ) string {
24- content = reParamsIntAssign .ReplaceAllString (content , "$1, $2 := fiber.Params[int]($3, $4), nil" )
25- content = reQueryIntAssign .ReplaceAllString (content , "$1, $2 := fiber.Query[int]($3, $4), nil" )
26- content = reQueryFloatAssign .ReplaceAllString (content , "$1, $2 := fiber.Query[float64]($3, $4), nil" )
27- content = reQueryBoolAssign .ReplaceAllString (content , "$1, $2 := fiber.Query[bool]($3, $4), nil" )
24+ assignReplacements := []struct {
25+ re * regexp.Regexp
26+ repl string
27+ }{
28+ {reParamsIntAssign , "$1, $2 := fiber.Params[int]($3, $4), error(nil)" },
29+ {reQueryIntAssign , "$1, $2 := fiber.Query[int]($3, $4), error(nil)" },
30+ {reQueryFloatAssign , "$1, $2 := fiber.Query[float64]($3, $4), error(nil)" },
31+ {reQueryBoolAssign , "$1, $2 := fiber.Query[bool]($3, $4), error(nil)" },
32+ }
33+ for _ , r := range assignReplacements {
34+ content = r .re .ReplaceAllString (content , r .repl )
35+ }
2836
2937 content = reParamsInt .ReplaceAllString (content , "fiber.Params[int]($1, " )
3038 content = reQueryInt .ReplaceAllString (content , "fiber.Query[int]($1, " )
0 commit comments