Enforce Go style rules across codebase

Apply five style rules: convert iota string enums to typed
string constants, replace errors.As with errors.AsType,
merge three-group imports into two groups, fix multiline
parameter/argument formatting, and replace fmt.Sprintf URL
construction with net/url.

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-05-20 11:46:39 +04:00
parent 34c25c2727
commit f5703d390b
105 changed files with 1180 additions and 940 deletions

View File

@@ -68,9 +68,11 @@ func CheckCORSTool() agent.Tool {
"Send a CORS preflight (OPTIONS) request to a URL with a given Origin and analyze the Access-Control-* response headers, flagging wildcard origins and origin reflection.",
func(ctx context.Context, p corsParams) (agent.ToolResult, error) {
if err := netcheck.ValidatePublicURL(p.URL); err != nil {
return agent.ResultJSON(corsResult{
ErrorDetail: fmt.Sprintf("URL not allowed: %s", err),
}), nil
return agent.ResultJSON(
corsResult{
ErrorDetail: fmt.Sprintf("URL not allowed: %s", err),
},
), nil
}
client := &http.Client{
@@ -87,9 +89,11 @@ func CheckCORSTool() agent.Tool {
nil,
)
if err != nil {
return agent.ResultJSON(corsResult{
ErrorDetail: fmt.Sprintf("cannot build request: %s", err),
}), nil
return agent.ResultJSON(
corsResult{
ErrorDetail: fmt.Sprintf("cannot build request: %s", err),
},
), nil
}
req.Header.Set("Origin", p.Origin)
@@ -97,9 +101,11 @@ func CheckCORSTool() agent.Tool {
resp, err := client.Do(req)
if err != nil {
return agent.ResultJSON(corsResult{
ErrorDetail: fmt.Sprintf("cannot fetch %s: %s", p.URL, err),
}), nil
return agent.ResultJSON(
corsResult{
ErrorDetail: fmt.Sprintf("cannot fetch %s: %s", p.URL, err),
},
), nil
}
defer func() { _ = resp.Body.Close() }()