Skip to content
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

cmd/go: No recursive directory copy in Go standard libraries #10074

Closed
AlexFinkel opened this issue Mar 4, 2015 · 3 comments
Closed

cmd/go: No recursive directory copy in Go standard libraries #10074

AlexFinkel opened this issue Mar 4, 2015 · 3 comments

Comments

@AlexFinkel
Copy link

It would be great to have an analog of "cp -r" for the Go standard libraries. I needed this function today for storing an archive containing a couple of nested directories, and couldn't find a ready-to-go solution that is correct wrt linux file ownership and permissions. It seems to be a common enough use case (and difficult enough to implement correctly) that it should be in the standard libraries. As it is, I ended up shelling out using os/exec - which is fine for my purposes, but not cross-platform and requires creation of another process, so it's kind of heavy-weight.

@ianlancetaylor
Copy link
Contributor

This is a fine function to put into an external package, but I don't see a need for it in the standard library. There are too many different options to make it appropriate for the standard library--see the GNU/Linux cp --preserve option, for example.

@mikioh mikioh changed the title No recursive directory copy in Go standard libraries cmd/go: No recursive directory copy in Go standard libraries Mar 4, 2015
@jtarchie
Copy link

I disagree. We needed this functionality today several times. This is a common pattern needed when working with file systems and especially for cross platform use.

I come from a long Ruby background, there is a great FileUtils class, which implements common use cases for file/dir manipulation.

The issue above, even with --preserve option is implemented in pure Ruby and cross platform compatible.

If one was to provide a PR for this functionality for go, would it be accepted?

@ianlancetaylor
Copy link
Contributor

@jtarchie It's unfortunately generally not useful to hold discussions on closed issues. Very few people see them. The place to discuss things like this is the golang-dev mailing list.

I think the first step would be to write a go-gettable external package. If that is solid and clean, then we can discuss whether it should come into the standard library, or into golang.org/x.

@golang golang locked and limited conversation to collaborators Nov 27, 2016
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

4 participants