Guidelines
Please make sure to use the .editorconfig in your editor.
Code Formatting
Section titled “Code Formatting”To ensure consistent code formatting across all team members and development environments make sure to use one of the following methods:
Automatic Setup (Recommended)
Section titled “Automatic Setup (Recommended)”- One-time setup: Run
./scripts/setup-git-hooks.shfrom theserver/directory - That’s it! All commits will automatically format Go code
Manual Commands (Optional)
Section titled “Manual Commands (Optional)”With Git hooks enabled, these commands are rarely needed but available when necessary:
- Auto-format code:
make format- manually format all Go code - Check formatting:
make format-check- verify code is properly formatted - Run linting:
make go-lint- run all linters including formatting checks - Update golangci-lint:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest- fix local version conflicts
IDE Setup (Optional but Recommended)
Section titled “IDE Setup (Optional but Recommended)”Configure your editor to format on save:
VS Code
Section titled “VS Code”Add the following lines to .vscode/settings.json to configure VS Code to trigger the formatter on save.
{ "go.formatTool": "goimports", "editor.formatOnSave": true, "[go]": { "editor.formatOnSave": true }}GoLand/IntelliJ
Section titled “GoLand/IntelliJ”For GoLand follow these steps to configure the formatter
- Go to Settings → Tools → File Watchers
- Add “goimports” file watcher
- Or enable “Reformat code” in commit dialog
How It Works
Section titled “How It Works”- Git hooks: Automatically format staged Go files before commit
- CI checks: Verify formatting in pull requests
- Tools: Uses
goimportsfor import organization andgofmtfor code formatting - Bypass: Use
git commit --no-verifyto skip formatting (not recommended)
The project uses goimports for automatic import organization and gofmt for code formatting.
Code style
Section titled “Code style”Each service should have an interface in which the public methods are defined. This interface should be placed in the api file, where it is used.
If the service needs access to the database, an interface should be defined with the methods to access the database. This interface should be defined in the service, where it is used.
Naming conventions
Section titled “Naming conventions”The interface for the database access should end with Database and start with the name of the service.
The interface for the service should end with Service and start with the name of the service.
The names of the methods should contain the following if needed
- Create: Creates a new object
- Update: Updates an object by its id
- Delete: Deletes an object by its id
- Get: Get an object by its id
- GetAll: Get a list of objects
- Exists: Check if an object exists