Skip to content

Instantly share code, notes, and snippets.

@aramboyajyan
Created January 12, 2021 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aramboyajyan/0f649fbac7130107332cfdced23816e4 to your computer and use it in GitHub Desktop.
Save aramboyajyan/0f649fbac7130107332cfdced23816e4 to your computer and use it in GitHub Desktop.
Golang check if target directory exists
func DirExists(path string) (bool, error) {
_, err := os.Stat(path)
if err == nil {
return true, nil
} else if os.IsNotExist(err) {
return false, nil
}
return false, err
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment