Skip to content

morehao/goark

Repository files navigation

English | 简体中文

Project Overview

goark is a Go backend engineering practice project based on Gin. It provides a layered, maintainable, and scalable service structure with multiple app modules.


Features

  • Clear Project Structure: Inspired by project-layout, follows layered architecture principles, organized for team collaboration and long-term maintenance.
  • Common Component Integration: Includes built-in examples for MySQL, Redis, and Elasticsearch.
  • Full Link Logging: Provides a custom logging package glog based on zap, supporting full trace ID propagation across MySQL, Redis, ES, and HTTP calls.
  • Code Generation Tool: Comes with a command-line tool gocli that can generate standardized code (including model, dao, object, dto, code, service, controller, router layers) based on config.
  • Swagger API Documentation: Automatically generate interactive API docs using swaggo for easier frontend-backend collaboration and testing.
  • Docker Support: Includes a basic Dockerfile for containerized deployment.
  • Makefile Toolchain: Provides a rich set of make commands to simplify code build, run, generation, Swagger docs, and Docker deployment.
  • Growing Golib Library: Common utility components are abstracted and reusable via the golib package.

Project Structure

Follows project-layout. Current structure:

.
├── apps
│   ├── demo
│   │   ├── cmd
│   │   ├── client
│   │   ├── config
│   │   ├── dao
│   │   ├── model
│   │   ├── docs
│   │   ├── internal
│   │   │   ├── controller
│   │   │   ├── dto
│   │   │   ├── router
│   │   │   └── service
│   │   ├── middleware
│   │   ├── object
│   │   └── scripts
│   └── iam
│       ├── cmd
│       ├── config
│       ├── docs
│       ├── dao
│       ├── model
│       ├── internal
│       │   ├── controller
│       │   ├── dto
│       │   ├── router
│       │   └── service
│       ├── object
│       └── scripts
├── pkg
│   ├── code
│   ├── dbclient
│   ├── testsetup
│   └── utils
└── scripts

Core Features

Code Generation

Install the CLI tool:

go install github.com/morehao/gocli@latest

Ensure a code_gen.yaml config file exists under the application directory, e.g., goark/apps/demo/config/code_gen.yaml.

Run code generation commands:

# Generate full module based on table
make codegen APP=demo COMMAND=module

# Generate only model code
make codegen APP=demo COMMAND=model

# Generate API endpoint code
make codegen APP=demo COMMAND=api

See generate for full documentation.


API Documentation

Install Swagger tool:

go install github.com/swaggo/swag/cmd/swag@latest

Generate Swagger docs:

make swag APP=demo

Access docs at (dev mode):

http://localhost:8099/demo/redocs

Project Deployment

Build Docker image:

make docker-build APP=demo

Run container:

make docker-run APP=demo

Quickly Scaffold a New Project

Install the cutter tool:

go install github.com/morehao/gocli@latest

Run under the root of the template project (e.g., ./):

gocli cutter -d /goProject/yourAppName

This will scaffold a new project named yourAppName under /goProject based on the current template.

See cutter for more usage details.


Related Libraries

All related components are implemented in the golib package.

About

goark is a Golang-based monorepo that hosts a collection of backend services

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages