archive: New() can't fail, so don't return an error type

It could fail if the system can't allocate memory or something
undeterministic like that, but in that case it's best to just let the
runtime panic.
This commit is contained in:
Clayton Craft
2023-03-19 22:04:57 -07:00
parent e6ee43826d
commit 1e8580a0a1
2 changed files with 3 additions and 6 deletions

View File

@@ -152,10 +152,7 @@ func generateArchive(name string, format archive.CompressFormat, level archive.C
log.Printf("- Using compression format %s with level %q\n", format, level)
defer misc.TimeFunc(time.Now(), name)
a, err := archive.New(format, level)
if err != nil {
return err
}
a := archive.New(format, level)
fs := initramfs.New(features)
if err := a.AddItems(fs); err != nil {

View File

@@ -51,7 +51,7 @@ type Archive struct {
items archiveItems
}
func New(format CompressFormat, level CompressLevel) (*Archive, error) {
func New(format CompressFormat, level CompressLevel) *Archive {
buf := new(bytes.Buffer)
archive := &Archive{
cpioWriter: cpio.NewWriter(buf),
@@ -60,7 +60,7 @@ func New(format CompressFormat, level CompressLevel) (*Archive, error) {
compress_level: level,
}
return archive, nil
return archive
}
type archiveItem struct {