From 20090792468eff39dedfe50a166cf07cf2effef5 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Wed, 19 Jun 2024 15:20:40 -0400 Subject: [PATCH] packer: remove ineffasign pointed assigns/decls Some of the variables we create are flagged by our linters as ineffective assignments, which makes sense as those are generally fed by code below, so we don't need to use the declaration/assignation syntax (:=) but instead can fall back to using var with a type to get the zero value of the declared entity. --- datasource/hcp-packer-image/data.go | 2 +- packer/core.go | 1 - post-processor/manifest/post-processor.go | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/datasource/hcp-packer-image/data.go b/datasource/hcp-packer-image/data.go index 6b72366ea..ef79bfa37 100644 --- a/datasource/hcp-packer-image/data.go +++ b/datasource/hcp-packer-image/data.go @@ -188,7 +188,7 @@ func (d *Datasource) Execute() (cty.Value, error) { iteration.ID) } - output := DatasourceOutput{} + var output DatasourceOutput cloudAndRegions := map[string][]string{} for _, build := range iteration.Builds { diff --git a/packer/core.go b/packer/core.go index 0f3ea9c9c..cac6469e8 100644 --- a/packer/core.go +++ b/packer/core.go @@ -939,7 +939,6 @@ func (c *Core) renderVarsRecursively() (*interpolate.Context, error) { } } } - deleteKeys = []string{} } if !changed && shouldRetry { diff --git a/post-processor/manifest/post-processor.go b/post-processor/manifest/post-processor.go index 74f203525..af2b9f9b1 100644 --- a/post-processor/manifest/post-processor.go +++ b/post-processor/manifest/post-processor.go @@ -141,7 +141,7 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, source defer os.Remove(lockFilename) // Read the current manifest file from disk - contents := []byte{} + var contents []byte if contents, err = os.ReadFile(p.config.OutputPath); err != nil && !os.IsNotExist(err) { return source, true, true, fmt.Errorf("Unable to open %s for reading: %s", p.config.OutputPath, err) }