将1.0.221.9289转换为0001+0000+0221+9289,然后转换为int64。
$ b

比较两个int64值。



试试


I have two strings (they are actually version numbers and they could be any version numbers)

a := "1.05.00.0156"  
b := "1.0.221.9289"

I want to compare which one is bigger. How to do it in golang?

Convert "1.05.00.0156" to "0001"+"0005"+"0000"+"0156", then to int64.

Convert "1.0.221.9289" to "0001"+"0000"+"0221"+"9289", then to int64.

Compare the two int64 values.

Try it on the

这篇关于如何比较golang中的两个版本号字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!