Skip to content

io/fs: Sub should return a fs.FS that implements fs.SubFS #45349

@drew-richardson

Description

@drew-richardson

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

$ go version
go version go1.16.2 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/drew-richardson/.cache/go-build"
GOENV="/home/drew-richardson/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/drew-richardson/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/drew-richardson/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.2"
GCCGO="gccgo"
AR="ar"
CC="x86_64-pc-linux-gnu-gcc"
CXX="x86_64-pc-linux-gnu-g++"
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 -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build992509347=/tmp/go-build -gno-record-gcc-switche
s"

What did you do?

https://play.golang.org/p/uSfpnL8qxCC

What did you expect to see?

main.noopFS.Open
io/fs.(*subFS).Open
io/fs.(*subFS).Open
io/fs.(*subFS).Open
io/fs.(*subFS).Open
io/fs.(*subFS).Open
main.main
runtime.main
runtime.goexit

What did you see instead?

main.noopFS.Open
io/fs.(*subFS).Open
main.main
runtime.main
runtime.goexit

Comments

fs.subFS could implement fs.SubFS and return a new appropriately scoped fs.subFS and the callstack would collapse. Assuming there are no objections, I'll start working on a change

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions