go-ddd

(โ˜… 800)

Opinionated Domain Driven Design Template for Go

  • .env.example
  • .gitignore
  • .golangci.yml
  • codecov.yml
  • CONTRIBUTING.md
  • ddd-diagram-onion.png
  • DDD_CQRS_PRINCIPLES.md
  • docker-compose.yml
  • Dockerfile
  • go.mod
  • go.sum
  • LICENSE
  • Makefile
  • migrate.go
  • mkdocs.yml
  • README.md
  • README.zh-CN.md
  • SECURITY.md
  • sqlc.yaml

๐Ÿš€ Installation Guide

1. Get the code
git clone https://github.com/sklinkert/go-ddd

Downloads the entire project code from GitHub to your computer.

cd go-ddd

Moves into the project folder you just downloaded.

2. Official Install Script

Easy Recommended
Prerequisites
  • Go Go is required to use go install.
go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest

Downloads and installs the specified version directly โ€” no need to clone the repo yourself.

โœ… After installing, open a new terminal and run the program's version command (e.g. --version) to confirm it worked.

Pulled directly from this repo's README.

3. Docker

Easy
Prerequisites
  • Git Needed to download the project code from GitHub.
  • Docker Desktop Needed to build and run containers. Install it and keep it running in the background.
make docker-up # docker compose up --build

Builds and starts all defined containers (server, database, etc.) at once, in the background.

make docker-down # tear everything down

Compiles the code based on the generated build configuration to produce an executable.

make test # run all tests with the race detector (needs Docker)

Compiles the code based on the generated build configuration to produce an executable.

make test-unit # run only tests that don't require Docker

Compiles the code based on the generated build configuration to produce an executable.

โœ… Run docker compose ps to check the containers are Up. If the README mentions a port, open http://localhost:PORT in your browser.

Pulled directly from this repo's README.

4. Go

Medium
Prerequisites
  • Git Needed to download the project code from GitHub.
  • Go The Go compiler and toolchain.
go run migrate.go -database-url "postgres://user:pass@localhost/db?sslmode=disable" -command up

Runs the Go program directly without a separate build step.

go run migrate.go -database-url "postgres://user:pass@localhost/db?sslmode=disable" -command down -steps 1

Runs the Go program directly without a separate build step.

go run migrate.go -database-url "postgres://user:pass@localhost/db?sslmode=disable" -command version

Runs the Go program directly without a separate build step.

go run migrate.go -database-url "postgres://user:pass@localhost/db?sslmode=disable" -command force -version 1

Runs the Go program directly without a separate build step.

go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest

Type this command into your terminal and run it.

โœ… If the build finishes without errors, it worked. If you used go run ., check the terminal output.

Pulled directly from this repo's README.

5. Make

Medium
Prerequisites
  • Git Needed to download the project code from GitHub.
  • Make Usually pre-installed on Linux/macOS. On Windows, install separately (e.g. via MSYS2 or WSL).
make docker-up # docker compose up --build

Builds and starts all defined containers (server, database, etc.) at once, in the background.

make docker-down # tear everything down

Compiles the code based on the generated build configuration to produce an executable.

make run # or: go run ./cmd/marketplace

Compiles the code based on the generated build configuration to produce an executable.

make build # build the server binary into ./bin

Compiles the code based on the generated build configuration to produce an executable.

make test # run all tests with the race detector (needs Docker)

Compiles the code based on the generated build configuration to produce an executable.

โœ… If it finishes without errors, it worked. Try running the generated executable directly.

Pulled directly from this repo's README.

// repository documentation