Repository: go
Issue: all: resource leaks due to missing .Close() calls in various conditions
Labels: NeedsInvestigation

<!--
Please answer these questions before submitting your issue. Thanks!
-->

### What version of Go are you using (`go version`)?

<pre>
$ go version

go version devel go1.20-a813be86df Tue Sep 13 17:43:40 2022 +0000 darwin/amd64
</pre>

### Does this issue reproduce with the latest release?
Yes


### What operating system and processor architecture are you using (`go env`)?
Irrelevant


### What did you do?
Ran a static analyzer developed at Orijtech Inc called "staticmajor" and available on Github actions  per https://github.com/marketplace/actions/staticmajor-analyzer and it produced a laundry list of leaking resources like for example
https://github.com/golang/go/blob/972870da11bb4ddd3df393473c494bd2b546cc56/src/compress/flate/deflate.go#L665-L670

in which  the return on line 668 doesn't invoke `dw.Close()` which leaks the Writer

or 
https://github.com/golang/go/blob/972870da11bb4ddd3df393473c494bd2b546cc56/src/encoding/pem/pem.go#L291-L294

in which the return on line 293 doesn't invoke `b64.Close()`


### What did you expect to see?
No resource leaks


### What did you see instead?

The laundry list is

```shell
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/compress/flate/deflate.go:668:3: leaking resource created on line 0
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/archive/zip/reader.go:77:3: leaking resource created on line 0
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/compress/gzip/gunzip.go:95:3: leaking resource created on line 0
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/compress/zlib/reader.go:86:3: leaking resource created on line 0
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/compress/zlib/writer.go:132:42: leaking resource
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/encoding/pem/pem.go:293:3: leaking resource created on line 291
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/net/sock_posix.go:65:5: leaking resource created on line 27
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/net/sock_posix.go:67:4: leaking resource created on line 27
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/net/sock_posix.go:72:3: leaking resource created on line 27
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/net/sock_posix.go:74:2: leaking resource created on line 27
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/net/udpsock_posix.go:235:4: leaking resource created on line 226
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/crypto/tls/tls.go:159:3: leaking resource created on line 156
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/debug/macho/file.go:227:3: leaking resource created on line 0
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/debug/macho/file.go:239:3: leaking resource created on line 0
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/debug/pe/file.go:70:3: leaking resource created on line 0
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/debug/pe/file.go:78:4: leaking resource created on line 0
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/internal/xcoff/ar.go:120:3: leaking resource created on line 0
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/internal/xcoff/ar.go:122:3: leaking resource created on line 0
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/encoding/xml/marshal.go:84:3: leaking resource created on line 82
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/encoding/xml/marshal.go:135:3: leaking resource created on line 132
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/go/build/build.go:1170:5: leaking resource created on line 1159
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/go/internal/gccgoimporter/ar.go:119:24: leaking resource
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/go/internal/gccgoimporter/ar.go:145:4: leaking resource created on line 139
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/go/internal/gccgoimporter/gccgoinstallation.go:40:3: leaking resource created on line 33
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/internal/fuzz/sys_posix.go:66:3: leaking resource created on line 61
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/internal/fuzz/sys_posix.go:66:3: leaking resource created on line 62
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/internal/fuzz/sys_posix.go:66:3: leaking resource created on line 63
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/internal/fuzz/sys_posix.go:70:3: leaking resource created on line 61
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/internal/fuzz/sys_posix.go:70:3: leaking resource created on line 62
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/internal/fuzz/sys_posix.go:70:3: leaking resource created on line 63
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/internal/fuzz/sys_posix.go:75:3: leaking resource created on line 61
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/internal/fuzz/sys_posix.go:75:3: leaking resource created on line 62
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/internal/trace/parser.go:889:3: leaking resource created on line 882
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/internal/trace/parser.go:893:3: leaking resource created on line 882
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/internal/trace/parser.go:893:3: leaking resource created on line 887
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/net/http/cgi/host.go:249:3: leaking resource created on line 240
/Users/emmanuelodeke/go/src/go.googlesource.com/go/src/net/smtp/smtp.go:369:3: leaking resource created on line 363
```

Just an FYI to @eliasnaur @kirbyquerby @willpoint @jhusdero