diff --git a/go.mod b/go.mod index 31dfb1d0..d86629dd 100644 --- a/go.mod +++ b/go.mod @@ -2,19 +2,21 @@ module github.com/xo/xo require ( github.com/alexflint/go-arg v1.3.0 - github.com/denisenkom/go-mssqldb v0.0.0-20200206145737-bbfc9a55622e + github.com/denisenkom/go-mssqldb v0.9.0 github.com/gedex/inflector v0.0.0-20170307190818-16278e9db813 github.com/go-sql-driver/mysql v1.5.0 - github.com/knq/snaker v0.0.0-20181215144011-2bc8a4db4687 + github.com/godror/godror v0.22.0 + github.com/kenshaw/snaker v0.1.0 github.com/kr/pretty v0.1.0 // indirect - github.com/lib/pq v1.4.0 + github.com/lib/pq v1.9.0 github.com/mattn/go-sqlite3 v2.0.3+incompatible github.com/pkg/errors v0.9.1 // indirect github.com/stretchr/testify v1.4.0 // indirect - github.com/xo/dburl v0.0.0-20200124232849-e9ec94f52bc3 + github.com/xo/dburl v0.0.0-20200910011426-652e0d5720a3 github.com/xo/xoutil v0.0.0-20171112033149-46189f4026a5 - golang.org/x/crypto v0.0.0-20200423211502-4bdfaf469ed5 // indirect + golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9 // indirect golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a // indirect + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect gopkg.in/rana/ora.v4 v4.1.15 ) diff --git a/go.sum b/go.sum index 9e9ccb7a..f734c7a8 100644 --- a/go.sum +++ b/go.sum @@ -5,23 +5,29 @@ github.com/alexflint/go-scalar v1.0.0/go.mod h1:GpHzbCOZXEKMEcygYQ5n/aa4Aq84zbxj github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/denisenkom/go-mssqldb v0.0.0-20200206145737-bbfc9a55622e h1:LzwWXEScfcTu7vUZNlDDWDARoSGEtvlDKK2BYHowNeE= -github.com/denisenkom/go-mssqldb v0.0.0-20200206145737-bbfc9a55622e/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= +github.com/denisenkom/go-mssqldb v0.9.0 h1:RSohk2RsiZqLZ0zCjtfn3S4Gp4exhpBWHyQ7D0yGjAk= +github.com/denisenkom/go-mssqldb v0.9.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/gedex/inflector v0.0.0-20170307190818-16278e9db813 h1:Uc+IZ7gYqAf/rSGFplbWBSHaGolEQlNLgMgSE3ccnIQ= github.com/gedex/inflector v0.0.0-20170307190818-16278e9db813/go.mod h1:P+oSoE9yhSRvsmYyZsshflcR6ePWYLql6UU1amW13IM= +github.com/go-logfmt/logfmt v0.5.0 h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih4= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= 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/godror/godror v0.22.0 h1:Ikn+yT60njiQGP/k1NJg+sbvkC0QhpLgoTYsHq035fw= +github.com/godror/godror v0.22.0/go.mod h1:YlPoIf962ZZKPM5Xqa8NxmGgck39pi51tqAs+K3IaFM= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= -github.com/knq/snaker v0.0.0-20181215144011-2bc8a4db4687 h1:ZrOZbqW7T2EgLd4soRATeSZrP3ijy2CgNFXG44cUuS8= -github.com/knq/snaker v0.0.0-20181215144011-2bc8a4db4687/go.mod h1:f0Dmq8fkddh8nOsVabYmtOHHdxlq2q4X+LQ1xWQEdUU= +github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/kenshaw/snaker v0.1.0 h1:h6dvdkBw6Qe1ya/LE9kMa9Y8M3RSAhbELfirZHIFobU= +github.com/kenshaw/snaker v0.1.0/go.mod h1:0xAAdPB2IwUAxxUZj5ZvPclku2HJBSB7TRcJxvhVwM8= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= 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 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/lib/pq v1.4.0 h1:TmtCFbH+Aw0AixwyttznSMQDgbR5Yed/Gg6S8Funrhc= -github.com/lib/pq v1.4.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.9.0 h1:L8nSXQQzAYByakOFMTwpjRoHsMJklur4Gi59b6VivR8= +github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U= github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -33,20 +39,26 @@ github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1 github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/xo/dburl v0.0.0-20200124232849-e9ec94f52bc3 h1:NC3CI7do3KHtiuYhk1CdS9V2qS3jNa7Fs2Afcnnt+IE= -github.com/xo/dburl v0.0.0-20200124232849-e9ec94f52bc3/go.mod h1:A47W3pdWONaZmXuLZgfKLAVgUY0qvfTRM5vVDKS40S4= +github.com/xo/dburl v0.0.0-20200910011426-652e0d5720a3 h1:WchQs0yWhP3iA3CFE57fmCltE5dx5FkbUZOJZBjEtJ8= +github.com/xo/dburl v0.0.0-20200910011426-652e0d5720a3/go.mod h1:TM8VMBT+LWqC3MBOulZjb8FAthcvZq0t/qvDLwS6skU= github.com/xo/xoutil v0.0.0-20171112033149-46189f4026a5 h1:3ANIpg9VQB91yCAyY+5dobfm30xQNOG3sCjPoPQo5i8= github.com/xo/xoutil v0.0.0-20171112033149-46189f4026a5/go.mod h1:GngMELAA694UVFs172352HAA2KQEf4XuETgWmL4XSoY= 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-20200423211502-4bdfaf469ed5 h1:Q7tZBpemrlsc2I7IyODzhtallWRSm4Q0d09pL6XbQtU= -golang.org/x/crypto v0.0.0-20200423211502-4bdfaf469ed5/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9 h1:sYNJzB4J8toYPQTM6pAkcmBRgw9SnQKP9oXCHfgy604= +golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a h1:WXEvlFVvvGxCJLG6REjsT03iWnKLEWinaScsxF2Vm2o= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/fkmode.go b/internal/fkmode.go index 44d03948..a5bd6f29 100644 --- a/internal/fkmode.go +++ b/internal/fkmode.go @@ -4,7 +4,7 @@ import ( "errors" "strings" - "github.com/knq/snaker" + "github.com/kenshaw/snaker" ) // FkMode represents the different foreign key naming modes. diff --git a/internal/funcs.go b/internal/funcs.go index 07e3ea9c..6b415d46 100644 --- a/internal/funcs.go +++ b/internal/funcs.go @@ -5,7 +5,7 @@ import ( "strings" "text/template" - "github.com/knq/snaker" + "github.com/kenshaw/snaker" "github.com/xo/xo/models" ) diff --git a/internal/loader.go b/internal/loader.go index 090d6661..9208dcfe 100644 --- a/internal/loader.go +++ b/internal/loader.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/gedex/inflector" - "github.com/knq/snaker" + "github.com/kenshaw/snaker" "github.com/xo/xo/models" ) @@ -723,7 +723,7 @@ func (tl TypeLoader) LoadTableIndexes(args *ArgType, typeTpl *Type, ixMap map[st // if no primary key index loaded, but a primary key column was defined in // the type, then create the definition here. this is needed for sqlite, as // sqlite doesn't define primary keys in its index list - if args.LoaderType != "ora" && !priIxLoaded && pk != nil { + if args.LoaderType != "godror" && !priIxLoaded && pk != nil { ixName := typeTpl.Table.TableName + "_" + pk.Col.ColumnName + "_pkey" ixMap[ixName] = &Index{ FuncName: typeTpl.Name + "By" + pk.Name, diff --git a/internal/templates.go b/internal/templates.go index 54504637..28dc9796 100644 --- a/internal/templates.go +++ b/internal/templates.go @@ -55,7 +55,7 @@ func (a *ArgType) ExecuteTemplate(tt TemplateType, name string, sub string, obj // build template name loaderType := "" if tt != XOTemplate { - if a.LoaderType == "oci8" || a.LoaderType == "ora" { + if a.LoaderType == "oci8" || a.LoaderType == "godror" { // force oracle for oci8 since the oracle driver doesn't recognize // 'oracle' as valid protocol loaderType = "oracle." diff --git a/internal/util.go b/internal/util.go index e7f74a3e..c1e37b4d 100644 --- a/internal/util.go +++ b/internal/util.go @@ -10,7 +10,7 @@ import ( "time" "github.com/gedex/inflector" - "github.com/knq/snaker" + "github.com/kenshaw/snaker" ) // ParseQuery takes the query in args and looks for strings in the form of diff --git a/loaders/mssql.go b/loaders/mssql.go index 59fba227..64a329ee 100644 --- a/loaders/mssql.go +++ b/loaders/mssql.go @@ -5,7 +5,7 @@ import ( _ "github.com/denisenkom/go-mssqldb" - "github.com/knq/snaker" + "github.com/kenshaw/snaker" "github.com/xo/xo/internal" "github.com/xo/xo/models" @@ -17,10 +17,10 @@ func init() { ProcessRelkind: MsRelkind, Schema: MsSchema, ParseType: MsParseType, - //EnumList: models.MsEnums, - //EnumValueList: models.MsEnumValues, - //ProcList: models.MsProcs, - //ProcParamList: models.MsProcParams, + // EnumList: models.MsEnums, + // EnumValueList: models.MsEnumValues, + // ProcList: models.MsProcs, + // ProcParamList: models.MsProcParams, TableList: MsTables, ColumnList: models.MsTableColumns, ForeignKeyList: models.MsTableForeignKeys, diff --git a/loaders/mysql.go b/loaders/mysql.go index b06f5f5e..6d9d8dd7 100644 --- a/loaders/mysql.go +++ b/loaders/mysql.go @@ -5,7 +5,7 @@ import ( _ "github.com/go-sql-driver/mysql" - "github.com/knq/snaker" + "github.com/kenshaw/snaker" "github.com/xo/xo/internal" "github.com/xo/xo/models" @@ -125,7 +125,7 @@ switchDT: } case "tinyint": - //people using tinyint(1) really want a bool + // people using tinyint(1) really want a bool if precision == 1 { nilVal = "false" typ = "bool" diff --git a/loaders/oracle.go b/loaders/oracle.go index f8d22588..f02a515d 100644 --- a/loaders/oracle.go +++ b/loaders/oracle.go @@ -8,23 +8,23 @@ import ( "regexp" "strings" - _ "gopkg.in/rana/ora.v4" + _ "github.com/godror/godror" "github.com/xo/xo/internal" "github.com/xo/xo/models" ) func init() { - internal.SchemaLoaders["ora"] = internal.TypeLoader{ + internal.SchemaLoaders["godror"] = internal.TypeLoader{ ParamN: func(i int) string { return fmt.Sprintf(":%d", i+1) }, MaskFunc: func() string { return ":%d" }, ProcessRelkind: OrRelkind, Schema: OrSchema, ParseType: OrParseType, - //EnumList: models.OrEnums, - //EnumValueList: OrEnumValues, - //ProcList: models.OrProcs, - //ProcParamList: models.OrProcParams, + // EnumList: models.OrEnums, + // EnumValueList: OrEnumValues, + // ProcList: models.OrProcs, + // ProcParamList: models.OrProcParams, TableList: models.OrTables, ColumnList: models.OrTableColumns, ForeignKeyList: models.OrTableForeignKeys, diff --git a/loaders/postgres.go b/loaders/postgres.go index c6c9dd81..aabbeef3 100644 --- a/loaders/postgres.go +++ b/loaders/postgres.go @@ -8,7 +8,7 @@ import ( _ "github.com/lib/pq" - "github.com/knq/snaker" + "github.com/kenshaw/snaker" "github.com/xo/xo/internal" "github.com/xo/xo/models" @@ -170,7 +170,7 @@ func PgParseType(args *internal.ArgType, dt string, nullable bool) (int, string, // // this is mainly here because postgres's pg_catalog.* meta tables have // this as a type. - //typ = "rune" + // typ = "rune" nilVal = `uint8(0)` typ = "uint8" @@ -280,7 +280,7 @@ func PgQueryColumns(args *internal.ArgType, inspect []string) ([]*models.Column, } // query to determine schema name where temporary view was created - var nspq = `SELECT n.nspname ` + + nspq := `SELECT n.nspname ` + `FROM pg_class c ` + `JOIN pg_namespace n ON n.oid = c.relnamespace ` + `WHERE n.nspname LIKE 'pg_temp%' AND c.relname = $1` diff --git a/main.go b/main.go index 44765ab4..40b41915 100644 --- a/main.go +++ b/main.go @@ -29,10 +29,9 @@ func main() { // support if len(os.Args) == 2 && os.Args[1] == "--has-oracle-support" { var out int - if _, ok := internal.SchemaLoaders["ora"]; ok { + if _, ok := internal.SchemaLoaders["godror"]; ok { out = 1 } - fmt.Fprintf(os.Stdout, "%d", out) return } @@ -244,7 +243,7 @@ func getFile(args *internal.ArgType, t *internal.TBuf) (*os.File, error) { var err error // determine filename - var filename = strings.ToLower(t.Name) + args.Suffix + filename := strings.ToLower(t.Name) + args.Suffix if args.SingleFile { filename = args.Filename } diff --git a/tplbin/templates.go b/tplbin/templates.go index cf1f313e..864898c9 100644 --- a/tplbin/templates.go +++ b/tplbin/templates.go @@ -1,43 +1,43 @@ -// Code generated by go-bindata. +// Code generated by go-bindata. DO NOT EDIT. // sources: -// templates/mssql.foreignkey.go.tpl -// templates/mssql.index.go.tpl -// templates/mssql.query.go.tpl -// templates/mssql.querytype.go.tpl -// templates/mssql.type.go.tpl -// templates/mysql.enum.go.tpl -// templates/mysql.foreignkey.go.tpl -// templates/mysql.index.go.tpl -// templates/mysql.proc.go.tpl -// templates/mysql.query.go.tpl -// templates/mysql.querytype.go.tpl -// templates/mysql.type.go.tpl -// templates/oracle.foreignkey.go.tpl -// templates/oracle.index.go.tpl -// templates/oracle.query.go.tpl -// templates/oracle.querytype.go.tpl -// templates/oracle.type.go.tpl -// templates/postgres.enum.go.tpl -// templates/postgres.foreignkey.go.tpl -// templates/postgres.index.go.tpl -// templates/postgres.proc.go.tpl -// templates/postgres.query.go.tpl -// templates/postgres.querytype.go.tpl -// templates/postgres.type.go.tpl -// templates/sqlite3.foreignkey.go.tpl -// templates/sqlite3.index.go.tpl -// templates/sqlite3.query.go.tpl -// templates/sqlite3.querytype.go.tpl -// templates/sqlite3.type.go.tpl -// templates/xo_db.go.tpl -// templates/xo_package.go.tpl -// DO NOT EDIT! +// templates/mssql.foreignkey.go.tpl (432B) +// templates/mssql.index.go.tpl (1.427kB) +// templates/mssql.query.go.tpl (1.461kB) +// templates/mssql.querytype.go.tpl (285B) +// templates/mssql.type.go.tpl (3.866kB) +// templates/mysql.enum.go.tpl (1.846kB) +// templates/mysql.foreignkey.go.tpl (432B) +// templates/mysql.index.go.tpl (1.427kB) +// templates/mysql.proc.go.tpl (826B) +// templates/mysql.query.go.tpl (1.461kB) +// templates/mysql.querytype.go.tpl (285B) +// templates/mysql.type.go.tpl (4.795kB) +// templates/oracle.foreignkey.go.tpl (432B) +// templates/oracle.index.go.tpl (1.427kB) +// templates/oracle.query.go.tpl (1.461kB) +// templates/oracle.querytype.go.tpl (285B) +// templates/oracle.type.go.tpl (3.473kB) +// templates/postgres.enum.go.tpl (1.846kB) +// templates/postgres.foreignkey.go.tpl (432B) +// templates/postgres.index.go.tpl (1.427kB) +// templates/postgres.proc.go.tpl (826B) +// templates/postgres.query.go.tpl (1.461kB) +// templates/postgres.querytype.go.tpl (285B) +// templates/postgres.type.go.tpl (5.714kB) +// templates/sqlite3.foreignkey.go.tpl (432B) +// templates/sqlite3.index.go.tpl (1.427kB) +// templates/sqlite3.query.go.tpl (1.461kB) +// templates/sqlite3.querytype.go.tpl (285B) +// templates/sqlite3.type.go.tpl (4.795kB) +// templates/xo_db.go.tpl (1.925kB) +// templates/xo_package.go.tpl (256B) package tplbin import ( "bytes" "compress/gzip" + "crypto/sha256" "fmt" "io" "io/ioutil" @@ -50,26 +50,28 @@ import ( func bindataRead(data, name string) ([]byte, error) { gz, err := gzip.NewReader(strings.NewReader(data)) if err != nil { - return nil, fmt.Errorf("Read %q: %v", name, err) + return nil, fmt.Errorf("read %q: %v", name, err) } var buf bytes.Buffer _, err = io.Copy(&buf, gz) - clErr := gz.Close() if err != nil { - return nil, fmt.Errorf("Read %q: %v", name, err) + return nil, fmt.Errorf("read %q: %v", name, err) } + + clErr := gz.Close() if clErr != nil { - return nil, err + return nil, clErr } return buf.Bytes(), nil } type asset struct { - bytes []byte - info os.FileInfo + bytes []byte + info os.FileInfo + digest [sha256.Size]byte } type bindataFileInfo struct { @@ -114,7 +116,7 @@ func mssqlForeignkeyGoTpl() (*asset, error) { } info := bindataFileInfo{name: "mssql.foreignkey.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa0, 0x20, 0x2f, 0x23, 0xb0, 0xac, 0xe5, 0x57, 0xbb, 0x51, 0x9, 0x7d, 0x46, 0x48, 0x80, 0x33, 0xbc, 0xb3, 0x16, 0x69, 0x64, 0xf2, 0x76, 0xb2, 0xf7, 0xcc, 0x46, 0xfe, 0x6, 0x41, 0x91, 0x3a}} return a, nil } @@ -134,7 +136,7 @@ func mssqlIndexGoTpl() (*asset, error) { } info := bindataFileInfo{name: "mssql.index.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xfb, 0xdc, 0x65, 0x20, 0x9d, 0x18, 0x3f, 0x52, 0xaf, 0x28, 0x3a, 0xf3, 0xb5, 0xe3, 0xe7, 0xf6, 0x67, 0xd0, 0x77, 0x6a, 0xc5, 0xad, 0xe9, 0xff, 0x55, 0xf7, 0x87, 0xfa, 0x99, 0x8, 0x17, 0x53}} return a, nil } @@ -154,7 +156,7 @@ func mssqlQueryGoTpl() (*asset, error) { } info := bindataFileInfo{name: "mssql.query.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xeb, 0xfd, 0xa, 0x74, 0xd3, 0xf8, 0x48, 0x9d, 0x8d, 0x5e, 0xef, 0x80, 0x19, 0xa9, 0x94, 0x63, 0xa4, 0xf4, 0xc9, 0x2, 0xca, 0xc1, 0x14, 0xf8, 0x53, 0x20, 0xe3, 0x24, 0x4d, 0x2c, 0x75, 0xd6}} return a, nil } @@ -174,7 +176,7 @@ func mssqlQuerytypeGoTpl() (*asset, error) { } info := bindataFileInfo{name: "mssql.querytype.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x5d, 0x28, 0xf8, 0x16, 0x8d, 0xcd, 0x5d, 0x1c, 0xdb, 0x44, 0xe6, 0x28, 0xdc, 0x74, 0xc4, 0x7d, 0xcd, 0x42, 0xeb, 0xce, 0xb5, 0x94, 0x3e, 0xad, 0x9a, 0x67, 0x37, 0x6f, 0x1f, 0x3e, 0x3c, 0x32}} return a, nil } @@ -194,7 +196,7 @@ func mssqlTypeGoTpl() (*asset, error) { } info := bindataFileInfo{name: "mssql.type.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x81, 0x45, 0x45, 0x6e, 0x89, 0xae, 0xb4, 0xf4, 0x42, 0xe9, 0x5, 0x5b, 0x27, 0x4c, 0x8a, 0x67, 0xe2, 0x50, 0xbc, 0x6a, 0x4e, 0xe7, 0x92, 0xc4, 0x76, 0xdd, 0xe, 0xed, 0x23, 0x35, 0x9, 0x57}} return a, nil } @@ -214,7 +216,7 @@ func mysqlEnumGoTpl() (*asset, error) { } info := bindataFileInfo{name: "mysql.enum.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa9, 0x35, 0x7d, 0x77, 0x46, 0xa, 0x7b, 0x1f, 0xe0, 0x77, 0xd, 0x53, 0x37, 0xa1, 0x39, 0x6, 0x7d, 0xa9, 0x71, 0x80, 0x2e, 0x7f, 0xf7, 0x13, 0xc1, 0xf0, 0x23, 0x86, 0xd9, 0xbf, 0x94, 0x81}} return a, nil } @@ -234,7 +236,7 @@ func mysqlForeignkeyGoTpl() (*asset, error) { } info := bindataFileInfo{name: "mysql.foreignkey.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa0, 0x20, 0x2f, 0x23, 0xb0, 0xac, 0xe5, 0x57, 0xbb, 0x51, 0x9, 0x7d, 0x46, 0x48, 0x80, 0x33, 0xbc, 0xb3, 0x16, 0x69, 0x64, 0xf2, 0x76, 0xb2, 0xf7, 0xcc, 0x46, 0xfe, 0x6, 0x41, 0x91, 0x3a}} return a, nil } @@ -254,7 +256,7 @@ func mysqlIndexGoTpl() (*asset, error) { } info := bindataFileInfo{name: "mysql.index.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xfb, 0xdc, 0x65, 0x20, 0x9d, 0x18, 0x3f, 0x52, 0xaf, 0x28, 0x3a, 0xf3, 0xb5, 0xe3, 0xe7, 0xf6, 0x67, 0xd0, 0x77, 0x6a, 0xc5, 0xad, 0xe9, 0xff, 0x55, 0xf7, 0x87, 0xfa, 0x99, 0x8, 0x17, 0x53}} return a, nil } @@ -274,7 +276,7 @@ func mysqlProcGoTpl() (*asset, error) { } info := bindataFileInfo{name: "mysql.proc.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa9, 0x51, 0x8d, 0x1a, 0x69, 0xab, 0xf0, 0xe8, 0xe1, 0x92, 0xc9, 0x41, 0xaf, 0x34, 0xc9, 0xc, 0xcc, 0x6a, 0xe5, 0xf1, 0xfd, 0x79, 0xc1, 0xe9, 0x2a, 0xf6, 0xaf, 0xf8, 0x33, 0x44, 0xc8, 0x4b}} return a, nil } @@ -294,7 +296,7 @@ func mysqlQueryGoTpl() (*asset, error) { } info := bindataFileInfo{name: "mysql.query.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xeb, 0xfd, 0xa, 0x74, 0xd3, 0xf8, 0x48, 0x9d, 0x8d, 0x5e, 0xef, 0x80, 0x19, 0xa9, 0x94, 0x63, 0xa4, 0xf4, 0xc9, 0x2, 0xca, 0xc1, 0x14, 0xf8, 0x53, 0x20, 0xe3, 0x24, 0x4d, 0x2c, 0x75, 0xd6}} return a, nil } @@ -314,7 +316,7 @@ func mysqlQuerytypeGoTpl() (*asset, error) { } info := bindataFileInfo{name: "mysql.querytype.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x5d, 0x28, 0xf8, 0x16, 0x8d, 0xcd, 0x5d, 0x1c, 0xdb, 0x44, 0xe6, 0x28, 0xdc, 0x74, 0xc4, 0x7d, 0xcd, 0x42, 0xeb, 0xce, 0xb5, 0x94, 0x3e, 0xad, 0x9a, 0x67, 0x37, 0x6f, 0x1f, 0x3e, 0x3c, 0x32}} return a, nil } @@ -334,7 +336,7 @@ func mysqlTypeGoTpl() (*asset, error) { } info := bindataFileInfo{name: "mysql.type.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x29, 0x6c, 0x55, 0x14, 0xb4, 0xbd, 0xf9, 0x8c, 0x5f, 0x3e, 0x87, 0x6d, 0x9, 0xe7, 0x8d, 0x5f, 0x15, 0x57, 0x61, 0xf6, 0x54, 0xd4, 0x28, 0x29, 0xc7, 0x72, 0x95, 0x19, 0x20, 0x2f, 0xb2, 0xdf}} return a, nil } @@ -354,7 +356,7 @@ func oracleForeignkeyGoTpl() (*asset, error) { } info := bindataFileInfo{name: "oracle.foreignkey.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa0, 0x20, 0x2f, 0x23, 0xb0, 0xac, 0xe5, 0x57, 0xbb, 0x51, 0x9, 0x7d, 0x46, 0x48, 0x80, 0x33, 0xbc, 0xb3, 0x16, 0x69, 0x64, 0xf2, 0x76, 0xb2, 0xf7, 0xcc, 0x46, 0xfe, 0x6, 0x41, 0x91, 0x3a}} return a, nil } @@ -374,7 +376,7 @@ func oracleIndexGoTpl() (*asset, error) { } info := bindataFileInfo{name: "oracle.index.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xfb, 0xdc, 0x65, 0x20, 0x9d, 0x18, 0x3f, 0x52, 0xaf, 0x28, 0x3a, 0xf3, 0xb5, 0xe3, 0xe7, 0xf6, 0x67, 0xd0, 0x77, 0x6a, 0xc5, 0xad, 0xe9, 0xff, 0x55, 0xf7, 0x87, 0xfa, 0x99, 0x8, 0x17, 0x53}} return a, nil } @@ -394,7 +396,7 @@ func oracleQueryGoTpl() (*asset, error) { } info := bindataFileInfo{name: "oracle.query.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xeb, 0xfd, 0xa, 0x74, 0xd3, 0xf8, 0x48, 0x9d, 0x8d, 0x5e, 0xef, 0x80, 0x19, 0xa9, 0x94, 0x63, 0xa4, 0xf4, 0xc9, 0x2, 0xca, 0xc1, 0x14, 0xf8, 0x53, 0x20, 0xe3, 0x24, 0x4d, 0x2c, 0x75, 0xd6}} return a, nil } @@ -414,7 +416,7 @@ func oracleQuerytypeGoTpl() (*asset, error) { } info := bindataFileInfo{name: "oracle.querytype.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x5d, 0x28, 0xf8, 0x16, 0x8d, 0xcd, 0x5d, 0x1c, 0xdb, 0x44, 0xe6, 0x28, 0xdc, 0x74, 0xc4, 0x7d, 0xcd, 0x42, 0xeb, 0xce, 0xb5, 0x94, 0x3e, 0xad, 0x9a, 0x67, 0x37, 0x6f, 0x1f, 0x3e, 0x3c, 0x32}} return a, nil } @@ -434,7 +436,7 @@ func oracleTypeGoTpl() (*asset, error) { } info := bindataFileInfo{name: "oracle.type.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe9, 0x36, 0xd1, 0x95, 0xd2, 0x4, 0xdc, 0x39, 0x6b, 0xa1, 0x67, 0x12, 0xf7, 0x4c, 0x1d, 0xde, 0xb5, 0x74, 0x36, 0x0, 0x84, 0xb0, 0x40, 0xfe, 0x4c, 0xb8, 0x4b, 0xbd, 0x90, 0xd4, 0xe, 0xe4}} return a, nil } @@ -454,7 +456,7 @@ func postgresEnumGoTpl() (*asset, error) { } info := bindataFileInfo{name: "postgres.enum.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa9, 0x35, 0x7d, 0x77, 0x46, 0xa, 0x7b, 0x1f, 0xe0, 0x77, 0xd, 0x53, 0x37, 0xa1, 0x39, 0x6, 0x7d, 0xa9, 0x71, 0x80, 0x2e, 0x7f, 0xf7, 0x13, 0xc1, 0xf0, 0x23, 0x86, 0xd9, 0xbf, 0x94, 0x81}} return a, nil } @@ -474,7 +476,7 @@ func postgresForeignkeyGoTpl() (*asset, error) { } info := bindataFileInfo{name: "postgres.foreignkey.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa0, 0x20, 0x2f, 0x23, 0xb0, 0xac, 0xe5, 0x57, 0xbb, 0x51, 0x9, 0x7d, 0x46, 0x48, 0x80, 0x33, 0xbc, 0xb3, 0x16, 0x69, 0x64, 0xf2, 0x76, 0xb2, 0xf7, 0xcc, 0x46, 0xfe, 0x6, 0x41, 0x91, 0x3a}} return a, nil } @@ -494,7 +496,7 @@ func postgresIndexGoTpl() (*asset, error) { } info := bindataFileInfo{name: "postgres.index.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xfb, 0xdc, 0x65, 0x20, 0x9d, 0x18, 0x3f, 0x52, 0xaf, 0x28, 0x3a, 0xf3, 0xb5, 0xe3, 0xe7, 0xf6, 0x67, 0xd0, 0x77, 0x6a, 0xc5, 0xad, 0xe9, 0xff, 0x55, 0xf7, 0x87, 0xfa, 0x99, 0x8, 0x17, 0x53}} return a, nil } @@ -514,7 +516,7 @@ func postgresProcGoTpl() (*asset, error) { } info := bindataFileInfo{name: "postgres.proc.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa9, 0x51, 0x8d, 0x1a, 0x69, 0xab, 0xf0, 0xe8, 0xe1, 0x92, 0xc9, 0x41, 0xaf, 0x34, 0xc9, 0xc, 0xcc, 0x6a, 0xe5, 0xf1, 0xfd, 0x79, 0xc1, 0xe9, 0x2a, 0xf6, 0xaf, 0xf8, 0x33, 0x44, 0xc8, 0x4b}} return a, nil } @@ -534,7 +536,7 @@ func postgresQueryGoTpl() (*asset, error) { } info := bindataFileInfo{name: "postgres.query.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xeb, 0xfd, 0xa, 0x74, 0xd3, 0xf8, 0x48, 0x9d, 0x8d, 0x5e, 0xef, 0x80, 0x19, 0xa9, 0x94, 0x63, 0xa4, 0xf4, 0xc9, 0x2, 0xca, 0xc1, 0x14, 0xf8, 0x53, 0x20, 0xe3, 0x24, 0x4d, 0x2c, 0x75, 0xd6}} return a, nil } @@ -554,7 +556,7 @@ func postgresQuerytypeGoTpl() (*asset, error) { } info := bindataFileInfo{name: "postgres.querytype.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x5d, 0x28, 0xf8, 0x16, 0x8d, 0xcd, 0x5d, 0x1c, 0xdb, 0x44, 0xe6, 0x28, 0xdc, 0x74, 0xc4, 0x7d, 0xcd, 0x42, 0xeb, 0xce, 0xb5, 0x94, 0x3e, 0xad, 0x9a, 0x67, 0x37, 0x6f, 0x1f, 0x3e, 0x3c, 0x32}} return a, nil } @@ -574,7 +576,7 @@ func postgresTypeGoTpl() (*asset, error) { } info := bindataFileInfo{name: "postgres.type.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf5, 0xe6, 0xc, 0x66, 0xf0, 0x31, 0x50, 0x3a, 0xa5, 0x2d, 0x66, 0x23, 0x7b, 0x43, 0x9, 0x9e, 0xd2, 0xd9, 0x23, 0x90, 0xf4, 0x3d, 0x31, 0x51, 0x75, 0xea, 0x89, 0x77, 0x78, 0xca, 0x19, 0x55}} return a, nil } @@ -594,7 +596,7 @@ func sqlite3ForeignkeyGoTpl() (*asset, error) { } info := bindataFileInfo{name: "sqlite3.foreignkey.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa0, 0x20, 0x2f, 0x23, 0xb0, 0xac, 0xe5, 0x57, 0xbb, 0x51, 0x9, 0x7d, 0x46, 0x48, 0x80, 0x33, 0xbc, 0xb3, 0x16, 0x69, 0x64, 0xf2, 0x76, 0xb2, 0xf7, 0xcc, 0x46, 0xfe, 0x6, 0x41, 0x91, 0x3a}} return a, nil } @@ -614,7 +616,7 @@ func sqlite3IndexGoTpl() (*asset, error) { } info := bindataFileInfo{name: "sqlite3.index.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xfb, 0xdc, 0x65, 0x20, 0x9d, 0x18, 0x3f, 0x52, 0xaf, 0x28, 0x3a, 0xf3, 0xb5, 0xe3, 0xe7, 0xf6, 0x67, 0xd0, 0x77, 0x6a, 0xc5, 0xad, 0xe9, 0xff, 0x55, 0xf7, 0x87, 0xfa, 0x99, 0x8, 0x17, 0x53}} return a, nil } @@ -634,7 +636,7 @@ func sqlite3QueryGoTpl() (*asset, error) { } info := bindataFileInfo{name: "sqlite3.query.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xeb, 0xfd, 0xa, 0x74, 0xd3, 0xf8, 0x48, 0x9d, 0x8d, 0x5e, 0xef, 0x80, 0x19, 0xa9, 0x94, 0x63, 0xa4, 0xf4, 0xc9, 0x2, 0xca, 0xc1, 0x14, 0xf8, 0x53, 0x20, 0xe3, 0x24, 0x4d, 0x2c, 0x75, 0xd6}} return a, nil } @@ -654,7 +656,7 @@ func sqlite3QuerytypeGoTpl() (*asset, error) { } info := bindataFileInfo{name: "sqlite3.querytype.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x5d, 0x28, 0xf8, 0x16, 0x8d, 0xcd, 0x5d, 0x1c, 0xdb, 0x44, 0xe6, 0x28, 0xdc, 0x74, 0xc4, 0x7d, 0xcd, 0x42, 0xeb, 0xce, 0xb5, 0x94, 0x3e, 0xad, 0x9a, 0x67, 0x37, 0x6f, 0x1f, 0x3e, 0x3c, 0x32}} return a, nil } @@ -674,7 +676,7 @@ func sqlite3TypeGoTpl() (*asset, error) { } info := bindataFileInfo{name: "sqlite3.type.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x29, 0x6c, 0x55, 0x14, 0xb4, 0xbd, 0xf9, 0x8c, 0x5f, 0x3e, 0x87, 0x6d, 0x9, 0xe7, 0x8d, 0x5f, 0x15, 0x57, 0x61, 0xf6, 0x54, 0xd4, 0x28, 0x29, 0xc7, 0x72, 0x95, 0x19, 0x20, 0x2f, 0xb2, 0xdf}} return a, nil } @@ -694,7 +696,7 @@ func xo_dbGoTpl() (*asset, error) { } info := bindataFileInfo{name: "xo_db.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf2, 0xa3, 0x31, 0x2b, 0xc9, 0x43, 0x7c, 0x3, 0xf1, 0xdb, 0x63, 0x9c, 0xc2, 0x9c, 0xbe, 0xd, 0x61, 0x26, 0x93, 0xac, 0xbc, 0xed, 0x77, 0xd8, 0x74, 0xdd, 0x49, 0x14, 0xf, 0x9d, 0x2f, 0x33}} return a, nil } @@ -714,7 +716,7 @@ func xo_packageGoTpl() (*asset, error) { } info := bindataFileInfo{name: "xo_package.go.tpl", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x6f, 0x6d, 0x26, 0x48, 0xe3, 0xc5, 0xa3, 0x2, 0x3f, 0xfc, 0xec, 0xa3, 0x6b, 0x0, 0xb0, 0xea, 0x88, 0xd1, 0xa0, 0x53, 0x37, 0xf, 0x46, 0xa6, 0xc8, 0x1a, 0x35, 0x84, 0xb7, 0x84, 0xe6, 0xd9}} return a, nil } @@ -722,8 +724,8 @@ func xo_packageGoTpl() (*asset, error) { // It returns an error if the asset could not be found or // could not be loaded. func Asset(name string) ([]byte, error) { - cannonicalName := strings.Replace(name, "\\", "/", -1) - if f, ok := _bindata[cannonicalName]; ok { + canonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[canonicalName]; ok { a, err := f() if err != nil { return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err) @@ -733,6 +735,12 @@ func Asset(name string) ([]byte, error) { return nil, fmt.Errorf("Asset %s not found", name) } +// AssetString returns the asset contents as a string (instead of a []byte). +func AssetString(name string) (string, error) { + data, err := Asset(name) + return string(data), err +} + // MustAsset is like Asset but panics when Asset would return an error. // It simplifies safe initialization of global variables. func MustAsset(name string) []byte { @@ -744,12 +752,18 @@ func MustAsset(name string) []byte { return a } +// MustAssetString is like AssetString but panics when Asset would return an +// error. It simplifies safe initialization of global variables. +func MustAssetString(name string) string { + return string(MustAsset(name)) +} + // AssetInfo loads and returns the asset info for the given name. // It returns an error if the asset could not be found or // could not be loaded. func AssetInfo(name string) (os.FileInfo, error) { - cannonicalName := strings.Replace(name, "\\", "/", -1) - if f, ok := _bindata[cannonicalName]; ok { + canonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[canonicalName]; ok { a, err := f() if err != nil { return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err) @@ -759,6 +773,33 @@ func AssetInfo(name string) (os.FileInfo, error) { return nil, fmt.Errorf("AssetInfo %s not found", name) } +// AssetDigest returns the digest of the file with the given name. It returns an +// error if the asset could not be found or the digest could not be loaded. +func AssetDigest(name string) ([sha256.Size]byte, error) { + canonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[canonicalName]; ok { + a, err := f() + if err != nil { + return [sha256.Size]byte{}, fmt.Errorf("AssetDigest %s can't read by error: %v", name, err) + } + return a.digest, nil + } + return [sha256.Size]byte{}, fmt.Errorf("AssetDigest %s not found", name) +} + +// Digests returns a map of all known files and their checksums. +func Digests() (map[string][sha256.Size]byte, error) { + mp := make(map[string][sha256.Size]byte, len(_bindata)) + for name := range _bindata { + a, err := _bindata[name]() + if err != nil { + return nil, err + } + mp[name] = a.digest + } + return mp, nil +} + // AssetNames returns the names of the assets. func AssetNames() []string { names := make([]string, 0, len(_bindata)) @@ -770,37 +811,37 @@ func AssetNames() []string { // _bindata is a table, holding each asset generator, mapped to its name. var _bindata = map[string]func() (*asset, error){ - "mssql.foreignkey.go.tpl": mssqlForeignkeyGoTpl, - "mssql.index.go.tpl": mssqlIndexGoTpl, - "mssql.query.go.tpl": mssqlQueryGoTpl, - "mssql.querytype.go.tpl": mssqlQuerytypeGoTpl, - "mssql.type.go.tpl": mssqlTypeGoTpl, - "mysql.enum.go.tpl": mysqlEnumGoTpl, - "mysql.foreignkey.go.tpl": mysqlForeignkeyGoTpl, - "mysql.index.go.tpl": mysqlIndexGoTpl, - "mysql.proc.go.tpl": mysqlProcGoTpl, - "mysql.query.go.tpl": mysqlQueryGoTpl, - "mysql.querytype.go.tpl": mysqlQuerytypeGoTpl, - "mysql.type.go.tpl": mysqlTypeGoTpl, - "oracle.foreignkey.go.tpl": oracleForeignkeyGoTpl, - "oracle.index.go.tpl": oracleIndexGoTpl, - "oracle.query.go.tpl": oracleQueryGoTpl, - "oracle.querytype.go.tpl": oracleQuerytypeGoTpl, - "oracle.type.go.tpl": oracleTypeGoTpl, - "postgres.enum.go.tpl": postgresEnumGoTpl, + "mssql.foreignkey.go.tpl": mssqlForeignkeyGoTpl, + "mssql.index.go.tpl": mssqlIndexGoTpl, + "mssql.query.go.tpl": mssqlQueryGoTpl, + "mssql.querytype.go.tpl": mssqlQuerytypeGoTpl, + "mssql.type.go.tpl": mssqlTypeGoTpl, + "mysql.enum.go.tpl": mysqlEnumGoTpl, + "mysql.foreignkey.go.tpl": mysqlForeignkeyGoTpl, + "mysql.index.go.tpl": mysqlIndexGoTpl, + "mysql.proc.go.tpl": mysqlProcGoTpl, + "mysql.query.go.tpl": mysqlQueryGoTpl, + "mysql.querytype.go.tpl": mysqlQuerytypeGoTpl, + "mysql.type.go.tpl": mysqlTypeGoTpl, + "oracle.foreignkey.go.tpl": oracleForeignkeyGoTpl, + "oracle.index.go.tpl": oracleIndexGoTpl, + "oracle.query.go.tpl": oracleQueryGoTpl, + "oracle.querytype.go.tpl": oracleQuerytypeGoTpl, + "oracle.type.go.tpl": oracleTypeGoTpl, + "postgres.enum.go.tpl": postgresEnumGoTpl, "postgres.foreignkey.go.tpl": postgresForeignkeyGoTpl, - "postgres.index.go.tpl": postgresIndexGoTpl, - "postgres.proc.go.tpl": postgresProcGoTpl, - "postgres.query.go.tpl": postgresQueryGoTpl, - "postgres.querytype.go.tpl": postgresQuerytypeGoTpl, - "postgres.type.go.tpl": postgresTypeGoTpl, - "sqlite3.foreignkey.go.tpl": sqlite3ForeignkeyGoTpl, - "sqlite3.index.go.tpl": sqlite3IndexGoTpl, - "sqlite3.query.go.tpl": sqlite3QueryGoTpl, - "sqlite3.querytype.go.tpl": sqlite3QuerytypeGoTpl, - "sqlite3.type.go.tpl": sqlite3TypeGoTpl, - "xo_db.go.tpl": xo_dbGoTpl, - "xo_package.go.tpl": xo_packageGoTpl, + "postgres.index.go.tpl": postgresIndexGoTpl, + "postgres.proc.go.tpl": postgresProcGoTpl, + "postgres.query.go.tpl": postgresQueryGoTpl, + "postgres.querytype.go.tpl": postgresQuerytypeGoTpl, + "postgres.type.go.tpl": postgresTypeGoTpl, + "sqlite3.foreignkey.go.tpl": sqlite3ForeignkeyGoTpl, + "sqlite3.index.go.tpl": sqlite3IndexGoTpl, + "sqlite3.query.go.tpl": sqlite3QueryGoTpl, + "sqlite3.querytype.go.tpl": sqlite3QuerytypeGoTpl, + "sqlite3.type.go.tpl": sqlite3TypeGoTpl, + "xo_db.go.tpl": xo_dbGoTpl, + "xo_package.go.tpl": xo_packageGoTpl, } // AssetDir returns the file names below a certain @@ -812,15 +853,15 @@ var _bindata = map[string]func() (*asset, error){ // img/ // a.png // b.png -// then AssetDir("data") would return []string{"foo.txt", "img"} -// AssetDir("data/img") would return []string{"a.png", "b.png"} -// AssetDir("foo.txt") and AssetDir("notexist") would return an error +// then AssetDir("data") would return []string{"foo.txt", "img"}, +// AssetDir("data/img") would return []string{"a.png", "b.png"}, +// AssetDir("foo.txt") and AssetDir("notexist") would return an error, and // AssetDir("") will return []string{"data"}. func AssetDir(name string) ([]string, error) { node := _bintree if len(name) != 0 { - cannonicalName := strings.Replace(name, "\\", "/", -1) - pathList := strings.Split(cannonicalName, "/") + canonicalName := strings.Replace(name, "\\", "/", -1) + pathList := strings.Split(canonicalName, "/") for _, p := range pathList { node = node.Children[p] if node == nil { @@ -842,41 +883,42 @@ type bintree struct { Func func() (*asset, error) Children map[string]*bintree } + var _bintree = &bintree{nil, map[string]*bintree{ - "mssql.foreignkey.go.tpl": &bintree{mssqlForeignkeyGoTpl, map[string]*bintree{}}, - "mssql.index.go.tpl": &bintree{mssqlIndexGoTpl, map[string]*bintree{}}, - "mssql.query.go.tpl": &bintree{mssqlQueryGoTpl, map[string]*bintree{}}, - "mssql.querytype.go.tpl": &bintree{mssqlQuerytypeGoTpl, map[string]*bintree{}}, - "mssql.type.go.tpl": &bintree{mssqlTypeGoTpl, map[string]*bintree{}}, - "mysql.enum.go.tpl": &bintree{mysqlEnumGoTpl, map[string]*bintree{}}, - "mysql.foreignkey.go.tpl": &bintree{mysqlForeignkeyGoTpl, map[string]*bintree{}}, - "mysql.index.go.tpl": &bintree{mysqlIndexGoTpl, map[string]*bintree{}}, - "mysql.proc.go.tpl": &bintree{mysqlProcGoTpl, map[string]*bintree{}}, - "mysql.query.go.tpl": &bintree{mysqlQueryGoTpl, map[string]*bintree{}}, - "mysql.querytype.go.tpl": &bintree{mysqlQuerytypeGoTpl, map[string]*bintree{}}, - "mysql.type.go.tpl": &bintree{mysqlTypeGoTpl, map[string]*bintree{}}, - "oracle.foreignkey.go.tpl": &bintree{oracleForeignkeyGoTpl, map[string]*bintree{}}, - "oracle.index.go.tpl": &bintree{oracleIndexGoTpl, map[string]*bintree{}}, - "oracle.query.go.tpl": &bintree{oracleQueryGoTpl, map[string]*bintree{}}, - "oracle.querytype.go.tpl": &bintree{oracleQuerytypeGoTpl, map[string]*bintree{}}, - "oracle.type.go.tpl": &bintree{oracleTypeGoTpl, map[string]*bintree{}}, - "postgres.enum.go.tpl": &bintree{postgresEnumGoTpl, map[string]*bintree{}}, + "mssql.foreignkey.go.tpl": &bintree{mssqlForeignkeyGoTpl, map[string]*bintree{}}, + "mssql.index.go.tpl": &bintree{mssqlIndexGoTpl, map[string]*bintree{}}, + "mssql.query.go.tpl": &bintree{mssqlQueryGoTpl, map[string]*bintree{}}, + "mssql.querytype.go.tpl": &bintree{mssqlQuerytypeGoTpl, map[string]*bintree{}}, + "mssql.type.go.tpl": &bintree{mssqlTypeGoTpl, map[string]*bintree{}}, + "mysql.enum.go.tpl": &bintree{mysqlEnumGoTpl, map[string]*bintree{}}, + "mysql.foreignkey.go.tpl": &bintree{mysqlForeignkeyGoTpl, map[string]*bintree{}}, + "mysql.index.go.tpl": &bintree{mysqlIndexGoTpl, map[string]*bintree{}}, + "mysql.proc.go.tpl": &bintree{mysqlProcGoTpl, map[string]*bintree{}}, + "mysql.query.go.tpl": &bintree{mysqlQueryGoTpl, map[string]*bintree{}}, + "mysql.querytype.go.tpl": &bintree{mysqlQuerytypeGoTpl, map[string]*bintree{}}, + "mysql.type.go.tpl": &bintree{mysqlTypeGoTpl, map[string]*bintree{}}, + "oracle.foreignkey.go.tpl": &bintree{oracleForeignkeyGoTpl, map[string]*bintree{}}, + "oracle.index.go.tpl": &bintree{oracleIndexGoTpl, map[string]*bintree{}}, + "oracle.query.go.tpl": &bintree{oracleQueryGoTpl, map[string]*bintree{}}, + "oracle.querytype.go.tpl": &bintree{oracleQuerytypeGoTpl, map[string]*bintree{}}, + "oracle.type.go.tpl": &bintree{oracleTypeGoTpl, map[string]*bintree{}}, + "postgres.enum.go.tpl": &bintree{postgresEnumGoTpl, map[string]*bintree{}}, "postgres.foreignkey.go.tpl": &bintree{postgresForeignkeyGoTpl, map[string]*bintree{}}, - "postgres.index.go.tpl": &bintree{postgresIndexGoTpl, map[string]*bintree{}}, - "postgres.proc.go.tpl": &bintree{postgresProcGoTpl, map[string]*bintree{}}, - "postgres.query.go.tpl": &bintree{postgresQueryGoTpl, map[string]*bintree{}}, - "postgres.querytype.go.tpl": &bintree{postgresQuerytypeGoTpl, map[string]*bintree{}}, - "postgres.type.go.tpl": &bintree{postgresTypeGoTpl, map[string]*bintree{}}, - "sqlite3.foreignkey.go.tpl": &bintree{sqlite3ForeignkeyGoTpl, map[string]*bintree{}}, - "sqlite3.index.go.tpl": &bintree{sqlite3IndexGoTpl, map[string]*bintree{}}, - "sqlite3.query.go.tpl": &bintree{sqlite3QueryGoTpl, map[string]*bintree{}}, - "sqlite3.querytype.go.tpl": &bintree{sqlite3QuerytypeGoTpl, map[string]*bintree{}}, - "sqlite3.type.go.tpl": &bintree{sqlite3TypeGoTpl, map[string]*bintree{}}, - "xo_db.go.tpl": &bintree{xo_dbGoTpl, map[string]*bintree{}}, - "xo_package.go.tpl": &bintree{xo_packageGoTpl, map[string]*bintree{}}, + "postgres.index.go.tpl": &bintree{postgresIndexGoTpl, map[string]*bintree{}}, + "postgres.proc.go.tpl": &bintree{postgresProcGoTpl, map[string]*bintree{}}, + "postgres.query.go.tpl": &bintree{postgresQueryGoTpl, map[string]*bintree{}}, + "postgres.querytype.go.tpl": &bintree{postgresQuerytypeGoTpl, map[string]*bintree{}}, + "postgres.type.go.tpl": &bintree{postgresTypeGoTpl, map[string]*bintree{}}, + "sqlite3.foreignkey.go.tpl": &bintree{sqlite3ForeignkeyGoTpl, map[string]*bintree{}}, + "sqlite3.index.go.tpl": &bintree{sqlite3IndexGoTpl, map[string]*bintree{}}, + "sqlite3.query.go.tpl": &bintree{sqlite3QueryGoTpl, map[string]*bintree{}}, + "sqlite3.querytype.go.tpl": &bintree{sqlite3QuerytypeGoTpl, map[string]*bintree{}}, + "sqlite3.type.go.tpl": &bintree{sqlite3TypeGoTpl, map[string]*bintree{}}, + "xo_db.go.tpl": &bintree{xo_dbGoTpl, map[string]*bintree{}}, + "xo_package.go.tpl": &bintree{xo_packageGoTpl, map[string]*bintree{}}, }} -// RestoreAsset restores an asset under the given directory +// RestoreAsset restores an asset under the given directory. func RestoreAsset(dir, name string) error { data, err := Asset(name) if err != nil { @@ -894,14 +936,10 @@ func RestoreAsset(dir, name string) error { if err != nil { return err } - err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) - if err != nil { - return err - } - return nil + return os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) } -// RestoreAssets restores an asset under the given directory recursively +// RestoreAssets restores an asset under the given directory recursively. func RestoreAssets(dir, name string) error { children, err := AssetDir(name) // File @@ -919,7 +957,6 @@ func RestoreAssets(dir, name string) error { } func _filePath(dir, name string) string { - cannonicalName := strings.Replace(name, "\\", "/", -1) - return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) + canonicalName := strings.Replace(name, "\\", "/", -1) + return filepath.Join(append([]string{dir}, strings.Split(canonicalName, "/")...)...) } -