diff --git a/internal/template/template.go b/internal/filenametemplate/template.go similarity index 87% rename from internal/template/template.go rename to internal/filenametemplate/template.go index 43c4941c6..46d17acb4 100644 --- a/internal/template/template.go +++ b/internal/filenametemplate/template.go @@ -1,10 +1,10 @@ -// Package template contains the code used to template names of goreleaser's -// packages and archives. -package template +// Package filenametemplate contains the code used to template names of +// goreleaser's packages and archives. +package filenametemplate import ( "bytes" - gotemplate "text/template" + "text/template" "github.com/goreleaser/goreleaser/context" "github.com/goreleaser/goreleaser/internal/artifact" @@ -39,7 +39,7 @@ func NewFields(ctx *context.Context, a artifact.Artifact, replacements map[strin // Apply applies the given fields to the given template and returns the // evaluation and any error that might occur. func Apply(tmpl string, fields Fields) (string, error) { - t, err := gotemplate.New(tmpl).Parse(tmpl) + t, err := template.New(tmpl).Parse(tmpl) if err != nil { return "", err } diff --git a/internal/template/template_test.go b/internal/filenametemplate/template_test.go similarity index 98% rename from internal/template/template_test.go rename to internal/filenametemplate/template_test.go index 161ddb8f5..262bd0fd2 100644 --- a/internal/template/template_test.go +++ b/internal/filenametemplate/template_test.go @@ -1,4 +1,4 @@ -package template +package filenametemplate import ( "testing" diff --git a/pipeline/archive/archive.go b/pipeline/archive/archive.go index edb069292..5e78942b1 100644 --- a/pipeline/archive/archive.go +++ b/pipeline/archive/archive.go @@ -16,7 +16,7 @@ import ( "github.com/goreleaser/archive" "github.com/goreleaser/goreleaser/context" "github.com/goreleaser/goreleaser/internal/artifact" - "github.com/goreleaser/goreleaser/internal/template" + "github.com/goreleaser/goreleaser/internal/filenametemplate" ) const ( @@ -77,9 +77,9 @@ func (Pipe) Run(ctx *context.Context) error { func create(ctx *context.Context, artifacts []artifact.Artifact) error { var format = packageFormat(ctx, artifacts[0].Goos) - folder, err := template.Apply( + folder, err := filenametemplate.Apply( ctx.Config.Archive.NameTemplate, - template.NewFields(ctx, artifacts[0], ctx.Config.Archive.Replacements), + filenametemplate.NewFields(ctx, artifacts[0], ctx.Config.Archive.Replacements), ) if err != nil { return err @@ -122,8 +122,8 @@ func create(ctx *context.Context, artifacts []artifact.Artifact) error { func skip(ctx *context.Context, artifacts []artifact.Artifact) error { for _, a := range artifacts { log.WithField("binary", a.Name).Info("skip archiving") - var fields = template.NewFields(ctx, a, ctx.Config.Archive.Replacements) - name, err := template.Apply(ctx.Config.Archive.NameTemplate, fields) + var fields = filenametemplate.NewFields(ctx, a, ctx.Config.Archive.Replacements) + name, err := filenametemplate.Apply(ctx.Config.Archive.NameTemplate, fields) if err != nil { return err } diff --git a/pipeline/fpm/fpm.go b/pipeline/fpm/fpm.go index 6d3d05cdd..e111af04f 100644 --- a/pipeline/fpm/fpm.go +++ b/pipeline/fpm/fpm.go @@ -15,8 +15,8 @@ import ( "github.com/goreleaser/goreleaser/context" "github.com/goreleaser/goreleaser/internal/artifact" + "github.com/goreleaser/goreleaser/internal/filenametemplate" "github.com/goreleaser/goreleaser/internal/linux" - "github.com/goreleaser/goreleaser/internal/template" "github.com/goreleaser/goreleaser/pipeline" ) @@ -86,9 +86,9 @@ func doRun(ctx *context.Context) error { } func create(ctx *context.Context, format, arch string, binaries []artifact.Artifact) error { - name, err := template.Apply( + name, err := filenametemplate.Apply( ctx.Config.FPM.NameTemplate, - template.NewFields(ctx, binaries[0], ctx.Config.FPM.Replacements), + filenametemplate.NewFields(ctx, binaries[0], ctx.Config.FPM.Replacements), ) if err != nil { return err diff --git a/pipeline/snapcraft/snapcraft.go b/pipeline/snapcraft/snapcraft.go index a5561a301..947ddba67 100644 --- a/pipeline/snapcraft/snapcraft.go +++ b/pipeline/snapcraft/snapcraft.go @@ -15,8 +15,8 @@ import ( "github.com/goreleaser/goreleaser/context" "github.com/goreleaser/goreleaser/internal/artifact" + "github.com/goreleaser/goreleaser/internal/filenametemplate" "github.com/goreleaser/goreleaser/internal/linux" - "github.com/goreleaser/goreleaser/internal/template" "github.com/goreleaser/goreleaser/pipeline" ) @@ -100,9 +100,9 @@ func (Pipe) Run(ctx *context.Context) error { func create(ctx *context.Context, arch string, binaries []artifact.Artifact) error { var log = log.WithField("arch", arch) - folder, err := template.Apply( + folder, err := filenametemplate.Apply( ctx.Config.Snapcraft.NameTemplate, - template.NewFields(ctx, binaries[0], ctx.Config.Snapcraft.Replacements), + filenametemplate.NewFields(ctx, binaries[0], ctx.Config.Snapcraft.Replacements), ) if err != nil { return err