Skip to content

Commit bb8609f

Browse files
authored
fix: update logging imports in helpers file (#1592)
Fixes bug where some imports are missing if only rest or only grpc transport is specified.
1 parent 1875166 commit bb8609f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

internal/gengapic/gengapic.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ func (g *generator) genAndCommitHelpers(scopes []string) error {
232232
g.reset()
233233
g.imports[pbinfo.ImportSpec{Path: "context"}] = true
234234
g.imports[pbinfo.ImportSpec{Path: "google.golang.org/api/option"}] = true
235-
g.imports[pbinfo.ImportSpec{Path: "github.com/googleapis/gax-go/v2/internallog"}] = true
236235

237236
p("const serviceName = %q", g.serviceConfig.GetName())
238237
p("")
@@ -267,6 +266,7 @@ func (g *generator) genAndCommitHelpers(scopes []string) error {
267266
g.imports[pbinfo.ImportSpec{Path: "log/slog"}] = true
268267
g.imports[pbinfo.ImportSpec{Path: "net/http"}] = true
269268
g.imports[pbinfo.ImportSpec{Path: "google.golang.org/api/googleapi"}] = true
269+
g.imports[pbinfo.ImportSpec{Path: "github.com/googleapis/gax-go/v2/internallog"}] = true
270270

271271
p("func executeHTTPRequest(ctx context.Context, client *http.Client, req *http.Request, logger *slog.Logger, body []byte, rpc string) ([]byte, error) {")
272272
p(` logger.DebugContext(ctx, "api request", "serviceName", serviceName, "rpcName", rpc, "request", internallog.HTTPRequest(req, body))`)
@@ -303,6 +303,7 @@ func (g *generator) genAndCommitHelpers(scopes []string) error {
303303
}
304304

305305
if containsTransport(g.opts.transports, grpc) {
306+
g.imports[pbinfo.ImportSpec{Path: "log/slog"}] = true
306307
g.imports[pbinfo.ImportSpec{Path: "github.com/googleapis/gax-go/v2/internallog/grpclog"}] = true
307308
g.imports[pbinfo.ImportSpec{Path: "google.golang.org/grpc"}] = true
308309
g.imports[pbinfo.ImportSpec{Path: "google.golang.org/protobuf/proto"}] = true

0 commit comments

Comments
 (0)