diff --git a/lwcomponent/staging.go b/lwcomponent/staging.go index b106363a9..d90355458 100644 --- a/lwcomponent/staging.go +++ b/lwcomponent/staging.go @@ -11,6 +11,7 @@ import ( "github.com/Masterminds/semver" "github.com/lacework/go-sdk/internal/file" + dircopy "github.com/otiai10/copy" "github.com/pkg/errors" ) @@ -73,21 +74,10 @@ func (s *stageTarGz) Commit(targetDir string) (err error) { return } - dirEntries, err := os.ReadDir(s.dir) - if err != nil { + if err = dircopy.Copy(s.dir, targetDir); err != nil { return } - for _, entry := range dirEntries { - src := filepath.Join(s.dir, entry.Name()) - dst := filepath.Join(targetDir, entry.Name()) - - err = os.Rename(src, dst) - if err != nil { - return err - } - } - return }