Help us shape the future of Go! Take the 2026 Go Developer Survey

gostructure

module
v0.0.0-...-42aafda Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2026 License: BSD-2-Clause

README

gostructure

A template repository for starting a new Go service.

Business logic code is separated from infrastructure, making the system easier to test and change if needed. It also includes common boilerplate files you will likely need.

Inspired by Clean Architecture and golang-standards/project-layout.

Code Structure

See go-project-structure.

Working with AI Agents

The .claude/ directory in this repo is the author's centralized agent setup (rules, skills, session analysis).

How to start a new project

  • Copy this directory, rename it to your new project name, then remove the .git folder.
  • In .claude/, keep only CLAUDE.md (project rules) and settings.json (deny reading secrets). Remove everything else (skills, scripts, and shell helpers are for the author's personal workflow).
  • Update the module path in go.mod and all import statements (use Replace in All Files or a similar IDE feature).
  • Rename cmd/main to something meaningful (e.g. cmd/shop-assistant) and update the Dockerfile build path and any scripts that reference it.
  • If you use Docker or config, update project-specific names (e.g. database name, container names).

Deployment

Local Development

Environment variables are loaded from config/.env or config/.env.example. See config/.env.example for configuration details.

Run all services except the main application with docker compose, then run the application directly with Go (or debug mode in your IDE).

# Start all services except the main application
docker compose up -d --scale application=0

# Run the application locally
go run ./cmd/main

To start fresh and remove all existing persistent data:

docker compose down -v
# then compose up
Production

Build and run all services including the main application. The application will be available at http://host:20808. For production, use a secret management solution (e.g. Bitwarden Secrets Manager).

Directories

Path Synopsis
cmd
main command
script-import-data command
this script is meant to be run as a one-off, not as a long-running service.
this script is meant to be run as a one-off, not as a long-running service.
pkg
logic
Package logic contains business logic.
Package logic contains business logic.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL