From 1d0ca7b11683a8a2cb61e0050d75e6143e5a5109 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 14 Oct 2013 16:33:07 +0800 Subject: [PATCH] bug fixed --- mysql.go | 3 ++- xorm/README.md | 40 ++++++++++++++++++++++++++++++++++++++++ xorm/reverse.go | 2 +- 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 xorm/README.md diff --git a/mysql.go b/mysql.go index 4d436616..5d200ccf 100644 --- a/mysql.go +++ b/mysql.go @@ -179,7 +179,8 @@ func (db *mysql) GetColumns(tableName string) (map[string]*Column, error) { cts := strings.Split(string(content), "(") var len1, len2 int if len(cts) == 2 { - lens := strings.Split(cts[1][0:len(cts[1])-1], ",") + idx := strings.Index(cts[1], ")") + lens := strings.Split(cts[1][0:idx], ",") len1, err = strconv.Atoi(strings.TrimSpace(lens[0])) if err != nil { return nil, err diff --git a/xorm/README.md b/xorm/README.md new file mode 100644 index 00000000..188a41fa --- /dev/null +++ b/xorm/README.md @@ -0,0 +1,40 @@ +# xorm tools + + +xorm tools is a set of tools for database operation. + +## Install + +`go get github.com/lunny/xorm/xorm` + +and you should install the depends below: + +* github.com/lunny/xorm + +* Mysql: [github.com/Go-SQL-Driver/MySQL](https://github.com/Go-SQL-Driver/MySQL) + +* MyMysql: [github.com/ziutek/mymysql/godrv](https://github.com/ziutek/mymysql/godrv) + +* SQLite: [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3) + +* Postgres: [github.com/bylevel/pq](https://github.com/bylevel/pq) + + +## Reverse + +After you installed the tool, you can type + +`xorm help reverse` + +to get help + +example: + +`xorm reverse sqite3 test.db templates/goxorm` + +will generated go files in `./model` directory + +## LICENSE + + BSD License + [http://creativecommons.org/licenses/BSD/](http://creativecommons.org/licenses/BSD/) diff --git a/xorm/reverse.go b/xorm/reverse.go index 8725143c..37e84e79 100644 --- a/xorm/reverse.go +++ b/xorm/reverse.go @@ -56,7 +56,7 @@ func runReverse(cmd *Command, args []string) { args = args[num:] if len(args) < 3 { - fmt.Println("no") + fmt.Println("params error, please see xorm help reverse") return }