Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use google go linter #50

Open
wwwdata opened this issue Oct 24, 2014 · 9 comments
Open

Use google go linter #50

wwwdata opened this issue Oct 24, 2014 · 9 comments

Comments

@wwwdata
Copy link

wwwdata commented Oct 24, 2014

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

@sharpner
Copy link

+1

@coocood
Copy link
Owner

coocood commented Oct 24, 2014

Thank you for the suggestion.
But it breaks the API.

@mantenie
Copy link

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?

@sharpner
Copy link

It does not have break the api if both methods are possible.

@coocood
Copy link
Owner

coocood commented Oct 24, 2014

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.

@sharpner
Copy link

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.

@mantenie
Copy link

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

@coocood
Copy link
Owner

coocood commented Oct 24, 2014

Neat solution.

@mantenie
Copy link

Thx. You can use it like this:

qbs.ColumnNameToFieldName = snaker.SnakeToCamel
qbs.FieldNameToColumnName = snaker.CamelToSnake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants