Skip to main content
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.

Directory Layout

That’s only 4 files!

File Details

main.go

This is your entire application:
Line by line explanation:

go.mod

The Go module file defines your project:
What each line means:
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:
This prevents compiled binaries and editor files from being committed.

README.md

Basic project documentation:
Open http://localhost:8080
This is a handler - a function that processes HTTP requests.
  • app.Get - Registers this handler for GET requests
  • "/" - The URL path to match
  • func(c *mizu.Ctx) error - The handler function
  • c - The context, contains request info and response methods
  • c.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”
  • Listen blocks 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:
  1. main.go is over 100 lines - Time to split into multiple files
  2. You have related routes - Group them into packages
  3. You need configuration - Add a config file/struct
  4. Multiple developers - Need clearer organization
At this point, consider using the api template or building your own structure.

Next Steps

Tutorial

Build your first app step by step

API Template

See a more structured approach