code: func ensureDirectoryForFile(file string) error {
  	baseDir := path.Dir(file)
  	_, err := os.Stat(baseDir)
  	if err != nil && !os.IsNotExist(err) {
  		return err
  	}
  
  	return os.MkdirAll(baseDir, defaultDirectoryPermission)
  }
docs: // check if the directory exists to create file. creates if don't exists