Go-sword is a visual web management background generation tool based on Go language
http://go-sword-app.osinger.com/
The goal is to quickly create a CRUD visual background
According to the table structure of MySQL, create a complete management background interface, developers no longer need to manually create CRUD-capable pages Just click the button to generate a complete management background
- One-key generation without writing a line of code
- Support add, delete, edit, list, batch delete, paging, search
- The page is based on Vue.js + iView
- A separate logical file is generated for each data table, and developers can seek to use Vue or iView to implement more feature-rich pages
go get -u github.com/sunshinev/go-sword
go build
After the installation is complete, make sure that the go-sword
command is in the GOPATH/bin
directory, executable
go-sword -db {db_database} -password {db_password} -user {db_uesr} -module {module_name}
For example: go-sword -db blog -password 123456 -user root -module go-sword-app
The above command is to connect to the database blog
, the username root
, the password 12345
, and create the project go-sword-app
in the current directory of the go-sword command
Tips for successful startup
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:
//Database information to be connected
-db string
MySQL database
-host string
MySQL Host (default "localhost")
//Important: module parameters are explained separately
-module string
New project module, the same as 'module' in go.mod file. (Default "go-sword-app /")
//The default port where the go-sword service starts
-p string
Go-sword Server port (default "8080")
-password string
MySQL password
-port int
MySQL port (default 3306)
-user string
MySQL user
The -module
parameter is the name of the project to be created, and it is also the value of the module
field in the go.mod
file of the new project. Please make sure that this is consistent.
The new project will directly create the module
directory under the current directory where the go-sword
command is run as the new project
Start successful, server is running ...
Please request: http://localhost: 8080
According to the prompt of service startup, directly click http://localhost: 8080
to enter the web visualization tool page
- First, select the MySQL table by drop-down, and then click the
Preview
button to render the file to be created - The first time you create a new project file you need to click
select all
to select all, the first time you create a core file that contains the necessary project start - Click the
Generate
button, you can see the prompt file successfully created - So far, our background has been successfully created
note:
- For the first time, all files need to be selected
- If you create a second management page, you can just select the
select diff & new
button and click theGenerate
button - Every time a new management interface is generated, please restart the newly created project
Go to our newly created project directory
➜ test tree -L 2
.
└── go-sword-app
├── controller
├── core
├── go.mod
├── go.sum
├── main.go
├── model
├── resource
├── route
└── view
For example, if we just run the go-sword
command in the test
directory, the created project is test/go-sword-app
We enter the test/go-sword-app
directory and start the project according to the following command
Use go mod
to initialize the project, and the module
here is the same as the project name we mentioned earlier! !
go mod init {module}
###Startup project
go run main.go
Then you will see the following prompt, click http://localhost: 8082
to enter the background management interface
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
- Back-end error notification
- Add, delete, edit, list, bulk delete, paging, search
- Because of the out-of-order traversal of golang's map structure, the field order of some pages cannot be guaranteed to be consistent with the database field order
- There may be better solutions regarding the parameters of
module
- The ability to register and log in is not provided, which is not in line with the original intention. At the beginning, I wanted to do more basic things and quickly create pages
- The generated project code has a lot of room for optimization
If you want to customize, then you need to note that the Go-sword project can be packaged into a single command to execute, because all static files are also packaged
The static file compression commands are as follows:
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/...