Go version
go version devel go1.24-c5430dc1d8 Wed Jul 24 01:01:48 2024 +0000 windows/amd64
Output of go env
in your module/workspace:
set GO111MODULE=on
set GOARCH=wasm
set GOBIN=
set GOCACHE=C:\Users\zxilly\AppData\Local\go-build
set GOENV=C:\Users\zxilly\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\zxilly\go\pkg\mod
set GONOPROXY=1
set GONOSUMDB=
set GOOS=js
set GOPATH=C:\Users\zxilly\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=E:/Temp/go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=E:\Temp\go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=devel go1.24-c5430dc1d8 Wed Jul 24 01:01:48 2024 +0000
set GODEBUG=
set GOTELEMETRY=local
set GOTELEMETRYDIR=C:\Users\zxilly\AppData\Roaming\go\telemetry
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\zxilly\AppData\Local\Temp\go-build1954128060=/tmp/go-build -gno-record-gcc-switches
What did you do?
Assume a basic file open program located at E:\Temp\bug
package main
import (
"fmt"
"os"
)
func main() {
filePath := "E:\Temp\bug\file.txt"
file, err := os.Open(filePath)
if err != nil {
fmt.Printf("Failed to open file: %v\n", err)
return
}
defer file.Close()
fmt.Println("File opened successfully!")
}
Compile to wasm and run it with node.js wrapper.
What did you see happen?
open E:\Temp\bug\E:\Temp\bug\file.txt: No such file or directory
What did you expect to see?
Open success.
Comment From: gabyhelp
Related Issues and Documentation
- syscall,misc/wasm: fix path expansion on non-unix platforms #68255
- os: invalid tmp dir for GOARCH=wasm, GOOS=js when GOHOSTOS=windows #27306 (closed)
- path/filepath: WebAssembly uses *nix conventions on Windows #43768
- path/filepath: filepath.Abs("[...]\...") returns different results on Windows than other systems #42362 (closed)
- os: ReadDir on regular file returns ERROR_PATH_NOT_FOUND instead of ENOTDIR #46734
- wasm: reading from stdin fails with Windows #43913
- os: `GOOS=wasip1 GOARCH=wasm` the `ReadFile` function gives `-1` as the `rootFd` to `path_open` causing `Bad file number` error #63466
- os: `ReadDir` fails on file systems without File ID support on Windows #61907 (closed)
- cmd/distpack: wasm runtime js should be kept in the toolchain package #68024
- affected/package: path #60799 (closed)
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Comment From: gopherbot
Change https://go.dev/cl/595797 mentions this issue: syscall,misc/wasm: fix path expansion on non-unix platforms
Comment From: seankhliao
related #43768 cc @golang/wasm
Comment From: Zxilly
I'm wondering if this fix can't be introduced in 1.23? I don't know much about Go's release process.
Comment From: dmitshur
Bugs are first fixed on the main branch, where development for the upcoming major release (Go 1.24) is happening. If appropriate, fixes may be backported to supported minor versions. See https://go.dev/s/release and https://go.dev/wiki/MinorReleases.
Comment From: Zxilly
I hope this fix gets a backport, at least for 1.23. One of my applications requires complex relative position calculations in order to workaround this bug. Thanks.