| 100 | } |
| 101 | |
| 102 | func loop(args ...int) (<-chan int, error) { |
| 103 | var start, stop, step int |
| 104 | switch len(args) { |
| 105 | case 1: |
| 106 | start, stop, step = 0, args[0], 1 |
| 107 | case 2: |
| 108 | start, stop, step = args[0], args[1], 1 |
| 109 | case 3: |
| 110 | start, stop, step = args[0], args[1], args[2] |
| 111 | default: |
| 112 | return nil, fmt.Errorf("wrong number of arguments, expected 1-3"+ |
| 113 | ", but got %d", len(args)) |
| 114 | } |
| 115 | |
| 116 | c := make(chan int) |
| 117 | go func() { |
| 118 | for i := start; i < stop; i += step { |
| 119 | c <- i |
| 120 | } |
| 121 | close(c) |
| 122 | }() |
| 123 | return c, nil |
| 124 | } |
| 125 | |
| 126 | func generateFile(templatePath, destPath string) bool { |
| 127 | templateMap := template.FuncMap{ |