From b5513bc2408b686da6da7ffbd1e64d844df4a7cd Mon Sep 17 00:00:00 2001 From: Foil-hat-guy Date: Sun, 20 Apr 2025 02:00:13 +0300 Subject: [PATCH] Feat: detecting a git version. --- main.go | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index baa36b4..2dcb2e5 100644 --- a/main.go +++ b/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) }