package main import ( "os" "path/filepath" ) type FileType string const ( FileTypeFile FileType = "file" FileTypeDir FileType = "directory" ) func resolvePath(path string) string { if filepath.IsAbs(path) { return path } return filepath.Join(os.Getenv("PWD"), path) } func fileExists(path string) (FileType, error) { fileInfo, err := os.Stat(path) if err != nil { return "", err } if fileInfo.IsDir() { return FileTypeDir, nil } return FileTypeFile, nil } func isDir(path string) bool { info, err := os.Stat(path) if err != nil { return false } return info.IsDir() }