github.com/axxelG/goreleaser@v0.92.0/pkg/archive/archive.go (about) 1 // Package archive provides tar.gz and zip archiving 2 package archive 3 4 import ( 5 "os" 6 7 "path/filepath" 8 9 "github.com/goreleaser/goreleaser/pkg/archive/tar" 10 "github.com/goreleaser/goreleaser/pkg/archive/zip" 11 ) 12 13 // Archive represents a compression archive files from disk can be written to. 14 type Archive interface { 15 Close() error 16 Add(name, path string) error 17 } 18 19 // New archive 20 // If the exentions of the target file is .zip, the archive will be in the zip 21 // format, otherwise, it will be a tar.gz archive. 22 func New(file *os.File) Archive { 23 if filepath.Ext(file.Name()) == ".zip" { 24 return zip.New(file) 25 } 26 return tar.New(file) 27 }