Skip to content

Commit 561349c

Browse files
committed
Add ExeExt template function
1 parent 398a2c5 commit 561349c

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@ Task also adds the following functions:
309309
path format to `/`.
310310
- `FromSlash`: Oposite of `ToSlash`. Does nothing on Unix, but on Windows
311311
converts a string from `\` path format to `/`.
312+
- `ExeExt`: Returns the right executable extension for the current OS
313+
(`".exe"` for Windows, `""` for others).
312314

313315
Example:
314316

variable_handling.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ func init() {
9191
"ToSlash": func(path string) string {
9292
return filepath.ToSlash(path)
9393
},
94+
"ExeExt": func() string {
95+
if runtime.GOOS == "windows" {
96+
return ".exe"
97+
}
98+
return ""
99+
},
94100
}
95101

96102
templateFuncs = sprig.TxtFuncMap()

0 commit comments

Comments
 (0)