Skip to content

Commit 8984be2

Browse files
committed
internal/fetch: close directory file in defer in extractReadme
This addresses bcmills's comment in CL 559615 Fixes golang/go#65545. Change-Id: I02a4ba48eb897f33b4f4c47911e9cc80c99f7869 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/562176 TryBot-Result: Gopher Robot <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> kokoro-CI: kokoro <[email protected]> Run-TryBot: Michael Matloob <[email protected]> Reviewed-by: Bryan Mills <[email protected]>
1 parent 299e4ee commit 8984be2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

internal/fetch/readme.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ func extractReadme(modulePath, dir, resolvedVersion string, contentDir fs.FS) (_
3535
}
3636
return nil, err
3737
}
38+
defer func() {
39+
cerr := f.Close()
40+
if err == nil {
41+
err = cerr
42+
}
43+
}()
3844
rdf, ok := f.(fs.ReadDirFile)
3945
if !ok {
4046
return nil, fmt.Errorf("could not open directory for %v", dir)

0 commit comments

Comments
 (0)