From 98615e26623fa419535bb11d9098709b58e7b271 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Fri, 2 Jun 2023 17:24:53 +0300 Subject: [PATCH] Refactor to use strings.ReplaceAll --- pkg/codegen/codegen.go | 2 +- pkg/codegen/utils.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/codegen/codegen.go b/pkg/codegen/codegen.go index 1cf431ed9c..d8ba40fca8 100644 --- a/pkg/codegen/codegen.go +++ b/pkg/codegen/codegen.go @@ -820,7 +820,7 @@ func GenerateUnionAndAdditionalProopertiesBoilerplate(t *template.Template, type func SanitizeCode(goCode string) string { // remove any byte-order-marks which break Go-Code // See: https://groups.google.com/forum/#!topic/golang-nuts/OToNIPdfkks - return strings.Replace(goCode, "\uFEFF", "", -1) + return strings.ReplaceAll(goCode, "\uFEFF", "") } // GetUserTemplateText attempts to retrieve the template text from a passed in URL or file diff --git a/pkg/codegen/utils.go b/pkg/codegen/utils.go index 6fb031e49c..cf8826e39f 100644 --- a/pkg/codegen/utils.go +++ b/pkg/codegen/utils.go @@ -728,8 +728,8 @@ func stringToGoCommentWithPrefix(in, prefix string) string { } // Normalize newlines from Windows/Mac to Linux - in = strings.Replace(in, "\r\n", "\n", -1) - in = strings.Replace(in, "\r", "\n", -1) + in = strings.ReplaceAll(in, "\r\n", "\n") + in = strings.ReplaceAll(in, "\r", "\n") // Add comment to each line var lines []string