fix(go/fio): nil http client panic in fio.New
All checks were successful
Deploy to K8s / deploy (push) Successful in 10s

When token is empty, New falls back to transparentClient with the
caller-supplied hc. main.go passes nil, so the first Do() call panicked.
Default to http.DefaultClient when hc is nil.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-07 10:36:20 +02:00
parent 36a28a40d2
commit 8275db1a63

View File

@@ -4,6 +4,7 @@ package fio
import ( import (
"context" "context"
"net/http"
"time" "time"
) )
@@ -29,7 +30,11 @@ type Client interface {
} }
// New returns an apiClient when token is non-empty, otherwise a transparentClient. // New returns an apiClient when token is non-empty, otherwise a transparentClient.
// hc may be nil, in which case http.DefaultClient is used.
func New(token, accountNum string, hc httpDoer) Client { func New(token, accountNum string, hc httpDoer) Client {
if hc == nil {
hc = http.DefaultClient
}
if token != "" { if token != "" {
return &apiClient{token: token, hc: hc} return &apiClient{token: token, hc: hc}
} }