RapidGo
No results found

Scaffolding

Generate controllers, models, services, providers, and migrations with the CLI.

RapidGo's scaffolding commands generate boilerplate code files with the correct structure and package declarations.

make:controller

Creates a resource controller with Index, Show, Store, Update, and Destroy methods.

go run cmd/main.go make:controller Post
# Creates: http/controllers/post.go

Generated code:

package controllers

import (
    "net/http"
    "github.com/gin-gonic/gin"
)

type Post struct{}

func (ctrl *Post) Index(c *gin.Context) {
    c.JSON(http.StatusOK, gin.H{"message": "Post index"})
}

func (ctrl *Post) Show(c *gin.Context) {
    id := c.Param("id")
    c.JSON(http.StatusOK, gin.H{"id": id})
}

func (ctrl *Post) Store(c *gin.Context) {
    c.JSON(http.StatusCreated, gin.H{"message": "created"})
}

func (ctrl *Post) Update(c *gin.Context) {
    id := c.Param("id")
    c.JSON(http.StatusOK, gin.H{"id": id, "message": "updated"})
}

func (ctrl *Post) Destroy(c *gin.Context) {
    c.JSON(http.StatusOK, gin.H{"message": "deleted"})
}

make:model

Creates a GORM model with BaseModel embedded.

go run cmd/main.go make:model Post
# Creates: database/models/post.go

Generated code:

package models

type Post struct {
    BaseModel
    // Add fields here
}

make:service

Creates a service with a database dependency.

go run cmd/main.go make:service Payment
# Creates: app/services/payment.go

Generated code:

package services

import "gorm.io/gorm"

type Payment struct {
    DB *gorm.DB
}

func NewPayment(db *gorm.DB) *Payment {
    return &Payment{DB: db}
}

make:provider

Creates a service provider with Register and Boot methods.

go run cmd/main.go make:provider Mail
# Creates: app/providers/mail.go

Generated code:

package providers

import "github.com/RAiWorks/RapidGo/v2/core/container"

type Mail struct{}

func (p *Mail) Register(c *container.Container) {
    // Bind services into the container
}

func (p *Mail) Boot(c *container.Container) {
    // Run after all providers are registered
}

make:migration

Creates a timestamped migration file with Up and Down functions.

go run cmd/main.go make:migration create_posts_table
# Creates: database/migrations/20260308120000_create_posts_table.go

make:admin

Interactively creates an admin user by prompting for email and password.

go run cmd/main.go make:admin
# Prompts for email and password

Naming Convention

All scaffolding commands convert the name to snake_case for the filename:

Input File
Post post.go
UserProfile user_profile.go
PaymentGateway payment_gateway.go

Files are never overwritten — if the file already exists, the command returns an error.