Skip to content

Commit ec8b3b8

Browse files
author
James Brundage
committed
Adding example for Go Transpiler (re #285)
1 parent a9b2ee6 commit ec8b3b8

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Transpilers/Templates/Go.Template.psx.ps1

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,37 @@
1515
* ```nil```
1616
* ```""```
1717
* ```''```
18+
.EXAMPLE
19+
$helloGo = HelloWorld.go template '
20+
package main
21+
22+
import "fmt"
23+
func main() {
24+
fmt.Println("/*{param($msg = "hello world") "`"$msg`""}*/")
25+
}
26+
'
27+
.EXAMPLE
28+
$HelloWorld = {param([Alias('msg')]$message = "Hello world") "`"$message`""}
29+
$helloGo = HelloWorld.go template "
30+
package main
31+
32+
import `"fmt`"
33+
func main() {
34+
fmt.Println(`"/*{$helloWorld}*/`")
35+
}
36+
"
37+
38+
$helloGo.Save() |
39+
Foreach-Object {
40+
$file = $_
41+
if (Get-Command go -commandType Application) {
42+
$null = go build $file.FullName
43+
& ".\$($file.Name.Replace($file.Extension, '.exe'))"
44+
} else {
45+
Write-Error "Go install Go"
46+
}
47+
}
48+
1849
#>
1950
[ValidatePattern('\.go$')]
2051
param(

0 commit comments

Comments
 (0)