Feat: detecting a git version.
This commit is contained in:
parent
5e5526ba77
commit
b5513bc240
1 changed files with 20 additions and 3 deletions
23
main.go
23
main.go
|
@ -1,7 +1,24 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func main () {
|
||||
fmt.Println("version is here")
|
||||
const header = "package main\nconst Value = \""
|
||||
|
||||
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)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue