qbs
qbs copied to clipboard
Use google go linter
I suggest that the source code get's linted with https://github.com/golang/lint
According to the linter, it is for example necessary to name all methods that contain the keyword id
uppercase, for example getId
must be getID
and so on.
here is a complete list of those uppercase keywords: https://github.com/golang/lint/blob/master/lint.go#L656
+1
Thank you for the suggestion. But it breaks the API.
Okay. But I have currently a problem using qbs for my models.
Currently the id fields of a struct must be "Id" when using qbs. Unfortunately the correct usage of "ID" results in "i_d".
Can you add an exceptional case for ID?
It does not have break the api if both methods are possible.
I think adding extra APIs or special case just for golint is not worth it. I don't feel like hacking for coding style. If I were to build a new package I may follow golint's suggestions.
most packages provide an aliasing feature with go tags (sql:"last_name"
), like sqlx, gorm etc.
this is not "hacking for coding style" its also to allow using existing database schemes etc. I know that qbs provides an optional function for rename magic, but this feature would be much cleaner.
Maybe this would be an acceptable option for you.
I've written a small library to solve this problem. Maybe it is useful for some other users who wants to code without golint warnings. https://github.com/serenize/snaker
Neat solution.
Thx. You can use it like this:
qbs.ColumnNameToFieldName = snaker.SnakeToCamel
qbs.FieldNameToColumnName = snaker.CamelToSnake