github.com/microsoft/moc@v0.17.1/pkg/path/path.go (about) 1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the Apache v2.0 license. 3 4 // Package path has code for working with windows paths. 5 package path 6 7 import ( 8 "fmt" 9 "os" 10 "path/filepath" 11 ) 12 13 // CheckPath verifies that the path provided exists and returns the absolute path. 14 func CheckPath(path string) error { 15 cleanPath := filepath.Clean(path) 16 fileInfo, err := os.Stat(cleanPath) 17 if err != nil { 18 return err 19 } 20 if !fileInfo.IsDir() { 21 return fmt.Errorf("%s is not a directory", path) 22 } 23 return nil 24 }