1
0
Fork 0

Updates of Lego.

This commit is contained in:
Ludovic Fernandez 2019-02-11 08:52:03 +01:00 committed by Traefiker Bot
parent 5f4d440493
commit 2b2cfdfb32
102 changed files with 8355 additions and 902 deletions

View file

@ -1,46 +0,0 @@
package tilde
import (
"errors"
"os"
"path/filepath"
"runtime"
"strings"
)
var (
ErrNoHome = errors.New("no home found")
)
func Expand(path string) (string, error) {
if !strings.HasPrefix(path, "~") {
return path, nil
}
home, err := Home()
if err != nil {
return "", err
}
return home + path[1:], nil
}
func Home() (string, error) {
home := ""
switch runtime.GOOS {
case "windows":
home = filepath.Join(os.Getenv("HomeDrive"), os.Getenv("HomePath"))
if home == "" {
home = os.Getenv("UserProfile")
}
default:
home = os.Getenv("HOME")
}
if home == "" {
return "", ErrNoHome
}
return home, nil
}