The minimal template creates the simplest possible project structure. This page explains every file so you understand exactly what you’re working with. Don’t worry if some concepts are new - we’ll explain everything.Documentation 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.
Directory Layout
File Details
main.go
This is your entire application:| Line | Code | What it does |
|---|---|---|
| 1 | package main | Marks this as an executable program |
| 4 | "log" | Import Go’s logging package |
| 5 | "github.com/go-mizu/mizu" | Import the Mizu framework |
| 8 | func main() | Entry point - runs when you start the app |
| 9 | app := mizu.New() | Create a new Mizu application |
| 11 | app.Get("/", ...) | Register a handler for GET / |
| 12 | func(c *mizu.Ctx) error | Handler function signature |
| 13 | return c.Text(200, ...) | Send HTTP 200 with text |
| 16 | log.Println(...) | Log that we’re starting |
| 17 | app.Listen(":8080") | Start server on port 8080 |
| 18 | log.Fatal(err) | Exit if server fails to start |
go.mod
The Go module file defines your project:| Line | Meaning |
|---|---|
module example.com/myapp | Your project’s import path |
go 1.22 | Minimum Go version required |
require github.com/go-mizu/mizu | Dependency on Mizu |
The version
v0.0.0 is a placeholder. When you run go mod tidy, it’s replaced with the actual latest version..gitignore
Tells Git which files to ignore:README.md
Basic project documentation:app.Get- Registers this handler for GET requests"/"- The URL path to matchfunc(c *mizu.Ctx) error- The handler functionc- The context, contains request info and response methodsc.Text(200, ...)- Send a text response with status 200
The Context
The*mizu.Ctx parameter gives you access to:
Starting the Server
":8080"means “listen on port 8080 on all interfaces”Listenblocks until the server is stopped- If it fails (port in use, etc.), we log the error and exit
Common Modifications
Change the Port
Add More Routes
Add URL Parameters
Handle POST Requests
When to Add More Structure
Signs you’ve outgrown the minimal template:- main.go is over 100 lines - Time to split into multiple files
- You have related routes - Group them into packages
- You need configuration - Add a config file/struct
- Multiple developers - Need clearer organization
api template or building your own structure.
Next Steps
Tutorial
Build your first app step by step
API Template
See a more structured approach