mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-08 03:31:59 +02:00
docs: godoc of template pkg
This commit is contained in:
parent
915e404629
commit
9b0441cbe4
@ -1,3 +1,5 @@
|
||||
// Package template contains the code used to template names of goreleaser's
|
||||
// packages and archives.
|
||||
package template
|
||||
|
||||
import (
|
||||
@ -8,6 +10,7 @@ import (
|
||||
"github.com/goreleaser/goreleaser/internal/artifact"
|
||||
)
|
||||
|
||||
// Fields contains all accepted fields in the template string
|
||||
type Fields struct {
|
||||
Version string
|
||||
Tag string
|
||||
@ -19,6 +22,7 @@ type Fields struct {
|
||||
Binary string
|
||||
}
|
||||
|
||||
// NewFields returns a Fields instances filled with the data provided
|
||||
func NewFields(ctx *context.Context, a artifact.Artifact, replacements map[string]string) Fields {
|
||||
return Fields{
|
||||
Env: ctx.Env,
|
||||
@ -32,6 +36,8 @@ 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)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user