1
0
mirror of https://github.com/go-task/task.git synced 2024-12-12 10:45:49 +02:00

Simple refactor of getEnvironmentVariables()

This commit is contained in:
Andrey Nering 2017-03-05 16:17:50 -03:00
parent 7db3db48b0
commit f4c8997192

View File

@ -45,15 +45,16 @@ func ReplaceVariables(initial string, variables map[string]string) string {
// GetEnvironmentVariables returns environment variables as map // GetEnvironmentVariables returns environment variables as map
func getEnvironmentVariables() map[string]string { func getEnvironmentVariables() map[string]string {
getenvironment := func(data []string, getkeyval func(item string) (key, val string)) map[string]string { type getKeyValFunc func(item string) (key, val string)
getEnvironment := func(data []string, getKeyVal getKeyValFunc) map[string]string {
items := make(map[string]string) items := make(map[string]string)
for _, item := range data { for _, item := range data {
key, val := getkeyval(item) key, val := getKeyVal(item)
items[key] = val items[key] = val
} }
return items return items
} }
return getenvironment(os.Environ(), func(item string) (key, val string) { return getEnvironment(os.Environ(), func(item string) (key, val string) {
splits := strings.Split(item, "=") splits := strings.Split(item, "=")
key = splits[0] key = splits[0]
val = splits[1] val = splits[1]