GO程序员的一些快捷开发工具,告别体力活

2020年9月7日 307点热度 0人点赞 0条评论

GO程序员的一些快捷开发工具,告别体力活,其实java或者其它语言也有这样那样的快捷工具,能够告别体力活,顺便偷懒,这也是我目前正在规划的事情,做一个真正的程序员工具平台,服务广大程序员,解放双手,有更多时间陪女朋友陪老婆陪小孩。

【1】、在线json转go结构体

json字段:

{"code":200,"message":"success","data":{"tips":"未收藏","status":false}}

一键转go结构体:

网址推荐:

1、https://www.sojson.com/json/json2go.html

2、https://oktools.net/json2go

//第一个type AutoGenerated struct {  Code int `json:"code"`  Message string `json:"message"`  Data struct {    Tips string `json:"tips"`    Status bool `json:"status"`  } `json:"data"`}
//第二个type AutoGenerated struct { Code int `json:"code"` Message string `json:"message"` Data Data `json:"data"`}type Data struct { Tips string `json:"tips"` Status bool `json:"status"`}

【2】、在线sql转go结构体,gorm或xorm

sql语句:

CREATE TABLE `user_account_tbl` (  `id` int(11) NOT NULL AUTO_INCREMENT,  `account` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,  `password` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,  `account_type` int(11) NOT NULL DEFAULT '0' COMMENT '帐号类型:0手机号,1邮件',  `app_key` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT 'authbucket_oauth2_client表的id',  `user_info_tbl_id` int(11) NOT NULL,  `reg_time` datetime DEFAULT NULL,  `reg_ip` varchar(15) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,  `bundle_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,  `describ` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,  PRIMARY KEY (`id`) USING BTREE,  UNIQUE KEY `account` (`account`) USING BTREE,  KEY `user_info_id` (`user_info_tbl_id`) USING BTREE,  CONSTRAINT `user_account_tbl_ibfk_1` FOREIGN KEY (`user_info_tbl_id`) REFERENCES `user_info_tbl` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='用户账号'

sql2go,一键将sql语句转为go结构体,xorm的orm框架

网址:http://stming.cn/tool/sql2go.html

type UserAccountTbl struct {  Id            int            `json:"id" xorm:"not null pk autoincr INT(11) 'id'"`  Account       string         `json:"account" xorm:"not null VARCHAR(64) 'account'"`  Password      string         `json:"password" xorm:"not null VARCHAR(64) 'password'"`  AccountType   int            `json:"account_type" xorm:"not null default 0 comment('帐号类型:0手机号,1邮件') INT(11) 'account_type'"`  AppKey        string         `json:"app_key" xorm:"not null comment('authbucket_oauth2_client表的id') VARCHAR(255) 'app_key'"`  UserInfoTblId int            `json:"user_info_tbl_id" xorm:"not null INT(11) 'user_info_tbl_id'"`  RegTime       sql.NullTime   `json:"reg_time" xorm:"default 'NULL' DATETIME 'reg_time'"`  RegIp         sql.NullString `json:"reg_ip" xorm:"default 'NULL' VARCHAR(15) 'reg_ip'"`  BundleId      sql.NullString `json:"bundle_id" xorm:"default 'NULL' VARCHAR(255) 'bundle_id'"`  Describ       sql.NullString `json:"describ" xorm:"default 'NULL' VARCHAR(255) 'describ'"`}

gormt,一键将sql语句转为go结构体,gorm的orm框架

网址,暂时没有在线工具,需要自己安装:

https://gitee.com/mirrors/gormt

CREATE TABLE `user_account_tbl` (  `id` int(11) NOT NULL AUTO_INCREMENT,  `account` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,  `password` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,  `account_type` int(11) NOT NULL DEFAULT '0' COMMENT '帐号类型:0手机号,1邮件',  `app_key` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT 'authbucket_oauth2_client表的id',  `user_info_tbl_id` int(11) NOT NULL,  `reg_time` datetime DEFAULT NULL,  `reg_ip` varchar(15) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,  `bundle_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,  `describ` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,  PRIMARY KEY (`id`) USING BTREE,  UNIQUE KEY `account` (`account`) USING BTREE,  KEY `user_info_id` (`user_info_tbl_id`) USING BTREE,  CONSTRAINT `user_account_tbl_ibfk_1` FOREIGN KEY (`user_info_tbl_id`) REFERENCES `user_info_tbl` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='用户账号'

自动生成的golang gorm结构体如下

type UserAccountTbl struct {  ID            int    `gorm:"primary_key"`  Account       string `gorm:"unique"`  Password      string  AccountType   int         // 帐号类型:0手机号,1邮件  AppKey        string      // authbucket_oauth2_client表的id  UserInfoTblID int         `gorm:"index"`  UserInfoTbl   UserInfoTbl `gorm:"association_foreignkey:user_info_tbl_id;foreignkey:id"` // 用户信息  RegTime       time.Time  RegIP         string  BundleID      string  Describ       string}

【3】IDE采用Goland

【4】toml2go 

https://xuri.me/toml-to-go/

用于将编码后的 toml 文本转换 golang 的 struct

【5】curl-to-go

https://github.com/mholt/curl-to-go

将curl语句转为go代码

【6】go泛型

https://github.com/cheekybits/genny

36350GO程序员的一些快捷开发工具,告别体力活

这个人很懒,什么都没留下

文章评论