xorm reverse 采坑日记

1 安装 xorm 工具

> go get github.com/go-xorm/cmd/xorm

2 验证是否安装成功

> xorm help reverse
usage: xorm reverse [-s] driverName datasourceName tmplPath [generatedPath] [tableFilterReg]

according database's tables and columns to generate codes for Go, C++ and etc.

    -s                Generated one go file for every table
    driverName        Database driver name, now supported four: mysql mymysql sqlite3 postgres
    datasourceName    Database connection uri, for detail infomation please visit driver's project page
    tmplPath          Template dir for generated. the default templates dir has provide 1 template
    generatedPath     This parameter is optional, if blank, the default value is models, then will
                      generated all codes in models dir
    tableFilterReg    Table name filter regexp

3 在项目的src目录下建立一个models文件夹
4 找到reverse工具的模板目录 .../github.com/go-xmorm/cmd/xorm/templates
5 执行reverse命令

> xorm reverse mysql root:123456@tcp\(127.0.0.1:3306\)/test ./templates/goxorm/  ./models

你可能感兴趣的:(xorm reverse 采坑日记)