Feat: detecting a git version.

This commit is contained in:
Foil-hat-guy 2025-04-20 02:00:13 +03:00
parent 5e5526ba77
commit b5513bc240
No known key found for this signature in database
GPG key ID: 221CC305A7B23591

23
main.go
View file

@ -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)
}