1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-08 03:31:59 +02:00
goreleaser/pipeline/build/ldflags.go
Carlos Alexandro Becker 34cd3c4196
fixed ldflags time format
2017-04-09 10:22:09 -03:00

31 lines
555 B
Go

package build
import (
"bytes"
"text/template"
"time"
"github.com/goreleaser/goreleaser/context"
)
type ldflagsData struct {
Date string
Commit string
Version string
}
func ldflags(ctx *context.Context) (string, error) {
var data = ldflagsData{
Commit: ctx.Git.Commit,
Version: ctx.Git.CurrentTag,
Date: time.Now().UTC().Format(time.RFC3339),
}
var out bytes.Buffer
t, err := template.New("ldflags").Parse(ctx.Config.Build.Ldflags)
if err != nil {
return "", err
}
err = t.Execute(&out, data)
return out.String(), err
}