Go version
go version go1.26.2 darwin/arm64
Output of go env in your module/workspace:
What did you do?
- Read https://pkg.go.dev/os#Root documentation.
- Run https://go.dev/play/p/q9mW-k5sg-X
- Got confused.
What did you see happen?
2009/11/10 23:00:00 root /tmp/860037159
2009/11/10 23:00:00 mkdirat /tmp/860037159/123: path escapes from parent
What did you expect to see?
Root documentation says (relevant bits):
Root may be used to only access files within a single directory tree.
Methods on Root can only access files and directories beneath a root directory. If any component of a file name passed to a method of Root references a location outside the root, the method returns an error. File names may reference the directory itself (.).
Methods on Root will follow symbolic links, but symbolic links may not reference a location outside the root. Symbolic links must not be absolute.
/tmp/860037159 and /tmp/860037159/123 are within a single directory tree. /tmp/860037159/123 is beneath a root directory /tmp/860037159. There are no symbolic links. So what I do is correct according to the documentation.
I guess what documentation fails to mention is that the arguments to root methods must be relative paths, even if there are no symbolic links. If the current behavior is intentional, it should be documented; "within a single directory tree" and " beneath a root directory" are not enough.
Go version
go version go1.26.2 darwin/arm64
Output of
go envin your module/workspace:What did you do?
What did you see happen?
What did you expect to see?
Rootdocumentation says (relevant bits):/tmp/860037159and/tmp/860037159/123are within a single directory tree./tmp/860037159/123is beneath a root directory/tmp/860037159. There are no symbolic links. So what I do is correct according to the documentation.I guess what documentation fails to mention is that the arguments to root methods must be relative paths, even if there are no symbolic links. If the current behavior is intentional, it should be documented; "within a single directory tree" and " beneath a root directory" are not enough.