goark

module
v0.0.0-...-a694461 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2026 License: MIT

README

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
│   │   ├── demodao
│   │   ├── demomodel
│   │   ├── docs
│   │   ├── internal
│   │   │   ├── controller
│   │   │   ├── dto
│   │   │   ├── router
│   │   │   └── service
│   │   ├── middleware
│   │   ├── object
│   │   └── scripts
│   └── iam
│       ├── cmd
│       ├── config
│       ├── docs
│       ├── iamdao
│       ├── iammodel
│       ├── 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 MODE=module APP=demo

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

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

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.


All related components are implemented in the golib package.

Directories

Path Synopsis
apps
demo/client/httpbingo
* @Author: morehao morehao@qq.com * @Date: 2025-11-08 17:44:59 * @LastEditors: morehao morehao@qq.com * @LastEditTime: 2025-11-08 17:46:54 * @FilePath: /golib/Users/morehao/Documents/practice/go/go-gin-web/apps/demo/client/httpbingo/httpbingo.go * @Description: 这默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @Author: morehao morehao@qq.com * @Date: 2025-11-08 17:44:59 * @LastEditors: morehao morehao@qq.com * @LastEditTime: 2025-11-08 17:46:54 * @FilePath: /golib/Users/morehao/Documents/practice/go/go-gin-web/apps/demo/client/httpbingo/httpbingo.go * @Description: 这默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
demo/cmd command
demo/docs
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.
iam
iam/cmd command
iam/docs
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.
pkg module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL