Skip to content

ccollicutt/go-app-template-skeleton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go App Skeleton Template

⚠️ Work in Progress: This template is currently in beta. While functional and suitable for development, it may have rough edges and is actively being improved. Use as a starting point and expect updates. Please consider using this template and passing back any improvements you have made (of which there will be many) to make it better for everyone. Thank you!

Hey there! Looking to develop a Go application with an API, web interface and command-line interface (CLI) all within a single repository? You've come to the right place!

This template repository is a good starting point for building an application consisting of a server, a command line interface and a web interface. Rather than starting from scratch every time you want to create a new Go app, just grab this template and you'll already be 60–80% of the way there. Just add your business or personal logic and you're ready to go!

Modern-Day Software Development

With the rise of AI-powered development tools, the barrier to entry for building custom software has never been lower. This template is designed to help you build custom software quickly.

Personal software

This template exists partly to help you build custom personal software faster and more easily. It gets you started with the boilerplate and provides a relatively simple way to run and use a piece of software from both the command line and a web interface.

Internal Tools

This template is also useful for building internal tools and on-premises applications within your organisation's infrastructure. Whether you're creating dashboards for operations teams, admin interfaces for managing company resources, data processing tools for analysts or specialised workflow automation systems, this template offers a solid foundation.

Why This Tool?

Most problems need custom software, not massive scale. This template is designed for the 90% of business problems that need internal tools, team productivity apps, and custom solutions - not the 1% that need to handle millions of users.

Skip the boilerplate. Every Go web app needs the same basic stuff - routing, auth, database connections, CLI parsing, tests, build scripts. This template provides all of that, already integrated and working together.

Deploy anywhere, no infrastructure team needed. Single binary with embedded SQLite means you can deploy to any server without coordinating with DevOps teams. No Redis to provision, no PostgreSQL to configure, no additional services to maintain. Just a binary and SQLite database file.

AI-powered rapid development. With today's AI coding assistants, starting with a solid foundation means you can build a custom internal tool in hours instead of days or weeks. Focus on solving your actual business problem, not setting up infrastructure and boilerplate code.

Ready to customize. The example echo API shows you exactly how to add your own endpoints. The web interface demonstrates user management. The CLI shows different output formats. Just follow the patterns and add your business logic.

What You Get Out of the Box

We've done the boring setup work for you:

  • A working HTTP API server (with an echo example to show you the patterns)
  • A simple web interface with login and user management
  • A CLI tool that talks to your API
  • Database integration (SQLite - simple and portable)
  • Authentication that actually works (API keys + web sessions)
  • Tests, build scripts, and CI/CD setup

The echo server example is just there to show you how everything connects. Replace it with whatever your app actually needs to do!

Getting Started

Want to see it in action? It takes about 2 minutes to get everything running:

# Clone and build
git clone https://github.com/ccollicutt/go-app-skeleton-template
cd go-app-skeleton-template
make build

# Generate certificates for HTTPS
./bin/app-server generate-certs

# Set up and start the server
mkdir -p data
export SERVER_PORT=8081 DATABASE_PATH=./data/app.db API_KEY=dev-secret
export ADMIN_USERNAME=admin ADMIN_PASSWORD=SecureAdmin123
./bin/app-server

Then in another terminal, try the CLI:

export SERVER_URL=http://localhost:8081 API_KEY=dev-secret
./bin/app-cli health
./bin/app-cli echo-public "Hello World"

Or visit http://localhost:8081 in your browser (login: admin/SecureAdmin123).

That's it! You now have a working API server, web interface, and CLI tool.

That's all you need to get started!

GUI

Here's a quick look at the GUI:

GUI

GUI

GUI

What's Next?

Ready to build something? Here's how to make this template your own:

  1. Clone it: Fork this repo or use it as a template
  2. Customize it: Replace the echo API with your actual business logic
  3. Extend it: Add new endpoints, database tables, CLI commands, or web pages
  4. Deploy it: The build system and CI/CD pipeline are ready to go

Project Structure

├── cmd/
│   ├── server/     # Server entry point
│   └── cli/        # CLI entry point
├── internal/
│   ├── server/     # Server implementation
│   ├── cli/        # CLI implementation
│   └── assets/     # Web assets (HTML, CSS, JS)
├── pkg/
│   ├── config/     # Configuration management
│   ├── database/   # Database interface
│   ├── logger/     # Logging utilities
│   └── version/    # Version information
├── tests/          # Integration tests
└── Makefile        # Build and development tasks

Common Tasks

make build          # Build server and CLI binaries
make run            # Run the server locally
make clean          # Clean build artifacts
make help           # Show all available commands

Configuration

Server Environment Variables

  • SERVER_PORT - HTTP server port (default: 8080)
  • DATABASE_PATH - SQLite database path (default: ./app.db)
  • API_KEY - API authentication key
  • ADMIN_USERNAME - Admin username for web interface
  • ADMIN_PASSWORD - Admin password for web interface
  • SESSION_SECRET - Secret key for session management

CLI Environment Variables

  • SERVER_URL - Server URL (default: http://localhost:8080)
  • API_KEY - API authentication key
  • DEBUG - Enable debug output (true/false)

Customization Guide

Adding API Endpoints

  1. Add your handler in internal/server/handlers/
  2. Register the route in internal/server/routes.go
  3. Add corresponding CLI command in internal/cli/commands/

Adding Database Tables

  1. Create migration in pkg/database/migrations.go
  2. Add model struct in pkg/database/models.go
  3. Implement CRUD operations

Adding Web Pages

  1. Create HTML template in internal/assets/templates/
  2. Add route handler in internal/server/web_handlers.go
  3. Update navigation in base template

Security Features

  • API Key Authentication - Secure API access
  • Session Management - Cookie-based web sessions
  • Password Hashing - bcrypt for password storage
  • HTTPS Support - TLS certificate generation included
  • Input Validation - Request validation and sanitization

Deployment

The application builds to a single binary that can be deployed anywhere:

# Build for production
make build

# Copy binary and run
scp bin/app-server your-server:/usr/local/bin/
ssh your-server
app-server --port 8080 --database /var/lib/app/data.db

Requirements

  • Go 1.23 or higher
  • Make (for build automation)
  • Git (for version control)

Built With

Go 1.23+Gorilla MuxSQLitebcryptCobra CLIGitHub Actions

The template uses proven libraries and follows Go best practices.

License

MIT License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published