Skip to content

Commit 1e0095a

Browse files
committedMay 13, 2016
Misc fixes:
* Protect against "client" package and local variable names clash * Default client CLI tool version to "0" if no version in API * Sort flags used to spawn generator tool so generated header comments are deterministic.
1 parent c5b2b79 commit 1e0095a

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed
 

‎goagen/codegen/types.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -650,12 +650,13 @@ var reserved = map[string]bool{
650650
"type": true,
651651
"var": true,
652652

653-
// stdlib packages used by generated code
654-
"fmt": true,
655-
"http": true,
656-
"json": true,
657-
"os": true,
658-
"time": true,
653+
// stdlib and goa packages used by generated code
654+
"fmt": true,
655+
"http": true,
656+
"json": true,
657+
"os": true,
658+
"time": true,
659+
"client": true,
659660
}
660661

661662
// toSlice returns Go code that represents the given slice.

‎goagen/gen_client/cli_generator.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ func (g *Generator) generateMain(mainFile string, clientPkg string, funcs templa
5151
return err
5252
}
5353
g.genfiles = append(g.genfiles, mainFile)
54+
version := design.Design.Version
55+
if version == "" {
56+
version = "0"
57+
}
5458

5559
data := map[string]interface{}{
5660
"API": api,
57-
"Version": design.Design.Version,
61+
"Version": version,
5862
}
5963
if err := file.ExecuteTemplate("main", mainTmpl, funcs, data); err != nil {
6064
return err

‎goagen/meta/generator.go

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"os/exec"
88
"path/filepath"
9+
"sort"
910
"strconv"
1011
"strings"
1112
"text/template"
@@ -176,6 +177,7 @@ func (m *Generator) spawn(genbin string) ([]string, error) {
176177
args[i] = fmt.Sprintf("--%s=%s", k, v)
177178
i++
178179
}
180+
sort.Strings(args)
179181
cmd := exec.Command(genbin, args...)
180182
out, err := cmd.CombinedOutput()
181183
if err != nil {

0 commit comments

Comments
 (0)