以下是一个在 Go 中读取文件夹中所有文件并根据文件名中包含的日期判断,删除 7 天前的文件的示例程序:
package main
import (
"fmt"
"os"
"time"
"path/filepath"
)
func main() {
dir := "path/to/folder" // 替换为文件夹的路径
now := time.Now()
fmt.Println("Deleting files older than 7 days...")
filepath.Walk(dir, fu