mirror of
https://github.com/go-task/task.git
synced 2025-03-19 21:17:46 +02:00
So a path like this works: $GOPATH/src/github.com/go-task/task Allowing of "~" was also implemented. See #74 and baac067a1a0aa0d387b60a19977c901a3863fe97 Fixes #116
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
|
|
}
|