otiai10 / copy

Go copy directory recursively
https://pkg.go.dev/github.com/otiai10/copy
MIT License
713 stars 115 forks source link

Add support for embed directories #71

Closed 4k1k0 closed 1 year ago

4k1k0 commented 2 years ago

It would be super useful if this package could copy embed directories.

For example:

Given the following fs tree:

/
  /assets
    /foo
       foo.txt
       bar.txt
    hello.txt
    goodbye.txt
  main.go

It could use the embed FS to use the copy function.

//go:embed assets
var assets embed.FS

func foo() error {
  file, err := assets.Open("assets")
  if err != nil {
    return err
  }

  err := Copy(file, "destination")
  if err != nil {
    return err
  }
  return nil
}

Or maybe use the Option structure

opt := Options{
    FS: assets,
}
err := Copy("assets/foo", "new/destination", opt)
otiai10 commented 2 years ago

Thank you for your feedback. Let me take time to think of it

otiai10 commented 2 years ago

@otiai10 https://pkg.go.dev/io/fs#Glob

tomaswarynyca commented 1 year ago

@otiai10 is this planned to be implemented?

otiai10 commented 1 year ago

will tackle it this weekend ;)

otiai10 commented 1 year ago

See v1.12.0