Skip to content

Commit

Permalink
refactor(http): remove redundant nil check (#4563)
Browse files Browse the repository at this point in the history
From the Go specification [^1]:

> "3. If the map is nil, the number of iterations is 0."

Therefore, it is not required to do a nil check for the map before the
loop.

[^1]: https://go.dev/ref/spec#For_range

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
  • Loading branch information
Juneezee committed Jan 22, 2024
1 parent 6097ea5 commit 1d44832
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions internal/http/http.go
Expand Up @@ -238,15 +238,13 @@ func uploadAsset(ctx *context.Context, upload *config.Upload, artifact *artifact
}
log.Debugf("generated target url: %s", targetURL)

headers := map[string]string{}
if upload.CustomHeaders != nil {
for name, value := range upload.CustomHeaders {
resolvedValue, err := tmpl.New(ctx).WithArtifact(artifact).Apply(value)
if err != nil {
return fmt.Errorf("%s: %s: failed to resolve custom_headers template: %w", upload.Name, kind, err)
}
headers[name] = resolvedValue
headers := make(map[string]string, len(upload.CustomHeaders))
for name, value := range upload.CustomHeaders {
resolvedValue, err := tmpl.New(ctx).WithArtifact(artifact).Apply(value)
if err != nil {
return fmt.Errorf("%s: %s: failed to resolve custom_headers template: %w", upload.Name, kind, err)
}
headers[name] = resolvedValue
}
if upload.ChecksumHeader != "" {
sum, err := artifact.Checksum("sha256")
Expand Down

0 comments on commit 1d44832

Please sign in to comment.