Skip to content

Commit

Permalink
Support both 1 and 2 args for Loop
Browse files Browse the repository at this point in the history
  • Loading branch information
gmile committed Aug 21, 2017
1 parent 436dd2c commit 736c246
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/fakedata/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ func newTemplateFactory() *templateFactory {

func (tf templateFactory) getFunctions() template.FuncMap {
funcMap := template.FuncMap{
"Loop": func(min int, max int) []int {
"Loop": func(minmax ...int) []int {
var size int;

if max == 0 {
size = min;
if len(minmax) == 1 {
size = minmax[0];
} else {
min := minmax[0];
max := minmax[1];
size = rand.Intn(max - min) + min;
}

Expand Down

0 comments on commit 736c246

Please sign in to comment.