Files
zogo/verx/README.md
T
4566704 1c9c717579 feat(verx): 自 go-hua/common 迁入版本号工具并独立成包
- 点分版本号解析/还原/比较,CompareVersion 依赖 numx.Min
- 附单元测试、examples/verx 例程与包 README
2026-09-20 12:20:51 +08:00

27 lines
874 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# verx
版本号工具:点分版本号与结构互转、版本比较。
> 迁移自 go-hua/common(原 version.go,Max/Min 归入 numx)。
## 用法
```go
import "git.zeroonesoft.cn/golib/zogo/verx"
// 结构化版本:解析 / 还原 / 比较
ver := verx.StringToVersionInfo("1.2.3") // {1,2,3,0}
s := verx.VersionToString(ver) // "1.2.3.0"
verx.VersionComparison(ver, verx.StringToVersionInfo("2.0.0.0")) // -1
// 点分字符串直接比较:1 大于 / -1 小于 / 0 等于
verx.CompareVersion("1.2.0", "1.10.0") // -1
```
完整可运行例程:[examples/verx/main.go](../examples/verx/main.go)
## 注意
- `VersionInfo` 每段为 int64,但与 2 字节互转的历史约定仍在:超过 65535 会溢出截断。
- `CompareVersion` 按段逐段数字比较,段数不同时缺段按 0 处理("2.0" > "1.9.9")。