Skip to content

Commit 2641d4a

Browse files
committed
review: add tests
1 parent fa7be9f commit 2641d4a

File tree

8 files changed

+1165
-14
lines changed

8 files changed

+1165
-14
lines changed

cmd/foo/foo.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package main
2+
3+
import (
4+
"bytes"
5+
"fmt"
6+
"strings"
7+
"text/template"
8+
)
9+
10+
const tmplSrc = `
11+
// foo{{ .Count }} test function
12+
func foo{{ .Count }}() string {
13+
fmt.Println("foo{{ .Count }} is a test")
14+
return "bar"
15+
}
16+
`
17+
const tmplSrc1 = `
18+
func foo{{ .Count }}() string {
19+
fmt.Println("foo{{ .Count }} is a test")
20+
return "bar"
21+
}
22+
`
23+
24+
func main() {
25+
parse, err := template.New("base").Parse(tmplSrc1)
26+
if err != nil {
27+
panic(err)
28+
}
29+
30+
buf := bytes.NewBuffer([]byte{})
31+
32+
for i := range 83 {
33+
err = parse.Execute(buf, map[string]any{"Count": i})
34+
if err != nil {
35+
panic(err)
36+
}
37+
}
38+
39+
val := buf.String()
40+
41+
fmt.Println(len(strings.Split(val, "\n")))
42+
43+
// fmt.Println(val)
44+
}

0 commit comments

Comments
 (0)