refractor: remove dependency on pkg/errors.
This commit is contained in:
parent
09cdf6158d
commit
d40985099c
4 changed files with 8 additions and 11 deletions
|
|
@ -5,12 +5,12 @@
|
|||
package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/arduino/go-paths-helper"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/roddhjav/apparmor.d/pkg/util"
|
||||
)
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ func (t Tldr) Download() error {
|
|||
if !gzPath.Exist() {
|
||||
resp, err := http.Get(t.Url)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "downloading %s", t.Url)
|
||||
return fmt.Errorf("downloading %s: %w", t.Url, err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ package util
|
|||
import (
|
||||
"archive/tar"
|
||||
"compress/gzip"
|
||||
"fmt"
|
||||
"io"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/arduino/go-paths-helper"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Either or not to extract the file
|
||||
|
|
@ -29,18 +29,18 @@ func toExtrat(name string, subfolders []string) bool {
|
|||
func ExtratTo(src *paths.Path, dst *paths.Path, subfolders []string) error {
|
||||
gzIn, err := src.Open()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "opening %s", src)
|
||||
return fmt.Errorf("opening %s: %w", src, err)
|
||||
}
|
||||
defer gzIn.Close()
|
||||
|
||||
in, err := gzip.NewReader(gzIn)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "decoding %s", src)
|
||||
return fmt.Errorf("decoding %s: %w", src, err)
|
||||
}
|
||||
defer in.Close()
|
||||
|
||||
if err := dst.MkdirAll(); err != nil {
|
||||
return errors.Wrapf(err, "creating %s", src)
|
||||
return fmt.Errorf("creating %s: %w", src, err)
|
||||
}
|
||||
|
||||
tarIn := tar.NewReader(in)
|
||||
|
|
@ -60,10 +60,10 @@ func ExtratTo(src *paths.Path, dst *paths.Path, subfolders []string) error {
|
|||
path := dst.Join(filepath.Base(header.Name))
|
||||
file, err := path.Create()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "creating %s", file.Name())
|
||||
return fmt.Errorf("creating %s: %w", file.Name(), err)
|
||||
}
|
||||
if _, err := io.Copy(file, tarIn); err != nil {
|
||||
return errors.Wrapf(err, "extracting %s", file.Name())
|
||||
return fmt.Errorf("extracting %s: %w", file.Name(), err)
|
||||
}
|
||||
file.Close()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue