Skip to content

os: provide a way to duplicate os.Root or, at least, clean up the base path when duplicating via relative path #79617

Description

@oakad

Proposal Details

When dealing with os.Root, a need arises to pass it around to goroutines doing things. To simplify the lifecycle management, it will be the best to have an ability to duplicate the os.Root via a proper file descriptor duplication method, so each goroutine can close its own instance of os.Root when it's done.

In the meantime, duplication via OpenRoot(".") is available. Unfortunately, successive duplication don't carry the same name:

r1, _ := os.OpenRoot("/my/dir")
// r1.Name() == "/my/dir"

r2, _ := r1.OpenRoot(".")
// r2.Name() == "/my/dir/."

r3, _ := r2.OpenRoot(".")
// r3.Name() == "/my/dir/./."

One can, of course, always use filepath.Clean on the name returned, but then, so can the OpenRoot method internally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions