久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      詳解xorm怎么自動(dòng)生成model

      本文由go語言教程欄目給大家介紹關(guān)于xorm自動(dòng)生成mode的方法 ,希望對(duì)需要的朋友有所幫助!

      xorm自動(dòng)生成model文件

      進(jìn)入項(xiàng)目根目錄

      luwei@luweideMacBook-Pro-2 go-simple-task % pwd/Users/myself/Golang/common_project/src/go-simple-task luwei@luweideMacBook-Pro-2 go-simple-task % ls Dockerfile      go-simple-task  go.mod          go.sum          logic           logs            main.go         model           models          overall         serv            templates       tool luwei@luweideMacBook-Pro-2 go-simple-task %

      如果沒有g(shù)o-sql-driver/mysql就先安裝

      go get -u github.com/go-sql-driver/mysql

      安裝xorm,在cmd命令行下

      go get github.com/go-xorm/xorm

      再安裝xorm的cmd命令工具

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

      安裝 cmd 報(bào)錯(cuò)處理

      luwei@luweideMacBook-Pro-2 go-simple-task % go get github.com/go-xorm/cmd/xorm # github.com/go-xorm/cmd/xorm ../../pkg/mod/github.com/go-xorm/cmd/xorm@v0.0.0-20190426080617-f87981e709a1/dump.go:45:26: cannot use "github.com/go-xorm/core".LOG_UNKNOWN (type "github.com/go-xorm/core".LogLevel) as type "xorm.io/core".LogLevel in argument to engine.Logger().SetLevel ../../pkg/mod/github.com/go-xorm/cmd/xorm@v0.0.0-20190426080617-f87981e709a1/reverse.go:246:34: cannot use tables (type []*"xorm.io/core".Table) as type []*"github.com/go-xorm/core".Table in argument to langTmpl.GenImports ../../pkg/mod/github.com/go-xorm/cmd/xorm@v0.0.0-20190426080617-f87981e709a1/reverse.go:254:18: cannot use table (type *"xorm.io/core".Table) as type *"github.com/go-xorm/core".Table in append ../../pkg/mod/github.com/go-xorm/cmd/xorm@v0.0.0-20190426080617-f87981e709a1/reverse.go:291:26: cannot use table (type *"xorm.io/core".Table) as type *"github.com/go-xorm/core".Table in slice literal ../../pkg/mod/github.com/go-xorm/cmd/xorm@v0.0.0-20190426080617-f87981e709a1/shell.go:60:26: cannot use "github.com/go-xorm/core".LOG_UNKNOWN (type "github.com/go-xorm/core".LogLevel) as type "xorm.io/core".LogLevel in argument to engine.Logger().SetLevel ../../pkg/mod/github.com/go-xorm/cmd/xorm@v0.0.0-20190426080617-f87981e709a1/source.go:45:26: cannot use "github.com/go-xorm/core".LOG_UNKNOWN (type "github.com/go-xorm/core".LogLevel) as type "xorm.io/core".LogLevel in argument to engine.Logger().SetLevel luwei@luweideMacBook-Pro-2 go-simple-task %

      跳出項(xiàng)目目錄執(zhí)行,完了再跳回去

      luwei@luweideMacBook-Pro-2 go-simple-task % cd ../luwei@luweideMacBook-Pro-2 src % go get github.com/go-xorm/cmd/xorm luwei@luweideMacBook-Pro-2 src %

      在項(xiàng)目目錄下建立 templates/goxorm 文件夾

      • 這個(gè)文件下建立config和struct.go.tpl文件.
      • 模板內(nèi)容可以根據(jù)你自己的需要修改
      • config內(nèi)容如下
        lang=go genJson=1prefix=
      • struct.go.tpl內(nèi)容如下
      package {{.Models}}{{$ilen := len .Imports}}{{if gt $ilen 0}}import (     {{range .Imports}}"{{.}}"{{end}}){{end}}{{range .Tables}}type {{Mapper .Name}} struct {{{$table := .}}{{range .ColumnsSeq}}{{$col := $table.GetColumn .}} {{Mapper $col.Name}}    {{Type $col}} {{Tag $table $col}}{{end}}}{{end}}
      • 最后執(zhí)行命令

        程序會(huì)在當(dāng)前目錄下生成models文件夾,并在models文件夾中生成go文件

        xorm reverse mysql root:root@/fox?charset=utf8 templates/goxorm

      執(zhí)行報(bào)錯(cuò)

      luwei@luweideMacBook-Pro-2 go-simple-task % xorm reverse mysql root:123456@/bubble?charset=utf8 templates/goxorm zsh: no matches found: root:123456@/bubble?charset=utf8
      • 解決方案
        vim ~/.zshrc
      • 在~/.zshrc中加入:
        setopt no_nomatch
      • 檢查一下
        luwei@luweideMacBook-Pro-2 go-simple-task % cat ~/.zshrc                                               source ~/.bash_profileexport GOPROXY=https://goproxy.io,direct setopt no_nomatch
      • 最后執(zhí)行
        source ~/.zshrc

      再次執(zhí)行

      luwei@luweideMacBook-Pro-2 go-simple-task % xorm reverse mysql root:123456@/bubble?charset=utf8 templates/goxorm luwei@luweideMacBook-Pro-2 go-simple-task %

      詳解xorm怎么自動(dòng)生成model

      剩下就是把models里的內(nèi)容賦值到model 對(duì)應(yīng)的model里面了

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)