使用Golang快速开发web应用

本文介绍了如何使用Golang和dolphin工具快速搭建web应用。首先在命令终端安装dolphin,接着初始化项目并等待doc生成。然后编辑app.properties文件配置数据库,运行项目。再利用配置自动生成CRUD,实现基本的增删改查功能。更多详情可查阅github上的dolphin项目。
摘要由CSDN通过智能技术生成

 

1. 打开命令终端安装dolphin(一个集合Golang, web开发的工具)

go get -u github.com/2637309949/dolphin/cmd/dolphin

2. 初始化项目

mkdir hello && cd hello && dolphin init && dolphin build && go run main.go

生成doc会有点慢, 需要等一下

3. 打开hello/app.properties

db.dataSource=root:111111@/dolphin?charset=utf8&parseTime=True&loc=Local

修改数据库配置

4. 运行

[double@manjaro hello]$ go run main.go 
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /static/*filepath         --> github.com/2637309949/dolphin/packages/gin.(*RouterGroup).createStaticHandler.func1 (2 handlers)
[GIN-debug] HEAD   /static/*filepath         --> github.com/2637309949/dolphin/packages/gin.(*RouterGroup).createStaticHandler.func1 (2 handlers)
[GIN-debug] POST   /api/sys/app/fun/add      --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] POST   /api/sys/app/fun/batch_add --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] DELETE /api/sys/app/fun/del      --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] DELETE /api/sys/app/fun/batch_del --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] PUT    /api/sys/app/fun/update   --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] PUT    /api/sys/app/fun/batch_update --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] GET    /api/sys/app/fun/page     --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] GET    /api/sys/app/fun/tree     --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] GET    /api/sys/app/fun/get      --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] POST   /api/sys/area/add         --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] POST   /api/sys/area/batch_add   --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] DELETE /api/sys/area/del         --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] DELETE /api/sys/area/batch_del   --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] PUT    /api/sys/area/update      --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] PUT    /api/sys/area/batch_update --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] GET    /api/sys/area/page        --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] GET    /api/sys/area/get         --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] POST   /api/sys/attachment/add   --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] POST   /api/sys/attachment/batch_add --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] POST   /api/sys/attachment/upload --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] GET    /api/sys/attachment/export --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (5 handlers)
[GIN-debug] DELETE /api/sys/attachment/del   --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] POST   /api/sys/attachment/batch_del --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] PUT    /api/sys/attachment/update --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] POST   /api/sys/attachment/batch_update --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] GET    /api/sys/attachment/page  --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] GET    /api/sys/attachment/get   --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] POST   /api/sys/cas/login        --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (5 handlers)
[GIN-debug] GET    /api/sys/cas/logout       --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (5 handlers)
[GIN-debug] POST   /api/sys/cas/affirm       --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (5 handlers)
[GIN-debug] GET    /api/sys/cas/authorize    --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (5 handlers)
[GIN-debug] POST   /api/sys/cas/token        --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (5 handlers)
[GIN-debug] GET    /api/sys/cas/url          --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (5 handlers)
[GIN-debug] GET    /api/sys/cas/oauth2       --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (5 handlers)
[GIN-debug] GET    /api/sys/cas/refresh      --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (5 handlers)
[GIN-debug] GET    /api/sys/cas/check        --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (5 handlers)
[GIN-debug] GET    /api/sys/cas/profile      --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] GET    /api/sys/cas/qrcode       --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (5 handlers)
[GIN-debug] POST   /api/sys/client/add       --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] POST   /api/sys/client/batch_add --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] DELETE /api/sys/client/del       --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] DELETE /api/sys/client/batch_del --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] PUT    /api/sys/client/update    --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] PUT    /api/sys/client/batch_update --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] GET    /api/sys/client/page      --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] GET    /api/sys/client/get       --> github.com/2637309949/dolphin/platform/app.(*Engine).HandlerFunc.func1 (6 handlers)
[GIN-debug] POST   /api/sys/comment/add      -->
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值