Files
workspace/notes/后端开发/golang/项目骨架.md
T
2025-08-01 17:30:28 +08:00

27 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 项目结构
```
myapp/
├── cmd/ # 启动程序的入口(main.go 通常放在这里)
│ └── myapp/
│ └── main.go # 主程序入口
│
├── internal/ # 内部模块,不能被外部引入
│ ├── app/ # 应用逻辑层(服务、用例)
│ ├── config/ # 配置读取相关逻辑(如viper/yaml/env)
│ ├── handler/ # HTTP handler(路由处理函数)
│ ├── repository/ # 数据访问层(如数据库、缓存)
│ ├── service/ # 业务逻辑层
│ └── model/ # 实体结构体、DTO、表结构等
│
├── pkg/ # 可被外部引入的公共包
│ ├── logger/ # 日志封装
│ ├── utils/ # 工具函数
│ └── middleware/ # HTTP中间件
│
├── go.mod # Go module 定义
├── go.sum # Go module 校验文件
└── README.md # 项目说明
```