I think there is an error in answer https://stackoverflow.com/a/46590476/16460395.
The file used in gzip, gerr := gzip.NewReader(file)
will never close, because Reader.Close does not close the underlying io.Reader (https://pkg.go.dev/compress/gzip#Reader.Close).