Open
Description
Go version
1.25rc2
Output of go env
in your module/workspace:
`go env` output, not particularly relevant
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/cheetah/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/cheetah/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1694165664=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/cheetah/src/gdev/go.mod'
GOMODCACHE='/home/cheetah/.go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/cheetah/.go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/cheetah/.go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25rc2.linux-amd64'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/cheetah/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/cheetah/.go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25rc2.linux-amd64/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.25rc2'
GOWORK='/home/cheetah/src/gdev/go.work'
PKG_CONFIG='pkg-config'
What did you do?
I (mistakenly) tried to do a struct embedding of an os.Root
in my application, and then got confused when I got file already closed
errors.
Since os.OpenRoot
attaches a Cleanup to the *os.Root
pointer returned that calls *os.Root.Close()
once freed,, it's important that no struct copies be made, as those copies won't work properly.
What did you see happen?
file already closed
errors when my os.Root
instance was still live in active goroutine stacks
What did you expect to see?
Some combination of:
- A documentation note that the struct is not safe to copy
- A
vet
error telling me that same thing