feat(refacto): move everything in internal package

This allows to install katenary with `go install` and to clean up the
project folder.
This commit is contained in:
2025-08-03 15:54:58 +02:00
parent d1768e5742
commit 14ca5bf0ea
91 changed files with 291 additions and 282 deletions

View File

@@ -0,0 +1,28 @@
package generator
import (
"regexp"
"runtime/debug"
)
// Version is the version of katenary. It is set at compile time.
var Version = "master" // changed at compile time
// GetVersion return the version of katneary. It's important to understand that
// the version is set at compile time for the github release. But, it the user get
// katneary using `go install`, the version should be different.
func GetVersion() string {
// try to get the semantic version from the Version variable (theorically set at compile time)
if reg := regexp.MustCompile(`^v?\d+.\d+.\d+.*|^release-.*`); reg.MatchString(Version) {
return Version
}
// OK... let's try to get the version from the build info
// get the version from the build info (when installed with go install)
if v, ok := debug.ReadBuildInfo(); ok {
return v.Main.Version + "-" + v.GoVersion
}
// OK... none worked, so we return the default version
return Version
}