2025-09-25 15:39:17 +03:00

19 lines
366 B
Go

package version
import (
"fmt"
"regexp"
)
var BranchPath = "/var/lib/os-branch"
// Parse extracts version from LABEL="rootfs-XXXX"
func Parse(label string) (string, error) {
re := regexp.MustCompile(`LABEL="rootfs-([0-9]+)"`)
m := re.FindStringSubmatch(label)
if len(m) < 2 {
return "", fmt.Errorf("version not found in: %s", label)
}
return m[1], nil
}