Skip to content

Commit a202a51

Browse files
committed
chore(golang): convert "integer" to "int" to unbreak compilation
Correction for 7f28351 commit. Part of #9
1 parent 7f28351 commit a202a51

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

examples/go/routes.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import "github.com/go-chi/chi"
1010
import "github.com/jmoiron/sqlx"
1111

1212
type CounterDto struct {
13-
Counter *integer `json:"counter,omitempty" db:"counter"`
13+
Counter *int `json:"counter,omitempty" db:"counter"`
1414
}
1515

1616
type CategoryDto struct {

src/templates/routes.go.ejs

+10-2
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,20 @@ function extractProperties(queryAst) {
7070
return [];
7171
}
7272
73+
function findOutType(fieldsInfo, fieldName) {
74+
const defaultType = '*string';
75+
const hasTypeInfo = fieldsInfo.hasOwnProperty(fieldName) && fieldsInfo[fieldName].hasOwnProperty('type');
76+
if (hasTypeInfo && fieldsInfo[fieldName].type === 'integer') {
77+
return '*int';
78+
}
79+
return defaultType;
80+
}
81+
7382
function addTypes(props, fieldsInfo) {
7483
return props.map(prop => {
75-
const hasTypeInfo = fieldsInfo.hasOwnProperty(prop) && fieldsInfo[prop].hasOwnProperty('type');
7684
return {
7785
"name": prop,
78-
"type": hasTypeInfo ? '*' + fieldsInfo[prop].type : '*string'
86+
"type": findOutType(fieldsInfo, prop),
7987
}
8088
});
8189
}

0 commit comments

Comments
 (0)