Skip to content

Commit e6e1ee3

Browse files
committed
chore(golang): don't omit null values in order to pass our tests
Part of #9
1 parent 2870482 commit e6e1ee3

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

examples/go/routes.go

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

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

1616
type CategoryDto struct {
17-
Id *string `json:"id,omitempty" db:"id"`
18-
Name *string `json:"name,omitempty" db:"name"`
19-
NameRu *string `json:"name_ru,omitempty" db:"name_ru"`
20-
Slug *string `json:"slug,omitempty" db:"slug"`
17+
Id *string `json:"id" db:"id"`
18+
Name *string `json:"name" db:"name"`
19+
NameRu *string `json:"name_ru" db:"name_ru"`
20+
Slug *string `json:"slug" db:"slug"`
2121
}
2222

2323
type CreateCategoryDto struct {
24-
Name *string `json:"name,omitempty" db:"name"`
25-
NameRu *string `json:"name_ru,omitempty" db:"name_ru"`
26-
Slug *string `json:"slug,omitempty" db:"slug"`
27-
UserId *string `json:"user_id,omitempty" db:"user_id"`
24+
Name *string `json:"name" db:"name"`
25+
NameRu *string `json:"name_ru" db:"name_ru"`
26+
Slug *string `json:"slug" db:"slug"`
27+
UserId *string `json:"user_id" db:"user_id"`
2828
}
2929

3030
type CategoryInfoDto struct {
31-
Id *string `json:"id,omitempty" db:"id"`
32-
Name *string `json:"name,omitempty" db:"name"`
33-
NameRu *string `json:"name_ru,omitempty" db:"name_ru"`
34-
Slug *string `json:"slug,omitempty" db:"slug"`
31+
Id *string `json:"id" db:"id"`
32+
Name *string `json:"name" db:"name"`
33+
NameRu *string `json:"name_ru" db:"name_ru"`
34+
Slug *string `json:"slug" db:"slug"`
3535
}
3636

3737
func registerRoutes(r chi.Router, db *sqlx.DB) {

src/templates/routes.go.ejs

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function dto2struct(dto) {
131131
let result = `type ${dto.name} struct {\n`;
132132
dto.props.forEach(prop => {
133133
const fieldName = capitalize(snake2camelCase(prop.name)).padEnd(dto.maxFieldNameLength);
134-
result += `\t${fieldName} ${prop.type} \`json:"${prop.name},omitempty" db:"${prop.name}"\`\n`
134+
result += `\t${fieldName} ${prop.type} \`json:"${prop.name}" db:"${prop.name}"\`\n`
135135
});
136136
result += '}\n';
137137

0 commit comments

Comments
 (0)