mirror of
https://github.com/go-task/task.git
synced 2025-03-19 21:17:46 +02:00
23 lines
399 B
Go
23 lines
399 B
Go
|
package osext
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
|
||
|
"github.com/mitchellh/go-homedir"
|
||
|
)
|
||
|
|
||
|
// Expand is an improved version of os.ExpandEnv,
|
||
|
// that not only expand enrionment variable ($GOPATH/src/github.com/...)
|
||
|
// but also expands "~" as the home directory.
|
||
|
func Expand(s string) (string, error) {
|
||
|
s = os.ExpandEnv(s)
|
||
|
|
||
|
var err error
|
||
|
s, err = homedir.Expand(s)
|
||
|
if err != nil {
|
||
|
return "", err
|
||
|
}
|
||
|
|
||
|
return s, nil
|
||
|
}
|