first version

This commit is contained in:
2026-02-08 22:29:45 +01:00
commit d1e54774a7
15 changed files with 1355 additions and 0 deletions

65
constant/constant.go Normal file
View File

@@ -0,0 +1,65 @@
package constant
import (
"fmt"
"strconv"
)
type (
Version struct {
patch int
minor int
major int
}
)
var (
patch string = "0"
minor string = "0"
major string = "0"
version Version
)
func init() {
patchInt, err := strconv.Atoi(patch)
if err != nil {
panic(fmt.Errorf("failed to parse version number, this is a compilation error, try recompile the program"))
}
minorInt, err := strconv.Atoi(minor)
if err != nil {
panic(fmt.Errorf("failed to parse version number, this is a compilation error, try recompile the program"))
}
majorInt, err := strconv.Atoi(major)
if err != nil {
panic(fmt.Errorf("failed to parse version number, this is a compilation error, try recompile the program"))
}
version = Version{
patch: patchInt,
minor: minorInt,
major: majorInt,
}
}
func ProgramVersion() Version {
return version
}
func (v Version) Patch() int {
return v.patch
}
func (v Version) Minor() int {
return v.minor
}
func (v Version) Major() int {
return v.major
}
func (v Version) String() string {
return fmt.Sprintf("%d.%d.%d", v.major, v.minor, v.patch)
}