github.com/tomsquest/goreleaser@v0.34.3-0.20171008022654-7d6ef4d338b3/pipeline/build/ldflags.go (about) 1 package build 2 3 import ( 4 "bytes" 5 "text/template" 6 "time" 7 8 "github.com/goreleaser/goreleaser/config" 9 "github.com/goreleaser/goreleaser/context" 10 ) 11 12 type ldflagsData struct { 13 Date string 14 Tag string 15 Commit string 16 Version string 17 } 18 19 func ldflags(ctx *context.Context, build config.Build) (string, error) { 20 var data = ldflagsData{ 21 Commit: ctx.Git.Commit, 22 Tag: ctx.Git.CurrentTag, 23 Version: ctx.Version, 24 Date: time.Now().UTC().Format(time.RFC3339), 25 } 26 var out bytes.Buffer 27 t, err := template.New("ldflags").Parse(build.Ldflags) 28 if err != nil { 29 return "", err 30 } 31 err = t.Execute(&out, data) 32 return out.String(), err 33 }