From d1fbf73fa601ceccb608f5afc3122ba377bd3428 Mon Sep 17 00:00:00 2001 From: linhaicheng Date: Tue, 20 Oct 2020 10:51:36 +0800 Subject: [PATCH 01/16] add note --- cmd/db2struct/build.sh | 29 +++++++++++++++++++++++++++++ cmd/db2struct/run.sh | 4 ++++ utils_mysql.go | 24 +++++++++++++++++------- 3 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 cmd/db2struct/build.sh create mode 100644 cmd/db2struct/run.sh diff --git a/cmd/db2struct/build.sh b/cmd/db2struct/build.sh new file mode 100644 index 0000000..ade5909 --- /dev/null +++ b/cmd/db2struct/build.sh @@ -0,0 +1,29 @@ + +#!/bin/bash -e + +name="db2struct" +start_seconds=$(date +%s); + +#export CGO_ENABLED="0" +export GO111MODULE=on +go build -o $name main.go + +if [ $? -ne 0 ];then + end_seconds=$(date +%s); + echo + echo "---> build time: "$((end_seconds-start_seconds))"s, build error!!!" + echo + exit 1 +else + end_seconds=$(date +%s); + echo + ls -lt |grep $name + echo + echo "Build Success,took "$((end_seconds-start_seconds))"s" + echo + exit 0 +fi + + + + diff --git a/cmd/db2struct/run.sh b/cmd/db2struct/run.sh new file mode 100644 index 0000000..784dc90 --- /dev/null +++ b/cmd/db2struct/run.sh @@ -0,0 +1,4 @@ +sh build.sh +echo +db2struct --host localhost -d test -t test_table --package myGoPackage --struct testTable -p --user testUser +echo diff --git a/utils_mysql.go b/utils_mysql.go index 261d70e..77604a3 100644 --- a/utils_mysql.go +++ b/utils_mysql.go @@ -30,7 +30,7 @@ func GetColumnsFromMysqlTable(mariadbUser string, mariadbPassword string, mariad // Store colum as map of maps columnDataTypes := make(map[string]map[string]string) // Select columnd data from INFORMATION_SCHEMA - columnDataTypeQuery := "SELECT COLUMN_NAME, COLUMN_KEY, DATA_TYPE, IS_NULLABLE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = ? AND table_name = ?" + columnDataTypeQuery := "SELECT COLUMN_NAME, COLUMN_KEY, DATA_TYPE, IS_NULLABLE,COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = ? AND table_name = ?" if Debug { fmt.Println("running: " + columnDataTypeQuery) @@ -53,9 +53,10 @@ func GetColumnsFromMysqlTable(mariadbUser string, mariadbPassword string, mariad var columnKey string var dataType string var nullable string - rows.Scan(&column, &columnKey, &dataType, &nullable) + var comment string + rows.Scan(&column, &columnKey, &dataType, &nullable,&comment) - columnDataTypes[column] = map[string]string{"value": dataType, "nullable": nullable, "primary": columnKey} + columnDataTypes[column] = map[string]string{"value": dataType, "nullable": nullable, "primary": columnKey,"comment":comment} } return &columnDataTypes, err @@ -97,18 +98,27 @@ func generateMysqlTypes(obj map[string]map[string]string, depth int, jsonAnnotat if jsonAnnotation == true { annotations = append(annotations, fmt.Sprintf("json:\"%s\"", key)) } + var note string + if mysqlType["comment"] != "" { + note = fmt.Sprintf(" // %s", mysqlType["comment"]) + } if len(annotations) > 0 { - structure += fmt.Sprintf("\n%s %s `%s`", + structure += fmt.Sprintf("\n\t%s %s `%s` %s", fieldName, valueType, - strings.Join(annotations, " ")) + strings.Join(annotations, " "), + note) } else { - structure += fmt.Sprintf("\n%s %s", + structure += fmt.Sprintf("\n\t%s %s %s", fieldName, - valueType) + valueType, + note) } + + } + structure = structure + "\n" return structure } From b03eccf092161084cc16cbaac55ab396b05fec6c Mon Sep 17 00:00:00 2001 From: linhaicheng Date: Tue, 20 Oct 2020 11:57:56 +0800 Subject: [PATCH 02/16] add jsonconv.go --- cmd/db2struct/build.sh => build.sh | 2 +- cmd/db2struct/run.sh | 4 - go.mod | 15 ++-- go.sum | 10 ++- jsonconv.go | 132 +++++++++++++++++++++++++++++ run.sh | 4 + utils_mysql.go | 3 +- 7 files changed, 156 insertions(+), 14 deletions(-) rename cmd/db2struct/build.sh => build.sh (90%) delete mode 100644 cmd/db2struct/run.sh create mode 100644 jsonconv.go create mode 100644 run.sh diff --git a/cmd/db2struct/build.sh b/build.sh similarity index 90% rename from cmd/db2struct/build.sh rename to build.sh index ade5909..2bd837a 100644 --- a/cmd/db2struct/build.sh +++ b/build.sh @@ -6,7 +6,7 @@ start_seconds=$(date +%s); #export CGO_ENABLED="0" export GO111MODULE=on -go build -o $name main.go +go build -o $name cmd/db2struct/main.go if [ $? -ne 0 ];then end_seconds=$(date +%s); diff --git a/cmd/db2struct/run.sh b/cmd/db2struct/run.sh deleted file mode 100644 index 784dc90..0000000 --- a/cmd/db2struct/run.sh +++ /dev/null @@ -1,4 +0,0 @@ -sh build.sh -echo -db2struct --host localhost -d test -t test_table --package myGoPackage --struct testTable -p --user testUser -echo diff --git a/go.mod b/go.mod index 8ddf5dc..aeccfd3 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,13 @@ -module github.com/Shelnutt2/db2struct +module hktk1001/db2struct -go 1.12 +go 1.15 require ( - github.com/droundy/goopt v0.0.0-20170604162106-0b8effe182da - github.com/go-sql-driver/mysql v1.4.1 - github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c - golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect + github.com/Shelnutt2/db2struct v1.0.1 // indirect + github.com/droundy/goopt v0.0.0-20170604162106-0b8effe182da // indirect + github.com/go-sql-driver/mysql v1.5.0 // indirect + github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c // indirect + golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 // indirect ) + +replace github.com/Shelnutt2/db2struct => ../db2struct diff --git a/go.sum b/go.sum index 87ad056..0fff2b7 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,18 @@ +github.com/Shelnutt2/db2struct v1.0.1 h1:Oii1GccL6nP1fmZgvtgaJf8UxTeD/fp5Y3oxl0CvjI4= +github.com/Shelnutt2/db2struct v1.0.1/go.mod h1:MNUMe6GxylqpbA7M9s1nVtlTmJAfaIeo94uEeaIWXHk= github.com/droundy/goopt v0.0.0-20170604162106-0b8effe182da h1:79H+mNJWOObWrQgbkSvvZ3t/D2lKWaTi9mu/v7fNRvg= github.com/droundy/goopt v0.0.0-20170604162106-0b8effe182da/go.mod h1:ytRJ64WkuW4kf6/tuYqBATBCRFUP8X9+LDtgcvE+koI= -github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= -github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c h1:kQWxfPIHVLbgLzphqk3QUflDy9QdksZR4ygR807bpy0= +github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= +github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs= +github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c h1:aY2hhxLhjEAbfXOx2nRJxCXezC6CO2V/yN+OCr1srtk= +github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E= +golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= diff --git a/jsonconv.go b/jsonconv.go new file mode 100644 index 0000000..d899232 --- /dev/null +++ b/jsonconv.go @@ -0,0 +1,132 @@ +package db2struct + +import ( + "bytes" + "encoding/json" + "log" + "regexp" + "strconv" + "strings" + "unicode" +) + +/*************************************** 下划线json ***************************************/ +type JsonSnakeCase struct { + Value interface{} +} + +func (c JsonSnakeCase) MarshalJSON() ([]byte, error) { + // Regexp definitions + var keyMatchRegex = regexp.MustCompile(`\"(\w+)\":`) + var wordBarrierRegex = regexp.MustCompile(`(\w)([A-Z])`) + marshalled, err := json.Marshal(c.Value) + converted := keyMatchRegex.ReplaceAllFunc( + marshalled, + func(match []byte) []byte { + return bytes.ToLower(wordBarrierRegex.ReplaceAll( + match, + []byte(`${1}_${2}`), + )) + }, + ) + return converted, err +} + +/*************************************** 驼峰json ***************************************/ +type JsonCamelCase struct { + Value interface{} +} + +func (c JsonCamelCase) MarshalJSON() ([]byte, error) { + var keyMatchRegex = regexp.MustCompile(`\"(\w+)\":`) + marshalled, err := json.Marshal(c.Value) + converted := keyMatchRegex.ReplaceAllFunc( + marshalled, + func(match []byte) []byte { + matchStr := string(match) + key := matchStr[1 : len(matchStr)-2] + resKey := Lcfirst(Case2Camel(key)) + return []byte(`"` + resKey + `":`) + }, + ) + return converted, err +} + +/*************************************** 其他方法 ***************************************/ +// 驼峰式写法转为下划线写法 +func Camel2Case(name string) string { + buffer := NewBuffer() + for i, r := range name { + if unicode.IsUpper(r) { + if i != 0 { + buffer.Append('_') + } + buffer.Append(unicode.ToLower(r)) + } else { + buffer.Append(r) + } + } + return buffer.String() +} + +// 下划线写法转为驼峰写法 +func Case2Camel(name string) string { + name = strings.Replace(name, "_", " ", -1) + name = strings.Title(name) + return strings.Replace(name, " ", "", -1) +} + +// 首字母大写 +func Ucfirst(str string) string { + for i, v := range str { + return string(unicode.ToUpper(v)) + str[i+1:] + } + return "" +} + +// 首字母小写 +func Lcfirst(str string) string { + for i, v := range str { + return string(unicode.ToLower(v)) + str[i+1:] + } + return "" +} + +// 内嵌bytes.Buffer,支持连写 +type Buffer struct { + *bytes.Buffer +} + +func NewBuffer() *Buffer { + return &Buffer{Buffer: new(bytes.Buffer)} +} + +func (b *Buffer) Append(i interface{}) *Buffer { + switch val := i.(type) { + case int: + b.append(strconv.Itoa(val)) + case int64: + b.append(strconv.FormatInt(val, 10)) + case uint: + b.append(strconv.FormatUint(uint64(val), 10)) + case uint64: + b.append(strconv.FormatUint(val, 10)) + case string: + b.append(val) + case []byte: + b.Write(val) + case rune: + b.WriteRune(val) + } + return b +} + +func (b *Buffer) append(s string) *Buffer { + defer func() { + if err := recover(); err != nil { + log.Println("*****内存不够了!******") + } + }() + b.WriteString(s) + return b +} \ No newline at end of file diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..15fdc5e --- /dev/null +++ b/run.sh @@ -0,0 +1,4 @@ +sh build.sh +echo +./db2struct --host localhost -d test -t test_table --package myGoPackage --struct testTable -p --user testUser +echo diff --git a/utils_mysql.go b/utils_mysql.go index 77604a3..657657d 100644 --- a/utils_mysql.go +++ b/utils_mysql.go @@ -96,7 +96,8 @@ func generateMysqlTypes(obj map[string]map[string]string, depth int, jsonAnnotat annotations = append(annotations, fmt.Sprintf("gorm:\"column:%s%s\"", key, primary)) } if jsonAnnotation == true { - annotations = append(annotations, fmt.Sprintf("json:\"%s\"", key)) + res :=Lcfirst(Case2Camel(key)) + annotations = append(annotations, fmt.Sprintf("json:\"%s\"", res)) } var note string if mysqlType["comment"] != "" { From 4dec1c181929b5d575b5dadccaa8e5f23ba89a14 Mon Sep 17 00:00:00 2001 From: linhaicheng Date: Tue, 27 Oct 2020 09:12:09 +0800 Subject: [PATCH 03/16] add --- run.sh | 24 +++++++++++++++++++++--- utils.go | 24 ++++++++++++++++-------- utils_mysql.go | 15 ++++++++++++++- 3 files changed, 51 insertions(+), 12 deletions(-) diff --git a/run.sh b/run.sh index 15fdc5e..af17359 100644 --- a/run.sh +++ b/run.sh @@ -1,4 +1,22 @@ -sh build.sh -echo -./db2struct --host localhost -d test -t test_table --package myGoPackage --struct testTable -p --user testUser +#sh build.sh echo + + +path="/f/code/go/src/mis/internal/" + +pwd=$IMPORT_DB_PWD + +function create() { + table=$1 + st=$2 + ./db2struct --host 192.168.67.9 -d clerk -t $table --package model --struct $st -p $pwd --user root --json --gorm >$path/model/$table.go + echo "create table $table to struct $st " + cat $path/model/$table.go +} +echo "start..." + + +create "mis_import_history" "MisImportHistory" + +echo "success, please open $path" + diff --git a/utils.go b/utils.go index 88f341e..8e2d1ae 100644 --- a/utils.go +++ b/utils.go @@ -11,18 +11,18 @@ import ( // Constants for return types of golang const ( golangByteArray = "[]byte" - gureguNullInt = "null.Int" - sqlNullInt = "sql.NullInt64" + gureguNullInt = "int" + sqlNullInt = "int64" golangInt = "int" golangInt64 = "int64" - gureguNullFloat = "null.Float" - sqlNullFloat = "sql.NullFloat64" + gureguNullFloat = "float" + sqlNullFloat = "float64" golangFloat = "float" golangFloat32 = "float32" golangFloat64 = "float64" - gureguNullString = "null.String" - sqlNullString = "sql.NullString" - gureguNullTime = "null.Time" + gureguNullString = "string" + sqlNullString = "string" + gureguNullTime = "time.Time" golangTime = "time.Time" ) @@ -84,8 +84,16 @@ var Debug = false func Generate(columnTypes map[string]map[string]string, tableName string, structName string, pkgName string, jsonAnnotation bool, gormAnnotation bool, gureguTypes bool) ([]byte, error) { var dbTypes string dbTypes = generateMysqlTypes(columnTypes, 0, jsonAnnotation, gormAnnotation, gureguTypes) - src := fmt.Sprintf("package %s\ntype %s %s}", + + strImport:=`import ( + "github.com/jinzhu/gorm" + _ "github.com/jinzhu/gorm/dialects/mysql" + )` + + + src := fmt.Sprintf("package %s\n\n%s\n\ntype %s %s}", pkgName, + strImport, structName, dbTypes) if gormAnnotation == true { diff --git a/utils_mysql.go b/utils_mysql.go index 657657d..0bc398f 100644 --- a/utils_mysql.go +++ b/utils_mysql.go @@ -64,7 +64,7 @@ func GetColumnsFromMysqlTable(mariadbUser string, mariadbPassword string, mariad // Generate go struct entries for a map[string]interface{} structure func generateMysqlTypes(obj map[string]map[string]string, depth int, jsonAnnotation bool, gormAnnotation bool, gureguTypes bool) string { - structure := "struct {" + structure := "struct {\n\tgorm.Model" keys := make([]string, 0, len(obj)) for key := range obj { @@ -99,10 +99,23 @@ func generateMysqlTypes(obj map[string]map[string]string, depth int, jsonAnnotat res :=Lcfirst(Case2Camel(key)) annotations = append(annotations, fmt.Sprintf("json:\"%s\"", res)) } + + var note string if mysqlType["comment"] != "" { note = fmt.Sprintf(" // %s", mysqlType["comment"]) } + + var key string + keys:=strings.Split(mysqlType["comment"], " ") + if len(keys)>0 { + key = keys[0] + }else { + key = mysqlType["comment"] + } + annotations = append(annotations, fmt.Sprintf("key:\"%s\"",key )) + + if len(annotations) > 0 { structure += fmt.Sprintf("\n\t%s %s `%s` %s", fieldName, From f9ce46a24ae534eda8c8310228a17b8b387a7c88 Mon Sep 17 00:00:00 2001 From: linhaicheng Date: Fri, 30 Oct 2020 14:58:41 +0800 Subject: [PATCH 04/16] add key --- run.sh | 4 +++- utils_mysql.go | 20 +++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/run.sh b/run.sh index af17359..c436589 100644 --- a/run.sh +++ b/run.sh @@ -16,7 +16,9 @@ function create() { echo "start..." -create "mis_import_history" "MisImportHistory" +#create "mis_import_history" "MisImportHistory" +create "mis_flows" "MisFlows" +create "mis_flow_Template" "MisFlowTemplate" echo "success, please open $path" diff --git a/utils_mysql.go b/utils_mysql.go index 0bc398f..731a7b2 100644 --- a/utils_mysql.go +++ b/utils_mysql.go @@ -96,24 +96,26 @@ func generateMysqlTypes(obj map[string]map[string]string, depth int, jsonAnnotat annotations = append(annotations, fmt.Sprintf("gorm:\"column:%s%s\"", key, primary)) } if jsonAnnotation == true { - res :=Lcfirst(Case2Camel(key)) + res := Lcfirst(Case2Camel(key)) annotations = append(annotations, fmt.Sprintf("json:\"%s\"", res)) } - var note string if mysqlType["comment"] != "" { note = fmt.Sprintf(" // %s", mysqlType["comment"]) } - var key string - keys:=strings.Split(mysqlType["comment"], " ") - if len(keys)>0 { - key = keys[0] - }else { - key = mysqlType["comment"] + keyAnnotation := false + if keyAnnotation == true { + var key string + keys := strings.Split(mysqlType["comment"], " ") + if len(keys) > 0 { + key = keys[0] + } else { + key = mysqlType["comment"] + } + annotations = append(annotations, fmt.Sprintf("key:\"%s\"", key)) } - annotations = append(annotations, fmt.Sprintf("key:\"%s\"",key )) if len(annotations) > 0 { From 876f8a702be505cecbdc7a5f67f4864ecc7668c9 Mon Sep 17 00:00:00 2001 From: linhaicheng Date: Thu, 3 Dec 2020 18:10:11 +0800 Subject: [PATCH 05/16] add some --- run.sh | 38 +++++++++++++++++++++++++++++++----- utils.go | 53 +++++++++++++++++++++++++++++++++++++++++++------- utils_mysql.go | 22 ++++++++++++++------- 3 files changed, 94 insertions(+), 19 deletions(-) diff --git a/run.sh b/run.sh index c436589..29515ec 100644 --- a/run.sh +++ b/run.sh @@ -2,23 +2,51 @@ echo -path="/f/code/go/src/mis/internal/" +#path="/f/code/go/src/mis/internal/" +#path="/c/Users/admin/Desktop" +path="/f/code/go/src/oms/internal" + pwd=$IMPORT_DB_PWD +#dbname="clerk" +dbname="oms" function create() { table=$1 st=$2 - ./db2struct --host 192.168.67.9 -d clerk -t $table --package model --struct $st -p $pwd --user root --json --gorm >$path/model/$table.go - echo "create table $table to struct $st " + ./db2struct --host 192.168.67.9 -d $dbname -t $table --package model --struct $st -p $pwd --user root --json --gorm >$path/model/$table.go + #./db2struct --host 192.168.67.9 -d information_schema -t $table --package model --struct $st -p $pwd --user root --json --gorm >$path/model/$table.go + echo "create table $table to struct $st $pwd" cat $path/model/$table.go } echo "start..." #create "mis_import_history" "MisImportHistory" -create "mis_flows" "MisFlows" -create "mis_flow_Template" "MisFlowTemplate" +#create "mis_flows" "MisFlows" +#create "mis_flow_template" "MisFlowTemplate" + +#create "ats_detail" "AtsDetail" +#create "ats_monthly" "AtsMonthly" + +#create "mis_wage_tax" "MisWageTax" +#create "mis_user_info" "MisUserInfo" +#create "mis_lock" "MisLock" +#create "COLUMNS" "TColumn" + +#oms=== +create "cluster" "OmsCluster" +create "config" "OmsConfig" +create "config_history" "OmsConfigHistory" +create "env" "OmsEnv" +create "env_history" "OmsEnvHistory" +create "image" "OmsImage" +create "instance_groups" "OmsInstanceGroups" +create "package" "OmsPackage" +create "script" "OmsScript" +create "script_history" "OmsScriptHistory" +create "service_type" "OmsServiceType" + echo "success, please open $path" diff --git a/utils.go b/utils.go index 8e2d1ae..0ced63c 100644 --- a/utils.go +++ b/utils.go @@ -85,23 +85,27 @@ func Generate(columnTypes map[string]map[string]string, tableName string, struct var dbTypes string dbTypes = generateMysqlTypes(columnTypes, 0, jsonAnnotation, gormAnnotation, gureguTypes) - strImport:=`import ( + strImport := `import ( "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/mysql" )` - src := fmt.Sprintf("package %s\n\n%s\n\ntype %s %s}", pkgName, strImport, structName, dbTypes) if gormAnnotation == true { - tableNameFunc := "// TableName sets the insert table name for this struct type\n" + - "func (" + strings.ToLower(string(structName[0])) + " *" + structName + ") TableName() string {\n" + - " return \"" + tableName + "\"" + - "}" - src = fmt.Sprintf("%s\n%s", src, tableNameFunc) + //tableNameFunc := "// TableName sets the insert table name for this struct type\n" + + // //"func (" + strings.ToLower(string(structName[0])) + " *" + structName + ") TableName() string {\n" + + // GetStructTile(structName) + "TableName() string {\n" + + // " return \"" + tableName + "\"" + + // "}\n" + + var funList string + funList += GetTableNameFun(structName, tableName) + funList += GetDeleteFun(structName) + src = fmt.Sprintf("%s\n%s", src, funList) } formatted, err := format.Source([]byte(src)) if err != nil { @@ -110,6 +114,41 @@ func Generate(columnTypes map[string]map[string]string, tableName string, struct return formatted, err } +func GetStructTile(structName string) string { + str := "func (" + strings.ToLower(string(structName[0])) + " *" + structName + ") " + return str +} + +func GetTableNameFun(structName string, tableName string) string { + str := ` +// TableName 返回数据库名字 +func (pLock *MisLock) TableName() string { + return "mis_lock" +} +` + res := ReplaceFun(str, structName) + res = strings.ReplaceAll(res, "mis_lock", tableName) + return res +} + +func GetDeleteFun(structName string) string { + str := ` +// Delete 删除函数,根据ID删除数据 +func (pLock *MisLock) Delete() error { + return db.Engine().Delete(pLock).Error +} +` + return ReplaceFun(str, structName) +} + +func ReplaceFun(str string, structName string) string { + res := str + m := strings.ToLower(string(structName[0])) + res = strings.ReplaceAll(res, "MisLock", structName) + res = strings.ReplaceAll(res, "pLock", m) + return res +} + // fmtFieldName formats a string as a struct key // // Example: diff --git a/utils_mysql.go b/utils_mysql.go index 731a7b2..5a78049 100644 --- a/utils_mysql.go +++ b/utils_mysql.go @@ -54,9 +54,9 @@ func GetColumnsFromMysqlTable(mariadbUser string, mariadbPassword string, mariad var dataType string var nullable string var comment string - rows.Scan(&column, &columnKey, &dataType, &nullable,&comment) + rows.Scan(&column, &columnKey, &dataType, &nullable, &comment) - columnDataTypes[column] = map[string]string{"value": dataType, "nullable": nullable, "primary": columnKey,"comment":comment} + columnDataTypes[column] = map[string]string{"value": dataType, "nullable": nullable, "primary": columnKey, "comment": comment} } return &columnDataTypes, err @@ -64,7 +64,7 @@ func GetColumnsFromMysqlTable(mariadbUser string, mariadbPassword string, mariad // Generate go struct entries for a map[string]interface{} structure func generateMysqlTypes(obj map[string]map[string]string, depth int, jsonAnnotation bool, gormAnnotation bool, gureguTypes bool) string { - structure := "struct {\n\tgorm.Model" + structure := "struct {\n\tModel" keys := make([]string, 0, len(obj)) for key := range obj { @@ -73,6 +73,15 @@ func generateMysqlTypes(obj map[string]map[string]string, depth int, jsonAnnotat sort.Strings(keys) for _, key := range keys { + //fmt.Println("key============= ", key) + if gormAnnotation == true { // gorm 跳过 id , create_at等字段 + if key == "id" || + key == "create_at" || + key == "deleted_at" || + key == "update_at" { + continue + } + } mysqlType := obj[key] nullable := false if mysqlType["nullable"] == "YES" { @@ -96,7 +105,8 @@ func generateMysqlTypes(obj map[string]map[string]string, depth int, jsonAnnotat annotations = append(annotations, fmt.Sprintf("gorm:\"column:%s%s\"", key, primary)) } if jsonAnnotation == true { - res := Lcfirst(Case2Camel(key)) + //res := Lcfirst(Case2Camel(key)) // 驼峰 + res := key // 下划线 annotations = append(annotations, fmt.Sprintf("json:\"%s\"", res)) } @@ -105,7 +115,7 @@ func generateMysqlTypes(obj map[string]map[string]string, depth int, jsonAnnotat note = fmt.Sprintf(" // %s", mysqlType["comment"]) } - keyAnnotation := false + keyAnnotation := true if keyAnnotation == true { var key string keys := strings.Split(mysqlType["comment"], " ") @@ -117,7 +127,6 @@ func generateMysqlTypes(obj map[string]map[string]string, depth int, jsonAnnotat annotations = append(annotations, fmt.Sprintf("key:\"%s\"", key)) } - if len(annotations) > 0 { structure += fmt.Sprintf("\n\t%s %s `%s` %s", fieldName, @@ -132,7 +141,6 @@ func generateMysqlTypes(obj map[string]map[string]string, depth int, jsonAnnotat note) } - } structure = structure + "\n" return structure From cba7f6ccda566186b9470647edac802418d93746 Mon Sep 17 00:00:00 2001 From: linhaicheng Date: Fri, 4 Dec 2020 10:41:11 +0800 Subject: [PATCH 06/16] add save --- run.sh | 8 ++++++-- utils.go | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/run.sh b/run.sh index 29515ec..cd4453c 100644 --- a/run.sh +++ b/run.sh @@ -35,16 +35,20 @@ echo "start..." #create "COLUMNS" "TColumn" #oms=== +create "brand" "OmsBrand" create "cluster" "OmsCluster" -create "config" "OmsConfig" -create "config_history" "OmsConfigHistory" +create "configure" "OmsConfigure" +create "configure_history" "OmsConfigureHistory" +create "ecs" "OmsEcs" create "env" "OmsEnv" create "env_history" "OmsEnvHistory" create "image" "OmsImage" +create "instance" "OmsInstance" create "instance_groups" "OmsInstanceGroups" create "package" "OmsPackage" create "script" "OmsScript" create "script_history" "OmsScriptHistory" +create "security_group" "OmsSecurityGroup" create "service_type" "OmsServiceType" diff --git a/utils.go b/utils.go index 0ced63c..87e8f1d 100644 --- a/utils.go +++ b/utils.go @@ -22,8 +22,8 @@ const ( golangFloat64 = "float64" gureguNullString = "string" sqlNullString = "string" - gureguNullTime = "time.Time" - golangTime = "time.Time" + gureguNullTime = "ctime.Time" + golangTime = "ctime.Time" ) // commonInitialisms is a set of common initialisms. @@ -86,7 +86,7 @@ func Generate(columnTypes map[string]map[string]string, tableName string, struct dbTypes = generateMysqlTypes(columnTypes, 0, jsonAnnotation, gormAnnotation, gureguTypes) strImport := `import ( - "github.com/jinzhu/gorm" + "oms/pkg/db" _ "github.com/jinzhu/gorm/dialects/mysql" )` @@ -105,6 +105,7 @@ func Generate(columnTypes map[string]map[string]string, tableName string, struct var funList string funList += GetTableNameFun(structName, tableName) funList += GetDeleteFun(structName) + funList += GetSaveFun(structName) src = fmt.Sprintf("%s\n%s", src, funList) } formatted, err := format.Source([]byte(src)) @@ -141,6 +142,16 @@ func (pLock *MisLock) Delete() error { return ReplaceFun(str, structName) } +func GetSaveFun(structName string) string { + str := ` +// Save 保存、更新函数,id为0新建数据,id不为0更新数据 +func (pLock *MisLock) Save() error { + return db.Engine().Save(pLock).Error +} +` + return ReplaceFun(str, structName) +} + func ReplaceFun(str string, structName string) string { res := str m := strings.ToLower(string(structName[0])) From 0f3cbef16a212d24a4be2bdc9dd29e0883e9f211 Mon Sep 17 00:00:00 2001 From: linhaicheng Date: Thu, 7 Jan 2021 10:52:57 +0800 Subject: [PATCH 07/16] test --- run.sh | 48 ++++++++++++++++++++++++++---------------------- utils.go | 16 +++++++++++++++- utils_mysql.go | 6 +++--- 3 files changed, 44 insertions(+), 26 deletions(-) diff --git a/run.sh b/run.sh index cd4453c..6382568 100644 --- a/run.sh +++ b/run.sh @@ -1,15 +1,15 @@ #sh build.sh echo - -#path="/f/code/go/src/mis/internal/" #path="/c/Users/admin/Desktop" -path="/f/code/go/src/oms/internal" +pwd=$IMPORT_DB_PWD -pwd=$IMPORT_DB_PWD -#dbname="clerk" -dbname="oms" +path="/f/code/go/src/mis/internal/" +dbname="clerk" + +#path="/f/code/go/src/oms/internal" +#dbname="oms" function create() { table=$1 @@ -34,23 +34,27 @@ echo "start..." #create "mis_lock" "MisLock" #create "COLUMNS" "TColumn" -#oms=== -create "brand" "OmsBrand" -create "cluster" "OmsCluster" -create "configure" "OmsConfigure" -create "configure_history" "OmsConfigureHistory" -create "ecs" "OmsEcs" -create "env" "OmsEnv" -create "env_history" "OmsEnvHistory" -create "image" "OmsImage" -create "instance" "OmsInstance" -create "instance_groups" "OmsInstanceGroups" -create "package" "OmsPackage" -create "script" "OmsScript" -create "script_history" "OmsScriptHistory" -create "security_group" "OmsSecurityGroup" -create "service_type" "OmsServiceType" +create "mis_hr_pwd" "MisHrPWD" +create "mis_wage_pwd" "MisWagePWD" + +#oms=== +#create "brand" "OmsBrand" +#create "cluster" "OmsCluster" +#create "configure" "OmsConfigure" +#create "configure_history" "OmsConfigureHistory" +#create "ecs" "OmsEcs" +#create "env" "OmsEnv" +#create "env_history" "OmsEnvHistory" +#create "image" "OmsImage" +#create "instance" "OmsInstance" +#create "instance_groups" "OmsInstanceGroups" +#create "package" "OmsPackage" +#create "script" "OmsScript" +#create "script_history" "OmsScriptHistory" +#create "security_group" "OmsSecurityGroup" +#create "service_type" "OmsServiceType" +# echo "success, please open $path" diff --git a/utils.go b/utils.go index 87e8f1d..cabd24b 100644 --- a/utils.go +++ b/utils.go @@ -86,7 +86,7 @@ func Generate(columnTypes map[string]map[string]string, tableName string, struct dbTypes = generateMysqlTypes(columnTypes, 0, jsonAnnotation, gormAnnotation, gureguTypes) strImport := `import ( - "oms/pkg/db" + "mis/pkg/db" _ "github.com/jinzhu/gorm/dialects/mysql" )` @@ -106,6 +106,7 @@ func Generate(columnTypes map[string]map[string]string, tableName string, struct funList += GetTableNameFun(structName, tableName) funList += GetDeleteFun(structName) funList += GetSaveFun(structName) + funList += GetFun(structName) src = fmt.Sprintf("%s\n%s", src, funList) } formatted, err := format.Source([]byte(src)) @@ -152,6 +153,19 @@ func (pLock *MisLock) Save() error { return ReplaceFun(str, structName) } +func GetFun(structName string) string { + str := ` +// GetByID 根据ID取值 +func (pLock *MisLock) GetByID() error { + if m.ID == 0 { + return fmt.Errorf("id can not be 0") + } + return db.Engine().Where("id=?",m.ID).First(pLock).Error +} +` + return ReplaceFun(str, structName) +} + func ReplaceFun(str string, structName string) string { res := str m := strings.ToLower(string(structName[0])) diff --git a/utils_mysql.go b/utils_mysql.go index 5a78049..e43638a 100644 --- a/utils_mysql.go +++ b/utils_mysql.go @@ -76,9 +76,9 @@ func generateMysqlTypes(obj map[string]map[string]string, depth int, jsonAnnotat //fmt.Println("key============= ", key) if gormAnnotation == true { // gorm 跳过 id , create_at等字段 if key == "id" || - key == "create_at" || + key == "created_at" || key == "deleted_at" || - key == "update_at" { + key == "updated_at" { continue } } @@ -105,7 +105,7 @@ func generateMysqlTypes(obj map[string]map[string]string, depth int, jsonAnnotat annotations = append(annotations, fmt.Sprintf("gorm:\"column:%s%s\"", key, primary)) } if jsonAnnotation == true { - //res := Lcfirst(Case2Camel(key)) // 驼峰 + //res := Lcfirst(Case2Camel(key)) // 驼峰 res := key // 下划线 annotations = append(annotations, fmt.Sprintf("json:\"%s\"", res)) } From 85b34075107cfd61c91271938d2ae3d47cf9ccdb Mon Sep 17 00:00:00 2001 From: hktk1001 Date: Thu, 7 Jan 2021 14:25:03 +0800 Subject: [PATCH 08/16] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 10 ++++++---- go.sum | 27 +++++++++++++++++++++++++++ readme_linhc.md | 5 +++++ run.sh | 45 +++++++++++++++++++++++++++++++++++---------- utils_mysql.go | 4 ++-- 5 files changed, 75 insertions(+), 16 deletions(-) create mode 100644 readme_linhc.md diff --git a/go.mod b/go.mod index aeccfd3..408feed 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,12 @@ module hktk1001/db2struct go 1.15 require ( - github.com/Shelnutt2/db2struct v1.0.1 // indirect - github.com/droundy/goopt v0.0.0-20170604162106-0b8effe182da // indirect - github.com/go-sql-driver/mysql v1.5.0 // indirect - github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c // indirect + github.com/Shelnutt2/db2struct v1.0.1 + github.com/droundy/goopt v0.0.0-20170604162106-0b8effe182da + github.com/go-sql-driver/mysql v1.5.0 + github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c + github.com/jinzhu/gorm v1.9.16 + github.com/smartystreets/goconvey v1.6.4 golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 // indirect ) diff --git a/go.sum b/go.sum index 0fff2b7..bc2a8e0 100644 --- a/go.sum +++ b/go.sum @@ -1,20 +1,47 @@ +github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/Shelnutt2/db2struct v1.0.1 h1:Oii1GccL6nP1fmZgvtgaJf8UxTeD/fp5Y3oxl0CvjI4= github.com/Shelnutt2/db2struct v1.0.1/go.mod h1:MNUMe6GxylqpbA7M9s1nVtlTmJAfaIeo94uEeaIWXHk= +github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= +github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/droundy/goopt v0.0.0-20170604162106-0b8effe182da h1:79H+mNJWOObWrQgbkSvvZ3t/D2lKWaTi9mu/v7fNRvg= github.com/droundy/goopt v0.0.0-20170604162106-0b8effe182da/go.mod h1:ytRJ64WkuW4kf6/tuYqBATBCRFUP8X9+LDtgcvE+koI= +github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs= github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c h1:aY2hhxLhjEAbfXOx2nRJxCXezC6CO2V/yN+OCr1srtk= github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs= +github.com/jinzhu/gorm v1.9.16 h1:+IyIjPEABKRpsu/F8OvDPy9fyQlgsg2luMV2ZIH5i5o= +github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E= golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= diff --git a/readme_linhc.md b/readme_linhc.md new file mode 100644 index 0000000..6e40bdb --- /dev/null +++ b/readme_linhc.md @@ -0,0 +1,5 @@ +# 使用说明 +# 调用命令 sh build.sh 编译 +# 请设置环境变量(数据库密码) IMPORT_DB_PWD +# sh run.sh 生成model文件 +# 如需要修改配置,请修改run.sh diff --git a/run.sh b/run.sh index 6382568..25930dc 100644 --- a/run.sh +++ b/run.sh @@ -1,27 +1,47 @@ -#sh build.sh + +echo +cat readme_linhc.md echo -#path="/c/Users/admin/Desktop" +#数据库host +dbhost="192.168.67.9" + +#库名 +dbname="clerk" + +#数据加密码 pwd=$IMPORT_DB_PWD +#生成的model存放目录 +path="/Users/linhaicheng/tmp/mis" -path="/f/code/go/src/mis/internal/" -dbname="clerk" +#path="/c/Users/admin/Desktop" +#path="/f/code/go/src/mis/internal/"run #path="/f/code/go/src/oms/internal" #dbname="oms" +#dbname="information_schema" + + if [ -z "$pwd" ];then + echo "请设置环境变量(数据库密码) IMPORT_DB_PWD 举个票子: export IMPORT_DB_PWD=\"xxx\"" + exit 1 + fi + + + +mkdir -p "$path/model" function create() { table=$1 st=$2 - ./db2struct --host 192.168.67.9 -d $dbname -t $table --package model --struct $st -p $pwd --user root --json --gorm >$path/model/$table.go - #./db2struct --host 192.168.67.9 -d information_schema -t $table --package model --struct $st -p $pwd --user root --json --gorm >$path/model/$table.go + ./db2struct --host $dbhost -d $dbname -t $table --package model --struct $st -p $pwd --user root --json --gorm >$path/model/$table.go + echo "file = $path/model/$table.go" echo "create table $table to struct $st $pwd" cat $path/model/$table.go } echo "start..." - +#mis------ #create "mis_import_history" "MisImportHistory" #create "mis_flows" "MisFlows" #create "mis_flow_template" "MisFlowTemplate" @@ -32,10 +52,15 @@ echo "start..." #create "mis_wage_tax" "MisWageTax" #create "mis_user_info" "MisUserInfo" #create "mis_lock" "MisLock" -#create "COLUMNS" "TColumn" +#create "COLUMNS" "TColumn"ls -create "mis_hr_pwd" "MisHrPWD" -create "mis_wage_pwd" "MisWagePWD" +#create "mis_hr_pwd" "MisHrPWD" +#create "mis_wage_pwd" "MisWagePWD" +create "mis_setting_allowance" "MisSettingAllowance" +create "mis_setting_ats" "MisSettingAts" +create "mis_setting_joblevel" "MisSettingJobLevel" +create "mis_user_info" "MisUserInfo" +create "mis_setting_severance" "MisSettingSeverance" #oms=== diff --git a/utils_mysql.go b/utils_mysql.go index e43638a..ec62fb1 100644 --- a/utils_mysql.go +++ b/utils_mysql.go @@ -105,8 +105,8 @@ func generateMysqlTypes(obj map[string]map[string]string, depth int, jsonAnnotat annotations = append(annotations, fmt.Sprintf("gorm:\"column:%s%s\"", key, primary)) } if jsonAnnotation == true { - //res := Lcfirst(Case2Camel(key)) // 驼峰 - res := key // 下划线 + res := Lcfirst(Case2Camel(key)) // 驼峰 + // res := key // 下划线 annotations = append(annotations, fmt.Sprintf("json:\"%s\"", res)) } From 0758fc72950b8504653cfabb4549360f58aad9ad Mon Sep 17 00:00:00 2001 From: hktk1001 Date: Tue, 12 Jan 2021 13:51:05 +0800 Subject: [PATCH 09/16] modify readme --- README.md | 93 +++---------------------------------------------------- run.sh | 13 +++++--- 2 files changed, 13 insertions(+), 93 deletions(-) diff --git a/README.md b/README.md index ea2827d..6e40bdb 100644 --- a/README.md +++ b/README.md @@ -1,88 +1,5 @@ -# db2struct [![Build Status](https://travis-ci.org/Shelnutt2/db2struct.svg?branch=master)](https://travis-ci.org/Shelnutt2/db2struct) [![Coverage Status](https://coveralls.io/repos/github/Shelnutt2/db2struct/badge.svg?branch=1-add-coveralls-support)](https://coveralls.io/github/Shelnutt2/db2struct?branch=1-add-coveralls-support) [![GoDoc](https://godoc.org/github.com/Shelnutt2/db2struct?status.svg)](https://godoc.org/github.com/Shelnutt2/db2struct) - -The db2struct package produces a usable golang struct from a given database table for use in a .go file. - -By reading details from the database about the column structure, db2struct generates a go compatible struct type -with the required column names, data types, and annotations. - -Generated datatypes include support for nullable columns [sql.NullX types](https://golang.org/pkg/database/sql/#NullBool) or [guregu null.X types](https://github.com/guregu/null) -and the expected basic built in go types. - -Db2Struct is based/inspired by the work of ChimeraCoder's gojson package -[gojson](https://github.com/ChimeraCoder/gojson) - - - -## Usage - -```BASH -go get github.com/Shelnutt2/db2struct/cmd/db2struct -db2struct --host localhost -d test -t test_table --package myGoPackage --struct testTable -p --user testUser -``` - -## Example - -MySQL table named users with four columns: id (int), user_name (varchar(255)), number_of_logins (int(11),nullable), and LAST_NAME (varchar(255), nullable) - -Example below uses guregu's null package, but without the option it procuded the sql.NullInt64 and so on. -```BASH -db2struct --host localhost -d example.com -t users --package example --struct user -p --user exampleUser --guregu --gorm -``` - -Output: -```GOLANG - -package example - -type User struct { - ID int `gorm:"column:id"` - UserName string `gorm:"column:user_name"` - NumberOfLogins null.Int `gorm:"column:number_of_logins"` - LastName null.String `gorm:"column:LAST_NAME"` -} -``` - -## Supported Databases - -Currently Supported -- MariaDB -- MySQL - -Planned Support -- PostgreSQL -- Oracle -- Microsoft SQL Server - -### MariaDB/MySQL - -Structures are created by querying the INFORMATION_SCHEMA.Columns table and then formatting the types, column names, -and metadata to create a usable go compatible struct type. - -#### Supported Datatypes - -Currently only a limited number of MariaDB/MySQL datatypes are supported. Initial support includes: -- tinyint (sql.NullInt64 or null.Int) -- int (sql.NullInt64 or null.Int) -- smallint (sql.NullInt64 or null.Int) -- mediumint (sql.NullInt64 or null.Int) -- bigint (sql.NullInt64 or null.Int) -- decimal (sql.NullFloat64 or null.Float) -- float (sql.NullFloat64 or null.Float) -- double (sql.NullFloat64 or null.Float) -- datetime (null.Time) -- time (null.Time) -- date (null.Time) -- timestamp (null.Time) -- var (sql.String or null.String) -- enum (sql.String or null.String) -- varchar (sql.String or null.String) -- longtext (sql.String or null.String) -- mediumtext (sql.String or null.String) -- text (sql.String or null.String) -- tinytext (sql.String or null.String) -- binary -- blob -- longblob -- mediumblob -- varbinary -- json +# 使用说明 +# 调用命令 sh build.sh 编译 +# 请设置环境变量(数据库密码) IMPORT_DB_PWD +# sh run.sh 生成model文件 +# 如需要修改配置,请修改run.sh diff --git a/run.sh b/run.sh index 25930dc..522ca0e 100644 --- a/run.sh +++ b/run.sh @@ -56,11 +56,14 @@ echo "start..." #create "mis_hr_pwd" "MisHrPWD" #create "mis_wage_pwd" "MisWagePWD" -create "mis_setting_allowance" "MisSettingAllowance" -create "mis_setting_ats" "MisSettingAts" -create "mis_setting_joblevel" "MisSettingJobLevel" -create "mis_user_info" "MisUserInfo" -create "mis_setting_severance" "MisSettingSeverance" +#create "mis_setting_allowance" "MisSettingAllowance" +#create "mis_setting_ats" "MisSettingAts" +#create "mis_setting_joblevel" "MisSettingJobLevel" +#create "mis_user_info" "MisUserInfo" +#create "mis_setting_severance" "MisSettingSeverance" +#create "mis_accident_judge" "MisAccidentJudge" + + #oms=== From 23974f2654e5cfefe07471734901bb6939da0d66 Mon Sep 17 00:00:00 2001 From: hktk1001 Date: Tue, 12 Jan 2021 13:55:14 +0800 Subject: [PATCH 10/16] modify readme --- README.md | 5 ++++- readme_linhc.md | 5 ++++- run.sh | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6e40bdb..76a07cb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # 使用说明 # 调用命令 sh build.sh 编译 # 请设置环境变量(数据库密码) IMPORT_DB_PWD +# 修改配置,请修改run.sh 中的create参数等 + +# create 表名 结构体名字 + # sh run.sh 生成model文件 -# 如需要修改配置,请修改run.sh diff --git a/readme_linhc.md b/readme_linhc.md index 6e40bdb..76a07cb 100644 --- a/readme_linhc.md +++ b/readme_linhc.md @@ -1,5 +1,8 @@ # 使用说明 # 调用命令 sh build.sh 编译 # 请设置环境变量(数据库密码) IMPORT_DB_PWD +# 修改配置,请修改run.sh 中的create参数等 + +# create 表名 结构体名字 + # sh run.sh 生成model文件 -# 如需要修改配置,请修改run.sh diff --git a/run.sh b/run.sh index 522ca0e..5a19216 100644 --- a/run.sh +++ b/run.sh @@ -41,6 +41,9 @@ function create() { } echo "start..." +#create 表名 结构体名字 +#create "mis_import_history" "MisImportHistory" + #mis------ #create "mis_import_history" "MisImportHistory" #create "mis_flows" "MisFlows" From d7c5604c88e5dc8e6a20d28a98d4134ff4c9b0ee Mon Sep 17 00:00:00 2001 From: hktk1001 Date: Tue, 12 Jan 2021 13:56:40 +0800 Subject: [PATCH 11/16] modify gitignore --- .gitignore | 3 +++ run.sh | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index daf913b..4bbb344 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ _testmain.go *.exe *.test *.prof +.vscode/ +db2struct +~/ diff --git a/run.sh b/run.sh index 5a19216..5306d0a 100644 --- a/run.sh +++ b/run.sh @@ -9,7 +9,7 @@ dbhost="192.168.67.9" #库名 dbname="clerk" -#数据加密码 +#数据密码 pwd=$IMPORT_DB_PWD #生成的model存放目录 From b138d06cf7093c38a26ddb8c032dd9d2954c1d09 Mon Sep 17 00:00:00 2001 From: hktk1001 Date: Wed, 17 Mar 2021 15:25:26 +0800 Subject: [PATCH 12/16] modify host --- README.md | 1 + readme_linhc.md | 1 + run.sh | 35 +++++++++-------------------------- 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 76a07cb..abc5c6d 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,5 @@ # create 表名 结构体名字 +# 保存run.sh后执行命令: # sh run.sh 生成model文件 diff --git a/readme_linhc.md b/readme_linhc.md index 76a07cb..abc5c6d 100644 --- a/readme_linhc.md +++ b/readme_linhc.md @@ -5,4 +5,5 @@ # create 表名 结构体名字 +# 保存run.sh后执行命令: # sh run.sh 生成model文件 diff --git a/run.sh b/run.sh index 5306d0a..402241d 100644 --- a/run.sh +++ b/run.sh @@ -4,7 +4,7 @@ cat readme_linhc.md echo #数据库host -dbhost="192.168.67.9" +dbhost=$IMPORT_DB_HOST #库名 dbname="clerk" @@ -27,6 +27,10 @@ path="/Users/linhaicheng/tmp/mis" exit 1 fi + if [ -z "$dbhost" ];then + echo "请设置环境变量(数据库host) IMPORT_DB_HOST 举个票子: export IMPORT_DB_HOST=\"xxx\"" + exit 1 + fi mkdir -p "$path/model" @@ -52,37 +56,16 @@ echo "start..." #create "ats_detail" "AtsDetail" #create "ats_monthly" "AtsMonthly" -#create "mis_wage_tax" "MisWageTax" -#create "mis_user_info" "MisUserInfo" -#create "mis_lock" "MisLock" -#create "COLUMNS" "TColumn"ls - -#create "mis_hr_pwd" "MisHrPWD" -#create "mis_wage_pwd" "MisWagePWD" -#create "mis_setting_allowance" "MisSettingAllowance" -#create "mis_setting_ats" "MisSettingAts" -#create "mis_setting_joblevel" "MisSettingJobLevel" -#create "mis_user_info" "MisUserInfo" -#create "mis_setting_severance" "MisSettingSeverance" #create "mis_accident_judge" "MisAccidentJudge" +#create "mis_holiday" "MisHoliday" +#create "ats_leave_detail" "MisAtsLeaveDetail" +#create "ats_duty" "AtsDuty" +create "ats_log" "AtsLog" #oms=== -#create "brand" "OmsBrand" -#create "cluster" "OmsCluster" -#create "configure" "OmsConfigure" -#create "configure_history" "OmsConfigureHistory" -#create "ecs" "OmsEcs" -#create "env" "OmsEnv" -#create "env_history" "OmsEnvHistory" -#create "image" "OmsImage" -#create "instance" "OmsInstance" -#create "instance_groups" "OmsInstanceGroups" -#create "package" "OmsPackage" -#create "script" "OmsScript" -#create "script_history" "OmsScriptHistory" #create "security_group" "OmsSecurityGroup" #create "service_type" "OmsServiceType" # From d0d595482a51a7fb9296d14089eacab3910b3a1f Mon Sep 17 00:00:00 2001 From: linhaicheng Date: Wed, 17 Mar 2021 15:49:33 +0800 Subject: [PATCH 13/16] modify run --- run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.sh b/run.sh index 402241d..f69ac74 100644 --- a/run.sh +++ b/run.sh @@ -70,5 +70,5 @@ create "ats_log" "AtsLog" #create "service_type" "OmsServiceType" # -echo "success, please open $path" +echo "success, please open $path/model" From ac8528412065f65394b4cb965d90772db2fcdaec Mon Sep 17 00:00:00 2001 From: linhaicheng Date: Fri, 19 Mar 2021 16:37:44 +0800 Subject: [PATCH 14/16] =?UTF-8?q?=E5=A2=9E=E5=8A=A0tmpfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/db2struct/main.go | 16 ++++- go.mod | 1 + go.sum | 38 +++++++++++ run.sh | 2 +- tmp_file/tmp_handle.go.tmp | 128 +++++++++++++++++++++++++++++++++++++ tmp_file/tmp_model.go.tmp | 62 ++++++++++++++++++ utils.go | 21 +++--- utils_tmp.go | 100 +++++++++++++++++++++++++++++ 8 files changed, 355 insertions(+), 13 deletions(-) create mode 100644 tmp_file/tmp_handle.go.tmp create mode 100644 tmp_file/tmp_model.go.tmp create mode 100644 utils_tmp.go diff --git a/cmd/db2struct/main.go b/cmd/db2struct/main.go index a6b85c6..1c9f836 100644 --- a/cmd/db2struct/main.go +++ b/cmd/db2struct/main.go @@ -21,6 +21,8 @@ var mariadbUser = goopt.String([]string{"-u", "--user"}, "user", "user to connec var verbose = goopt.Flag([]string{"-v", "--verbose"}, []string{}, "Enable verbose output", "") var packageName = goopt.String([]string{"--package"}, "", "name to set for package") var structName = goopt.String([]string{"--struct"}, "", "name to set for struct") +var projectName = goopt.String([]string{"--project"}, "", "name to set projectName") +var tableNote = goopt.String([]string{"--note"}, "", "table note 表-中文名") var jsonAnnotation = goopt.Flag([]string{"--json"}, []string{"--no-json"}, "Add json annotations (default)", "Disable json annotations") var gormAnnotation = goopt.Flag([]string{"--gorm"}, []string{}, "Add gorm annotations (tags)", "") @@ -99,8 +101,20 @@ func main() { if packageName == nil || *packageName == "" { *packageName = "newpackage" } + + tp := db2struct.TableParam{ + TableName: *mariadbTable, + StructName: *structName, + PkgName: *packageName, + JsonAnnotation: *jsonAnnotation, + GormAnnotation: *gormAnnotation, + GureguTypes: *gureguTypes, + TableNote: *tableNote, + ProjectName: *projectName, + } + // Generate struct string based on columnDataTypes - struc, err := db2struct.Generate(*columnDataTypes, *mariadbTable, *structName, *packageName, *jsonAnnotation, *gormAnnotation, *gureguTypes) + struc, err := db2struct.Generate(*columnDataTypes, &tp) if err != nil { fmt.Println("Error in creating struct from json: " + err.Error()) diff --git a/go.mod b/go.mod index 408feed..8c07f3c 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.15 require ( github.com/Shelnutt2/db2struct v1.0.1 github.com/droundy/goopt v0.0.0-20170604162106-0b8effe182da + github.com/gin-gonic/gin v1.6.3 github.com/go-sql-driver/mysql v1.5.0 github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c github.com/jinzhu/gorm v1.9.16 diff --git a/go.sum b/go.sum index bc2a8e0..7d884c4 100644 --- a/go.sum +++ b/go.sum @@ -2,14 +2,30 @@ github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBK github.com/Shelnutt2/db2struct v1.0.1 h1:Oii1GccL6nP1fmZgvtgaJf8UxTeD/fp5Y3oxl0CvjI4= github.com/Shelnutt2/db2struct v1.0.1/go.mod h1:MNUMe6GxylqpbA7M9s1nVtlTmJAfaIeo94uEeaIWXHk= github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/droundy/goopt v0.0.0-20170604162106-0b8effe182da h1:79H+mNJWOObWrQgbkSvvZ3t/D2lKWaTi9mu/v7fNRvg= github.com/droundy/goopt v0.0.0-20170604162106-0b8effe182da/go.mod h1:ytRJ64WkuW4kf6/tuYqBATBCRFUP8X9+LDtgcvE+koI= github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= +github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= +github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= +github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= +github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs= github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c h1:aY2hhxLhjEAbfXOx2nRJxCXezC6CO2V/yN+OCr1srtk= @@ -18,14 +34,29 @@ github.com/jinzhu/gorm v1.9.16 h1:+IyIjPEABKRpsu/F8OvDPy9fyQlgsg2luMV2ZIH5i5o= github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= +github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= +github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= +github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc= @@ -41,7 +72,14 @@ golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/run.sh b/run.sh index f69ac74..0ad8054 100644 --- a/run.sh +++ b/run.sh @@ -60,7 +60,7 @@ echo "start..." #create "mis_holiday" "MisHoliday" #create "ats_leave_detail" "MisAtsLeaveDetail" #create "ats_duty" "AtsDuty" -create "ats_log" "AtsLog" +create "package" "AtsLog" diff --git a/tmp_file/tmp_handle.go.tmp b/tmp_file/tmp_handle.go.tmp new file mode 100644 index 0000000..18176aa --- /dev/null +++ b/tmp_file/tmp_handle.go.tmp @@ -0,0 +1,128 @@ +package handler + +import ( + "oms/api" + "oms/internal/model" + "oms/internal/restful/ctx" + "oms/pkg/log" + + "github.com/gin-gonic/gin" +) + +type ReqMisLockGet struct { + ID uint +} + +// @Title updater +// @Description 程序包-获取 +// @Tags updater +// @Accept text/html +// @Produce json +// @Param id query int true "id" +// @Param X-Token header string true "登录token" +// @Success 200 {object} api.RespCommon +// @Router /oms/v1/updater/mis-lock [get] +func HandleMisLockGet(c *gin.Context) { + var req = ReqMisLockGet{} + var resp = &api.RespCommon{} + ctx.Context(c).HandleQuery(req, func() (err error) { + var p model.MisLock + p.ID = req.ID + err = p.GetByID() + if err != nil { + log.Error(err) + return err + } + resp.Data = &p + return nil + }, resp) +} + +// @Title updater +// @Summary 程序包-新增 +// @Tags updater +// @Param X-Token header string true "登录token" +// @Param req body model.MisLock true "程序包" +// @Success 200 {object} api.RespIDResult +// @Router /oms/v1/updater/mis-lock [post] +func HandleMisLockPost(c *gin.Context) { + var req model.MisLock + var resp api.RespIDResult + ctx.Context(c).HandleBindJSON(&req, func() error { + err := req.Save() + if err != nil { + log.Error(err) + return err + } + resp.Data.ID = req.ID + return nil + }, &resp) +} + +// @Title updater +// @Summary 程序包-修改 +// @Tags 升级 +// @Param X-Token header string true "登录token" +// @Param req body model.MisLock true "程序包" +// @Success 200 {object} api.RespIDResult +// @Router /oms/v1/updater/mis-lock [put] +func HandleMisLockPut(c *gin.Context) { + var req model.MisLock + var resp api.RespIDResult + ctx.Context(c).HandleBindJSON(&req, func() error { + err := req.Save() + if err != nil { + log.Error(err) + return err + } + resp.Data.ID = req.ID + return nil + }, &resp) +} + +// RespMisLockList 程序返回列表response +type RespMisLockList struct { + Code int32 `json:"code"` // 错误码 + Msg string `json:"msg"` // 错误消息 + Data struct { + Page model.Page `json:"page"` // 分页信息 + List []model.MisLock `json:"list"` // 数据 + } `json:"data,omitempty"` +} + +// @Title updater +// @Summary 程序包-获取列表(带分页) +// @Tags updater +// @Param page query int true "获取页码 基于1" +// @Param size query int true "每页条数" +// @Param order query string true "排序字段" +// @Param desc query int false "排列 0-升序(默认) 1-降序" +// @Param X-Token header string true "登录token" +// @Success 200 {object} RespMisLockList +// @Router /oms/v1/updater/mis-lock-list [get] +func HandleMisLockList(c *gin.Context) { + var req model.ReqMisLockList + ctx.Context(c).HandleList(&req, func() (interface{}, error) { + return model.GetMisLockList(&req) + }) +} + +// @Title updater +// @Summary 程序包-删除 +// @Tags updater +// @Param X-Token header string true "登录token" +// @Param id query int true "要删除的id" +// @Success 200 {object} api.RespCommon +// @Router /oms/v1/updater/mis-lock [delete] +func HandleMisLockDelete(c *gin.Context) { + var id int + ctx.Context(c).HandleID(&id, func() error { + m := model.MisLock{} + m.ID = uint(id) + err := m.Delete() + if err != nil { + log.Error(err) + } + return err + }) +} diff --git a/tmp_file/tmp_model.go.tmp b/tmp_file/tmp_model.go.tmp new file mode 100644 index 0000000..d93e020 --- /dev/null +++ b/tmp_file/tmp_model.go.tmp @@ -0,0 +1,62 @@ + + + + +// TableName 返回数据库名字 +func (pLock *MisLock) TableName() string { + return "mis_lock" +} + +// Delete 删除函数,根据ID删除数据 +func (pLock *MisLock) Delete() error { + return db.Engine().Delete(pLock).Error +} + +// Save 保存、更新函数,id为0新建数据,id不为0更新数据 +func (pLock *MisLock) Save() error { + return db.Engine().Save(pLock).Error +} + +// GetByID 根据ID取值 +func (pLock *MisLock) GetByID() error { + if pLock.ID == 0 { + return fmt.Errorf("id can not be 0") + } + return db.Engine().Where("id=?", pLock.ID).First(pLock).Error +} + +// GetAllList 获取全部数据列表不带分页 +func (pLock *MisLock) GetAllList() ([]*MisLock, error) { + var list []*MisLock + // todo 请修改列表查询条件 + err := db.Engine().Find(&list).Error + if gorm.IsRecordNotFoundError(err) { + return list, nil + } + if err != nil { + return list, err + } + return list, nil +} + +// ReqMisLockList 获取列表request(带分页) +type ReqMisLockList struct { + OrderPage +} + +// GetMisLockList 获取列表(带分页) +func GetMisLockList(req *ReqMisLockList) ([]*MisLock, error) { + var list []*MisLock + + whereConn := db.Engine().Where("1=1") + // todo 增加查询条件 + // if req.Check != 0 { + // whereConn = whereConn.Where("`check`=?", req.Check) + // } + + err := req.Paging(whereConn).Find(&list).Error + if gorm.IsRecordNotFoundError(err) { + return list, nil + } + return list, nil +} diff --git a/utils.go b/utils.go index cabd24b..2f8c0b1 100644 --- a/utils.go +++ b/utils.go @@ -81,21 +81,23 @@ var Debug = false // Generate Given a Column map with datatypes and a name structName, // attempts to generate a struct definition -func Generate(columnTypes map[string]map[string]string, tableName string, structName string, pkgName string, jsonAnnotation bool, gormAnnotation bool, gureguTypes bool) ([]byte, error) { +func Generate(columnTypes map[string]map[string]string, tp *TableParam) ([]byte, error) { var dbTypes string - dbTypes = generateMysqlTypes(columnTypes, 0, jsonAnnotation, gormAnnotation, gureguTypes) + dbTypes = generateMysqlTypes(columnTypes, 0, tp.JsonAnnotation, tp.GormAnnotation, tp.GureguTypes) strImport := `import ( + "fmt" + "mis/pkg/db" _ "github.com/jinzhu/gorm/dialects/mysql" )` src := fmt.Sprintf("package %s\n\n%s\n\ntype %s %s}", - pkgName, + tp.PkgName, strImport, - structName, + tp.StructName, dbTypes) - if gormAnnotation == true { + if tp.GormAnnotation == true { //tableNameFunc := "// TableName sets the insert table name for this struct type\n" + // //"func (" + strings.ToLower(string(structName[0])) + " *" + structName + ") TableName() string {\n" + // GetStructTile(structName) + "TableName() string {\n" + @@ -103,10 +105,7 @@ func Generate(columnTypes map[string]map[string]string, tableName string, struct // "}\n" var funList string - funList += GetTableNameFun(structName, tableName) - funList += GetDeleteFun(structName) - funList += GetSaveFun(structName) - funList += GetFun(structName) + funList = GetModelFromTmp(tp) src = fmt.Sprintf("%s\n%s", src, funList) } formatted, err := format.Source([]byte(src)) @@ -157,10 +156,10 @@ func GetFun(structName string) string { str := ` // GetByID 根据ID取值 func (pLock *MisLock) GetByID() error { - if m.ID == 0 { + if pLock.ID == 0 { return fmt.Errorf("id can not be 0") } - return db.Engine().Where("id=?",m.ID).First(pLock).Error + return db.Engine().Where("id=?",pLock.ID).First(pLock).Error } ` return ReplaceFun(str, structName) diff --git a/utils_tmp.go b/utils_tmp.go new file mode 100644 index 0000000..515e9a2 --- /dev/null +++ b/utils_tmp.go @@ -0,0 +1,100 @@ +package db2struct + +import ( + "fmt" + "io/ioutil" + "os" + "strings" +) + +// ReadFileMethod1 使用ioutil.ReadFile 直接从文件读取到 []byte中 +func ReadFile(fileName string) string { + f, err := ioutil.ReadFile(fileName) + if err != nil { + fmt.Printf("读取文件失败: %#v \n", err) + return "" + } + return string(f) +} + +func CopyFile(sourceFile string, destinationFile string) error { + input, err := ioutil.ReadFile(sourceFile) + if err != nil { + fmt.Println(err) + return err + } + + err = ioutil.WriteFile(destinationFile, input, 0644) + if err != nil { + fmt.Println("Error creating", destinationFile) + fmt.Println(err) + return err + } + return nil +} + +type TableParam struct { + ProjectName string + TableName string + StructName string + TableNote string + PkgName string + TmpPath string + JsonAnnotation bool + GormAnnotation bool + GureguTypes bool + HandlerUrl string +} + +func CreateHandleFileFromTemp(tp *TableParam) error { + tmpFile := "./tmp_file/tmp_handle.go.tmp" + // tmpFile := fmt.Sprintf("%s/tmp_file/tmp_handle.go.tmp", tp.TmpPath) + srcPath := fmt.Sprintf("/tmp/%s/handle", tp.ProjectName) + err := os.MkdirAll(srcPath, 0666) + if err != nil { + return err + } + newFile := fmt.Sprintf("%s/%s_handler.go", srcPath, tp.TableName) + CopyFile(newFile, newFile+".bak") // 备份文件 + + text := ReadFile(tmpFile) + text = ReplaceAllFun(text, tp) + + err = ioutil.WriteFile(newFile, []byte(text), 0644) + if err != nil { + fmt.Println("Error creating", newFile) + fmt.Println(err) + return err + } + return nil +} + +func ReplaceAllFun(str string, tp *TableParam) string { + text := str + m := strings.ToLower(string(tp.StructName[0])) + text = strings.ReplaceAll(text, "pLock", m) + text = strings.ReplaceAll(text, "handler", tp.PkgName) + text = strings.ReplaceAll(text, "MisLock", tp.StructName) + text = strings.ReplaceAll(text, "mis_lock", tp.TableName) + text = strings.ReplaceAll(text, "mis-lock", strings.ReplaceAll(tp.TableName, "_", "-")) // 下划线转- + text = strings.ReplaceAll(text, "程序包", tp.TableNote) + return text +} + +// 从tmp_model.go.tmp读取model模板 +func GetModelFromTmp(tp *TableParam) string { + // tmpFile := fmt.Sprintf("%s/tmp_file/tmp_model.go.tmp", tp.TmpPath) + // tmpFile := "/Users/linhaicheng/go/src/db2struct/tmp_file/tmp_model.go.tmp" + tmpFile := "./tmp_file/tmp_model.go.tmp" + srcPath := fmt.Sprintf("/tmp/%s/model", tp.ProjectName) + err := os.MkdirAll(srcPath, 0666) + if err != nil { + fmt.Println(err) + return "" + } + newFile := fmt.Sprintf("%s/%s.go", srcPath, tp.TableName) + CopyFile(newFile, newFile+".bak") // 备份文件 + text := ReadFile(tmpFile) + text = ReplaceAllFun(text, tp) + return text +} From 06cb6cf91a155f5549d6ca432cf313d91de15ddd Mon Sep 17 00:00:00 2001 From: linhaicheng Date: Mon, 22 Mar 2021 15:38:28 +0800 Subject: [PATCH 15/16] custom code --- cmd/db2struct/main.go | 62 ++++--- go.mod | 1 + go.sum | 364 ++++++++++++++++++++++++++++++++++++++ tmp_file/tmp_model.go.tmp | 4 +- utils.go | 61 +------ utils_mysql.go | 10 +- utils_tmp.go | 87 +++++++-- 7 files changed, 491 insertions(+), 98 deletions(-) diff --git a/cmd/db2struct/main.go b/cmd/db2struct/main.go index 1c9f836..f453bd0 100644 --- a/cmd/db2struct/main.go +++ b/cmd/db2struct/main.go @@ -86,13 +86,6 @@ func main() { return } - columnDataTypes, err := db2struct.GetColumnsFromMysqlTable(*mariadbUser, *mariadbPassword, mariadbHost, *mariadbPort, *mariadbDatabase, *mariadbTable) - - if err != nil { - fmt.Println("Error in selecting column data information from mysql information schema") - return - } - // If structName is not set we need to default it if structName == nil || *structName == "" { *structName = "newstruct" @@ -102,6 +95,15 @@ func main() { *packageName = "newpackage" } + dp := db2struct.DBParam{ + MariadbUser: *mariadbUser, + MariadbPassword: *mariadbPassword, + MariadbHost: mariadbHost, + MariadbPort: *mariadbPort, + MariadbDatabase: *mariadbDatabase, + MariadbTable: *mariadbTable, + } + tp := db2struct.TableParam{ TableName: *mariadbTable, StructName: *structName, @@ -113,32 +115,46 @@ func main() { ProjectName: *projectName, } + StartCreate(&tp, &dp) + +} + +func getMariadbPassword(password string) error { + mariadbPassword = new(string) + *mariadbPassword = password + return nil +} + +func StartCreate(tp *db2struct.TableParam, dp *db2struct.DBParam) error { + + columnDataTypes, err := db2struct.GetColumnsFromMysqlTable(dp) + if err != nil { + fmt.Println("Error in selecting column data information from mysql information schema") + return err + } + // Generate struct string based on columnDataTypes - struc, err := db2struct.Generate(*columnDataTypes, &tp) + struc, err := db2struct.Generate(*columnDataTypes, tp) if err != nil { fmt.Println("Error in creating struct from json: " + err.Error()) - return + return err } + var saveFile string if targetFile != nil && *targetFile != "" { - file, err := os.OpenFile(*targetFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + saveFile = *targetFile + "/model/" + tp.TableName + ".go" + length, err := db2struct.AutoSaveFile(saveFile, string(struc)) if err != nil { - fmt.Println("Open File fail: " + err.Error()) - return - } - length, err := file.WriteString(string(struc)) - if err != nil { - fmt.Println("Save File fail: " + err.Error()) - return + fmt.Println(err) + return err } fmt.Printf("wrote %d bytes\n", length) - } else { - fmt.Println(string(struc)) } -} + fmt.Println(string(struc)) + fmt.Println("") + fmt.Println("======================================") + fmt.Println("save model file to ", saveFile) + fmt.Println("") -func getMariadbPassword(password string) error { - mariadbPassword = new(string) - *mariadbPassword = password return nil } diff --git a/go.mod b/go.mod index 8c07f3c..4ad66db 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,7 @@ require ( github.com/go-sql-driver/mysql v1.5.0 github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c github.com/jinzhu/gorm v1.9.16 + github.com/prometheus/common v0.19.0 github.com/smartystreets/goconvey v1.6.4 golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 // indirect ) diff --git a/go.sum b/go.sum index 7d884c4..1629717 100644 --- a/go.sum +++ b/go.sum @@ -1,17 +1,78 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/Shelnutt2/db2struct v1.0.1 h1:Oii1GccL6nP1fmZgvtgaJf8UxTeD/fp5Y3oxl0CvjI4= github.com/Shelnutt2/db2struct v1.0.1/go.mod h1:MNUMe6GxylqpbA7M9s1nVtlTmJAfaIeo94uEeaIWXHk= +github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= +github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= +github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E= +github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= +github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= +github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= +github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= +github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= +github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= +github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/droundy/goopt v0.0.0-20170604162106-0b8effe182da h1:79H+mNJWOObWrQgbkSvvZ3t/D2lKWaTi9mu/v7fNRvg= github.com/droundy/goopt v0.0.0-20170604162106-0b8effe182da/go.mod h1:ytRJ64WkuW4kf6/tuYqBATBCRFUP8X9+LDtgcvE+koI= +github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= +github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= +github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= +github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= @@ -19,67 +80,370 @@ github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD87 github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= +github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= +github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= +github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= +github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs= github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c h1:aY2hhxLhjEAbfXOx2nRJxCXezC6CO2V/yN+OCr1srtk= github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/jinzhu/gorm v1.9.16 h1:+IyIjPEABKRpsu/F8OvDPy9fyQlgsg2luMV2ZIH5i5o= github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= +github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= +github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= +github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= +github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= +github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= +github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= +github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= +github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= +github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= +github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= +github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= +github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= +github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= +github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= +github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= +github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= +github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= +github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= +github.com/prometheus/common v0.19.0 h1:Itb4+NjG9wRdkAWgVucbM/adyIXxEhbw0866e0uZE6A= +github.com/prometheus/common v0.19.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= +github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= +github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= +go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= +go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= +go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E= golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/tmp_file/tmp_model.go.tmp b/tmp_file/tmp_model.go.tmp index d93e020..e994a15 100644 --- a/tmp_file/tmp_model.go.tmp +++ b/tmp_file/tmp_model.go.tmp @@ -1,7 +1,5 @@ - - // TableName 返回数据库名字 func (pLock *MisLock) TableName() string { return "mis_lock" @@ -25,7 +23,7 @@ func (pLock *MisLock) GetByID() error { return db.Engine().Where("id=?", pLock.ID).First(pLock).Error } -// GetAllList 获取全部数据列表不带分页 +// GetAllList 获取全部数据列表(不带分页) func (pLock *MisLock) GetAllList() ([]*MisLock, error) { var list []*MisLock // todo 请修改列表查询条件 diff --git a/utils.go b/utils.go index 2f8c0b1..021eb40 100644 --- a/utils.go +++ b/utils.go @@ -87,10 +87,12 @@ func Generate(columnTypes map[string]map[string]string, tp *TableParam) ([]byte, strImport := `import ( "fmt" - "mis/pkg/db" + + "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/mysql" )` + strImport = strings.ReplaceAll(strImport, "mis", tp.ProjectName) src := fmt.Sprintf("package %s\n\n%s\n\ntype %s %s}", tp.PkgName, @@ -98,12 +100,7 @@ func Generate(columnTypes map[string]map[string]string, tp *TableParam) ([]byte, tp.StructName, dbTypes) if tp.GormAnnotation == true { - //tableNameFunc := "// TableName sets the insert table name for this struct type\n" + - // //"func (" + strings.ToLower(string(structName[0])) + " *" + structName + ") TableName() string {\n" + - // GetStructTile(structName) + "TableName() string {\n" + - // " return \"" + tableName + "\"" + - // "}\n" - + // 获取函数模板 var funList string funList = GetModelFromTmp(tp) src = fmt.Sprintf("%s\n%s", src, funList) @@ -115,56 +112,6 @@ func Generate(columnTypes map[string]map[string]string, tp *TableParam) ([]byte, return formatted, err } -func GetStructTile(structName string) string { - str := "func (" + strings.ToLower(string(structName[0])) + " *" + structName + ") " - return str -} - -func GetTableNameFun(structName string, tableName string) string { - str := ` -// TableName 返回数据库名字 -func (pLock *MisLock) TableName() string { - return "mis_lock" -} -` - res := ReplaceFun(str, structName) - res = strings.ReplaceAll(res, "mis_lock", tableName) - return res -} - -func GetDeleteFun(structName string) string { - str := ` -// Delete 删除函数,根据ID删除数据 -func (pLock *MisLock) Delete() error { - return db.Engine().Delete(pLock).Error -} -` - return ReplaceFun(str, structName) -} - -func GetSaveFun(structName string) string { - str := ` -// Save 保存、更新函数,id为0新建数据,id不为0更新数据 -func (pLock *MisLock) Save() error { - return db.Engine().Save(pLock).Error -} -` - return ReplaceFun(str, structName) -} - -func GetFun(structName string) string { - str := ` -// GetByID 根据ID取值 -func (pLock *MisLock) GetByID() error { - if pLock.ID == 0 { - return fmt.Errorf("id can not be 0") - } - return db.Engine().Where("id=?",pLock.ID).First(pLock).Error -} -` - return ReplaceFun(str, structName) -} - func ReplaceFun(str string, structName string) string { res := str m := strings.ToLower(string(structName[0])) diff --git a/utils_mysql.go b/utils_mysql.go index ec62fb1..5d65af9 100644 --- a/utils_mysql.go +++ b/utils_mysql.go @@ -10,14 +10,14 @@ import ( ) // GetColumnsFromMysqlTable Select column details from information schema and return map of map -func GetColumnsFromMysqlTable(mariadbUser string, mariadbPassword string, mariadbHost string, mariadbPort int, mariadbDatabase string, mariadbTable string) (*map[string]map[string]string, error) { +func GetColumnsFromMysqlTable(dp *DBParam) (*map[string]map[string]string, error) { var err error var db *sql.DB - if mariadbPassword != "" { - db, err = sql.Open("mysql", mariadbUser+":"+mariadbPassword+"@tcp("+mariadbHost+":"+strconv.Itoa(mariadbPort)+")/"+mariadbDatabase+"?&parseTime=True") + if dp.MariadbPassword != "" { + db, err = sql.Open("mysql", dp.MariadbUser+":"+dp.MariadbPassword+"@tcp("+dp.MariadbHost+":"+strconv.Itoa(dp.MariadbPort)+")/"+dp.MariadbDatabase+"?&parseTime=True") } else { - db, err = sql.Open("mysql", mariadbUser+"@tcp("+mariadbHost+":"+strconv.Itoa(mariadbPort)+")/"+mariadbDatabase+"?&parseTime=True") + db, err = sql.Open("mysql", dp.MariadbUser+"@tcp("+dp.MariadbHost+":"+strconv.Itoa(dp.MariadbPort)+")/"+dp.MariadbDatabase+"?&parseTime=True") } defer db.Close() @@ -36,7 +36,7 @@ func GetColumnsFromMysqlTable(mariadbUser string, mariadbPassword string, mariad fmt.Println("running: " + columnDataTypeQuery) } - rows, err := db.Query(columnDataTypeQuery, mariadbDatabase, mariadbTable) + rows, err := db.Query(columnDataTypeQuery, dp.MariadbDatabase, dp.MariadbTable) if err != nil { fmt.Println("Error selecting from db: " + err.Error()) diff --git a/utils_tmp.go b/utils_tmp.go index 515e9a2..07a6386 100644 --- a/utils_tmp.go +++ b/utils_tmp.go @@ -5,6 +5,8 @@ import ( "io/ioutil" "os" "strings" + + "github.com/prometheus/common/log" ) // ReadFileMethod1 使用ioutil.ReadFile 直接从文件读取到 []byte中 @@ -33,6 +35,15 @@ func CopyFile(sourceFile string, destinationFile string) error { return nil } +type DBParam struct { + MariadbUser string + MariadbPassword string + MariadbHost string + MariadbPort int + MariadbDatabase string + MariadbTable string +} + type TableParam struct { ProjectName string TableName string @@ -78,23 +89,79 @@ func ReplaceAllFun(str string, tp *TableParam) string { text = strings.ReplaceAll(text, "mis_lock", tp.TableName) text = strings.ReplaceAll(text, "mis-lock", strings.ReplaceAll(tp.TableName, "_", "-")) // 下划线转- text = strings.ReplaceAll(text, "程序包", tp.TableNote) + text = strings.ReplaceAll(text, "mis", tp.ProjectName) + return text } // 从tmp_model.go.tmp读取model模板 func GetModelFromTmp(tp *TableParam) string { - // tmpFile := fmt.Sprintf("%s/tmp_file/tmp_model.go.tmp", tp.TmpPath) - // tmpFile := "/Users/linhaicheng/go/src/db2struct/tmp_file/tmp_model.go.tmp" tmpFile := "./tmp_file/tmp_model.go.tmp" - srcPath := fmt.Sprintf("/tmp/%s/model", tp.ProjectName) - err := os.MkdirAll(srcPath, 0666) - if err != nil { - fmt.Println(err) - return "" - } - newFile := fmt.Sprintf("%s/%s.go", srcPath, tp.TableName) - CopyFile(newFile, newFile+".bak") // 备份文件 text := ReadFile(tmpFile) text = ReplaceAllFun(text, tp) return text } + +// 自动保存文件 +// 根据 ----------custom-code---以下为用户代码:----------- +// 分隔文件 +// +func AutoSaveFile(fileName string, struc string) (int, error) { + + c, err := GetCustomCode(fileName) + if err != nil { + log.Error(err) + return 0, err + } + + file, err := os.OpenFile(fileName, os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + fmt.Println("Open File fail: " + err.Error()) + return 0, err + } + + allCode := struc + c.MyCode // 生成的代码+自定义的代码 + + length, err := file.WriteString(allCode) + if err != nil { + fmt.Println("Save File fail: " + err.Error()) + return 0, err + } + + return length, nil +} + +type CustomCode struct { + Lines []string + MyCode string +} + +// 根据 ----------custom-code-------------- +// 截出用户代码 +func GetCustomCode(fileName string) (*CustomCode, error) { + var c CustomCode + err := ReadByLine(fileName, &c) + if err != nil { + return nil, err + } + isAdd := false + for _, one := range c.Lines { + if strings.Contains(one, "----------custom-code-") { + isAdd = true + } + if isAdd { + c.MyCode += one + "\n" + } + } + return &c, nil +} + +func ReadByLine(fileName string, c *CustomCode) error { + + file_bytes, err := ioutil.ReadFile(fileName) + if err != nil { + return err + } + c.Lines = strings.Split(string(file_bytes), "\n") + return nil +} From 9881330db985e0e3848f52b4785c02a041ae3058 Mon Sep 17 00:00:00 2001 From: linhaicheng Date: Mon, 22 Mar 2021 16:00:59 +0800 Subject: [PATCH 16/16] modify run --- cmd/db2struct/main.go | 19 +++++++++------- run.sh | 52 +++++++++++++------------------------------ utils_tmp.go | 10 ++++----- 3 files changed, 32 insertions(+), 49 deletions(-) diff --git a/cmd/db2struct/main.go b/cmd/db2struct/main.go index f453bd0..42dc97b 100644 --- a/cmd/db2struct/main.go +++ b/cmd/db2struct/main.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "log" "os" "strconv" @@ -47,6 +48,8 @@ func init() { func main() { + log.SetFlags(log.Lshortfile | log.LstdFlags) + // Username is required if mariadbUser == nil || *mariadbUser == "user" { fmt.Println("Username is required! Add it with --user=name") @@ -64,7 +67,7 @@ func main() { stringPass := string(pass) mariadbPassword = &stringPass if err != nil { - fmt.Println("Error reading password: " + err.Error()) + log.Println("Error reading password: " + err.Error()) return } } else if mariadbPassword == nil { @@ -73,16 +76,16 @@ func main() { } if *verbose { - fmt.Println("Connecting to mysql server " + mariadbHost + ":" + strconv.Itoa(*mariadbPort)) + log.Println("Connecting to mysql server " + mariadbHost + ":" + strconv.Itoa(*mariadbPort)) } if mariadbDatabase == nil || *mariadbDatabase == "" { - fmt.Println("Database can not be null") + log.Println("Database can not be null") return } if mariadbTable == nil || *mariadbTable == "" { - fmt.Println("Table can not be null") + log.Println("Table can not be null") return } @@ -129,7 +132,7 @@ func StartCreate(tp *db2struct.TableParam, dp *db2struct.DBParam) error { columnDataTypes, err := db2struct.GetColumnsFromMysqlTable(dp) if err != nil { - fmt.Println("Error in selecting column data information from mysql information schema") + log.Println("Error in selecting column data information from mysql information schema") return err } @@ -137,7 +140,7 @@ func StartCreate(tp *db2struct.TableParam, dp *db2struct.DBParam) error { struc, err := db2struct.Generate(*columnDataTypes, tp) if err != nil { - fmt.Println("Error in creating struct from json: " + err.Error()) + log.Println("Error in creating struct from json: " + err.Error()) return err } var saveFile string @@ -145,10 +148,10 @@ func StartCreate(tp *db2struct.TableParam, dp *db2struct.DBParam) error { saveFile = *targetFile + "/model/" + tp.TableName + ".go" length, err := db2struct.AutoSaveFile(saveFile, string(struc)) if err != nil { - fmt.Println(err) + log.Println("open err: ", err) return err } - fmt.Printf("wrote %d bytes\n", length) + log.Printf("wrote %d bytes\n", length) } fmt.Println(string(struc)) fmt.Println("") diff --git a/run.sh b/run.sh index 0ad8054..bce1b00 100644 --- a/run.sh +++ b/run.sh @@ -1,3 +1,4 @@ +sh build.sh echo cat readme_linhc.md @@ -9,66 +10,45 @@ dbhost=$IMPORT_DB_HOST #库名 dbname="clerk" +#项目名 +projectname="mis" + #数据密码 pwd=$IMPORT_DB_PWD #生成的model存放目录 -path="/Users/linhaicheng/tmp/mis" +path="/Users/linhaicheng/go/src/mis/internal" -#path="/c/Users/admin/Desktop" -#path="/f/code/go/src/mis/internal/"run -#path="/f/code/go/src/oms/internal" -#dbname="oms" -#dbname="information_schema" if [ -z "$pwd" ];then echo "请设置环境变量(数据库密码) IMPORT_DB_PWD 举个票子: export IMPORT_DB_PWD=\"xxx\"" exit 1 fi - if [ -z "$dbhost" ];then - echo "请设置环境变量(数据库host) IMPORT_DB_HOST 举个票子: export IMPORT_DB_HOST=\"xxx\"" - exit 1 - fi mkdir -p "$path/model" function create() { + #表名 table=$1 + #结体体名字 st=$2 - ./db2struct --host $dbhost -d $dbname -t $table --package model --struct $st -p $pwd --user root --json --gorm >$path/model/$table.go - echo "file = $path/model/$table.go" - echo "create table $table to struct $st $pwd" - cat $path/model/$table.go + #表-中文名 + note=$3 + ./db2struct --host $dbhost -d $dbname -t $table --package model --struct $st --project $projectname --note $note --target $path -p $pwd --user root --json --gorm + #echo "file = $path/model/$table.go" + #echo "create table $table to struct $st $pwd" + #cat $path/model/$table.go } echo "start..." #create 表名 结构体名字 -#create "mis_import_history" "MisImportHistory" - -#mis------ -#create "mis_import_history" "MisImportHistory" -#create "mis_flows" "MisFlows" -#create "mis_flow_template" "MisFlowTemplate" - -#create "ats_detail" "AtsDetail" -#create "ats_monthly" "AtsMonthly" - -#create "mis_accident_judge" "MisAccidentJudge" -#create "mis_holiday" "MisHoliday" -#create "ats_leave_detail" "MisAtsLeaveDetail" -#create "ats_duty" "AtsDuty" -create "package" "AtsLog" - - - -#oms=== -#create "security_group" "OmsSecurityGroup" -#create "service_type" "OmsServiceType" -# +#mis=== +#create "service_type" "misServiceType" +create "mis_setting_ats" "MisSettingAts" "考勤设置" echo "success, please open $path/model" diff --git a/utils_tmp.go b/utils_tmp.go index 07a6386..def68c9 100644 --- a/utils_tmp.go +++ b/utils_tmp.go @@ -114,14 +114,14 @@ func AutoSaveFile(fileName string, struc string) (int, error) { return 0, err } + var allCode string file, err := os.OpenFile(fileName, os.O_CREATE|os.O_WRONLY, 0644) - if err != nil { - fmt.Println("Open File fail: " + err.Error()) - return 0, err + if err != nil { // 原文件不存在 + allCode = struc + } else { + allCode = struc + c.MyCode // 生成的代码+自定义的代码 } - allCode := struc + c.MyCode // 生成的代码+自定义的代码 - length, err := file.WriteString(allCode) if err != nil { fmt.Println("Save File fail: " + err.Error())