diff --git a/client/sse.go b/client/sse.go index cf4a102..76f2ed9 100644 --- a/client/sse.go +++ b/client/sse.go @@ -399,7 +399,7 @@ func (c *SSEMCPClient) Initialize( err, ) } - resp.Body.Close() + defer resp.Body.Close() c.initialized = true return &result, nil diff --git a/server/internal/gen/main.go b/server/internal/gen/main.go index 5bb3e81..4fe5d60 100644 --- a/server/internal/gen/main.go +++ b/server/internal/gen/main.go @@ -28,21 +28,19 @@ func RenderTemplateToFile(templateContent, destPath, fileName string, data any) } tempFilePath := tempFile.Name() defer os.Remove(tempFilePath) // Clean up temp file when done + defer tempFile.Close() // Parse and execute template to temp file tmpl, err := template.New(fileName).Funcs(template.FuncMap{ "toLower": strings.ToLower, }).Parse(templateContent) if err != nil { - tempFile.Close() return err } if err := tmpl.Execute(tempFile, data); err != nil { - tempFile.Close() return err } - tempFile.Close() // Run goimports on the temp file cmd := exec.Command("go", "run", "golang.org/x/tools/cmd/goimports@latest", "-w", tempFilePath)