How to compare two version number strings in golang

前端 未结 10 662
别跟我提以往
别跟我提以往 2020-12-30 02:06

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\"

10条回答
  •  隐瞒了意图╮
    2020-12-30 02:23

    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 Go playground

提交回复
热议问题