code: func (s *LocalState) createStateFiles() error {
  	if s.PathOut == "" {
  		s.PathOut = s.Path
  	}
  
  	// yes this could race, but we only use it to clean up empty files
  	if _, err := os.Stat(s.PathOut); os.IsNotExist(err) {
  		s.created = true
  	}
  
  	// Create all the directories
  	if err := os.MkdirAll(filepath.Dir(s.PathOut), 0755); err != nil {
  		return err
  	}
  
  	f, err := os.OpenFile(s.PathOut, os.O_RDWR|os.O_CREATE, 0666)
  	if err != nil {
  		return err
  	}
  
  	s.stateFileOut = f
  	return nil
  }
docs: // Open the state file, creating the directories and file as needed.