当前位置: 首页 > news >正文

网站建设中页面模板下载人工智能培训班

网站建设中页面模板下载,人工智能培训班,公司做网站文案怎么写,驻马店住房和城乡建设局网站gorm的自动化工具gen 官方 https://gorm.io/zh_CN/gen/假设数据库结构如 这里使用gen-tool 安装 go install gorm.io/gen/tools/gentoollatest用法 gentool -hUsage of gentool:-c string配置文件名、默认值 “”、命令行选项的优先级高于配置文件。 -db string指定Driver…

gorm的自动化工具gen

官方

https://gorm.io/zh_CN/gen/

假设数据库结构如

Image1

这里使用gen-tool

安装

go install gorm.io/gen/tools/gentool@latest

用法

gentool -hUsage of gentool:-c string配置文件名、默认值 “”、命令行选项的优先级高于配置文件。 -db string指定Driver,默认值“mysql”,referer:https://gorm.io/docs/connecting_to_the_database.html-dsn string用于连接数据库的DSN reference: https://gorm.io/docs/connecting_to_the_database.html-fieldNullable当字段允许空时用指针生成-fieldWithIndexTag生成带有gorm index 标签的字段-fieldWithTypeTag生成带有gorm type标签的字段-modelPkgName string生成模型代码包名称。-outFile stringGenrated 查询代码文件名称,默认值:gen.go-outPath string指定输出目录(默认 “./dao/query”)-tables string指定要生成的表名称,默认所有表。-onlyModel指生成Models不生成对应的query-withUnitTest生成单元测试,默认值 false, 选项: false / true-fieldSignabledetect integer field's unsigned type, adjust generated data type

Example

gentool -dsn "user:pwd@tcp(localhost:3306)/database?charset=utf8mb4&parseTime=True&loc=Local" -tables "orders,doctor"gentool -c "./gen.tool" # 配置文件像下面
version: "0.1"
database:# consult[https://gorm.io/docs/connecting_to_the_database.html]"dsn : "username:password@tcp(address:port)/db?charset=utf8mb4&parseTime=true&loc=Local"# 选择mysql或者其他引擎,比方sqlserverdb  : "mysql"# 指定要生成的table,流控则全部tables  : "user"# 指定输出目录outPath :  "./dao/query"# 输出的代码,默认gen.gooutFile :  ""# 是否生成单元测试withUnitTest  : false# generated model code's package name# 生成的model的代码的包名modelPkgName  : ""# 使用指针当字段是空的fieldNullable : false# 生成的字段带有gorm tagfieldWithIndexTag : false# 生成的字段时候带有gorm type 标签fieldWithTypeTag  : false

ubuntu将gobin加入到PATH的做法

个人来说,gentool没有被加入到PATH中,这边手动把GOPATH加入到PATH中,我用的是

zsh,所以把环境变量加入到~/.zshrc中,参考下面的命令

Image2

echo 'export PATH=$PATH:~/go/bin' | tee -a ~/.zshrc

现在gentool可以在任意地方被调用了

Image3

实例

在项目根目录新疆gentool文件里面写入内容

version: "0.1"
database:# consult[https://gorm.io/docs/connecting_to_the_database.html]"dsn : "root:root@tcp(127.0.0.1:3306)/school?charset=utf8mb4&parseTime=true&loc=Local"# 选择mysql或者其他引擎,比方sqlserverdb  : "mysql"# 指定要生成的table,流控则全部# 指定输出目录outPath :  "./dao/query"# 输出的代码,默认gen.gooutFile :  ""# 是否生成单元测试withUnitTest  : false# generated model code's package name# 生成的model的代码的包名modelPkgName  : "models"# 使用指针当字段是空的fieldNullable : false# 生成的字段带有gorm tagfieldWithIndexTag : false# 生成的字段时候带有gorm type 标签fieldWithTypeTag  : false

然后使用gentool指定-c

结果如在dao包下生成了对应的models和query

Image4

http://www.hkea.cn/news/937800/

相关文章:

  • 什么网站做一手房好系统优化的例子
  • wordpress 插入wordseo排名点击工具
  • 网站推广易网宣seo的主要分析工具
  • 安徽网站定制最大免费广告发布平台
  • 怎么查网站有没有做404公司宣传网页怎么做
  • 靠谱营销网站开发选哪家seo的优点和缺点
  • 企业网站建设论文文献综述百度推广的广告真实可信吗
  • 企业网站优化方式广州最新消息今天
  • 旅游网站开发的意义seo优化方案案例
  • 山东做网站的公司seo数据分析哪些方面
  • 做网站用哪几个端口 比较好百度贴吧官网网页
  • 弹幕网站是怎么做的百度在线翻译
  • 独立网站域名代发关键词包收录
  • 如何建立门户网站百度可以发布广告吗
  • 网站开发毕设文献郑州网站优化顾问
  • 青海建设银行的官方网站自己制作网页的网站
  • 网站建设的图片叠加步骤过程2021年搜索引擎排名
  • 网站链接到邮箱怎么做搜索引擎推广试题
  • 十堰城市建设网站制作自己的网站
  • 传媒网站建设公司深圳百度seo优化
  • 公司需要网站 该怎么做公司推广咨询
  • 高中男女做那个视频网站seo做的好的网站
  • 网站建设 摄影服务上海seo网站排名优化公司
  • 网页设计中html代码seo博客网站
  • 怎样建设小游戏网站google关键词搜索技巧
  • 淘宝 客要推广网站怎么做全媒体广告代理
  • 那个b2b网站可以做外贸武汉全网推广
  • 深圳css3网站开发多少钱如何策划一个营销方案
  • 织梦统计网站访问量代码网络营销公司如何建立
  • 外贸营销型网站建设今日最新重大新闻