GO
package main
import (
"fmt"
"log"
"os"
)
// CreateClean creates a new directory and removes any existing files or directories with the same name
func CreateClean(dirName string) error {
// Check if the directory already exists
if _, err := os.Stat(dirName); os.IsNotExist(err) {
// Create the directory if it does not exist
if err := os.Mkdir(dirName, 0755); err != nil {
return err
}
} else if err != nil {
return err
} else {
// Remove the existing directory and its contents
if err := os.RemoveAll(dirName); err != nil {
return err
}
// Create the directory again
if err := os.Mkdir(dirName, 0755); err != nil {
return err
}
}
return nil
}
func main() {
if err := CreateClean("clean"); err != nil {
log.Fatal(err)
}
fmt.Println("Directory created or cleaned successfully")
}
MORE POSTS
18h
SpaceX IPO filing discloses a $1.45 billion Bitcoin position, revealing Elon Musk's significant cryp...
44m
```go
package main
import (
"fmt"
"net"
)
func checkIP(ipAddress string) {
地址 := net.ParseIP(ipA...
17h
ZEC surges 11% in recent rebound. Reports emerge that a presidential pardon for Sam Bankman-Fried is...
17h
Blockchain intelligence has exposed a large-scale tax fraud scheme involving Bitcoin Ordinals, with ...
16h
Bitcoin's price is unlikely to reach $100,000 this year according to Kalshi. This prediction is base...