Skip to content

Guidelines

Please make sure to use the .editorconfig in your editor.

To ensure consistent code formatting across all team members and development environments make sure to use one of the following methods:

  1. One-time setup: Run ./scripts/setup-git-hooks.sh from the server/ directory
  2. That’s it! All commits will automatically format Go code

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

Configure your editor to format on save:

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
}
}

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
  • Git hooks: Automatically format staged Go files before commit
  • CI checks: Verify formatting in pull requests
  • Tools: Uses goimports for import organization and gofmt for code formatting
  • Bypass: Use git commit --no-verify to skip formatting (not recommended)

The project uses goimports for automatic import organization and gofmt for code formatting.

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.

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