Posts Create a fresh golang project using gozen
Post
Cancel

Create a fresh golang project using gozen

Building modern web services and APIs in Go (Golang) often requires writing a repetitive amount of boilerplate code—setting up HTTP/REST routing, gRPC proto definitions, configuration management, directory layouts, and Docker environments.

GoZen is a simplified Golang MVC code generator and boilerplate tool created to solve this exact problem. It allows developers to scaffold fully structured, production-ready Go microservices and applications in seconds.

What is GoZen?

gozen (developed by tech-thinker) is a lightweight CLI utility and generator designed for Go developers. It acts as an opinionated starter generator that structures your project around clean Architecture and MVC principles, supporting both REST controllers and gRPC services out of the box.

Key Benefits of Using GoZen

  1. Instant MVC & Modular Architecture Scaffold
    • Instead of spending hours designing project directory structures, gozen creates a standard, modular structure adhering to Go community standards.
  2. Dual-Protocol Support (REST + gRPC)
    • Out of the box, gozen prepares both REST API controllers and gRPC handlers with Protocol Buffers (.proto) scaffolding, allowing you to build multi-protocol APIs seamlessly.
  3. Pre-configured Docker & Live Reloading
    • Includes ready-to-use Dockerfile.dev, Dockerfile.debug, and modd configuration (modd-dev.conf, modd-debug.conf) for effortless containerized local development and hot-reloading.
  4. Structured Environment & Configuration Management
    • Includes standardized .env, .env.sample, and config/config.go files to manage application settings safely across environments.
  5. Reduced Boilerplate & Human Error
    • Minimizes manual setup errors when wiring up routers, handlers, health check endpoints, and server initializations.

How GoZen Makes Developer Life Easy

  • Focus on Business Logic: Developers can jump straight into writing core API endpoints rather than configuring routing tables, server initialization routines, and container files.
  • Consistency Across Projects: Teams can use gozen to ensure every microservice across the organization shares an identical layout, making code reviews and maintenance straightforward.
  • Seamless Debugging & Local Dev: With pre-packaged Docker debug setups and live-reloading tools, local testing and step-debugging are hassle-free.

Step-by-Step: Creating a Fresh Go Project with GoZen

1. Installation

On macOS (using Homebrew)

1
2
brew tap tech-thinker/tap
brew install gozen

On Linux / macOS (using Binary Release)

1
2
3
4
TAG="v1.0.0" # Use the latest tag from GitHub releases
curl -sL "https://github.com/tech-thinker/gozen/releases/download/${TAG}/gozen-darwin-amd64" -o gozen
chmod +x gozen
sudo mv gozen /usr/bin

2. Running & Developing

Create project using gozen cli-

1
gozen create -p <package-name> -d postgres <app-name>

3. Generated Directory Structure

When gozen scaffolds a project, it generates the following clean structure:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
.
├── .editorconfig
├── .env
├── .env.sample
├── .gitignore
├── app/
│   ├── grpc/
│   │   ├── handlers/
│   │   │   └── health.go
│   │   ├── proto/
│   │   │   ├── health.proto
│   │   │   ├── health.pb.go
│   │   │   └── health_grpc.pb.go
│   │   └── router/
│   │       └── router.go
│   ├── init.go
│   └── rest/
│       ├── controllers/
│       │   └── health.go
│       └── router/
│           └── router.go
├── config/
│   └── config.go
├── constants/
│   └── app.go
└── docker/
    ├── Dockerfile.debug
    ├── Dockerfile.dev
    ├── Dockerfile.prod
    ├── modd-debug.conf
    └── modd-dev.conf

4. Running & Developing

  1. Environment Variables: Copy .env.sample to .env and set your local configurations.
  2. Local Live Reloading: Run your app inside Docker with hot reload:
1
docker-compose up
  1. REST & gRPC Health Checks: The project comes pre-configured with ready /health REST and gRPC health endpoints.

Summary

gozen is a powerful, time-saving tool for Golang developers looking to quick-start projects with clean MVC architecture, REST + gRPC support, and containerized development tooling out of the box.