otiai10 / copy

Go copy directory recursively

Home Page:https://pkg.go.dev/github.com/otiai10/copy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for embed directories

4k1k0 opened this issue · comments

commented

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)

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

@otiai10 is this planned to be implemented?

will tackle it this weekend ;)

See v1.12.0