This repo is a Go workspace (go.work) containing multiple Go modules:
service/: main OpenTDF server and platform services (binary entrypoint:service/main.go).sdk/: Go SDK and generated clients.lib/*/: shared libraries (e.g.,lib/ocrypto,lib/identifier).protocol/andservice/: protobuf sources; generated Go lives underprotocol/go/and docs underdocs/grpc/+docs/openapi/.tests-bdd/: BDD/integration-style tests (Godog) and feature files (tests-bdd/features/).docs/,examples/,adr/: documentation, example code, and architecture decisions.
Prefer make targets at repo root:
make toolcheck: verifies required tooling (Buf, golangci-lint, generators).make build: regenerates protos/codegen and buildsopentdf+sdk+examples.make lint: runsbuf lint,golangci-lint, andgovulncheckacross modules.make test: runsgo test ./... -raceacross core modules (does not includetests-bdd/).docker compose up: brings up local infra (Postgres + Keycloak). Seedocs/Contributing.md.
- Go formatting is enforced: run
make fmt(usesgolangci-lint fmt; Go uses tabs for indentation). - Imports should be goimports-compatible; keep package names lowercase; exported identifiers use
PascalCase. - Protobuf changes must pass
buf lintand should be regenerated viamake proto-generate. - Always run
gofumpton Go files after making changes - The project uses
gofumpt(stricter thangofmt) for formatting - Before completing Go-related tasks, run:
~/go/bin/gofumpt -w <files>
CRITICAL: All Go code changes must pass these checks before being marked as complete:
-
Linting:
golangci-lint run ./path/to/changed/files.go- Must pass with 0 issues
- Fixes common issues: formatting, shadowing, unused code, suspicious constructs
- Never let the user discover linting issues from CI
-
Unit Tests:
go test ./...(ormake testfrom repo root)- All existing tests must continue to pass
- Add tests for new functionality
-
README Code Block Tests:
- SDK README examples:
cd sdk && go test -run TestREADMECodeBlocks - Ensures documentation examples remain compilable
- SDK README examples:
- Unit tests:
*_test.gonext to code; runmake test. - BDD tests: run
cd tests-bdd && go test ./...(requires Docker; feature files aretests-bdd/features/*.feature). - Integration tests may require the compose stack; follow module README(s) under
service/. - README tests: verify code examples in documentation compile and work correctly.
- Commit messages follow Conventional Commits (e.g.,
feat(sdk): ...,fix(core): ...). - DCO sign-off is required: use
git commit -s -m "feat(scope): summary". SeeCONTRIBUTING.md. - PRs should describe changes, include testing notes, and update docs/tests when applicable (see
.github/pull_request_template.md).
- Don’t commit secrets/keys. Use local configs like
opentdf-dev.yamland followSECURITY.md.