RapidGo
No results found

Configuration

Configure your RapidGo application with environment variables.

RapidGo uses a .env file for all configuration. Copy the example to get started:

cp .env.example .env

Application Settings

Variable Description Default
APP_NAME Application name RapidGo
APP_ENV Environment: development, production, testing development
APP_DEBUG Enable debug mode true
APP_PORT HTTP server port 8080
APP_URL Public URL of the application http://localhost:8080
APP_KEY 32-byte encryption key for sessions and crypto

Service Mode

RAPIDGO_MODE=all    # Run all services (web + api + ws + worker)
# Or run individual modes:
# RAPIDGO_MODE=web
# RAPIDGO_MODE=api
# RAPIDGO_MODE=worker

Database

RapidGo supports SQLite, PostgreSQL, and MySQL via GORM.

SQLite (zero config, great for development):

DB_DRIVER=sqlite
DB_NAME=storage/database/app.db

PostgreSQL:

DB_DRIVER=postgres
DB_HOST=localhost
DB_PORT=5432
DB_NAME=myapp_dev
DB_USER=postgres
DB_PASSWORD=secret
DB_SSL_MODE=disable

MySQL:

DB_DRIVER=mysql
DB_HOST=localhost
DB_PORT=3306
DB_NAME=myapp_dev
DB_USER=root
DB_PASSWORD=secret

Sessions

SESSION_DRIVER=cookie    # cookie, db, file, memory, redis
SESSION_LIFETIME=120     # Minutes
SESSION_SECRET=change-me-to-a-random-string

Cache

CACHE_DRIVER=memory    # memory, file, redis
CACHE_PREFIX=rapidgo_

Redis

REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=
REDIS_DB=0

Queue

QUEUE_DRIVER=database    # database, redis, memory, sync
QUEUE_DEFAULT=default
QUEUE_MAX_ATTEMPTS=3
QUEUE_RETRY_DELAY=30
QUEUE_TIMEOUT=60

JWT

JWT_SECRET=change-me-to-a-random-string-at-least-32-bytes
JWT_EXPIRY=3600    # Seconds

Mail

MAIL_HOST=smtp.example.com
MAIL_PORT=587
MAIL_USERNAME=your-username
MAIL_PASSWORD=your-password
MAIL_FROM_ADDRESS=noreply@example.com
MAIL_FROM_NAME=MyApp

Logging

LOG_LEVEL=debug    # debug, info, warn, error
LOG_FORMAT=json    # json, text
LOG_OUTPUT=stdout  # stdout, file

Storage

STORAGE_DRIVER=local    # local, s3
S3_BUCKET=
S3_REGION=
S3_KEY=
S3_SECRET=

Accessing Config in Code

Use the config package to read environment variables:

import "github.com/raiworks/rapidgo/v2/core/config"

// Load .env file (called automatically by the framework)
config.Load()

// Read a value with a default fallback
port := config.Env("APP_PORT", "8080")

// Check the current environment
if config.IsProduction() {
    // production-only logic
}