delve/pkg/goversion/compat.go
Alessandro Arzilli 79e0f543c0 cmd/dlv: add Go version check (#1533)
Before doing anything check that the version of Go is compatible with
the current version of Delve.
This will improve the error message in the case that  another change as
disruptive as Go1.11 dwarf compression, happens.
2019-04-26 10:24:21 -07:00

29 lines
994 B
Go

package goversion
import (
"fmt"
)
var (
minSupportedVersionOfGoMinor = 10
maxSupportedVersionOfGoMinor = 12
goTooOldErr = fmt.Errorf("Version of Go is too old for this version of Delve (minimum supported version 1.%d, suppress this error with --check-go-version=false)", minSupportedVersionOfGoMinor)
dlvTooOldErr = fmt.Errorf("Version of Delve is too old for this version of Go (maximum supported version 1.%d, suppress this error with --check-go-version=false)", maxSupportedVersionOfGoMinor)
)
// Compatible checks that the version specified in the producer string is compatible with
// this version of delve.
func Compatible(producer string) error {
ver := parseProducer(producer)
if ver.IsDevel() {
return nil
}
if !ver.AfterOrEqual(GoVersion{1, minSupportedVersionOfGoMinor, -1, 0, 0, ""}) {
return goTooOldErr
}
if ver.AfterOrEqual(GoVersion{1, maxSupportedVersionOfGoMinor + 1, -1, 0, 0, ""}) {
return dlvTooOldErr
}
return nil
}