Skip to content

Commit 1d2338d

Browse files
committed
Do not shadow the return error in the defer function
1 parent 1115cb9 commit 1d2338d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

internal/cmd/new.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ func (c *newScriptCmd) run(_ *cobra.Command, args []string) (err error) {
7575

7676
defer func() {
7777
if cerr := fd.Close(); cerr != nil {
78-
if _, err := fmt.Fprintf(c.gs.Stderr, "error closing file: %v\n", cerr); err != nil {
79-
err = fmt.Errorf("error writing error message to stderr: %w", err) //nolint:staticcheck,ineffassign,wastedassign
78+
if _, werr := fmt.Fprintf(c.gs.Stderr, "error closing file: %v\n", cerr); werr != nil {
79+
err = fmt.Errorf("error writing error message to stderr: %w", werr)
8080
} else {
81-
err = cerr //nolint:staticcheck,ineffassign,wastedassign
81+
err = cerr
8282
}
8383
}
8484
}()

0 commit comments

Comments
 (0)