github.com/cnboonhan/delve@v0.0.0-20230908061759-363f2388c2fb/pkg/goversion/compat.go (about) 1 package goversion 2 3 import ( 4 "fmt" 5 6 "github.com/go-delve/delve/pkg/logflags" 7 ) 8 9 var ( 10 MinSupportedVersionOfGoMajor = 1 11 MinSupportedVersionOfGoMinor = 19 12 MaxSupportedVersionOfGoMajor = 1 13 MaxSupportedVersionOfGoMinor = 21 14 goTooOldErr = fmt.Sprintf("Go version %%s is too old for this version of Delve (minimum supported version %d.%d, suppress this error with --check-go-version=false)", MinSupportedVersionOfGoMajor, MinSupportedVersionOfGoMinor) 15 goTooOldWarn = fmt.Sprintf("WARNING: undefined behavior - Go version %%s is too old for this version of Delve (minimum supported version %d.%d)", MinSupportedVersionOfGoMajor, MinSupportedVersionOfGoMinor) 16 dlvTooOldErr = fmt.Sprintf("Version of Delve is too old for Go version %%s (maximum supported version %d.%d, suppress this error with --check-go-version=false)", MaxSupportedVersionOfGoMajor, MaxSupportedVersionOfGoMinor) 17 dlvTooOldWarn = fmt.Sprintf("WARNING: undefined behavior - version of Delve is too old for Go version %%s (maximum supported version %d.%d)", MaxSupportedVersionOfGoMajor, MaxSupportedVersionOfGoMinor) 18 ) 19 20 // Compatible checks that the version specified in the producer string is compatible with 21 // this version of delve. 22 func Compatible(producer string, warnonly bool) error { 23 ver := ParseProducer(producer) 24 if ver.IsDevel() { 25 return nil 26 } 27 if !ver.AfterOrEqual(GoVersion{MinSupportedVersionOfGoMajor, MinSupportedVersionOfGoMinor, betaRev(0), "", ""}) { 28 if warnonly { 29 logflags.WriteError(fmt.Sprintf(goTooOldWarn, ver.String())) 30 return nil 31 } 32 return fmt.Errorf(goTooOldErr, ver.String()) 33 } 34 if ver.AfterOrEqual(GoVersion{MaxSupportedVersionOfGoMajor, MaxSupportedVersionOfGoMinor + 1, betaRev(0), "", ""}) { 35 if warnonly { 36 logflags.WriteError(fmt.Sprintf(dlvTooOldWarn, ver.String())) 37 return nil 38 } 39 return fmt.Errorf(dlvTooOldErr, ver.String()) 40 } 41 return nil 42 }