Repository: goreleaser/goreleaser
Pull request #2128 (2021-03-21 18:11:58)

feat: allow to use ModulePath on templates
closes https://github.com/goreleaser/goreleaser/issues/1688

vercel[bot]: This pull request is being automatically deployed with Vercel ([learn more](https://vercel.link/github-learn-more)).  
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: [https://vercel.com/goreleaser/goreleaser/9pjehP3CUCax1t5BZ4qdc6qBfWyF](https://vercel.com/goreleaser/goreleaser/9pjehP3CUCax1t5BZ4qdc6qBfWyF)  
✅ Preview: [https://goreleaser-git-gomodulepath-goreleaser.vercel.app](https://goreleaser-git-gomodulepath-goreleaser.vercel.app)


codecov[bot]: # [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2128?src=pr&el=h1) Report
> Merging [#2128](https://codecov.io/gh/goreleaser/goreleaser/pull/2128?src=pr&el=desc) (13272ab) into [master](https://codecov.io/gh/goreleaser/goreleaser/commit/9f8750dcd22ef21ad6f2c7b7f07251864d85ea92?el=desc) (9f8750d) will **increase** coverage by `0.04%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/goreleaser/goreleaser/pull/2128/graphs/tree.svg?width=650&height=150&src=pr&token=3bJvv6b7hN)](https://codecov.io/gh/goreleaser/goreleaser/pull/2128?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #2128      +/-   ##
==========================================
+ Coverage   82.78%   82.82%   +0.04%     
==========================================
  Files          74       75       +1     
  Lines        4014     4024      +10     
==========================================
+ Hits         3323     3333      +10     
  Misses        564      564              
  Partials      127      127              
```


| [Impacted Files](https://codecov.io/gh/goreleaser/goreleaser/pull/2128?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [internal/pipe/gomod/gomod.go](https://codecov.io/gh/goreleaser/goreleaser/pull/2128/diff?src=pr&el=tree#diff-aW50ZXJuYWwvcGlwZS9nb21vZC9nb21vZC5nbw==) | `100.00% <100.00%> (ø)` | |
| [internal/tmpl/tmpl.go](https://codecov.io/gh/goreleaser/goreleaser/pull/2128/diff?src=pr&el=tree#diff-aW50ZXJuYWwvdG1wbC90bXBsLmdv) | `96.51% <100.00%> (+0.04%)` | :arrow_up: |
| [pkg/context/context.go](https://codecov.io/gh/goreleaser/goreleaser/pull/2128/diff?src=pr&el=tree#diff-cGtnL2NvbnRleHQvY29udGV4dC5nbw==) | `100.00% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2128?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2128?src=pr&el=footer). Last update [9f8750d...13272ab](https://codecov.io/gh/goreleaser/goreleaser/pull/2128?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/go.mod b/go.mod
index 2a8f97b9..1b7fa133 100644
--- a/go.mod
+++ b/go.mod
@@ -7,6 +7,7 @@ require (
 	github.com/Masterminds/semver/v3 v3.1.1
 	github.com/apex/log v1.9.0
 	github.com/caarlos0/ctrlc v1.0.0
+	github.com/caarlos0/go-shellwords v1.0.12
 	github.com/campoy/unique v0.0.0-20180121183637-88950e537e7e
 	github.com/fatih/color v1.10.0
 	github.com/google/go-github/v28 v28.1.1
@@ -14,7 +15,6 @@ require (
 	github.com/goreleaser/nfpm/v2 v2.3.1
 	github.com/imdario/mergo v0.3.12
 	github.com/jarcoal/httpmock v1.0.8
-	github.com/mattn/go-shellwords v1.0.10
 	github.com/mitchellh/go-homedir v1.1.0
 	github.com/spf13/cobra v1.1.3
 	github.com/stretchr/testify v1.7.0
@@ -26,6 +26,3 @@ require (
 	golang.org/x/tools v0.0.0-20210105210202-9ed45478a130 // indirect
 	gopkg.in/yaml.v2 v2.4.0
 )
-
-// https://github.com/mattn/go-shellwords/pull/39
-replace github.com/mattn/go-shellwords => github.com/caarlos0/go-shellwords v1.0.11
diff --git a/go.sum b/go.sum
index 77a7eefc..ec32059c 100644
--- a/go.sum
+++ b/go.sum
@@ -138,8 +138,8 @@ github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb h1:m935MPodAbYS46DG4
 github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb/go.mod h1:PkYb9DJNAwrSvRx5DYA+gUcOIgTGVMNkfSCbZM8cWpI=
 github.com/caarlos0/ctrlc v1.0.0 h1:2DtF8GSIcajgffDFJzyG15vO+1PuBWOMUdFut7NnXhw=
 github.com/caarlos0/ctrlc v1.0.0/go.mod h1:CdXpj4rmq0q/1Eb44M9zi2nKB0QraNKuRGYGrrHhcQw=
-github.com/caarlos0/go-shellwords v1.0.11 h1:AwPv3JZPpE2YVS51HQ8IYt1Hobtmzlzw4K6ygDOsDrc=
-github.com/caarlos0/go-shellwords v1.0.11/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=
+github.com/caarlos0/go-shellwords v1.0.12 h1:HWrUnu6lGbWfrDcFiHcZiwOLzHWjjrPVehULaTFgPp8=
+github.com/caarlos0/go-shellwords v1.0.12/go.mod h1:bYeeX1GrTLPl5cAMYEzdm272qdsQAZiaHgeF0KTk1Gw=
 github.com/caarlos0/testfs v0.4.3 h1:q1zEM5hgsssqWanAfevJYYa0So60DdK6wlJeTc/yfUE=
 github.com/caarlos0/testfs v0.4.3/go.mod h1:bRN55zgG4XCUVVHZCeU+/Tz1Q6AxEJOEJTliBy+1DMk=
 github.com/campoy/unique v0.0.0-20180121183637-88950e537e7e h1:V9a67dfYqPLAvzk5hMQOXYJlZ4SLIXgyKIE+ZiHzgGQ=
diff --git a/internal/exec/exec.go b/internal/exec/exec.go
index 2deb9ab3..f22ba30d 100644
--- a/internal/exec/exec.go
+++ b/internal/exec/exec.go
@@ -5,6 +5,7 @@ import (
 	"os/exec"
 
 	"github.com/apex/log"
+	"github.com/caarlos0/go-shellwords"
 	"github.com/goreleaser/goreleaser/internal/artifact"
 	"github.com/goreleaser/goreleaser/internal/logext"
 	"github.com/goreleaser/goreleaser/internal/pipe"
@@ -12,7 +13,6 @@ import (
 	"github.com/goreleaser/goreleaser/internal/tmpl"
 	"github.com/goreleaser/goreleaser/pkg/config"
 	"github.com/goreleaser/goreleaser/pkg/context"
-	"github.com/mattn/go-shellwords"
 )
 
 func Execute(ctx *context.Context, publishers []config.Publisher) error {
@@ -36,7 +36,7 @@ func executePublisher(ctx *context.Context, publisher config.Publisher) error {
 	artifacts := filterArtifacts(ctx.Artifacts, publisher)
 	log.Debugf("will execute custom publisher with %d artifacts", len(artifacts))
 
-	var g = semerrgroup.New(ctx.Parallelism)
+	g := semerrgroup.New(ctx.Parallelism)
 	for _, artifact := range artifacts {
 		artifact := artifact
 		g.Go(func() error {
@@ -57,8 +57,8 @@ func executeCommand(c *command) error {
 		WithField("env", c.Env).
 		Debug("executing command")
 
-	// nolint: gosec
-	var cmd = exec.CommandContext(c.Ctx, c.Args[0], c.Args[1:]...)
+		// nolint: gosec
+	cmd := exec.CommandContext(c.Ctx, c.Args[0], c.Args[1:]...)
 	cmd.Env = c.Env
 	if c.Dir != "" {
 		cmd.Dir = c.Dir
@@ -94,7 +94,7 @@ func filterArtifacts(artifacts artifact.Artifacts, publisher config.Publisher) [
 		filters = append(filters, artifact.ByType(artifact.Signature))
 	}
 
-	var filter = artifact.Or(filters...)
+	filter := artifact.Or(filters...)
 
 	if len(publisher.IDs) > 0 {
 		filter = artifact.And(filter, artifact.ByIDs(publisher.IDs...))
diff --git a/internal/pipe/before/before.go b/internal/pipe/before/before.go
index e71b0456..65fa2be8 100644
--- a/internal/pipe/before/before.go
+++ b/internal/pipe/before/before.go
@@ -6,10 +6,10 @@ import (
 	"os/exec"
 
 	"github.com/apex/log"
+	"github.com/caarlos0/go-shellwords"
 	"github.com/fatih/color"
 	"github.com/goreleaser/goreleaser/internal/tmpl"
 	"github.com/goreleaser/goreleaser/pkg/context"
-	"github.com/mattn/go-shellwords"
 )
 
 // Pipe is a global hook pipe.
@@ -22,7 +22,7 @@ func (Pipe) String() string {
 
 // Run executes the hooks.
 func (Pipe) Run(ctx *context.Context) error {
-	var tmpl = tmpl.New(ctx)
+	tmpl := tmpl.New(ctx)
 	/* #nosec */
 	for _, step := range ctx.Config.Before.Hooks {
 		s, err := tmpl.Apply(step)
diff --git a/internal/pipe/build/build.go b/internal/pipe/build/build.go
index 232cd799..5f6f8441 100644
--- a/internal/pipe/build/build.go
+++ b/internal/pipe/build/build.go
@@ -12,6 +12,7 @@ import (
 	"strings"
 
 	"github.com/apex/log"
+	"github.com/caarlos0/go-shellwords"
 	"github.com/goreleaser/goreleaser/internal/ids"
 	"github.com/goreleaser/goreleaser/internal/logext"
 	"github.com/goreleaser/goreleaser/internal/semerrgroup"
@@ -19,7 +20,6 @@ import (
 	builders "github.com/goreleaser/goreleaser/pkg/build"
 	"github.com/goreleaser/goreleaser/pkg/config"
 	"github.com/goreleaser/goreleaser/pkg/context"
-	"github.com/mattn/go-shellwords"
 
 	// langs to init.
 	_ "github.com/goreleaser/goreleaser/internal/builders/golang"
@@ -49,7 +49,7 @@ func (Pipe) Run(ctx *context.Context) error {
 
 // Default sets the pipe defaults.
 func (Pipe) Default(ctx *context.Context) error {
-	var ids = ids.New("builds")
+	ids := ids.New("builds")
 	for i, build := range ctx.Config.Builds {
 		build, err := buildWithDefaults(ctx, build)
 		if err != nil {
@@ -85,7 +85,7 @@ func buildWithDefaults(ctx *context.Context, build config.Build) (config.Build,
 }
 
 func runPipeOnBuild(ctx *context.Context, build config.Build) error {
-	var g = semerrgroup.New(ctx.Parallelism)
+	g := semerrgroup.New(ctx.Parallelism)
 	for _, target := range build.Targets {
 		target := target
 		build := build
@@ -163,7 +163,7 @@ func doBuild(ctx *context.Context, build config.Build, opts builders.Options) er
 }
 
 func buildOptionsForTarget(ctx *context.Context, build config.Build, target string) (*builders.Options, error) {
-	var ext = extFor(target, build.Flags)
+	ext := extFor(target, build.Flags)
 	var goos string
 	var goarch string
 
@@ -185,7 +185,7 @@ func buildOptionsForTarget(ctx *context.Context, build config.Build, target stri
 	}
 
 	build.Binary = binary
-	var name = build.Binary + ext
+	name := build.Binary + ext
 	path, err := filepath.Abs(
 		filepath.Join(
 			ctx.Config.Dist,
@@ -223,8 +223,8 @@ func extFor(target string, flags config.FlagArray) string {
 
 func run(ctx *context.Context, dir string, command, env []string) error {
 	/* #nosec */
-	var cmd = exec.CommandContext(ctx, command[0], command[1:]...)
-	var entry = log.WithField("cmd", command)
+	cmd := exec.CommandContext(ctx, command[0], command[1:]...)
+	entry := log.WithField("cmd", command)
 	cmd.Env = env
 	var b bytes.Buffer
 	cmd.Stderr = io.MultiWriter(logext.NewErrWriter(entry), &b)
diff --git a/internal/pipe/gomod/gomod.go b/internal/pipe/gomod/gomod.go
new file mode 100644
index 00000000..b05d3873
--- /dev/null
+++ b/internal/pipe/gomod/gomod.go
@@ -0,0 +1,34 @@
+package gomod
+
+import (
+	"fmt"
+	"os/exec"
+	"strings"
+
+	"github.com/goreleaser/goreleaser/internal/pipe"
+	"github.com/goreleaser/goreleaser/pkg/context"
+)
+
+// Pipe for env.
+type Pipe struct{}
+
+func (Pipe) String() string {
+	return "loading go mod information"
+}
+
+// Run the pipe.
+func (Pipe) Run(ctx *context.Context) error {
+	out, err := exec.CommandContext(ctx, "go", "list", "-m").CombinedOutput()
+	if err != nil {
+		return fmt.Errorf("failed to get module path: %w: %s", err, string(out))
+	}
+
+	result := strings.TrimSpace(string(out))
+	if result == "command-line-arguments" {
+		return pipe.Skip("not a go module")
+	}
+
+	ctx.ModulePath = result
+
+	return nil
+}
diff --git a/internal/pipeline/pipeline.go b/internal/pipeline/pipeline.go
index 8688dbd7..2c71432c 100644
--- a/internal/pipeline/pipeline.go
+++ b/internal/pipeline/pipeline.go
@@ -4,6 +4,7 @@ package pipeline
 import (
 	"fmt"
 
+	"github.com/goreleaser/goreleaser/internal/pipe/gomod"
 	"github.com/goreleaser/goreleaser/internal/pipe/semver"
 	"github.com/goreleaser/goreleaser/internal/pipe/sourcearchive"
 
@@ -37,6 +38,7 @@ type Piper interface {
 // BuildPipeline contains all build-related pipe implementations in order.
 // nolint:gochecknoglobals
 var BuildPipeline = []Piper{
+	gomod.Pipe{},           // setup gomod-related stuff
 	env.Pipe{},             // load and validate environment variables
 	git.Pipe{},             // get and validate git repo state
 	semver.Pipe{},          // parse current tag to a semver
diff --git a/internal/tmpl/tmpl.go b/internal/tmpl/tmpl.go
index 5c65072f..e711db57 100644
--- a/internal/tmpl/tmpl.go
+++ b/internal/tmpl/tmpl.go
@@ -44,6 +44,7 @@ const (
 	env             = "Env"
 	date            = "Date"
 	timestamp       = "Timestamp"
+	modulePath      = "ModulePath"
 
 	// artifact-only keys.
 	osKey        = "Os"
@@ -72,6 +73,7 @@ func New(ctx *context.Context) *Template {
 	return &Template{
 		fields: Fields{
 			projectName:     ctx.Config.ProjectName,
+			modulePath:      ctx.ModulePath,
 			version:         ctx.Version,
 			rawVersion:      rawVersionV,
 			tag:             ctx.Git.CurrentTag,
@@ -97,9 +99,9 @@ func New(ctx *context.Context) *Template {
 // WithEnvS overrides template's env field with the given KEY=VALUE list of
 // environment variables.
 func (t *Template) WithEnvS(envs []string) *Template {
-	var result = map[string]string{}
+	result := map[string]string{}
 	for _, env := range envs {
-		var parts = strings.SplitN(env, "=", 2)
+		parts := strings.SplitN(env, "=", 2)
 		result[parts[0]] = parts[1]
 	}
 	return t.WithEnv(result)
@@ -122,7 +124,7 @@ func (t *Template) WithExtraFields(f Fields) *Template {
 
 // WithArtifact populates Fields from the artifact and replacements.
 func (t *Template) WithArtifact(a *artifact.Artifact, replacements map[string]string) *Template {
-	var bin = a.Extra[binary]
+	bin := a.Extra[binary]
 	if bin == nil {
 		bin = t.fields[projectName]
 	}
diff --git a/pkg/context/context.go b/pkg/context/context.go
index fa1f604e..ffeeca39 100644
--- a/pkg/context/context.go
+++ b/pkg/context/context.go
@@ -32,7 +32,7 @@ type Env map[string]string
 
 // Copy returns a copy of the environment.
 func (e Env) Copy() Env {
-	var out = Env{}
+	out := Env{}
 	for k, v := range e {
 		out[k] = v
 	}
@@ -42,7 +42,7 @@ func (e Env) Copy() Env {
 // Strings returns the current environment as a list of strings, suitable for
 // os executions.
 func (e Env) Strings() []string {
-	var result = make([]string, 0, len(e))
+	result := make([]string, 0, len(e))
 	for k, v := range e {
 		result = append(result, k+"="+v)
 	}
@@ -76,6 +76,7 @@ type Context struct {
 	ReleaseHeader      string
 	ReleaseFooter      string
 	Version            string
+	ModulePath         string
 	Snapshot           bool
 	SkipPostBuildHooks bool
 	SkipPublish        bool
diff --git a/www/docs/ci/actions.md b/www/docs/ci/actions.md
index 8da4cc4a..027a0eab 100644
--- a/www/docs/ci/actions.md
+++ b/www/docs/ci/actions.md
@@ -151,6 +151,8 @@ create a secret named `GH_PAT`, the step will look like this:
           GITHUB_TOKEN: ${{ secrets.GH_PAT }}
 ```
 
+You can also read the [GitHub documentation](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) about it.
+
 ## How does it look like?
 
 You can check [this example repository](https://github.com/goreleaser/example) for a real world example.
diff --git a/www/docs/customization/templates.md b/www/docs/customization/templates.md
index 38b63fe4..d6b34a6b 100644
--- a/www/docs/customization/templates.md
+++ b/www/docs/customization/templates.md
@@ -31,6 +31,7 @@ On fields that support templating, these fields are always available:
 | `.Env`             | a map with system's environment variables                                                                                    |
 | `.Date`            | current UTC date in RFC 3339 format                                                                                          |
 | `.Timestamp`       | current UTC time in Unix format                                                                                              |
+| `.ModulePath`      | the go module path, as reported by `go list -m`                                                                              |
 
 On fields that are related to a single artifact (e.g., the binary name), you
 may have some extra fields:


Test patch:
diff --git a/internal/pipe/gomod/gomod_test.go b/internal/pipe/gomod/gomod_test.go
new file mode 100644
index 00000000..9af8ff1e
--- /dev/null
+++ b/internal/pipe/gomod/gomod_test.go
@@ -0,0 +1,36 @@
+package gomod
+
+import (
+	"os"
+	"testing"
+
+	"github.com/goreleaser/goreleaser/internal/testlib"
+	"github.com/goreleaser/goreleaser/pkg/config"
+	"github.com/goreleaser/goreleaser/pkg/context"
+	"github.com/stretchr/testify/require"
+)
+
+func TestRun(t *testing.T) {
+	ctx := context.New(config.Project{})
+	require.NoError(t, Pipe{}.Run(ctx))
+	require.Equal(t, "github.com/goreleaser/goreleaser", ctx.ModulePath)
+}
+
+func TestRunOutsideGoModule(t *testing.T) {
+	require.NoError(t, os.Chdir(t.TempDir()))
+	ctx := context.New(config.Project{})
+	testlib.AssertSkipped(t, Pipe{}.Run(ctx))
+	require.Empty(t, ctx.ModulePath)
+}
+
+func TestRunCommandError(t *testing.T) {
+	os.Unsetenv("PATH")
+	require.NoError(t, os.Chdir(t.TempDir()))
+	ctx := context.New(config.Project{})
+	require.EqualError(t, Pipe{}.Run(ctx), "failed to get module path: exec: \"go\": executable file not found in $PATH: ")
+	require.Empty(t, ctx.ModulePath)
+}
+
+func TestDescription(t *testing.T) {
+	require.NotEmpty(t, Pipe{}.String())
+}
diff --git a/internal/tmpl/tmpl_test.go b/internal/tmpl/tmpl_test.go
index 8835c79b..93999c51 100644
--- a/internal/tmpl/tmpl_test.go
+++ b/internal/tmpl/tmpl_test.go
@@ -13,9 +13,10 @@ import (
 )
 
 func TestWithArtifact(t *testing.T) {
-	var ctx = context.New(config.Project{
+	ctx := context.New(config.Project{
 		ProjectName: "proj",
 	})
+	ctx.ModulePath = "github.com/goreleaser/goreleaser"
 	ctx.Env = map[string]string{
 		"FOO": "bar",
 	}
@@ -31,21 +32,22 @@ func TestWithArtifact(t *testing.T) {
 	ctx.Git.FullCommit = "fullcommit"
 	ctx.Git.ShortCommit = "shortcommit"
 	for expect, tmpl := range map[string]string{
-		"bar":         "{{.Env.FOO}}",
-		"Linux":       "{{.Os}}",
-		"amd64":       "{{.Arch}}",
-		"6":           "{{.Arm}}",
-		"softfloat":   "{{.Mips}}",
-		"1.2.3":       "{{.Version}}",
-		"v1.2.3":      "{{.Tag}}",
-		"1-2-3":       "{{.Major}}-{{.Minor}}-{{.Patch}}",
-		"test-branch": "{{.Branch}}",
-		"commit":      "{{.Commit}}",
-		"fullcommit":  "{{.FullCommit}}",
-		"shortcommit": "{{.ShortCommit}}",
-		"binary":      "{{.Binary}}",
-		"proj":        "{{.ProjectName}}",
-		"":            "{{.ArtifactUploadHash}}",
+		"bar":                              "{{.Env.FOO}}",
+		"Linux":                            "{{.Os}}",
+		"amd64":                            "{{.Arch}}",
+		"6":                                "{{.Arm}}",
+		"softfloat":                        "{{.Mips}}",
+		"1.2.3":                            "{{.Version}}",
+		"v1.2.3":                           "{{.Tag}}",
+		"1-2-3":                            "{{.Major}}-{{.Minor}}-{{.Patch}}",
+		"test-branch":                      "{{.Branch}}",
+		"commit":                           "{{.Commit}}",
+		"fullcommit":                       "{{.FullCommit}}",
+		"shortcommit":                      "{{.ShortCommit}}",
+		"binary":                           "{{.Binary}}",
+		"proj":                             "{{.ProjectName}}",
+		"":                                 "{{.ArtifactUploadHash}}",
+		"github.com/goreleaser/goreleaser": "{{ .ModulePath }}",
 	} {
 		tmpl := tmpl
 		expect := expect
@@ -126,7 +128,7 @@ func TestEnv(t *testing.T) {
 			out:  "",
 		},
 	}
-	var ctx = context.New(config.Project{})
+	ctx := context.New(config.Project{})
 	ctx.Env = map[string]string{
 		"FOO": "BAR",
 	}
@@ -140,7 +142,7 @@ func TestEnv(t *testing.T) {
 }
 
 func TestWithEnv(t *testing.T) {
-	var ctx = context.New(config.Project{})
+	ctx := context.New(config.Project{})
 	ctx.Env = map[string]string{
 		"FOO": "BAR",
 	}
@@ -154,7 +156,7 @@ func TestWithEnv(t *testing.T) {
 }
 
 func TestFuncMap(t *testing.T) {
-	var ctx = context.New(config.Project{
+	ctx := context.New(config.Project{
 		ProjectName: "proj",
 	})
 	wd, err := os.Getwd()
@@ -293,7 +295,7 @@ func TestInvalidTemplate(t *testing.T) {
 }
 
 func TestEnvNotFound(t *testing.T) {
-	var ctx = context.New(config.Project{})
+	ctx := context.New(config.Project{})
 	ctx.Git.CurrentTag = "v1.2.4"
 	result, err := New(ctx).Apply("{{.Env.FOO}}")
 	require.Empty(t, result)
@@ -301,10 +303,9 @@ func TestEnvNotFound(t *testing.T) {
 }
 
 func TestWithExtraFields(t *testing.T) {
-	var ctx = context.New(config.Project{})
+	ctx := context.New(config.Project{})
 	out, _ := New(ctx).WithExtraFields(Fields{
 		"MyCustomField": "foo",
 	}).Apply("{{ .MyCustomField }}")
 	require.Equal(t, "foo", out)
-
 }