23 Star 299 Fork 181

guchengwuyue / yshop-gin

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
环境部署.md 2.76 KB
一键复制 编辑 原始数据 按行查看 历史

go环境配置

1、安装go>=1.15,这个可以https://studygolang.com/dl下载

2、开启mod: go env -w GO111MODULE=on

3、配置代理:go env -w GOPROXY=https://goproxy.cn,direct 这个让下载依赖速度更快

下载代码

下载项目:git clone https://github.com/guchengwuyue/yshop-gin.git

安装依赖

go mod tidy 安装所需依赖

导入数据库

请用mysql工具导入代码中sql文件,路径:./sql/yshop_go.sql

配置详解

在项目根目录 ./conf/app.ini 修改必要配置如下:


[app]
PageSize = 10
JwtSecret = go-mall
PrefixUrl = http://127.0.0.1:8000

RuntimeRootPath = runtime/

ImageSavePath = upload/images/

ImageMaxSize = 5
ImageAllowExts = .jpg,.jpeg,.png

ExportSavePath = export/
QrCodeSavePath = qrcode/
FontSavePath = fonts/

LogSavePath = logs/
LogSaveName = log
LogFileExt = log
TimeFormat = 20060102

[server]
#debug or release
RunMode = debug
HttpPort = 8000
ReadTimeout = 60
WriteTimeout = 60

[database]
Type = mysql
User = root
Password = root
Host = 127.0.0.1:3306
Name = yshop_go
TablePrefix =

[redis]
Host = 127.0.0.1:6379
Password =
MaxIdle = 30
MaxActive = 30
IdleTimeout = 200
#### 权限检验说明

权限校验中间件路径./middleware/authcheck.go 里面 注意下面注释的代码块,此处用于项目演示,请注意删除

func Jwt() gin.HandlerFunc {
   return func(c *gin.Context) {
      var data interface{}
      var appG = app.Gin{C: c}

      url := c.Request.URL.Path

      method := strings.ToLower(c.Request.Method)
      //部署线上开启
      //prohibit := "post,put,delete"
      //if url != "/admin/auth/logout" && strings.Contains(prohibit,method) {
      // ctx.Output.JSON(controllers.ErrMsg("演示环境禁止操作",40006),
      //    true,true)
      // return
      //}

      mytoken := c.Request.Header.Get("Authorization")
      if len(mytoken) < bearerLength {
         appG.Response(http.StatusUnauthorized,constant.ERROR_AUTH,data)
         c.Abort()
         return
      }
             .......
#### 项目运行

本地开发:本地运行air -c .air.conf 启动即可

线上部署: go build 打包然后上传服务器命令: nohup ./go-mall &


### vue前端项目

#### 下载代码

下载项目:git clone https://github.com/guchengwuyue/go-mall-vue


#### 安装依赖

npm install

#### 项目配置

路径:./env.development 与 ./env.production 上面一个开发环境,一个是生产环境下的配置

ENV = 'development'

接口地址

VUE_APP_BASE_API = 'http://localhost:8080' //配置后端api即可

#### 启动项目

本地运行:npm run dev 线上部署:npm run build 然后上传./dist/下编译后的文件到web服务器即可


Go
1
https://gitee.com/guchengwuyue/yshop-gin.git
git@gitee.com:guchengwuyue/yshop-gin.git
guchengwuyue
yshop-gin
yshop-gin
master

搜索帮助