mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-01 13:07:49 +02:00
docs: tmpl godoc
This commit is contained in:
parent
0311214cbe
commit
30feb1294f
@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Template holds data that can be applied to a template string
|
||||||
type Template struct {
|
type Template struct {
|
||||||
fields fields
|
fields fields
|
||||||
}
|
}
|
||||||
@ -33,6 +34,7 @@ type fields struct {
|
|||||||
Binary string
|
Binary string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// New Template
|
||||||
func New(ctx *context.Context) *Template {
|
func New(ctx *context.Context) *Template {
|
||||||
return &Template{
|
return &Template{
|
||||||
fields: fields{
|
fields: fields{
|
||||||
@ -45,6 +47,7 @@ func New(ctx *context.Context) *Template {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithArtifacts populate fields from the artifact and replacements
|
||||||
func (t *Template) WithArtifact(a artifact.Artifact, replacements map[string]string) *Template {
|
func (t *Template) WithArtifact(a artifact.Artifact, replacements map[string]string) *Template {
|
||||||
var binary = a.Extra["Binary"]
|
var binary = a.Extra["Binary"]
|
||||||
if binary == "" {
|
if binary == "" {
|
||||||
@ -57,6 +60,7 @@ func (t *Template) WithArtifact(a artifact.Artifact, replacements map[string]str
|
|||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply applies the given string against the fields stored in the template.
|
||||||
func (t *Template) Apply(s string) (string, error) {
|
func (t *Template) Apply(s string) (string, error) {
|
||||||
var out bytes.Buffer
|
var out bytes.Buffer
|
||||||
tmpl, err := template.New("tmpl").
|
tmpl, err := template.New("tmpl").
|
||||||
|
Loading…
x
Reference in New Issue
Block a user