in src/main/kotlin/org/jetbrains/tinygoplugin/services/ErrorRegexUtil.kt [52:65]
fun extractIncompatibleVersionsError(msg: String): Triple<String, String, String>? {
val minor2DigitsRule = "([0-9]\\.[0-9][0-9])"
val minor1DigitRule = "([0-9]\\.[0-9])" // rule produces 3 groups: (1d or 2d), (1d), (2d)
val goVersionRule = "($minor1DigitRule|$minor2DigitsRule)"
val errorPattern =
Regex("""requires go version $goVersionRule through $goVersionRule, got go$goVersionRule\n""")
val errorMatch = errorPattern.find(msg) ?: return null
val oldestCompatibleGoVersion = errorMatch.groupValues[1] // 1st = 2nd or 3rd
val latestCompatibleGoVersion = errorMatch.groupValues[4] // 4th = 5th or 6th
val currentGoVersion = errorMatch.groupValues[7] // 7th = 8th or 9th
return Triple(currentGoVersion, oldestCompatibleGoVersion, latestCompatibleGoVersion)
}