-
Notifications
You must be signed in to change notification settings - Fork 9
/
example_test.go
37 lines (31 loc) · 998 Bytes
/
example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package easygen_test
import (
"os"
"github.com/go-easygen/easygen"
"github.com/go-easygen/easygen/egVar"
)
// for standalone test, change package to `main` and the next func def to,
// func main() {
func ExampleProcess() {
tmpl0 := easygen.NewTemplate().Customize()
tmpl := tmpl0.Funcs(easygen.FuncDefs()).Funcs(egVar.FuncDefs())
tmplFileName := "test/var0"
easygen.Process(tmpl, os.Stdout, tmplFileName)
easygen.Process2(tmpl, os.Stdout, tmplFileName, tmplFileName)
// To use Execute(), TemplateFileName has to be exact
m := easygen.ReadDataFile(tmplFileName + ".yaml")
easygen.Execute(tmpl, os.Stdout, tmplFileName+".tmpl", m)
// Output:
// Input: "some-init-method"
// Output 1: "SomeInitMethod"
// Output 2: "SOME_INIT_METHOD"
// Input: "some-init-method"
// Output 1: "SomeInitMethod"
// Output 2: "SOME_INIT_METHOD"
// Input: "some-init-method"
// Output 1: "SomeInitMethod"
// Output 2: "SOME_INIT_METHOD"
}
// To show the full code in GoDoc
type dummy struct {
}