This repository has been archived by the owner on Oct 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
968 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package components | ||
|
||
import ( | ||
"embed" | ||
"io" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
//go:embed src/* package.json | ||
var files embed.FS | ||
|
||
func CopyTo(srcDir, destDir string) error { | ||
// Create the destination directory if it doesn't exist | ||
if err := os.MkdirAll(destDir, 0755); err != nil { | ||
return err | ||
} | ||
|
||
// List all files and directories in the embedded FS | ||
entries, err := files.ReadDir(srcDir) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Loop through each entry (file or directory) | ||
for _, entry := range entries { | ||
srcPath := filepath.Join(srcDir, entry.Name()) | ||
destPath := filepath.Join(destDir, entry.Name()) | ||
|
||
if entry.IsDir() { | ||
// If it's a directory, recursively copy its contents | ||
if err := CopyTo(srcPath, destPath); err != nil { | ||
return err | ||
} | ||
} else { | ||
// If it's a file, copy it to the destination directory | ||
srcFile, err := files.Open(srcPath) | ||
if err != nil { | ||
return err | ||
} | ||
defer srcFile.Close() | ||
|
||
destFile, err := os.Create(destPath) | ||
if err != nil { | ||
return err | ||
} | ||
defer destFile.Close() | ||
|
||
if _, err := io.Copy(destFile, srcFile); err != nil { | ||
return err | ||
} | ||
} | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.