1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

fix: general cleanup

This commit is contained in:
Carlos Alexandro Becker 2017-12-17 23:04:29 -02:00
parent 97ac740233
commit 9cfa2c35ce
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
4 changed files with 11 additions and 28 deletions

View File

@ -7,8 +7,6 @@ import (
"hash"
"io"
"os"
"github.com/apex/log"
)
// SHA256 sum of the given file
@ -21,11 +19,7 @@ func calculate(hash hash.Hash, path string) (string, error) {
if err != nil {
return "", err
}
defer func() {
if err := file.Close(); err != nil {
log.WithError(err).Errorf("failed to close %s", path)
}
}()
defer file.Close() // nolint: errcheck
return doCalculate(hash, file)
}

View File

@ -77,18 +77,10 @@ func create(ctx *context.Context, artifacts []artifact.Artifact) error {
if err != nil {
return fmt.Errorf("failed to create directory %s: %s", archivePath, err.Error())
}
defer func() {
if e := archiveFile.Close(); e != nil {
log.WithField("archive", archivePath).Errorf("failed to close file: %v", e)
}
}()
defer archiveFile.Close() // nolint: errcheck
log.WithField("archive", archivePath).Info("creating")
var a = archive.New(archiveFile)
defer func() {
if e := a.Close(); e != nil {
log.WithField("archive", archivePath).Errorf("failed to close archive: %v", e)
}
}()
defer a.Close() // nolint: errcheck
files, err := findFiles(ctx)
if err != nil {

View File

@ -42,16 +42,8 @@ func (Pipe) Run(ctx *context.Context) (err error) {
if err != nil {
return err
}
defer func() {
if err := file.Close(); err != nil {
log.WithError(err).Errorf("failed to close %s", file.Name())
}
ctx.Artifacts.Add(artifact.Artifact{
Type: artifact.Checksum,
Path: file.Name(),
Name: filename,
})
}()
defer file.Close() // nolint: errcheck
// TODO: parallelism should be considered here as well.
var g errgroup.Group
for _, artifact := range ctx.Artifacts.Filter(
@ -66,6 +58,11 @@ func (Pipe) Run(ctx *context.Context) (err error) {
return checksums(ctx, file, artifact)
})
}
ctx.Artifacts.Add(artifact.Artifact{
Type: artifact.Checksum,
Path: file.Name(),
Name: filename,
})
return g.Wait()
}

View File

@ -87,7 +87,7 @@ func upload(ctx *context.Context, c client.Client, releaseID int, artifact artif
if err != nil {
return err
}
defer func() { _ = file.Close() }()
defer file.Close() // nolint: errcheck
log.WithField("file", file.Name()).WithField("name", artifact.Name).Info("uploading to release")
return c.Upload(ctx, releaseID, artifact.Name, file)
}