golang server template without connect sql
Go to file Use this template
2025-01-02 11:10:18 +08:00
cmd feature: 初始化项目 2025-01-02 11:08:45 +08:00
internal feature: 初始化项目 2025-01-02 11:08:45 +08:00
.DS_Store feature: golang server template 2024-07-08 17:36:56 +08:00
.gitignore feature: golang server template 2024-07-08 17:36:56 +08:00
go.mod style: go mod tidy 2025-01-02 11:10:18 +08:00
go.sum style: go mod tidy 2025-01-02 11:10:18 +08:00
Makefile feature: 初始化项目 2025-01-02 11:08:45 +08:00
README.md feature: golang server template 2024-07-08 17:36:56 +08:00

项目结构

- bin # 可编译的二进制文件, 用于部署到服务器
- cmd
  - api # 业务代码, 处理请求,权限
    - main.go
- internel # 辅助代码, 处理数据库, 数据校验, 发邮件等
- migrations # sql迁移文件
- remote # 配置文件和启动脚本
- go.mod # 项目依赖, 版本号, 模块路径
- Makefile # 自动化处理任务, 审核代码, 生成二进制文件, 执行sql迁移

hello world

package main 
impot "fmt"
func main() {
  fmt.Println("hello world!")
}

执行代码

$ go run ./cmd/api # hello world!