diff --git a/README.md b/README.md index ee3005b3..3594ce72 100644 --- a/README.md +++ b/README.md @@ -309,6 +309,8 @@ Task also adds the following functions: path format to `/`. - `FromSlash`: Oposite of `ToSlash`. Does nothing on Unix, but on Windows converts a string from `\` path format to `/`. +- `ExeExt`: Returns the right executable extension for the current OS + (`".exe"` for Windows, `""` for others). Example: diff --git a/variable_handling.go b/variable_handling.go index 5e362875..bd53a90e 100644 --- a/variable_handling.go +++ b/variable_handling.go @@ -91,6 +91,12 @@ func init() { "ToSlash": func(path string) string { return filepath.ToSlash(path) }, + "ExeExt": func() string { + if runtime.GOOS == "windows" { + return ".exe" + } + return "" + }, } templateFuncs = sprig.TxtFuncMap()