1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-08 03:31:59 +02:00
goreleaser/pkg/archive/tarxz/tarxz.go
Carlos Alexandro Becker c08bb7f24c
refactor: order methods
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
2021-08-31 23:19:10 -03:00

41 lines
768 B
Go

// Package tarxz implements the Archive interface providing tar.xz archiving
// and compression.
package tarxz
import (
"io"
"github.com/goreleaser/goreleaser/pkg/archive/tar"
"github.com/goreleaser/goreleaser/pkg/config"
"github.com/ulikunitz/xz"
)
// Archive as tar.xz.
type Archive struct {
xzw *xz.Writer
tw *tar.Archive
}
// New tar.xz archive.
func New(target io.Writer) Archive {
xzw, _ := xz.WriterConfig{DictCap: 16 * 1024 * 1024}.NewWriter(target)
tw := tar.New(xzw)
return Archive{
xzw: xzw,
tw: &tw,
}
}
// Close all closeables.
func (a Archive) Close() error {
if err := a.tw.Close(); err != nil {
return err
}
return a.xzw.Close()
}
// Add file to the archive.
func (a Archive) Add(f config.File) error {
return a.tw.Add(f)
}