From c1506cc4b1030b8b17a7cfcac84997989692d031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Sat, 27 Jan 2024 16:52:18 -0800 Subject: [PATCH] use string builder because why not --- internal/handlers/handlers.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index 4dfe824..c07a2bb 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -77,15 +77,16 @@ func HomeHandler(writer http.ResponseWriter, request *http.Request) { // RobotHandler creates a handler for robots.txt out of existing Handlers func RobotHandler(writer http.ResponseWriter, request *http.Request) { - robots := fmt.Sprintf("User-agent: %s\nAllow: /\n", request.UserAgent()) + var robots strings.Builder + robots.WriteString(fmt.Sprintf("User-agent: %s\nAllow: /\n", request.UserAgent())) for _, handler := range Handlers { - robots += fmt.Sprintf("Allow: %s\n", handler.Handles) + robots.WriteString(fmt.Sprintf("Allow: %s\n", handler.Handles)) } - robots += "Disallow: /*\n" + robots.WriteString("Disallow: /*\n") - fmt.Fprint(writer, robots) + fmt.Fprint(writer, robots.String()) } // makeBasicHandler returns a simple handler that renders a template from `name`.page.tmpl