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 check
  • GET /user - List all users
  • GET /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

  1. Clone the sandbox repository:

    git clone https://github.com/awesome-goose/sandbox.git
    cd sandbox
    
  2. Choose an example:

    cd api  # or web, cli, multi
    
  3. 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:

  1. Copy the example that matches your use case
  2. Update go.mod with your module name
  3. 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