package archive import ( "errors" "io" "github.com/klauspost/pgzip" ) func WriteTarGzipEncoded(tar Tar, writer io.Writer) (err error) { s2Writer := pgzip.NewWriter(writer) defer func() { err = errors.Join(err, s2Writer.Close()) }() return tar.Write(s2Writer) }