Semaphore/util/version_gen/generator.go
tom whiston 17fa7bb407 add gometalinter to tools and run it in circle.
extract some error checking and logging in places where linting needed or errors not checked
2018-04-05 21:24:19 +00:00

47 lines
711 B
Go

// +build ignore
package main
import (
"log"
"os"
"text/template"
)
var versionTmpl = `package util
//Version is the Semaphore build version as a string
var Version = "{{ .VERSION }}"
`
func main(){
if len(os.Args) <= 1 {
log.Fatalln("Must pass in version number")
}
data := make(map[string]string)
data["VERSION"] = os.Args[1]
tmpl := template.New("version")
var err error
if tmpl, err = tmpl.Parse(versionTmpl); err != nil {
log.Fatalln(err)
}
f, err := os.Create("util/version.go")
if err != nil {
log.Fatalln(err)
}
defer func(r *os.File) {
err = r.Close()
if err != nil {
log.Fatalln(err)
}
}(f)
err = tmpl.Execute(f, data)
if err != nil {
log.Println(err)
}
}