File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ Ape ate Apple000002 at 1234.56 - true2
44Ape ate Apple000003 at 1234.56 - true3
55Ape ate Apple000004 at 1234.56 - true4
66Ape ate Apple000005 at 1234.56 - true5
7+ Ape ate Apple000000 at 1234.56 - true0
8+ Ape ate Apple000001 at 1234.56 - true1
9+ Ape ate Apple000002 at 1234.56 - true2
710Ape ate Apple001001 at 1234.56 - true1001
811Ape ate Apple001002 at 1234.56 - true1002
912Ape ate Apple001003 at 1234.56 - true1003
Original file line number Diff line number Diff line change 11{{- define "T1"}}Apple{{.i}} at {{.c.Price}} - {{.c.Shipped}}{{end}} {{- define "T2"}}Ape{{end}}
2- {{- range $val := iterate 5 }}
2+ {{- range $val := iterate "5" }}
33 {{- template "T2"}} ate {{template "T1" argsm "c" $ "i" (printf "%06d" $val)}}{{ $val }}
44{{end }}
5- {{- range $val := iterate 1003 1001 }}
5+ {{- range $val := iterate "2" (ENV "__START") }}
6+ {{- template "T2"}} ate {{template "T1" argsm "c" $ "i" (printf "%06d" $val)}}{{ $val }}
7+ {{end }}
8+ {{- range $val := iterate "1003" "1001" }}
69 {{- template "T2"}} ate {{template "T1" argsm "c" $ "i" (printf "%06d" $val)}}{{ $val }}
710{{end }}
Original file line number Diff line number Diff line change @@ -2,17 +2,19 @@ package easygen
22
33import (
44 "errors"
5+ "strconv"
56)
67
78//==========================================================================
89// template function somewhat related to calculations
910
1011// Iterate returns a slice whose end (& start) is controlled by the ic
11- func Iterate (ic ... int ) []int {
12- end := ic [0 ]
12+ func Iterate (ic ... string ) []int {
13+ // cannot think of a better way to report the Atoi error, other than --
14+ end , _ := strconv .Atoi (ic [0 ])
1315 start := 0
1416 if len (ic ) > 1 {
15- start = ic [1 ]
17+ start , _ = strconv . Atoi ( ic [1 ])
1618 }
1719 var Items []int
1820 for i := start ; i <= (end ); i ++ {
You can’t perform that action at this time.
0 commit comments