code: func pruneArchive(archiveDir string, refTime time.Time, max archiveConfig) (*pruneStats, error) {
  	d, err := os.Open(archiveDir)
  	if err != nil {
  		return nil, err
  	}
  	defer d.Close()
  
  	files, err := d.Readdir(0)
  	if err != nil {
  		return nil, err
  	}
  
  	sort.Sort(sort.Reverse(byModTime(files)))
  
  	var seen, curr pruneStats
  	for i := 0; i < len(files); i++ {
  		curr.age = refTime.Sub(files[i].ModTime())
  		curr.bytes = seen.bytes + files[i].Size()
  		curr.count = seen.count + 1
  		if curr.count > max.count || curr.bytes > max.bytes || curr.age > max.age {
  			seen.filesRemoved, seen.filesErrored = removeFiles(archiveDir, files[i:])
  			return &seen, nil
  		}
  		seen = curr
  	}
  
  	return &seen, nil
  }
docs: // pruneArchive removes files from the given directory to ensure that the specified
  // maximums are not exceeded. It returns the number of the files removed along with
  // the maximums observed in the current archive.