1
0
mirror of https://github.com/go-task/task.git synced 2025-03-19 21:17:46 +02:00
task/internal/osext/osext.go
Andrey Nering 102f8ab74e Expand environment variables on "dir", "sources" and "generates"
So a path like this works: $GOPATH/src/github.com/go-task/task

Allowing of "~" was also implemented. See #74 and baac067a1a0aa0d387b60a19977c901a3863fe97

Fixes #116
2018-06-16 14:30:40 -03:00

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
}