diff --git a/version.go b/vercmp/vercmp.go
similarity index 95%
rename from version.go
rename to vercmp/vercmp.go
index 9997d58..277a746 100644
--- a/version.go
+++ b/vercmp/vercmp.go
@@ -16,7 +16,7 @@
* along with this program. If not, see .
*/
-package main
+package vercmp
import (
_ "embed"
@@ -26,16 +26,11 @@ import (
"golang.org/x/exp/slices"
)
-//go:generate scripts/gen-version.sh
-
-//go:embed version.txt
-var version string
-
-// vercmp compares two version strings.
+// Compare compares two version strings.
// It returns 1 if v1 is greater,
// 0 if the versions are equal,
// and -1 if v2 is greater
-func vercmp(v1, v2 string) int {
+func Compare(v1, v2 string) int {
if v1 == v2 {
return 0
}
diff --git a/version_test.go b/vercmp/vercmp_test.go
similarity index 96%
rename from version_test.go
rename to vercmp/vercmp_test.go
index 461cbb8..92146a7 100644
--- a/version_test.go
+++ b/vercmp/vercmp_test.go
@@ -16,7 +16,7 @@
* along with this program. If not, see .
*/
-package main
+package vercmp
import (
"testing"
@@ -67,13 +67,13 @@ func TestVerCmp(t *testing.T) {
for _, it := range table {
t.Run(it.v1+"/"+it.v2, func(t *testing.T) {
- c := vercmp(it.v1, it.v2)
+ c := Compare(it.v1, it.v2)
if c != it.expected {
t.Errorf("Expected %d, got %d", it.expected, c)
}
// Ensure opposite comparison gives opposite value
- c = -vercmp(it.v2, it.v1)
+ c = -Compare(it.v2, it.v1)
if c != it.expected {
t.Errorf("Expected %d, got %d (opposite)", it.expected, c)
}