目前代码里有个小问题: ```go // CleanDir removes binary files under rundir in case they were not // accessed for more than CleanFileDelay nanoseconds. A last-cleaned // marker file is created so that the next verification is only done // after CleanFileDelay nanoseconds. func CleanDir(rundir string, now time.Time) error { cleanedfile := filepath.Join(rundir, "last-cleaned") cleanLine := now.Add(-CleanFileDelay) if info, err := os.Stat(cleanedfile); err == nil && info.ModTime().After(cleanLine) { // It's been cleaned recently. return nil } f, err := os.Create(cleanedfile) if err != nil { return err } _, err = f.Write([]byte(now.Format(time.RFC3339))) f.Close() if err != nil { return err }
// Look for expired files. d, err := os.Open(rundir) if err != nil { return err } infos, err := d.Readdir(-1) for _, info := range infos { atim := sysStat(info).Atim access := time.Unix(int64(atim.Sec), int64(atim.Nsec)) if access.Before(cleanLine) { os.Remove(filepath.Join(rundir, info.Name())) } } return nil }