TheDocumentation Index
Fetch the complete documentation index at: https://docs.go-mizu.dev/llms.txt
Use this file to discover all available pages before exploring further.
mizu dev command runs your Mizu application in development mode. It automatically finds your main package, compiles your code, starts your server, and handles shutdown gracefully when you press Ctrl+C. This is the command youβll use most during development.
Basic Usage
What Happens When You Run mizu dev
- Finds your main package - Looks in
cmd/folder first, then checks the root directory - Compiles your code - Uses
go runto build and run - Starts your server - Your application starts running
- Waits for shutdown - Listens for Ctrl+C or system signals
- Shuts down gracefully - Gives your app time to clean up before exiting
http://localhost:8080 to see it.
How to Stop the Server
PressCtrl+C in your terminal. Youβll see:
- Close database connections
- Finish processing requests
- Save any pending data
Flags Reference
| Flag | Description |
|---|---|
--cmd <path> | Specify which main package to run |
--json | Output lifecycle events as JSON |
-h, --help | Show help |
How Main Package Discovery Works
The CLI finds your main package automatically. Hereβs the order it checks:1. If You Specify --cmd
2. Look in cmd/ Directory
If you have a cmd/ folder, the CLI looks for main.go files inside subdirectories:
3. Check Root Directory
If thereβs nocmd/ folder, it checks the current directory:
When Discovery Fails
If no main package is found:- Create a
cmd/<name>/main.gofile - Create a
main.goin your root directory - Use
--cmdto point to your main package
Working with Multiple Commands
If your project has multiple entry points:Passing Arguments to Your Application
Use-- to separate CLI flags from your applicationβs arguments:
-- is passed to your application. Your app will receive --port 9000 --debug as arguments.
JSON Output Mode
For scripts and automation, use--json to get machine-readable output:
Lifecycle Events
| Event | When it happens |
|---|---|
starting | About to start your application |
started | Application started (includes process ID) |
signal | Received a shutdown signal (Ctrl+C) |
timeout | Graceful shutdown took too long |
stopped | Application exited |
error | Something went wrong |
Event Structure
event- Type of eventtimestamp- When it happened (UTC, ISO 8601 format)message- Human-readable descriptionexit_code- Only included when application exits
Verbose Mode
See more details about whatβs happening:Error Messages and Solutions
No Main Package Found
package main in your project.
Fix:
- Make sure youβre in the right directory
- Check that your
main.gofile haspackage mainat the top - Use
--cmdto specify the path manually
Path Does Not Exist
--cmd path that doesnβt exist.
Fix: Check the path and make sure itβs correct.
Build Errors
If your Go code has errors, youβll see the compiler output:Exit Codes
The exit code from your application passes throughmizu dev:
| Code | Meaning |
|---|---|
| 0 | Success - your app exited cleanly |
| 1 | Error during startup |
| 2 | Invalid flags or arguments |
| 3 | No main package found |
| Other | Passed through from your application |
If your app exits with code 5,
mizu dev also exits with code 5. This is important for scripts that check exit codes.Development Workflow
A typical development workflow:mizu dev does not watch for file changes. When you modify your code, stop the server with Ctrl+C and restart it.Recommended Project Structure
For the best experience withmizu dev, use this structure:
mizu devfinds./cmd/apiautomatically- Code is organized by feature
- Clear separation of concerns
Using with Scripts
Check if the server started successfully:Common Questions
Why doesnβt mizu dev watch for file changes?
File watching adds complexity and dependencies. For now, just restart manually. Many editors have built-in run commands that make this easy.
Can I run multiple servers at once?
Yes! Open multiple terminals:How do I change the port?
Configure the port in your application code or use arguments:--port flag)
Next Steps
Create a Project
Start a new project with mizu new
View Templates
See what templates are available