24 lines
430 B
Go
24 lines
430 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"os"
|
|
"os/exec"
|
|
)
|
|
//?
|
|
const header = "package main\nconst gitVersion = \""
|
|
|
|
func main() {
|
|
cmd := exec.Command("git", "describe", "--tags", "--abbrev=0")
|
|
out, err := cmd.Output()
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(0)
|
|
}
|
|
version := string(out)
|
|
version = version[:len(version)-1]
|
|
content := header + version + "\""
|
|
|
|
ioutil.WriteFile("version.go", []byte(content), 0644)
|
|
}
|