You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am looking for the camel case option, however, I am using snake case for the table, column names and camel case for the json tag
I have seen PR #194 and Issue #191
but it seems the flag turned to be a global switch for all tag formats.
The reason that we need a single case switch specifically for json tag is, using camel case in the database field names and table names could cause some case-sensitivity issues. For JSON, since it's used for the HTTP server, we'd like to have the response size as short as possible, and JavaScript uses camel case as its convention case for variable names, property names... etc. see Google JavaScript Style Guide https://google.github.io/styleguide/jsguide.html#naming-parameter-names
for example, right now it looks like this:
type User struct {
ID uint64 `db:"id" boil:"id" json:"id" toml:"id" yaml:"id"`
Email string `db:"email" boil:"email" json:"email" toml:"email" yaml:"email"`
Name string `db:"name" boil:"name" json:"name" toml:"name" yaml:"name"`
FirstName string `db:"first_name" boil:"first_name" json:"first_name" toml:"first_name" yaml:"first_name"`
LastName string `db:"last_name" boil:"last_name" json:"last_name" toml:"last_name" yaml:"last_name"`
}
and it would be great if we can generate camel case for the json tag:
type User struct {
ID uint64 `db:"id" boil:"id" json:"id" toml:"id" yaml:"id"`
Email string `db:"email" boil:"email" json:"email" toml:"email" yaml:"email"`
Name string `db:"name" boil:"name" json:"name" toml:"name" yaml:"name"`
FirstName string `db:"first_name" boil:"firstName" json:"first_name" toml:"first_name" yaml:"first_name"`
LastName string `db:"last_name" boil:"lastName" json:"last_name" toml:"last_name" yaml:"last_name"`
}
so, do you think if we could add an option that specifies the case for specific format, like: --struct-tag-case json:camel or --struct-tag-case yaml:camel ?
The text was updated successfully, but these errors were encountered:
I am looking for the camel case option, however, I am using snake case for the table, column names and camel case for the json tag
I have seen PR #194 and Issue #191
but it seems the flag turned to be a global switch for all tag formats.
The reason that we need a single case switch specifically for json tag is, using camel case in the database field names and table names could cause some case-sensitivity issues. For JSON, since it's used for the HTTP server, we'd like to have the response size as short as possible, and JavaScript uses camel case as its convention case for variable names, property names... etc. see Google JavaScript Style Guide https://google.github.io/styleguide/jsguide.html#naming-parameter-names
for example, right now it looks like this:
and it would be great if we can generate camel case for the json tag:
since in JavaScript convention (see here https://google.github.io/styleguide/jsguide.html#naming-parameter-names), we use camel case for property names, it should look like this:
so, do you think if we could add an option that specifies the case for specific format, like:
--struct-tag-case json:camel
or--struct-tag-case yaml:camel
?The text was updated successfully, but these errors were encountered: