Skip to content
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
15 changes: 9 additions & 6 deletions download/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/ansel1/merry/v2"
"golang.org/x/mod/semver"

"github.com/murfffi/getaduck/internal/sclerr"
"github.com/murfffi/gorich/helperr"
)

const (
Expand Down Expand Up @@ -211,14 +211,17 @@ func extractFile(file *zip.File) error {
if err != nil {
return err
}
defer sclerr.CloseQuietly(outFile)
defer helperr.CloseQuietly(outFile)
fileReader, err := file.Open()
if err != nil {
return err
}
defer sclerr.CloseQuietly(fileReader)
defer helperr.CloseQuietly(fileReader)
_, err = io.Copy(outFile, fileReader)
return err
if err != nil {
return err
}
return outFile.Close()
}

func getEntryName(spec Spec) string {
Expand Down Expand Up @@ -259,12 +262,12 @@ func fetchZip(url string) (string, error) {
if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("HTTP error when trying to download %s: %d", url, resp.StatusCode)
}
defer sclerr.CloseQuietly(resp.Body)
defer helperr.CloseQuietly(resp.Body)
tmpZip, err := os.CreateTemp("", "getaduck")
if err != nil {
return "", fmt.Errorf("failed to create temp file: %w", err)
}
defer sclerr.CloseQuietly(tmpZip)
defer helperr.CloseQuietly(tmpZip)
_, err = io.Copy(tmpZip, resp.Body)
if err != nil {
return "", genericDownloadErr(url, err)
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ module github.com/murfffi/getaduck
go 1.24.7

require (
github.com/ansel1/merry/v2 v2.2.1
github.com/stretchr/testify v1.8.3
github.com/ansel1/merry/v2 v2.2.2
github.com/murfffi/gorich v0.2.0
github.com/stretchr/testify v1.11.1
golang.org/x/mod v0.28.0
)

Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
github.com/ansel1/merry/v2 v2.2.1 h1:PJpynLFvIpJkn8ZGgNHLq332zIyBc/wTqp3o42ZpWdU=
github.com/ansel1/merry/v2 v2.2.1/go.mod h1:K9lCkM6tJ8s7LQVQ0ZmZ0WrB3BCyr+ZDzoqotzzoxpI=
github.com/ansel1/merry/v2 v2.2.2 h1:/R8URU5LtiYwP7UI1KoZW4ex4nTzr+/T49+TYZsjUas=
github.com/ansel1/merry/v2 v2.2.2/go.mod h1:sludwzkWfhZHOF4jSOViv+t2nnu2HNmtsMKzAfwmVB8=
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/go-errors/errors v1.1.1 h1:ljK/pL5ltg3qoN+OtN6yCv9HWSfMwxSx90GJCZQxYNg=
github.com/go-errors/errors v1.1.1/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs=
github.com/murfffi/gorich v0.2.0 h1:eUQ2xzjp7czPemnc0nSEDVBLz2xyFKfQg2kSgJ9ljwk=
github.com/murfffi/gorich v0.2.0/go.mod h1:o1VsmtwZ9U/E8eyiLvhUTOdV810J8v6Y0R3pi/97TdQ=
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.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U=
golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
Expand Down
7 changes: 0 additions & 7 deletions internal/sclerr/sclerr.go

This file was deleted.