Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kr opened this issue Feb 16, 2021 · 2 comments
Closed

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

kr opened this issue Feb 16, 2021 · 2 comments

Comments

@kr
Copy link
Contributor

kr commented Feb 16, 2021

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
@seankhliao
Copy link
Member

runtime.GOROOT() returns an absolute path which isn't valid for fs.Fs https://tip.golang.org/pkg/io/fs/#ValidPath

see also #44286

@kr
Copy link
Contributor Author

kr commented Feb 16, 2021

Oh, my bad, thanks. Sorry for the noise!

@kr kr closed this as completed Feb 16, 2021
@golang golang locked and limited conversation to collaborators Feb 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants