mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
support to parse devl version
Signed-off-by: sivchari <shibuuuu5@gmail.com>
This commit is contained in:
@@ -50,6 +50,9 @@ func GetGorootVersion() (major, minor int, err error) {
|
||||
// major, minor, and patch version: 1, 3, and 2 in this example.
|
||||
// If there is an error, (0, 0, 0) and an error will be returned.
|
||||
func Parse(version string) (major, minor, patch int, err error) {
|
||||
if strings.HasPrefix(version, "devel ") {
|
||||
version = strings.Split(strings.TrimPrefix(version, "devel "), version)[0]
|
||||
}
|
||||
if version == "" || version[:2] != "go" {
|
||||
return 0, 0, 0, errors.New("could not parse Go version: version does not start with 'go' prefix")
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ func TestParse(t *testing.T) {
|
||||
{"go1.23.5-rc6", 1, 23, 5, false},
|
||||
{"go2.0", 2, 0, 0, false},
|
||||
{"go2.0.15", 2, 0, 15, false},
|
||||
{"devel go1.24-f99f5da18f Thu Nov 14 22:29:26 2024 +0000 darwin/arm64", 1, 24, 0, false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.v, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user