aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/version.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-10-21 01:49:36 +0900
committerOphestra <cat@gensokyo.uk>2025-10-21 01:49:36 +0900
commit766dd89ffa198a315b043230f904636461c41efe (patch)
tree163290a35109da0cae36c6453fc4b56529cf4d54 /internal/version.go
parent699c19e972a3cbcc714403aedffcb5ff74386cfc (diff)
internal: clean up build strings
These names are less ambiguous and should be understandable without reading the source code. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/version.go')
-rw-r--r--internal/version.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/internal/version.go b/internal/version.go
new file mode 100644
index 00000000..5c671084
--- /dev/null
+++ b/internal/version.go
@@ -0,0 +1,19 @@
+package internal
+
+// FallbackVersion is returned when a version string was not set by the linker.
+const FallbackVersion = "dirty"
+
+// buildVersion is the Hakurei tree's version string at build time.
+//
+// This is set by the linker.
+var buildVersion string
+
+// Version returns the Hakurei tree's version string.
+// It is either the value of the constant [FallbackVersion] or,
+// when possible, a release tag like "v1.0.0".
+func Version() string {
+ if buildVersion != "" {
+ return buildVersion
+ }
+ return FallbackVersion
+}