mirror of
https://github.com/avelino/awesome-go.git
synced 2024-11-07 16:33:40 +00:00
extract drop/create dir func
This commit is contained in:
parent
494289eb6f
commit
e05067733e
24
main.go
24
main.go
@ -58,15 +58,8 @@ func main() {
|
||||
|
||||
// FIXME: choose a better name
|
||||
func renderAll() error {
|
||||
// Cleanup and re-create output directory
|
||||
{
|
||||
if err := os.RemoveAll(outDir); err != nil {
|
||||
return fmt.Errorf("unable to remove target dir: %w", err)
|
||||
}
|
||||
|
||||
if err := mkdirAll(outDir); err != nil {
|
||||
return fmt.Errorf("unable to create target dir: %w", err)
|
||||
}
|
||||
if err := dropCreateDir(outDir); err != nil {
|
||||
return fmt.Errorf("unable to drop-create out dir: %w", err)
|
||||
}
|
||||
|
||||
err := renderIndex(readmePath, outIndexFile)
|
||||
@ -130,6 +123,19 @@ func renderAll() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// dropCreateDir drop and create output directory
|
||||
func dropCreateDir(dir string) error {
|
||||
if err := os.RemoveAll(dir); err != nil {
|
||||
return fmt.Errorf("unable to remove dir: %w", err)
|
||||
}
|
||||
|
||||
if err := mkdirAll(dir); err != nil {
|
||||
return fmt.Errorf("unable to create dir: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func mkdirAll(path string) error {
|
||||
_, err := os.Stat(path)
|
||||
// NOTE: directory is exists
|
||||
|
Loading…
Reference in New Issue
Block a user