transferGoStruct

command module
v0.0.0-...-1823e9a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2023 License: Apache-2.0 Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

transferGoStruct

一、项目说明:

json/sql转换golang struct工具

二、使用说明:
1)插件构建
1、go mod init github.com/zhouxinlun/transferGoStruct \
2、go mod tidy \
3、go build
2)插件命令
Usage: transferGoStruct <command> 

Commands: 
v       查看当前版本号 
help    查看帮助信息 
json2go 根据json文件自动生成struct 
sql2go  根据db_sql连接自动生成struct 

Options: 
-json_file       json2go: json文件, 默认json文件为json2go.json 
-out_type        输出类型, 默认输出方式为输出到文件file/可选print、file 
-out_file        输出文件, 默认输出文件为gen_json2go_types.go 
-user_name       sql2go: 用户名, 默认root 
-password        sql2go: 密码, 默认'' 
-host    sql2go: db连接地址, 默认127.0.0.1:3306 
-charset         sql2go: 编码集, 默认utf8mb4 
-db_type         sql2go: 连接类型, 默认mysql 
-db_name         sql2go: 数据库名称, 默认'' 
-table_name      sql2go: 表名, 默认'' 

Examples: 
transferGoStruct json2go 
transferGoStruct json2go -out_type=print 
transferGoStruct json2go -out_type=file 
transferGoStruct json2go -out_type=file -out_file=out_types.go 
transferGoStruct sql2go -out_type=print -user_name=root -password=root -db_name=test -table_name=test 
transferGoStruct sql2go -out_type=file -out_file=out_types.go -user_name=root -password=root -db_name=test -table_name=test 
三、代码说明:
该代码是我在github转换示例中扩展出来的,主要功能目前只实现了json -> struct,sql -> struct,
思路是利用终端命令行参数初始化设定,并进行不同类型切换不同方式转换struct,
源码让我上传到了github上可以自行拉取:git@github.com:zhouxinlun/transferGoStruct.git
该工具接下来的扩展思路可以在sql转换上进一步优化,或者在配置方式上利用配置文件的方式,或者实现多张表的转换,又或者在struct结构体中的细节更加明确

img.png

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址