Skip to content

fs.Stat+os.DirFS gives an error but os.Stat works #44297

Closed
@kr

Description

@kr

What version of Go are you using (go version)?

$ go version
go version go1.16rc1 darwin/arm64

Does this issue reproduce with the latest release?

Yes (& it uses io/fs).

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN="/Users/kr/bin"
GOCACHE="/Users/kr/Library/Caches/go-build"
GOENV="/Users/kr/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/kr/lib/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/kr/lib/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.16rc1"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/m7/5qgxb_bd5yd4b7h7w7xthmh00000gn/T/go-build4121125842=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Ran this program with go run stat_test.go.

https://gist.github.com/kr/a337f4a7bda21d44048d7d83d52e5456

(It doesn't compile on play.golang.org because it needs 1.6rc1).

What did you expect to see?

FileInfo, same as from os.Stat(runtime.GOROOT()) in the commented line in the testcase gist linked above.

What did you see instead?

open /usr/local/go: invalid argument

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions