I'd like func FolderExists(path string) bool
that will tell whether a folder exists and is writable. I've gotten here:
func FolderExists(path string) bool {
info, err := os.Stat(path)
return os.IsExist(err) && info.Mode().IsDir() && info.Mode().???
}
How to tell if this folder is writable? I cannot simply check for filemode permissions (e.g. 0200 for user write permission) because then I'd have to check the owner of the file. Is there a straightforward way to do this in Go?
For those with UNIX backgrounds, looking for the equivalent of the very simple:
if [ -d "$n" && -w "$n" ] ; then ... fi