GoFrame gstr-版本比較

2022-04-11 17:48 更新

CompareVersion

  • 說明:?CompareVersion?將?a?和?b?作為標(biāo)準(zhǔn)?GNU?版本進(jìn)行比較。  
  • 格式:

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?作為標(biāo)準(zhǔn)的?Golang?版本進(jìn)行比較。  
  • 格式:

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
}


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)