func Dir() string {
	usrHome := os.Getenv("HOME")
	if usrHome != "" {
		return filepath.FromSlash(usrHome)
	}
	if usrHome = os.Getenv("USERPROFILE"); usrHome == "" {
		usrHome = os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH")
	}
	return filepath.FromSlash(usrHome)
}
Dir detects and returns the user home directory.
package home
import (
	"os"
	"path/filepath"
)