fail softly, as documented
This commit is contained in:
parent
a3af8e6c5b
commit
d4628bd751
10
gitver.go
10
gitver.go
|
@ -6,7 +6,6 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"go/format"
|
||||
"log"
|
||||
"os"
|
||||
"text/template"
|
||||
"time"
|
||||
|
@ -45,9 +44,14 @@ func main() {
|
|||
|
||||
v, err := gitver.ExecAndParse()
|
||||
if nil != err {
|
||||
log.Fatalf("Failed to get git version: %s\n", err)
|
||||
fmt.Fprintf(os.Stderr, "Failed to get git version: %s\n", err)
|
||||
if exitCode > 0 {
|
||||
os.Exit(exitCode)
|
||||
}
|
||||
v = &gitver.Versions{
|
||||
Timestamp: time.Now(),
|
||||
}
|
||||
}
|
||||
|
||||
// Create or overwrite the go file from template
|
||||
var buf bytes.Buffer
|
||||
|
@ -89,7 +93,9 @@ var versionTpl = template.Must(template.New("").Parse(`// Code generated by go g
|
|||
package {{ .Package }}
|
||||
|
||||
func init() {
|
||||
{{ if .GitRev -}}
|
||||
GitRev = "{{ .GitRev }}"
|
||||
{{ end -}}
|
||||
{{ if .Version -}}
|
||||
GitVersion = "{{ .Version }}"
|
||||
{{ end -}}
|
||||
|
|
Loading…
Reference in New Issue