Categories: GoFrame 教程

GoFrame gstr-版本比较

CompareVersion

  • 说明:​CompareVersion​将​a​和​b​作为标准​GNU​版本进行比较。
  • 格式:
CompareVersion(a, b string) int
  • 示例:
func ExampleCompareVersion() {
 fmt.Println(gstr.CompareVersion("v2.11.9", "v2.10.8"))
 fmt.Println(gstr.CompareVersion("1.10.8", "1.19.7"))
 fmt.Println(gstr.CompareVersion("2.8.beta", "2.8"))

 // Output:
 // 1
 // -1
 // 0
}

CompareVersionGo

  • 说明:​CompareVersionGo​将​a​和​b​作为标准的​Golang​版本进行比较。
  • 格式:
CompareVersionGo(a, b string) int
  • 示例:
func ExampleCompareVersionGo() {
 fmt.Println(gstr.CompareVersionGo("v2.11.9", "v2.10.8"))
 fmt.Println(gstr.CompareVersionGo("v4.20.1", "v4.20.1+incompatible"))
 fmt.Println(gstr.CompareVersionGo(
  "v0.0.2-20180626092158-b2ccc119800e",
  "v1.0.1-20190626092158-b2ccc519800e",
 ))

 // Output:
 // 1
 // 1
 // -1
}

唐伯虎点蚊香

前端小白,想各位学习!

Share
Published by
唐伯虎点蚊香

Recent Posts

聊聊vue3中的defineProps

在Vue 3中,defineP…

1 周 ago

在 Chrome 中删除、允许和管理 Cookie

您可以选择删除现有 Cooki…

2 周 ago

自定义指令:聊聊vue中的自定义指令应用法则

今天我们来聊聊vue中的自定义…

3 周 ago

聊聊Vue中@click.stop和@click.prevent

一起来学下聊聊Vue中@cli…

4 周 ago

Nginx 基本操作:启动、停止、重启命令。

我们来学习Nginx基础操作:…

1 月 ago

Vue3:手动清理keep-alive组件缓存的方法

Vue3中手动清理keep-a…

1 月 ago