Updates of Lego.
This commit is contained in:
parent
5f4d440493
commit
2b2cfdfb32
102 changed files with 8355 additions and 902 deletions
46
vendor/gopkg.in/mattes/go-expand-tilde.v1/tilde.go
generated
vendored
46
vendor/gopkg.in/mattes/go-expand-tilde.v1/tilde.go
generated
vendored
|
@ -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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue