code: func LastCheckpoint(dir string) (string, int, error) {
  	files, err := ioutil.ReadDir(dir)
  	if err != nil {
  		return "", 0, err
  	}
  	// Traverse list backwards since there may be multiple checkpoints left.
  	for i := len(files) - 1; i >= 0; i-- {
  		fi := files[i]
  
  		if !strings.HasPrefix(fi.Name(), checkpointPrefix) {
  			continue
  		}
  		if !fi.IsDir() {
  			return "", 0, errors.Errorf("checkpoint %s is not a directory", fi.Name())
  		}
  		idx, err := strconv.Atoi(fi.Name()[len(checkpointPrefix):])
  		if err != nil {
  			continue
  		}
  		return filepath.Join(dir, fi.Name()), idx, nil
  	}
  	return "", 0, ErrNotFound
  }
docs: // LastCheckpoint returns the directory name and index of the most recent checkpoint.
  // If dir does not contain any checkpoints, ErrNotFound is returned.