Skip to content

Commit ed47ed3

Browse files
vasilevncw
authored andcommitted
Fixed WASM compatibility by avoiding panic due to absence of os.Executable() in "js" and "wasip1" targets.
1 parent e9cde5f commit ed47ed3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

stdlib/sys/sys.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package sys
1919

2020
import (
2121
"os"
22+
"runtime"
2223

2324
"github.com/go-python/gpython/py"
2425
)
@@ -659,7 +660,14 @@ func init() {
659660

660661
executable, err := os.Executable()
661662
if err != nil {
662-
panic(err)
663+
switch runtime.GOOS {
664+
case "js", "wasip1":
665+
// These platforms don't implement os.Executable (at least as of Go
666+
// 1.21), see https://github.com/tailscale/tailscale/pull/8325
667+
executable = "gpython"
668+
default:
669+
panic(err)
670+
}
663671
}
664672

665673
globals := py.StringDict{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy