# go-empty-project **Repository Path**: uygurjan2008_admin/go-empty-project ## Basic Information - **Project Name**: go-empty-project - **Description**: go-empty-project using gin framework - **Primary Language**: Go - **License**: GPL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-09-07 - **Last Updated**: 2025-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # go-empty-project #### 介绍 go-empty-project 是一个go web项目骨架,方便快速创建go项目 #### 软件架构 软件架构说明 #### 安装教程 1. xxxx 2. xxxx 3. xxxx #### 使用说明 1. xxxx 2. xxxx 3. xxxx #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request #### 减小可执行文件大小 默认构建生成的可执行文件较大,可以通过以下方式进行优化: ``` go build -ldflags="-s -w" -o main.exe main.go ``` 其中: - `-s` 去掉符号表信息 - `-w` 去掉调试信息 这可以显著减小可执行文件的大小,大约减少30%左右的体积。 # 创建 ad 表 ```sql CREATE TABLE `ad` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '类型', `type` int(11) NOT NULL COMMENT '类型', `image` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '图片', `url` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '图片', `app_id` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '小程序ID', `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, `name_ug` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `name` (`name`) USING BTREE, KEY `type` (`type`) USING BTREE, KEY `app_id` (`app_id`) USING BTREE, KEY `created_at` (`created_at`) USING BTREE, KEY `name_ug` (`name_ug`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ``` # config.json 内容修改 ### environment 当前环境 ### port 运行端口 ### mysql_dsn 数据库链接 ```json { "environment": "local", "config": { "local": { "port":":9091", "mysql_dsn":"root:root@tcp(127.0.0.1:3308)/book_app?charset=utf8&parseTime=True&loc=Local" }, "online": { "port":":9091", "mysql_dsn":"book_app:book_app@tcp(127.0.0.1:3306)/book_app?charset=utf8&parseTime=True&loc=Local" } } } ``` # Go 语言环境搭建完成后 在项目目录下运行 ```cmd go mod tidy go mod vendor go build main.go .\main.exe ``` # 浏览器访问 http://localhost:9091/api/ad