github.com/fibonacci1729/draft@v0.3.0/pkg/osutil/osutil.go (about)

     1  package osutil
     2  
     3  import (
     4  	"os"
     5  )
     6  
     7  // Exists returns whether the given file or directory exists or not.
     8  func Exists(path string) (bool, error) {
     9  	_, err := os.Stat(path)
    10  	if err == nil {
    11  		return true, nil
    12  	}
    13  	if os.IsNotExist(err) {
    14  		return false, nil
    15  	}
    16  	return true, err
    17  }