Sample Applications
Explore complete, working examples of Goose applications to accelerate your learning and development.
Sandbox Repository
The Goose Sandbox contains reference implementations for all supported platform types. These examples demonstrate real-world patterns and best practices.
๐ฆ Repository: github.com/awesome-goose/sandbox
Available Examples
| Application | Description | Platform |
|---|---|---|
| api/ | REST API with JSON responses | API |
| web/ | Server-rendered web application | Web |
| cli/ | Command-line interface tool | CLI |
| multi/ | Multi-platform application | API + Web + CLI |
API Example
A REST API application demonstrating:
- JSON response handling
- RESTful routing patterns
- Resource modules with CRUD operations
- Dependency injection
- Structured logging
cd sandbox/api
go mod tidy
go run main.go
# Server starts at http://localhost:8080
Endpoints:
GET /- Health checkGET /user- List all usersGET /user/:id- Get user by ID
Web Example
A server-rendered web application demonstrating:
- HTML template rendering
- Form handling
- Static file serving
- Session management patterns
cd sandbox/web
go mod tidy
go run main.go
# Server starts at http://localhost:8080
CLI Example
A command-line application demonstrating:
- Command registration
- Argument and flag handling
- Output formatting
- Interactive prompts
cd sandbox/cli
go mod tidy
go run main.go
Multi-Platform Example
A single codebase serving multiple platforms:
- Shared business logic across platforms
- API endpoints (port 8080)
- Web interface (port 3000)
- CLI commands
cd sandbox/multi
go mod tidy
go run main.go
This example shows how to:
- Structure code for multi-platform support
- Share services and modules between platforms
- Configure platform-specific settings
Project Structure
Each sandbox application follows the standard Goose module structure:
app/
โโโ main.go # Application entry point
โโโ config.yaml # Configuration file
โโโ go.mod # Go module definition
โโโ app/
โ โโโ app.module.go # Root module
โ โโโ app.controller.go
โ โโโ app.service.go
โ โโโ app.routes.go
โ โโโ app.dtos.go
โโโ [feature]/ # Feature modules
โโโ [feature].module.go
โโโ [feature].controller.go
โโโ [feature].service.go
โโโ [feature].routes.go
โโโ [feature].dtos.go
Running Examples Locally
-
Clone the sandbox repository:
git clone https://github.com/awesome-goose/sandbox.git cd sandbox -
Choose an example:
cd api # or web, cli, multi -
Install dependencies and run:
go mod tidy go run main.go
Using as Templates
The sandbox examples can serve as starting points for your own applications:
- Copy the example that matches your use case
- Update
go.modwith your module name - Modify the application code as needed
Or use the Goose CLI to scaffold a new project:
# Create from template
goose app --name=myproject --template=api
goose app --name=myproject --template=web
goose app --name=myproject --template=cli
goose app --name=myproject --template=multi
Next Steps
- Quick Start - Build your first app
- Architecture - Understand Goose design
- Modules - Learn module patterns
- Building a REST API - Step-by-step tutorial