You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
533 B
28 lines
533 B
7 months ago
|
package genutil
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os"
|
||
|
"path/filepath"
|
||
|
)
|
||
|
|
||
|
// OutDir creates the absolute path name from path and checks path exists.
|
||
|
// Returns absolute path including trailing '/' or error if path does not exist.
|
||
|
func OutDir(path string) (string, error) {
|
||
|
outDir, err := filepath.Abs(path)
|
||
|
if err != nil {
|
||
|
return "", err
|
||
|
}
|
||
|
|
||
|
stat, err := os.Stat(outDir)
|
||
|
if err != nil {
|
||
|
return "", err
|
||
|
}
|
||
|
|
||
|
if !stat.IsDir() {
|
||
|
return "", fmt.Errorf("output directory %s is not a directory", outDir)
|
||
|
}
|
||
|
outDir += "/"
|
||
|
return outDir, nil
|
||
|
}
|