Skip to content

os: Open("file/.") does not produce an error on wasip1 #69509

Open
@neild

Description

@neild

Go version

master

Output of go env in your module/workspace:

$ go env
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/dneil/Library/Caches/go-build'
GOENV='/Users/dneil/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/dneil/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/dneil'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/dneil/src/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/dneil/src/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='devel go1.24-adf220a5d5 Mon Sep 9 17:11:52 2024 +0000'
GODEBUG=''
GOTELEMETRY='on'
GOTELEMETRYDIR='/Users/dneil/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/tmp/m2/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/kw/0t4d_x2n4plg9157krpjtxmw0047mf/T/go-build1969548244=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

package main

import (
        "fmt"
        "os"
)

func main() {
        _, err := os.Open("file/.")
        fmt.Println(err)
}
$ touch file
$ go run main.go
open file/.: not a directory
$ GOOS=wasip1 GOARCH=wasm go run main.go
<nil>

What did you see happen?

When built with GOOS=wasip1, the os package performs some path cleaning on filenames which results in a terminal "/." being removed. This causes opening a non-directory file to unexpectedly succeed.

What did you expect to see?

An error opening "file/.", because "file" is not a directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions