All Projects → sunshinev → Go Sword

sunshinev / Go Sword

Licence: mit
【Go-sword】可视化CRUD管理后台生成工具

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Go Sword

autogenu-jupyter
An automatic code generator for nonlinear model predictive control (NMPC) and the continuation/GMRES method (C/GMRES) based numerical solvers for NMPC
Stars: ✭ 89 (-75.55%)
Mutual labels:  code-generation
goverter
Generate type-safe Go converters by simply defining an interface
Stars: ✭ 100 (-72.53%)
Mutual labels:  code-generation
Rascal
The implementation of the Rascal meta-programming language (including interpreter, type checker, parser generator, compiler and JVM based run-time system)
Stars: ✭ 284 (-21.98%)
Mutual labels:  code-generation
metadsl
Domain Specific Languages in Python
Stars: ✭ 86 (-76.37%)
Mutual labels:  code-generation
regal86
Register Allocator for 8086
Stars: ✭ 62 (-82.97%)
Mutual labels:  code-generation
Efdesigner
Entity Framework visual design surface and code-first code generation for EF6, Core and beyond
Stars: ✭ 256 (-29.67%)
Mutual labels:  code-generation
molicode
molicode
Stars: ✭ 75 (-79.4%)
Mutual labels:  code-generation
Regenerate
Generate JavaScript-compatible regular expressions based on a given set of Unicode symbols or code points.
Stars: ✭ 306 (-15.93%)
Mutual labels:  code-generation
gapic-generator-python
Generate Python API client libraries from Protocol Buffers.
Stars: ✭ 74 (-79.67%)
Mutual labels:  code-generation
Fpp
Functional PHP Preprocessor - Generate Immutable Data Types
Stars: ✭ 282 (-22.53%)
Mutual labels:  code-generation
katapult
Kickstart Rails development!
Stars: ✭ 21 (-94.23%)
Mutual labels:  code-generation
php-code-generator
PHP code generator library
Stars: ✭ 144 (-60.44%)
Mutual labels:  code-generation
Apollo Tooling
✏️ Tooling for development and production Apollo workflows
Stars: ✭ 2,938 (+707.14%)
Mutual labels:  code-generation
qm
QM model-based design tool and code generator based on UML state machines
Stars: ✭ 54 (-85.16%)
Mutual labels:  code-generation
Data desk
New version "Metadesk" at https://github.com/Dion-Systems/metadesk
Stars: ✭ 289 (-20.6%)
Mutual labels:  code-generation
go-codegen
Go repos for code generation
Stars: ✭ 32 (-91.21%)
Mutual labels:  code-generation
Graphit
GraphIt - A High-Performance Domain Specific Language for Graph Analytics
Stars: ✭ 254 (-30.22%)
Mutual labels:  code-generation
Webrpc
webrpc is a schema-driven approach to writing backend services for modern Web apps and networks
Stars: ✭ 342 (-6.04%)
Mutual labels:  code-generation
Easyjson
Fast JSON serializer for golang.
Stars: ✭ 3,512 (+864.84%)
Mutual labels:  code-generation
Xmlschemaclassgenerator
Generate C# classes from XML Schema files
Stars: ✭ 277 (-23.9%)
Mutual labels:  code-generation

e5355b6316b83dcf4b6be9b7544f8e331588255151.jpg

Go-sword(利刃)是一款基于Go语言的可视化web管理后台生成工具

GitHub last commit GitHub GitHub repo size GitHub stars GitHub forks

官方网站 https://sunshinev.github.io/go-sword-home/

她能满足你哪些?

  1. 你有代码洁癖,不希望工具过多干扰你的业务逻辑
  2. 你希望生成的页面可以自定义修改,来实现更多的功能
  3. 你希望代码特别简单易读,且容易自定义
  4. 你希望能快速构建管理后台,哪怕仅仅是将数据库里的数据可视化
  5. 你希望一键生成CRUD,无需复杂操作
  6. 你希望使用 iView 的组件,快速构建页面

那么 go-sword 可以满足你

根据MySQL的表结构,创建完整的管理后台界面,开发者无需再重复手动的创建具有CRUD能力的页面 只需要点击按钮即可生成完整的管理后台

136e8b44d5d4acf00d5a63125928bd731587996269.jpg

特点

  1. 一键生成,无需写一行代码
  2. 支持增加、删除、编辑、列表、批量删除、分页、检索
  3. 页面基于Vue.js + iView
  4. 针对每个数据表都生成了单独的逻辑文件,开发者可以求使用Vue或者iView来实现功能更加丰富的页面

1626ee1d3300ac6db6669d63721d96381587996351.jpg

开始

安装

go get -u  github.com/sunshinev/go-sword

编译

go build

安装完成后,确保go-sword命令在GOPATH/bin目录下,可执行

启动服务

go-sword -db {db_database} -password {db_password} -user {db_uesr} -module {module_name}

例如:go-sword -db blog -password 123456 -user root -module go-sword-app

以上命令,就是连接数据库blog,用户名root,密码12345,在go-sword命令的当前目录下创建项目go-sword-app

启动成功的提示

Go-Sword will create new project named go-sword-app in current directory

[Server info]
Server port : 8080
Project module : go-sword-app

[db info]
MySQL host : localhost
MySQL port : 3306
MySQL user : root
MySQL password : 123456

Start successful, server is running ...
Please request: http://localhost:8080

参数说明

+---------------------------------------------------+
|                                                   |
|            Welcome to use Go-Sword                |
|                                                   |
|                Visualized tool                    |
|        Fastest to create CRUD background          |
|      https://github.com/sunshinev/go-sword        |
|                                                   |
+---------------------------------------------------+
Usage of go-sword:
  // 要连接的数据库信息
  -db string
      MySQL database
  -host string
      MySQL Host (default "localhost")
  // 重要:module参数单独作解释
  -module string
      New project module, the same as  'module' in go.mod file.   (default "go-sword-app/")
  // go-sword 服务启动的默认端口
  -p string
      Go-sword Server port (default "8080")
  -password string
      MySQL password
  -port int
      MySQL port (default 3306)
  -user string
      MySQL user

参数: -module

-module 参数是代表要创建的项目名称,同时也是新项目go.mod文件中的module字段的值,这点请务必保持一致。

注意

新项目会在运行go-sword命令的当前目录下,直接创建module目录,作为新项目

开始使用服务

Start successful, server is running ...
Please request: http://localhost:8080

根据服务启动的提示,直接点击http://localhost:8080即可进入web的可视化工具页面

59384a43cbc382dec53dd76d169a5d001587995174.jpg

重要:页面功能介绍

  1. 首先下拉选择MySQL 的表格,然后点击Preview按钮,即可渲染出需要创建的文件
  2. 首次创建新项目文件需要点击select all全部选择,首次创建包含了项目启动必需的核心文件
  3. 点击Generate按钮,既可以看到提示文件创建成功
  4. 到目前为止,我们的后台已经创建成功了

注意:

  1. 首次创建,文件需要全部选择
  2. 如果创建第二个管理页面,那么可以只选择 select diff & new按钮,然后点击Generate按钮
  3. 每次生成新的管理界面后,请重启新创建的项目

开始使用新项目

进入到我们新创建的项目目录

➜  test tree -L 2
.
└── go-sword-app
    ├── controller
    ├── core
    ├── go.mod
    ├── go.sum
    ├── main.go
    ├── model
    ├── resource
    ├── route
    └── view

比如说我们,刚刚是在test目录运行的go-sword命令,创建的项目就是test/go-sword-app

我们进入test/go-sword-app目录下按照以下命令启动项目

初始化新项目 go mod init

利用go mod初始化项目,这里的module就是我们前面讲到的要与项目名称保持一致!!

go mod init {module}

启动项目

go run main.go

然后会看到下面的提示,点击http://localhost:8082既可以进入后台管理界面

Enjoy your system ^ ^
Generated by Go-sword
https://github.com/sunshinev/go-sword

[Server info]
Server port : 8082

[db info]
MySQL host : localhost
MySQL port : 3306
MySQL user : root
MySQL password : 123456

Start successful, server is running ...
Please request: http://localhost:8082

管理后台效果

  1. 后端报错提醒
  2. 增加、删除、编辑、列表、批量删除、分页、检索

1626ee1d3300ac6db6669d63721d96381587996351.jpg

一些问题

  1. 因为golang的map结构遍历乱序的问题,部分页面输出的字段顺序不能保证和数据库字段顺序一致
  2. 关于module的参数,可能还会有更好的解决方案
  3. 没有提供用户注册、登录的能力,这也不符合初衷,最开始就是想做的更加基础,快速创建页面
  4. 生成的项目代码,还有很大的优化空间

页面功能展示

列表

ea1f86ebc1b5c88aaf6484fa078584951587997286.jpg

删除

70279af696d9a230001f821cdf3a1ac21587997368.jpg

预览

2d1871a645acc3d3544ad7f77a0d6fca1587997398.jpg

编辑

a9255db26b2af0365655840f6afd27851587997440.jpg

Go-sword fork

如果想要自定义的话,那么需要注意,Go-sword 项目可以打包成一个那单独的命令来执行,因为将所有的静态文件也进行了打包

静态文件压缩命令如下:

go-bindata -o assets/resource/dist.go -pkg resource resource/dist/...
go-bindata -o assets/stub/stub.go -pkg stub stub/...
go-bindata -o assets/view/view.go -pkg view view/...
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].