zoukankan      html  css  js  c++  java
  • 基于gin_scaffold开发Go语言的web项目

    源码地址: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/” =》 “你的本地项目名称/”

    比如你的项目名是WX,那么之后引入本地目录的地方应该是“WX/dao”这样

    查看go.mod

     第一行改成你的项目名称。比如WX

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

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

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

    controller 清空 dao清空

    router/route.go 只留这些

    重新启动

     

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

  • 相关阅读:
    DAY9 函数初识(各种参数的用法)
    CSS背景
    HTML/CSS 练习
    从JDBC到commons-DBUtils
    SQL
    MYSQL数据库基本操作
    JDBC
    Stream数据流(Collection接口扩充)
    Stack栈
    Map集合接口
  • 原文地址:https://www.cnblogs.com/qinghuaL/p/14828443.html
Copyright © 2011-2022 走看看