fix(transcribe): check (discard) the deferred Close errors golangci-lint flags
Found because the project's lint step cannot fail: the Taskfile runs 'golangci-lint run ./... || echo "not installed -- skipping"', so a failing lint prints that message and exits 0. CI's log showed these findings and still passed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -62,7 +62,7 @@ func (g *Gateway) Transcribe(ctx context.Context, path string) (domain.Transcrip
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return domain.Transcription{}, fmt.Errorf("transcribe: open audio: %w", err)
|
return domain.Transcription{}, fmt.Errorf("transcribe: open audio: %w", err)
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer func() { _ = f.Close() }()
|
||||||
info, err := f.Stat()
|
info, err := f.Stat()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return domain.Transcription{}, fmt.Errorf("transcribe: stat audio: %w", err)
|
return domain.Transcription{}, fmt.Errorf("transcribe: stat audio: %w", err)
|
||||||
@@ -95,7 +95,7 @@ func (g *Gateway) Transcribe(ctx context.Context, path string) (domain.Transcrip
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return domain.Transcription{}, fmt.Errorf("transcribe: %s: %w", g.model, err)
|
return domain.Transcription{}, fmt.Errorf("transcribe: %s: %w", g.model, err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer func() { _ = resp.Body.Close() }()
|
||||||
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
||||||
snip, _ := io.ReadAll(io.LimitReader(resp.Body, 200))
|
snip, _ := io.ReadAll(io.LimitReader(resp.Body, 200))
|
||||||
return domain.Transcription{}, &StatusError{Code: resp.StatusCode, Snippet: strings.TrimSpace(string(snip))}
|
return domain.Transcription{}, &StatusError{Code: resp.StatusCode, Snippet: strings.TrimSpace(string(snip))}
|
||||||
|
|||||||
Reference in New Issue
Block a user