project-manager

Project directory management for macOS
git clone git://git.lair.cx/project-manager
Log | Files | Refs | README | LICENSE

utils.go (418B)


      1 package main
      2 
      3 import (
      4 	"os"
      5 	"path/filepath"
      6 	"strings"
      7 )
      8 
      9 func exists(path string) bool {
     10 	if _, err := os.Stat(path); os.IsNotExist(err) {
     11 		return false
     12 	}
     13 	return true
     14 }
     15 
     16 func expandPath(path string) (string, error) {
     17 	if !strings.HasPrefix(path, "~") {
     18 		return path, nil
     19 	}
     20 
     21 	home, err := os.UserHomeDir()
     22 	if err != nil {
     23 		return "", err
     24 	}
     25 
     26 	return filepath.Clean(strings.Replace(path, "~", home, 1)), nil
     27 }