Skip to content

Commit eee238e

Browse files
committed
internal/wasmserve: consider Go 2
1 parent 3368f3a commit eee238e

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

internal/wasmserveutil/util.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@ func WasmExecJSURL(goVersion string) (string, error) {
1717
if len(m) == 0 {
1818
return "", fmt.Errorf("wasmserveutil: invalid Go version: %s", goVersion)
1919
}
20+
21+
major, _ := strconv.Atoi(m[1])
2022
minor, _ := strconv.Atoi(m[2])
2123

2224
// go.mod might have a version without `.0` like `go1.22`. This version might not work as a part of URL.
23-
if minor >= 22 && m[3] == "" {
25+
if (major > 1 || minor >= 22) && m[3] == "" {
2426
goVersion += ".0"
2527
}
2628

2729
// The directory name was changed from `misc` to `lib` at Go 1.24.
2830
dir := "lib"
29-
if minor <= 23 {
31+
if major == 1 && minor <= 23 {
3032
dir = "misc"
3133
}
3234

internal/wasmserveutil/util_test.go

+30
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,36 @@ func TestWasmExecJSURL(t *testing.T) {
7575
url: "https://go.googlesource.com/go/+/refs/tags/go1.24.1/lib/wasm/wasm_exec.js?format=TEXT",
7676
error: false,
7777
},
78+
{
79+
goVersion: "go2.23",
80+
url: "https://go.googlesource.com/go/+/refs/tags/go2.23.0/lib/wasm/wasm_exec.js?format=TEXT",
81+
error: false,
82+
},
83+
{
84+
goVersion: "go2.23.0",
85+
url: "https://go.googlesource.com/go/+/refs/tags/go2.23.0/lib/wasm/wasm_exec.js?format=TEXT",
86+
error: false,
87+
},
88+
{
89+
goVersion: "go2.23.1",
90+
url: "https://go.googlesource.com/go/+/refs/tags/go2.23.1/lib/wasm/wasm_exec.js?format=TEXT",
91+
error: false,
92+
},
93+
{
94+
goVersion: "go2.24",
95+
url: "https://go.googlesource.com/go/+/refs/tags/go2.24.0/lib/wasm/wasm_exec.js?format=TEXT",
96+
error: false,
97+
},
98+
{
99+
goVersion: "go2.24.0",
100+
url: "https://go.googlesource.com/go/+/refs/tags/go2.24.0/lib/wasm/wasm_exec.js?format=TEXT",
101+
error: false,
102+
},
103+
{
104+
goVersion: "go2.24.1",
105+
url: "https://go.googlesource.com/go/+/refs/tags/go2.24.1/lib/wasm/wasm_exec.js?format=TEXT",
106+
error: false,
107+
},
78108
}
79109

80110
for _, tc := range testCases {

0 commit comments

Comments
 (0)