欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

基于 gin_scaffold 用 Go 语言开发网络项目

最编程 2024-03-23 11:03:16
...

源码地址:https://github.com/e421083458/gin_scaffold

提前配置好go mod(好用的GO包管理工具,本地需要的第三方包和别的本地目录都可以自动导入)

git clone git@github.com:e421083458/gin_scaffold.git
cd gin_scaffold
go mod tidy

之后在自己的git上新建一个新项目,把当前的remote git地址删除,

 git remote rm origin

之后更新为自己的git仓库地址。

 git remote add origin git@github.com:xx.git

打开目录,找到controller/api.go

package controller

import (
    "errors"
    "github.com/e421083458/gin_scaffold/dao"
    "github.com/e421083458/gin_scaffold/dto"
    "github.com/e421083458/gin_scaffold/middleware"
    "github.com/e421083458/golang_common/lib"
    "github.com/gin-gonic/contrib/sessions"
    "github.com/gin-gonic/gin"
    "strings"
)

用goland全局替换“github.com/e421083458/gin_scaffold/” =》 “你的项目地址”

查看go.mod

 第一行改成你的项目地址:module github.com/XXX/XX

本地装好mysql和redis。在这里配置:

此时运行项目:url后面的地址是你的项目地址

 之后需要删除一些不需要的文件

controller 清空 dao清空

router/route.go 只留这些

重新启动

 访问:http://127.0.0.1:8880/ping

原文地址:https://www.cnblogs.com/qinghuaL/p/14828443.html