mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-25 06:15:56 +01:00
17fa7bb407
extract some error checking and logging in places where linting needed or errors not checked
47 lines
711 B
Go
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)
|
|
}
|
|
} |