# golang_study **Repository Path**: wrong1111/golang_study ## Basic Information - **Project Name**: golang_study - **Description**: golang_study - **Primary Language**: Go - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-09-03 - **Last Updated**: 2024-09-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # golang_study #### 介绍 golang_study #### 软件架构 软件架构说明 #### 安装教程 ##### 1.安装go环境 ##### 2.设置国内代理 go env -w GOPROXY=https://goproxy.cn ##### 3,查看环境 go env ##### 4,下载插件 go get github.com/jinzhu/gorm go get gorm.io/gorm ##### 5,数据库 引入 go get gorm.io/driver/sqllite go get gorm.io/driver/mysql 1,mysql 数据库连接字符串 mysql.Open("root@root12345@tcp(127.0.0.1:3306)/ginchat?charset=utf8mb4&parseTime=True&loc=Local") 2,创建表名 db.Create(&models.userBasic) 3,查询 db.First(&models.userBasic,1) //记录条数 1 4,更新 db.model(&models.userBasic).update("coloum","123") 5,删除 db.Delete(&models.userBasic) ##### 6,gin框架 引入 go get -u github.com/gin-gonic/gin 1, 创建监听服务 main.go package main import ( "ginchat/router" ) func main() { r := router.Router() r.Run(":8081") //listen and serve on 0.0.0.0:8080(for windows "localhost:8080") } 2, 创建 路由 router/app.go package router import ( "ginchat/service" "github.com/gin-gonic/gin" ) func Router() *gin.Engine { r := gin.Default() r.GET("/index", service.GetIndex) return r } 3, 创建服务 service/index.go package service import "github.com/gin-gonic/gin" func GetIndex(c *gin.Context) { c.JSON(200, gin.H{ "message": "Wellcome !", }) } 4, 浏览器访问 http://localhost:8081/index 返回 {"message":"Wellcome !"} #### 使用说明 1. xxxx 2. xxxx 3. xxxx #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request #### 特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)