Repository navigation
Feature/go conventions - #49
marcel-aan-zee wants to merge 7 commits into
Conversation
| ## Makefile | ||
|
|
||
| Every project must have a makefile. | ||
| (You can look at other projects for an universal working version) |
There was a problem hiding this comment.
Should we standardize the make commands? example would be the npm run start and npm run build
There was a problem hiding this comment.
Describe make file "standards"
|
|
||
| ## project structure for an API / Web application | ||
|
|
||
| main |
There was a problem hiding this comment.
I don't see why start is necessary, start should be the root.
project structure for an API / Web application
main / start
- business / app (separation of concerns)
- domain (e.g.: users, cars, chairs etc. etc.)
- handlers
- middleware (local middelware)
- models
- queries (if you work with a database)
- repositories
- services
- validators
- domain (e.g.: users, cars, chairs etc. etc.)
- config
- datamodels
- helpers
- middleware (global middelswares)
- web / server
There was a problem hiding this comment.
capWeb.Authenticate > capilaMiddleware.Au....
There was a problem hiding this comment.
config
go > src folder
dist
|
|
||
| ## Variable naming | ||
|
|
||
| A variable inside a function can have a short name like "a", if it is clear what it is used for. |
There was a problem hiding this comment.
Variables should always explain what it does
Like in this example:
assert := asserts.New(t)
assert.Equals("Check", someVar)
or in a loop, like in this example:
for key, user := range users {
println("key:", key)
println("val:", user)
}
In any other case, it is wise to name the variable after the thing it contains.
If is can hold a collection of things, name it plural, like "users".
If it can only hold one value, name it singular, like "user".
if it is a boolean var, start it with something like "has", or "is".
which is mostly used for checking if an element is present in a map.
It's also common use, when a variable name holds an abbreviation, that the letters are all capitals, or all lowercase.
like "SQLStatement" or "sqlStatement"
There was a problem hiding this comment.
Good suggestion. Let's use this instead.
There was a problem hiding this comment.
Also, what's the convention on naming const variables?
| // replace bitbucket.org/aanzeeonline/libgoaz => ../LibGOAZ | ||
| (and remove the comments) | ||
|
|
||
| Before pushing the final update to git, make sure that the fork isn't in use anymore |
There was a problem hiding this comment.
Standard behavior of go mod places the dependencies in your $GOPATH, go mod vendor puts them in a vendor folder inside your project, running go build -mod vendor uses the dependency put in the vendor folder. This further isolates the project from the globally installed dependencies
|
|
||
| ## Code Quality | ||
|
|
||
| I wrote a lint tool, which also checks for cognitive complexity. |
There was a problem hiding this comment.
I guess sonarQube will be sufficient. But can be used for all languages, so maybe move to general?
There was a problem hiding this comment.
I want to know how the sonarcube linting can be changed. (is the change of the configuration a project setting that can be exported/imported (and can be checked in with the project itself?)
| /services | ||
| /validators | ||
|
|
||
| ## |
There was a problem hiding this comment.
Looks like in the last commit the title 'Makefile' was removed (intentionally?) and an empty title ("##") was added. I would suggest adding a title or removing the empty title :)
|
|
||
| ## Project structure for an API / Web application | ||
|
|
||
| Root folder |
There was a problem hiding this comment.
Wellicht nog even goed kijken naar de MD structuur, leesbaar is het nu allerminst, geldt voor de volledige MD file
|
|
||
| It is nice to start a linter now and then. | ||
| Make check, or make check2 will run the linters and will check your files for "mistakes". | ||
| Try to improve your code with the hints you get from them. |
There was a problem hiding this comment.
Lint rules should be core. Without the correct 'style', the linter should fail with error code, thus the pull request cannot be merged
renewed the Go code conventions