1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-04 03:11:55 +02:00

feat: use maximum compression for gzip and zip archives (#1416)

* feat: use maximum compression for gzip and zip archives

* fix: add comment for skipping error check

Co-authored-by: John Taylor <ec2-user@ip-172-31-29-117.ap-south-1.compute.internal>
This commit is contained in:
John Taylor 2020-04-01 15:05:20 -04:00 committed by GitHub
parent 375109acd7
commit e2ef52032b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View File

@ -21,7 +21,8 @@ func (a Archive) Close() error {
// New gz archive
func New(target io.Writer) Archive {
gw := gzip.NewWriter(target)
// the error will be nil since the compression level is valid
gw, _ := gzip.NewWriterLevel(target, gzip.BestCompression)
return Archive{
gw: gw,
}

View File

@ -25,7 +25,8 @@ func (a Archive) Close() error {
// New tar.gz archive
func New(target io.Writer) Archive {
gw := gzip.NewWriter(target)
// the error will be nil since the compression level is valid
gw, _ := gzip.NewWriterLevel(target, gzip.BestCompression)
tw := tar.NewWriter(gw)
return Archive{
gw: gw,

View File

@ -4,6 +4,7 @@ package zip
import (
"archive/zip"
"compress/flate"
"io"
"os"
)
@ -20,8 +21,12 @@ func (a Archive) Close() error {
// New zip archive
func New(target io.Writer) Archive {
compressor := zip.NewWriter(target)
compressor.RegisterCompressor(zip.Deflate, func(out io.Writer) (io.WriteCloser, error) {
return flate.NewWriter(out, flate.BestCompression)
})
return Archive{
z: zip.NewWriter(target),
z: compressor,
}
}