Skip to content

Removed dependency on github.com/pkg/errors #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ module github.com/arduino/go-paths-helper

go 1.21

require (
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.8.4
)
require github.com/stretchr/testify v1.8.4

require (
github.com/davecgh/go-spew v1.1.1 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
Expand Down
11 changes: 5 additions & 6 deletions gzip.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ package paths

import (
"compress/gzip"
"fmt"
"io"

"github.com/pkg/errors"
)

// GZip compress src with gzip and writes the compressed file on dst
Expand All @@ -45,25 +44,25 @@ import (
func GUnzip(src, dest *Path) error {
gzIn, err := src.Open()
if err != nil {
return errors.Wrap(err, "opening "+src.String())
return fmt.Errorf("opening %s: %w", src, err)
}
defer gzIn.Close()

in, err := gzip.NewReader(gzIn)
if err != nil {
return errors.Wrap(err, "decoding "+src.String())
return fmt.Errorf("decoding %s: %w", src, err)
}
defer in.Close()

out, err := dest.Create()
if err != nil {
return errors.Wrap(err, "creating "+dest.String())
return fmt.Errorf("creating %s: %w", dest, err)
}
defer out.Close()

_, err = io.Copy(out, in)
if err != nil {
return errors.Wrap(err, "uncompressing "+dest.String())
return fmt.Errorf("uncompressing %s: %w", dest, err)
}

return nil
Expand Down
4 changes: 1 addition & 3 deletions paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ import (
"strings"
"syscall"
"time"

"github.com/pkg/errors"
)

// Path represents a path
Expand Down Expand Up @@ -442,7 +440,7 @@ func WriteToTempFile(data []byte, dir *Path, prefix string) (res *Path, err erro
if n, err := f.Write(data); err != nil {
return nil, err
} else if n < len(data) {
return nil, errors.Errorf("could not write all data (written %d bytes out of %d)", n, len(data))
return nil, fmt.Errorf("could not write all data (written %d bytes out of %d)", n, len(data))
}
return New(f.Name()), nil
}
Expand Down
3 changes: 1 addition & 2 deletions process.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ package paths
import (
"bytes"
"context"
"errors"
"io"
"os"
"os/exec"

"github.com/pkg/errors"
)

// Process is representation of an external process run
Expand Down