Merge remote-tracking branch 'remotes/origin/master' into camel_case_functions

Conflicts:
	tests/basic_test.go
This commit is contained in:
Vadim Petrov
2016-07-12 12:51:06 +03:00
3 changed files with 37 additions and 1 deletions
+6 -1
View File
@@ -240,8 +240,13 @@ func (g *Generator) pkgAlias(pkgPath string) string {
// getType return the textual type name of given type that can be used in generated code.
func (g *Generator) getType(t reflect.Type) string {
if t.Kind() == reflect.Ptr {
switch t.Kind() {
case reflect.Ptr:
return "*" + g.getType(t.Elem())
case reflect.Slice:
return "[]" + g.getType(t.Elem())
case reflect.Map:
return "map[" + g.getType(t.Key()) + "]" + g.getType(t.Elem())
}
if t.Name() == "" || t.PkgPath() == "" {
+1
View File
@@ -31,6 +31,7 @@ var testCases = []struct {
{&unexportedStructValue, unexportedStructString},
{&excludedFieldValue, excludedFieldString},
{&mapsValue, mapsString},
{&deepNestValue, deepNestString},
{&camelCasesFunctionsValue, camelCasesFunctionsString},
}
+30
View File
@@ -436,6 +436,36 @@ var mapsString = `{` +
`"CustomMap":{"c":"d"}` +
`}`
type DeepNest struct {
SliceMap map[Str][]Str
MapSlice []map[Str]Str
}
var deepNestValue = DeepNest{
SliceMap: map[Str][]Str{
"testSliceMap1": []Str{
"0",
"1",
},
"testSliceMap2": nil,
},
MapSlice: []map[Str]Str{
map[Str]Str{
"testMapSlice1": "someValue",
},
},
}
var deepNestString = `{` +
`"SliceMap":{` +
`"testSliceMap1":["0","1"],` +
`"testSliceMap2":[]` +
`},` +
`"MapSlice":[` +
`{"testMapSlice1":"someValue"}` +
`]` +
`}`
type RequiredOptionalStruct struct {
FirstName string `json:"first_name,required"`
Lastname string `json:"last_name"`