fix: restore go compatibility for runtime models

This commit is contained in:
Yoilun
2026-05-25 18:32:10 +08:00
parent d573bde194
commit bb8b8fe732
11 changed files with 262 additions and 60 deletions

View File

@@ -0,0 +1,45 @@
package runtime
import (
"os"
"path/filepath"
"runtime"
"testing"
)
func TestModuleKeepsGo122Compatibility(t *testing.T) {
if runtime.Version() == "" {
t.Fatal("runtime version unavailable")
}
data, err := os.ReadFile(filepath.Join("..", "..", "go.mod"))
if err != nil {
t.Fatal(err)
}
if !containsLine(string(data), "go 1.22") {
t.Fatalf("go.mod must keep Go 1.22 compatibility, got:\n%s", data)
}
}
func containsLine(input string, want string) bool {
for _, line := range splitLines(input) {
if line == want {
return true
}
}
return false
}
func splitLines(input string) []string {
var lines []string
start := 0
for i, char := range input {
if char == '\n' {
lines = append(lines, input[start:i])
start = i + 1
}
}
if start <= len(input) {
lines = append(lines, input[start:])
}
return lines
}