go/version, "go2.00.1" < "go1.0.0"

113 views
Skip to first unread message

leo zeng

unread,
Feb 26, 2024, 11:26:21 PM2/26/24
to golang-nuts
package main

import "go/version"

func main() {
    var val int
    val = version.Compare("go2.00.1", "go1.0.0")
    print(val) // -1
}

Ian Lance Taylor

unread,
Feb 26, 2024, 11:30:50 PM2/26/24
to leo zeng, golang-nuts
Please write plain text as plain text. It's difficult to read against
a dark background. Thanks.

The version code treats an unnecessary leading zero as an error. You
can try calling version.Lang: it will return the empty string for an
erroneous version.

Ian
Reply all
Reply to author
Forward
0 new messages