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:
parent
375109acd7
commit
e2ef52032b
@ -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,
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user