Aller au contenu

Quick Start (5 minutes)

bolt Générez et lancez un projet Go production-ready en 5 minutes.


1. Installer le CLI (30 secondes)

go install github.com/tky0065/go-starter-kit/cmd/create-go-starter@latest

Vérification:

create-go-starter doctor


2. Créer le projet (10 secondes)

create-go-starter my-api
cd my-api

check Généré: ~45 fichiers avec architecture hexagonale complète

Astuce: Utilisez create-go-starter -n my-api pour prévisualiser les fichiers avant de les créer, ou create-go-starter -i pour le mode interactif guidé.


3. Setup automatique (2 minutes)

./setup.sh

Ce script fait:

  • check Installe les dépendances Go
  • check Génère un JWT secret
  • check Configure PostgreSQL (Docker)
  • check Lance les migrations

4. Lancer l'application (5 secondes)

make run

Console output:

INFO  Server starting on :8080
INFO  Database connected successfully
INFO  Migrations applied: 2


5. Tester l'API (1 minute)

Health check

curl http://localhost:8080/health

Response:

{"status":"healthy","timestamp":"2026-02-12T10:30:00Z"}

Créer un utilisateur

curl -X POST http://localhost:8080/api/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "demo@example.com",
    "password": "SecurePass123!"
  }'

Response:

{
  "user": {
    "id": 1,
    "email": "demo@example.com"
  },
  "access_token": "eyJhbGc...",
  "refresh_token": "eyJhbGc..."
}

Accéder à votre profil (protégé)

TOKEN="<your_access_token>"

curl http://localhost:8080/api/v1/users/me \
  -H "Authorization: Bearer $TOKEN"

Response:

{
  "id": 1,
  "email": "demo@example.com",
  "created_at": "2026-02-12T10:32:00Z"
}


celebration Félicitations!

Vous avez maintenant une API REST complète avec:

  • check Architecture hexagonale (Ports & Adapters)
  • check Authentification JWT (access + refresh tokens)
  • check Base de données (PostgreSQL + GORM)
  • check Validation (go-playground/validator)
  • check Logging (zerolog)
  • check Dependency Injection (uber-go/fx)
  • check Tests (structure prête)
  • check Docker (Dockerfile + compose)

Prochaines étapes

code Développer

rocket_launch Déployer


Besoin d'aide?

  • help FAQ - Questions fréquentes
  • bug_report Issues - Reporter un bug
  • forum Discussions - Poser une question