当前位置:网站首页>Introduction to the structure of gocore-v2 framework scaffold generation project
Introduction to the structure of gocore-v2 framework scaffold generation project
2022-07-20 10:35:00 【Wen Zhenxi】
Github
Official document address - Ongoing update
Scaffolding allows you to quickly build projects , No need to 0 Start creating directory structure , There is no need to copy historical items and replace the item name uniformly , You can quickly generate the project structure and basic skeleton code with one line of command , And integrate the concept of interface development ADM(Api-Domain-Model) Develop the constraints of specifications in a hierarchical way .
The directory structure is as follows :
.
├── Dockerfile #docker Image packaging
├── README.md # Project introduction
├── app
│ ├── api #api Interface entry
│ │ └── user.go
│ ├── cronjob # Timing task , Business logic processing
│ │ └── sync_user.go
│ ├── def #api Interface request parameter and response parameter declaration
│ │ └── def.go
│ ├── domain # The final business logic processing
│ │ └── user.go
│ ├── errcode # Error code declaration
│ │ └── errcode.go
│ ├── job # One time task , Permanent mission , Business logic
│ │ └── init_user.go
│ ├── model
│ │ └── app #model Catalog ,app For database name
│ │ ├── mysql_client.go # database db Build table , obtain db example
│ │ └── user.go #model file ,user It's the name of the table
│ └── routes
│ └── routers.go # Routing rule settings
├── cmd # Program start entry
│ ├── api.go #api Interface start command
│ ├── cron.go # Scheduled task start command
│ ├── init.go # To configure , database ,redis Equal initialization
│ └── job.go # One time task , Resident task start command
├── common # Store global variables , Public methods
├── conf # Profile directory
│ ├── base.go # Basic general configuration , It will eventually be incorporated into the project configuration
│ ├── const.go # Global constants
│ └── local.go # The local configuration environment variable is local Will use
├── go.mod
├── go.sum
├── gocore.yaml #gocore Project generation configuration file
├── main.go # Program entrance
└── pkg # Public kits
ADM(Api-Domain-Model)
The project directory structure follows a certain development concept .
Api Layer can be understood as the place where the request starts and ends and the business is combined
- Mainly responsible for the following things :
- Get the request parameters and verify the validity of the request parameters
- Yes Domain The implementation of the domain layer is spliced to form the business of the whole interface
- Process the returned results
- Api The interface layer should do :
- Perform necessary detection of user login status
- Control the main process of business scenarios , Create a domain business instance , And call
- Make necessary log records
- Return interface result
- Api The interface layer should not :
- Process or calculate business rules
- Care about whether data is cached , Or perform cache related direct operations
- Direct operation database
Domain The layer is responsible for handling specific business logic
- Divide and reuse complex business code :
- One method can only accomplish one thing , Complex logic should be split
- Domain Layers minimize calls to each other , Should be determined by the API Layer splicing (API The layer can see at a glance what the whole interface should do )
- The core single test focuses on Domain In the layer
Model The layer is responsible for obtaining data
- Unified data access improves scalability :
- Each method accomplishes only one thing , such as GetInfoById、UpdateNameById、GetCountUser
- Avoid defining very general methods , such as where Conditions are passed as strings , Easily lead to SQL Injection problem
- You can adjust the data structure or optimize the cache by modifying only one file , There is no need to modify the business logic layer
边栏推荐
- Opencv编译及调用GPU版本
- Day006选择结构(if语句练习)
- pytorch梯度的计算过程
- Lambda usage
- How to turn a computer without public IP in a LAN into a server accessible to the public network (SSH access as an example)
- vs2017 编译遇到COM 组件的调用返回了错误 HRESULT E_FAIL
- Manually compile and install Apache
- [resource record] the relationship between manifold learning and PCA
- Calculation process of pytorch gradient
- Dark horse programmer multithreading implementation mode II
猜你喜欢
Lombok配合Logback实现最简单的日志输出
猫和狗的分类例子-Kaggle
论文笔记:Look Back and Predict Forward in Image Captioning# Look Back and Predict Forward in Image Capti
深入递归、深搜dfs、回溯、剪纸学习。
LVM和磁盘配额
Go-Zero 业务开发军火库
斐讯k1刷入Breed以及openwrt的教程
Kubernetes terminal management tool - kubebox
DevOps:从「蒸汽时代」到「高铁时代」,SUNMI DevOps转型之路
NN of pytorch Conv1d detailed explanation
随机推荐
Migrate KVM virtual machine to openstack environment, and prompt invaliddiskinfo disk info file is invalid QEMU img FAI
Variational Inference 笔记 from UCB CS 285 Sergey Levine
Dark horse programmer thread pool
Paper notes: neural baby talk
【资源记录】Bayesian Neural Network(BNN)介绍,常见package及区别
MySQL Galera cluster configuration
Redash - 强大的开源数据可视化平台
2020-09-17
Pytorch: Introduction à visdom
如何做好单元测试?Golang Mock”三剑客“ gomock、monkey、sqlmock
Kubernetes terminal management tool - kubebox
Win10 + CUDA11.7+pytorch手动安装-2.0版本
阿里云微消息队列 MQTT
How to turn a computer without public IP in a LAN into a server accessible to the public network (SSH access as an example)
[turn] method to solve memory / video memory leakage pytorch
CEPH detailed mon_ osd_ max_ split_ count
ZTE ZXR10 5250 command hints
invalid syntax
Three elements of network communication for dark horse programmers
websocket总结