Base is a powerful command-line tool designed to streamline development with the Base framework. It offers scaffolding, module generation, and utilities to accelerate Go application development.
curl -fsSL https://get.base.al | bashIf you need to install in a protected directory (like /usr/local/bin), use:
curl -fsSL https://get.base.al | sudo bash- Open PowerShell as Administrator
- Run:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/base-go/cmd/main/install.ps1'))curl -fsSL https://get.base.al | bashCreate a new project using the Base framework.
base new myappGenerate a new module with fields and relationships.
base g <module-name> [field:type ...] [options]Start the Base application server.
Options:
--docs,-d: Generate Swagger documentation
Examples:
# Start the server normally
base start
# Start with Swagger documentation
base s -dGenerate OpenAPI 3.0 documentation using swag by scanning controller annotations and create static files.
base docs [flags]Options:
-o, --output string: Output directory for generated files (default "docs")
Examples:
# Generate docs in default 'docs' directory
base docs
# Generate docs in custom directory
base docs --output api-docsGenerated files:
swagger.json: OpenAPI 3.0 specification in JSON formatswagger.yaml: OpenAPI 3.0 specification in YAML formatdocs.go: Go package with embedded OpenAPI spec for programmatic accessindex.html: Lightweight Swagger UI served from CDN
Notes:
- Documentation is served at
/docs/when running the server - You can also run
base start -dto auto-generate docs before starting the server - All swagger info (title, version, description) is extracted from main.go annotations
- Uses swag for modern OpenAPI 3.0 support with better performance
Manage scheduled tasks in your Base Framework application.
Subcommands:
generate,g: Generate a new scheduled tasklist,ls: List all registered tasksrun: Run a specific task immediatelyenable: Enable a specific taskdisable: Disable a specific taskstatus: Get scheduler status
Options:
--api-key: API key for authentication--url: Base URL of the application (default: http://localhost:8100)
Examples:
# Generate a new task (smart module detection)
base scheduler generate posts cleanup-old-posts
base scheduler g users send-weekly-digest
base scheduler g Post publish # Finds 'posts' module
base scheduler g User reminder # Finds 'users' module
# List all tasks (requires API key)
base scheduler list --api-key=your-key
# Run a task immediately
base scheduler run cleanup-old-posts --api-key=your-key
# Enable/disable tasks
base scheduler enable cleanup-old-posts --api-key=your-key
base scheduler disable cleanup-old-posts --api-key=your-key
# Get scheduler status
base scheduler status --api-key=your-key
# Alternative short commands
base sched g posts cleanup
base sched list --api-key=your-keyDestroy (delete) one or more existing modules.
base d [name1] [name2] ... [flags]Examples:
# Destroy a single module
base d user
# Destroy multiple modules at once
base d user customer order
# Alternative command name
base destroy user customerWhat gets removed:
- Module directory (
app/modulename/) - Model file (
app/models/modulename.go) - Import and registration from
app/init.go
Notes:
- Requires confirmation before destroying modules
- Will attempt to clean up orphaned entries even if module directory doesn't exist
- Shows progress for each module when destroying multiple modules
Update framework core components:
base updateUpgrade the Base CLI tool:
base upgradeDisplay version information:
base versionBase supports various field types for model generation:
Basic Types:
stringboolint,uint(alsoint8,int16,int32,int64,uint8,uint16,uint32,uint64)float,float32,float64text(stored as string with appropriate DB type)
Special Types and Aliases (mapping shown on the right):
email,url,slug→ stringdatetime,time,date→types.DateTimedecimal,float→float64sort→inttranslation,translatedField→translation.Fieldimage,file,attachment→*storage.Attachment
Notes:
- Attachment fields are handled via dedicated upload endpoints and are not included in JSON create/update payloads.
- Email/URL/Slug are strings; GORM tags may add size/indexing automatically.
- Datetime types use Base
types.DateTimeunder the hood.
Relationship Types (both snake_case and camelCase accepted):
belongs_to(orbelongsTo): one-to-one with FK on this modelhas_one(orhasOne): one-to-one with FK on the other modelhas_many(orhasMany): one-to-manyto_many(ortoMany): many-to-many with join table
Relationship auto-detection:
- Defining a field as
<name>_id:uintwill also generate the correspondingbelongs_torelationship for<name>automatically.
Type inference (when no explicit type is given):
<name>_id→uint(FK)- Contains one of:
description,content,body,notes,comment,summary,bio,about→text - Prefix or contains:
is_,has_,can_,enabled,active,published,verified,confirmed→bool - Contains:
price,amount→decimal; other numeric-like names (count,quantity,number,rating,score,weight,height,width) →int - Suffix
_at,_on,_dateor contains common datetime terms (date,time,created_at,updated_at,deleted_at,published_at,expires_at) →datetime - Contains
email→email(string) - Contains
urlorlink→url(string) - Contains
image,photo,picture,avatar→image(attachment) - Contains
file,document,attachment→file(attachment) - Contains
translation,i18n,locale→translatedField - Otherwise →
string
Example:
# Generate a post module with title and image
base g post title:string cover:image
# Generate a document module with title and file attachment
base g document title:string file:fileHere's a comprehensive example of building a blog system with categories, posts, tags, and comments:
# Generate Category model
base g Category \
name:string \
description:text \
image:attachment \
parent:belongsTo:Category \
posts:hasMany:Post
# Generate Post model
base g Post \
title:string \
content:text \
excerpt:text \
featured_image:attachment \
gallery:attachment \
published_at:datetime \
author:belongsTo:users.User \
category:belongsTo:Category \
comments:hasMany:Comment \
tags:toMany:Tag
# Generate Tag model
base g Tag \
name:string \
slug:string
# Generate Comment model
base g Comment \
content:text \
author:belongsTo:users.User \
post:belongsTo:PostThis will create:
- Full CRUD operations for all models
- RESTful API endpoints with Swagger documentation
- File upload handling for images
- Proper relationships and preloading
- Authentication and authorization integration
Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.