diff --git a/go.mod b/go.mod index 5b63ad31fa..ecb1c5822a 100644 --- a/go.mod +++ b/go.mod @@ -23,13 +23,13 @@ require ( github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c // indirect github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 // indirect + github.com/fatih/color v1.9.0 // indirect github.com/fortytw2/leaktest v1.3.0 // indirect github.com/francoispqt/gojay v1.2.13 github.com/fsnotify/fsnotify v1.4.9 github.com/getsentry/sentry-go v0.6.1 github.com/glycerine/go-unsnap-stream v0.0.0-20190901134440-81cf024a9e0a // indirect github.com/go-asn1-ber/asn1-ber v1.5.1 // indirect - github.com/go-gorp/gorp v2.2.0+incompatible // indirect github.com/go-sql-driver/mysql v1.5.0 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 github.com/gorilla/handlers v1.4.2 @@ -58,7 +58,7 @@ require ( github.com/magiconair/properties v1.8.1 // indirect github.com/mailru/easyjson v0.7.1 // indirect github.com/mattermost/go-i18n v1.11.0 - github.com/mattermost/gorp v2.0.1-0.20200527092429-d62b7b9cadfc+incompatible + github.com/mattermost/gorp v1.6.2-0.20200624165429-2595d5e54111 github.com/mattermost/gosaml2 v0.3.2 github.com/mattermost/ldap v0.0.0-20191128190019-9f62ba4b8d4d github.com/mattermost/logr v1.0.5 @@ -75,14 +75,11 @@ require ( github.com/oklog/run v1.1.0 // indirect github.com/olekukonko/tablewriter v0.0.4 // indirect github.com/olivere/elastic v6.2.33+incompatible // indirect - github.com/onsi/ginkgo v1.12.0 // indirect - github.com/onsi/gomega v1.9.0 // indirect github.com/oov/psd v0.0.0-20200705094106-99303fb2511f github.com/opentracing/opentracing-go v1.1.0 github.com/pborman/uuid v1.2.0 github.com/pelletier/go-toml v1.8.0 // indirect github.com/pkg/errors v0.9.1 - github.com/poy/onpar v1.0.0 // indirect github.com/prometheus/client_golang v1.7.1 github.com/prometheus/client_model v0.2.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20190728182440-6a916e37a237 // indirect @@ -104,7 +101,6 @@ require ( github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect github.com/throttled/throttled v2.2.4+incompatible github.com/tinylib/msgp v1.1.2 - github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31 // indirect github.com/tylerb/graceful v1.2.15 github.com/uber/jaeger-client-go v2.24.0+incompatible github.com/uber/jaeger-lib v2.2.0+incompatible @@ -112,8 +108,6 @@ require ( github.com/wiggin77/merror v1.0.2 github.com/wiggin77/srslog v1.0.1 github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect - github.com/ziutek/mymysql v1.5.4 // indirect - go.etcd.io/bbolt v1.3.5 // indirect go.uber.org/zap v1.15.0 golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de golang.org/x/image v0.0.0-20200618115811-c13761719519 @@ -132,7 +126,6 @@ require ( gopkg.in/natefinch/lumberjack.v2 v2.0.0 gopkg.in/olivere/elastic.v6 v6.2.33 gopkg.in/yaml.v2 v2.3.0 - gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect honnef.co/go/tools v0.0.1-2020.1.3 // indirect willnorris.com/go/imageproxy v0.10.0 ) diff --git a/go.sum b/go.sum index 56b05899fb..d944a8374a 100644 --- a/go.sum +++ b/go.sum @@ -36,7 +36,6 @@ github.com/RoaringBitmap/roaring v0.4.23/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06 github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= 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/a8m/expect v1.0.0/go.mod h1:4IwSCMumY49ScypDnjNbYEjgVeqy1/U2cEs3Lat96eA= github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -196,8 +195,6 @@ github.com/go-asn1-ber/asn1-ber v1.5.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkPro github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= -github.com/go-gorp/gorp v2.2.0+incompatible h1:xAUh4QgEeqPPhK3vxZN+bzrim1z5Av6q837gtjUlshc= -github.com/go-gorp/gorp v2.2.0+incompatible/go.mod h1:7IfkAQnO7jfT/9IQ3R9wL1dFhukN6aQxzKTHnkxzA/E= 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-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= @@ -408,6 +405,7 @@ github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhR github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw= github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.7.0 h1:h93mCPfUSkaul3Ka/VG8uZdmW1uMHDGxzu0NWHuJmHY= github.com/lib/pq v1.7.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= @@ -421,8 +419,8 @@ github.com/mailru/easyjson v0.7.1/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7 github.com/marstr/guid v0.0.0-20170427235115-8bdf7d1a087c/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho= github.com/mattermost/go-i18n v1.11.0 h1:1hLKqn/ZvhZ80OekjVPGYcCrBfMz+YxNNgqS+beL7zE= github.com/mattermost/go-i18n v1.11.0/go.mod h1:RyS7FDNQlzF1PsjbJWHRI35exqaKGSO9qD4iv8QjE34= -github.com/mattermost/gorp v2.0.1-0.20200527092429-d62b7b9cadfc+incompatible h1:Ve33W6zzI7DzwiBYvbSDYoxhMCWmsXL6x6LI+sW95Ik= -github.com/mattermost/gorp v2.0.1-0.20200527092429-d62b7b9cadfc+incompatible/go.mod h1:0kX1qa3DOpaPJyOdMLeo7TcBN0QmUszj9a/VygOhDe0= +github.com/mattermost/gorp v1.6.2-0.20200624165429-2595d5e54111 h1:32+lDqjkY8hvcSnBAWEeHgigfd9FF3zWhfiDdH9j1Ko= +github.com/mattermost/gorp v1.6.2-0.20200624165429-2595d5e54111/go.mod h1:QCQ3U0M9T/BlAdjKFJo0I1oe/YAgbyjNdhU8bpOLafk= github.com/mattermost/gosaml2 v0.3.2 h1:kq2dY5qUe6fPPHra171GVlgo+ycBsEog0gZMetxL8ow= github.com/mattermost/gosaml2 v0.3.2/go.mod h1:Z429EIOiEi9kbq6yHoApfzlcXpa6dzRDc6pO+Vy2Ksk= github.com/mattermost/ldap v0.0.0-20191128190019-9f62ba4b8d4d h1:2DV7VIlEv6J5R5o6tUcb3ZMKJYeeZuWZL7Rv1m23TgQ= @@ -502,11 +500,11 @@ github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7 github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= -github.com/nelsam/hel/v2 v2.3.2 h1:tXRsJBqRxj4ISSPCrXhbqF8sT+BXA/UaIvjhYjP5Bhk= -github.com/nelsam/hel/v2 v2.3.2/go.mod h1:1ZTGfU2PFTOd5mx22i5O0Lc2GY933lQ2wb/ggy+rL3w= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= github.com/ngdinhtoan/glide-cleanup v0.2.0/go.mod h1:UQzsmiDOb8YV3nOsCxK/c9zPpCZVNoHScRE3EO9pVMM= +github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= @@ -521,14 +519,15 @@ github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.3 h1:OoxbjfXVZyod1fmWYhI7SEyaD8B00ynP3T+D5GiyHOY= github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.0 h1:Iw5WCbBcaAAd0fpRb1c9r5YCylv4XDoCSigm1zLevwU= -github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.13.0 h1:M76yO2HkZASFjXL0HSoZJ1AYEmQxNJmY41Jx1zNUq1Y= +github.com/onsi/ginkgo v1.13.0/go.mod h1:+REjRxOmWfHCjfv9TTWB1jD1Frx4XydAD3zm1lskyM0= github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1 h1:K0jcRCwNQM3vFGh1ppMtDh/+7ApJrjldlX8fA0jDTLQ= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.9.0 h1:R1uwffexN6Pr340GtYRIdZmAiN4J+iw6WG4wog1DUXg= -github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= +github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/oov/psd v0.0.0-20200705094106-99303fb2511f h1:slBBh1GLx3xo0xx0v4HT0pI02+UcOJXTYRlg6QtN60Y= github.com/oov/psd v0.0.0-20200705094106-99303fb2511f/go.mod h1:GHI1bnmAcbp96z6LNfBJvtrjxhaXGkbsk967utPlvL8= github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= @@ -561,9 +560,6 @@ github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 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/poy/onpar v0.0.0-20200406201722-06f95a1c68e8/go.mod h1:nSbFQvMj97ZyhFRSJYtut+msi4sOY6zJDGCdSc+/rZU= -github.com/poy/onpar v1.0.0 h1:MfdQ9bnas+J1si8vUHAABXKxqOqDVaH4T3LRDYYv5Lo= -github.com/poy/onpar v1.0.0/go.mod h1:6X8FLNoxyr9kkmnlqpK6LSoiOtrO6MICtWwEuWkLjzg= github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= 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 h1:D+CiwcpGTW6pL6bv6KI3KbyEyCKyS+1JWS2h8PNDnGA= @@ -625,6 +621,7 @@ github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd h1:CmH9+J6ZSsIjUK github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/satori/go.uuid v0.0.0-20180103174451-36e9d2ebbde5/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= +github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/segmentio/backo-go v0.0.0-20200129164019-23eae7c10bd3 h1:ZuhckGJ10ulaKkdvJtiAqsLTiPrLaXSdnVgXJKJkTxE= @@ -676,7 +673,6 @@ github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= @@ -719,8 +715,6 @@ github.com/tinylib/msgp v1.1.0/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDW github.com/tinylib/msgp v1.1.2 h1:gWmO7n0Ys2RBEb7GPYB9Ujq8Mk5p2U08lRnmMcGy6BQ= github.com/tinylib/msgp v1.1.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31 h1:OXcKh35JaYsGMRzpvFkLv/MEyPuL49CThT1pZ8aSml4= -github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/tylerb/graceful v1.2.15 h1:B0x01Y8fsJpogzZTkDg6BDi6eMf03s01lEKGdrv83oA= github.com/tylerb/graceful v1.2.15/go.mod h1:LPYTbOYmUTdabwRt0TGhLllQ0MUNbs0Y5q1WXJOI9II= @@ -765,15 +759,12 @@ github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmv github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs= github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.4 h1:hi1bXHMVrlQh6WwxAy+qZCV/SYIlqo+Ushwdpa4tAKg= go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= -go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0= -go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.opencensus.io v0.19.1/go.mod h1:gug0GbSHa8Pafr0d2urOSgoXHZ6x/RUlaiT0d9pqb4A= go.opencensus.io v0.19.2/go.mod h1:NO/8qkisMZLZ1FCsKNqtJPwc8/TaclWyY0B6wcYNg9M= @@ -856,6 +847,7 @@ golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -893,6 +885,7 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -905,6 +898,7 @@ golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/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= @@ -943,7 +937,6 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200313205530-4303120df7d8/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= golang.org/x/tools v0.0.0-20200626171337-aa94e735be7f h1:JcoF/bowzCDI+MXu1yLqQGNO3ibqWsWq+Sk7pOT218w= golang.org/x/tools v0.0.0-20200626171337-aa94e735be7f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1044,8 +1037,6 @@ gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20180920025451-e3ad64cb4ed3/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/store/sqlstore/supplier.go b/store/sqlstore/supplier.go index a61204a697..05d71f1bcb 100644 --- a/store/sqlstore/supplier.go +++ b/store/sqlstore/supplier.go @@ -916,7 +916,7 @@ func (ss *SqlSupplier) createIndexIfNotExists(indexName string, tableName string _, err = ss.GetMaster().ExecNoTimeout("CREATE " + uniqueStr + fullTextIndex + " INDEX " + indexName + " ON " + tableName + " (" + strings.Join(columnNames, ", ") + ")") if err != nil { - mlog.Critical("Failed to create index", mlog.Err(err)) + mlog.Critical("Failed to create index", mlog.String("table", tableName), mlog.String("index_name", indexName), mlog.Err(err)) time.Sleep(time.Second) os.Exit(EXIT_CREATE_INDEX_FULL_MYSQL) } diff --git a/store/sqlstore/team_store.go b/store/sqlstore/team_store.go index b710db3050..b013be4e7f 100644 --- a/store/sqlstore/team_store.go +++ b/store/sqlstore/team_store.go @@ -218,10 +218,12 @@ func newSqlTeamStore(sqlStore SqlStore) store.TeamStore { table.ColMap("DisplayName").SetMaxSize(64) table.ColMap("Name").SetMaxSize(64).SetUnique(true) table.ColMap("Description").SetMaxSize(255) + table.ColMap("Type").SetMaxSize(255) table.ColMap("Email").SetMaxSize(128) table.ColMap("CompanyName").SetMaxSize(64) table.ColMap("AllowedDomains").SetMaxSize(1000) table.ColMap("InviteId").SetMaxSize(32) + table.ColMap("SchemeId").SetMaxSize(26) tablem := db.AddTableWithName(teamMember{}, "TeamMembers").SetKeys(false, "TeamId", "UserId") tablem.ColMap("TeamId").SetMaxSize(26) diff --git a/store/sqlstore/upgrade.go b/store/sqlstore/upgrade.go index 67ab6fa753..cf2178a792 100644 --- a/store/sqlstore/upgrade.go +++ b/store/sqlstore/upgrade.go @@ -4,6 +4,7 @@ package sqlstore import ( + "database/sql" "encoding/json" "os" "strings" @@ -838,9 +839,74 @@ func upgradeDatabaseToVersion527(sqlStore SqlStore) { func upgradeDatabaseToVersion528(sqlStore SqlStore) { // TODO: uncomment when the time arrive to upgrade the DB for 5.28 //if shouldPerformUpgrade(sqlStore, VERSION_5_27_0, VERSION_5_28_0) { + if err := precheckMigrationToVersion528(sqlStore); err != nil { + mlog.Error("Error upgrading DB schema to 5.28.0", mlog.Err(err)) + os.Exit(EXIT_GENERIC_FAILURE) + } + sqlStore.CreateColumnIfNotExistsNoDefault("Commands", "PluginId", "VARCHAR(190)", "VARCHAR(190)") sqlStore.GetMaster().Exec("UPDATE Commands SET PluginId = '' WHERE PluginId IS NULL") - // saveSchemaVersion(sqlStore, VERSION_5_28_0) + sqlStore.AlterColumnTypeIfExists("Teams", "Type", "VARCHAR(255)", "VARCHAR(255)") + sqlStore.AlterColumnTypeIfExists("Teams", "SchemeId", "VARCHAR(26)", "VARCHAR(26)") + sqlStore.AlterColumnTypeIfExists("IncomingWebhooks", "Username", "varchar(255)", "varchar(255)") + sqlStore.AlterColumnTypeIfExists("IncomingWebhooks", "IconURL", "text", "varchar(1024)") + + //saveSchemaVersion(sqlStore, VERSION_5_28_0) //} } + +func precheckMigrationToVersion528(sqlStore SqlStore) error { + teamsQuery, _, err := sqlStore.getQueryBuilder().Select(`COALESCE(SUM(CASE + WHEN CHAR_LENGTH(SchemeId) > 26 THEN 1 + ELSE 0 + END),0) as schemeidwrong, + COALESCE(SUM(CASE + WHEN CHAR_LENGTH(Type) > 255 THEN 1 + ELSE 0 + END),0) as typewrong`). + From("Teams").ToSql() + if err != nil { + return err + } + webhooksQuery, _, err := sqlStore.getQueryBuilder().Select(`COALESCE(SUM(CASE + WHEN CHAR_LENGTH(Username) > 255 THEN 1 + ELSE 0 + END),0) as usernamewrong, + COALESCE(SUM(CASE + WHEN CHAR_LENGTH(IconURL) > 1024 THEN 1 + ELSE 0 + END),0) as iconurlwrong`). + From("IncomingWebhooks").ToSql() + if err != nil { + return err + } + + var schemeIdWrong int + var typeWrong int + row := sqlStore.GetMaster().Db.QueryRow(teamsQuery) + if err = row.Scan(&schemeIdWrong, &typeWrong); err != nil && err != sql.ErrNoRows { + return err + } else if err == nil && schemeIdWrong > 0 { + return errors.New("Migration failure: " + + "Teams column SchemeId has data larger that 26 characters") + } else if err == nil && typeWrong > 0 { + return errors.New("Migration failure: " + + "Teams column Type has data larger that 255 characters") + } + + var usernameWrong int + var iconURLWrong int + row = sqlStore.GetMaster().Db.QueryRow(webhooksQuery) + if err = row.Scan(&usernameWrong, &iconURLWrong); err != nil && err != sql.ErrNoRows { + mlog.Error("Error fetching IncomingWebhooks columns data", mlog.Err(err)) + } else if err == nil && usernameWrong > 0 { + return errors.New("Migration failure: " + + "IncomingWebhooks column Username has data larger that 255 characters") + } else if err == nil && iconURLWrong > 0 { + return errors.New("Migration failure: " + + "IncomingWebhooks column IconURL has data larger that 1024 characters") + } + + return nil +} diff --git a/store/sqlstore/webhook_store.go b/store/sqlstore/webhook_store.go index df0bf08fd5..c4608cea63 100644 --- a/store/sqlstore/webhook_store.go +++ b/store/sqlstore/webhook_store.go @@ -36,6 +36,8 @@ func newSqlWebhookStore(sqlStore SqlStore, metrics einterfaces.MetricsInterface) table.ColMap("TeamId").SetMaxSize(26) table.ColMap("DisplayName").SetMaxSize(64) table.ColMap("Description").SetMaxSize(500) + table.ColMap("Username").SetMaxSize(255) + table.ColMap("IconURL").SetMaxSize(1024) tableo := db.AddTableWithName(model.OutgoingWebhook{}, "OutgoingWebhooks").SetKeys(false, "Id") tableo.ColMap("Id").SetMaxSize(26) diff --git a/vendor/github.com/mattermost/gorp/.travis.yml b/vendor/github.com/mattermost/gorp/.travis.yml deleted file mode 100644 index d35c77e71b..0000000000 --- a/vendor/github.com/mattermost/gorp/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ -language: go -go: -- 1.6 -- 1.7 -- tip - -matrix: - allow_failures: - - go: tip - -services: -- mysql -- postgres -- sqlite3 - -env: - global: - - secure: RriLxF6+2yMl67hdVv8ImXlu0h62mhcpqjaOgYNU+IEbUQ7hx96CKY6gkpYubW3BgApvF5RH6j3+HKvh2kGp0XhDOYOQCODfBSaSipZ5Aa5RKjsEYLtuVIobvJ80awR9hUeql69+WXs0/s72WThG0qTbOUY4pqHWfteeY235hWM= - -before_script: -- mysql -e "CREATE DATABASE gorptest;" -- mysql -u root -e "GRANT ALL ON gorptest.* TO gorptest@localhost IDENTIFIED BY 'gorptest'" -- psql -c "CREATE DATABASE gorptest;" -U postgres -- psql -c "CREATE USER "gorptest" WITH SUPERUSER PASSWORD 'gorptest';" -U postgres -- go get github.com/lib/pq -- go get github.com/mattn/go-sqlite3 -- go get github.com/ziutek/mymysql/godrv -- go get github.com/go-sql-driver/mysql -- go get golang.org/x/tools/cmd/cover -- go get github.com/mattn/goveralls -- go get github.com/onsi/ginkgo/ginkgo - -script: ./test_all.sh diff --git a/vendor/github.com/mattermost/gorp/Makefile b/vendor/github.com/mattermost/gorp/Makefile new file mode 100644 index 0000000000..25188fb062 --- /dev/null +++ b/vendor/github.com/mattermost/gorp/Makefile @@ -0,0 +1,24 @@ +GOTESTFLAGS ?= -test.count=1 + +test-all: test-unit test-mymysql test-gomysql test-postgres test-sqlite + +test-unit: + echo "Running unit tests" + ginkgo -r -race -randomizeAllSpecs -keepGoing -- -test.run TestGorp + +test-mymysql: + echo "Testing against mymysql" + go test . $(GOTESTFLAGS) -dsn="tcp:localhost:3306*gorptest/gorptest/gorptest" -dialect="mysql" + +test-gomysql: + echo "Testing against gomysql" + go test . $(GOTESTFLAGS) -dsn="gorptest:gorptest@tcp(localhost:3306)/gorptest" -dialect="gomysql" + +test-postgres: + echo "Testing against postgres" + go test . $(GOTESTFLAGS) -dsn="host=localhost user=gorptest password=gorptest dbname=gorptest sslmode=disable" -dialect="postgres" + +test-sqlite: + echo "Testing against sqlite" + go test . $(GOTESTFLAGS) -dsn="/tmp/gorptest.bin" -dialect="sqlite" + rm -f /tmp/gorptest.bin \ No newline at end of file diff --git a/vendor/github.com/mattermost/gorp/README.md b/vendor/github.com/mattermost/gorp/README.md index 53ee245d30..144af16d56 100644 --- a/vendor/github.com/mattermost/gorp/README.md +++ b/vendor/github.com/mattermost/gorp/README.md @@ -536,9 +536,9 @@ func (i *Invoice) PreUpdate(s gorp.SqlExecutor) error { // func (p *Person) PreDelete(s gorp.SqlExecutor) error { query := "delete from invoice_test where PersonId=?" - + _, err := s.Exec(query, p.Id) - + if err != nil { return err } @@ -655,7 +655,7 @@ MariaDB [test]> show create table Account; `AcctId` varchar(255) DEFAULT NULL, PRIMARY KEY (`Id`), UNIQUE KEY `AcctIdIndex` (`AcctId`) USING BTREE <<<--- yes! index added. -) ENGINE=InnoDB DEFAULT CHARSET=utf8 +) ENGINE=InnoDB DEFAULT CHARSET=utf8 +---------+--------------------------+ ``` @@ -732,14 +732,18 @@ Raw SQL strings passed to `Exec`, `Select`, `SelectOne`, `SelectInt`, etc will not be parsed. Consequently you may have portability issues if you write a query like this: -```go // works on MySQL and Sqlite3, but not with Postgresql err := +```go +go // works on MySQL and Sqlite3, but not with Postgresql err := dbmap.SelectOne(&val, "select * from foo where id = ?", 30) ``` +``` In `Select` and `SelectOne` you can use named parameters to work around this. The following is portable: -```go err := dbmap.SelectOne(&val, "select * from foo where id = :id", -map[string]interface{} { "id": 30}) ``` +```go +go err := dbmap.SelectOne(&val, "select * from foo where id = :id", +map[string]interface{} { "id": 30}) +``` Additionally, when using Postgres as your database, you should utilize `$1` instead of `?` placeholders as utilizing `?` placeholders when @@ -753,8 +757,7 @@ gorp will pass `time.Time` fields through to the `database/sql` driver, but note that the behavior of this type varies across database drivers. -MySQL users should be especially cautious. See: -https://github.com/ziutek/mymysql/pull/77 +MySQL users should be especially cautious. See [this PR](https://github.com/ziutek/mymysql/pull/77) To avoid any potential issues with timezone/DST, consider: @@ -766,25 +769,26 @@ To avoid any potential issues with timezone/DST, consider: ## Running the tests The included tests may be run against MySQL, Postgresql, or sqlite3. -You must set two environment variables so the test code knows which -driver to use, and how to connect to your database. +You must set two flags, dsn and dialect, in order to test the environment you want. +If not flag is passed the tests are going to use the default ones which are: +- DSN: `gorptest:gorptest@tcp(localhost:3306)/gorptest` +- Dialect: `gomysql` -```sh +```bash # MySQL example: -export GORP_TEST_DSN=gomysql_test/gomysql_test/abc123 -export GORP_TEST_DIALECT=mysql - # run the tests -go test +go test -dsn="gorptest:gorptest@tcp(localhost:3306)/gorptest" -dialect="gomysql" # run the tests and benchmarks go test -bench="Bench" -benchtime 10 ``` -Valid `GORP_TEST_DIALECT` values are: "mysql"(for mymysql), -"gomysql"(for go-sql-driver), "postgres", "sqlite" See the -`test_all.sh` script for examples of all 3 databases. This is the -script I run locally to test the library. +Valid `dialect` flag values are: + +- [mysql](https://github.com/ziutek/mymysql) +- [gomysql](https://github.com/Go-SQL-Driver/MySQL) +- [postgres](https://github.com/lib/pq) +- [sqlite](https://github.com/mattn/go-sqlite3) ## Performance diff --git a/vendor/github.com/mattermost/gorp/db.go b/vendor/github.com/mattermost/gorp/db.go index 9463fdf4ad..d25028fd94 100644 --- a/vendor/github.com/mattermost/gorp/db.go +++ b/vendor/github.com/mattermost/gorp/db.go @@ -12,7 +12,6 @@ package gorp import ( - "bytes" "context" "database/sql" "database/sql/driver" @@ -100,7 +99,7 @@ func (m *DbMap) CreateIndex() error { func (m *DbMap) createIndexImpl(dialect reflect.Type, table *TableMap, index *IndexMap) error { - s := bytes.Buffer{} + s := strings.Builder{} s.WriteString("create") if index.Unique { s.WriteString(" unique") @@ -133,7 +132,7 @@ func (t *TableMap) DropIndex(name string) error { dialect := reflect.TypeOf(t.dbmap.Dialect) for _, idx := range t.indexes { if idx.IndexName == name { - s := bytes.Buffer{} + s := strings.Builder{} s.WriteString(fmt.Sprintf("DROP INDEX %s", idx.IndexName)) if dname := dialect.Name(); dname == "MySQLDialect" { diff --git a/vendor/github.com/mattermost/gorp/dialect_mysql.go b/vendor/github.com/mattermost/gorp/dialect_mysql.go index b263c3308c..d4c245a206 100644 --- a/vendor/github.com/mattermost/gorp/dialect_mysql.go +++ b/vendor/github.com/mattermost/gorp/dialect_mysql.go @@ -72,21 +72,21 @@ func (d MySQLDialect) ToSqlType(val reflect.Type, maxsize int, isAutoIncr bool) return "datetime" } - if maxsize < 1 { - maxsize = 255 - } - /* == About varchar(N) == * N is number of characters. - * A varchar column can store up to 65535 bytes. - * Remember that 1 character is 3 bytes in utf-8 charset. - * Also remember that each row can store up to 65535 bytes, - * and you have some overheads, so it's not possible for a - * varchar column to have 65535/3 characters really. - * So it would be better to use 'text' type in stead of - * large varchar type. + * According to the documentation, 0 < N <= 65535. + * But one utf-8 character takes 3 bytes and each row can + * be only 65535 bytes. So there is no way to know exactly + * how many chars a varchar column can actually store. + * Text columns contribute only up to 12 bytes to the row + * size as their contents are stored off-page. + * Hence, we use a conservative maximum of 512 for varchar, + * after which we switch to the text type. */ - if maxsize < 256 { + if maxsize == 0 { + // Closer match for unbounded text + return "longtext" + } else if maxsize < 256 { return fmt.Sprintf("varchar(%d)", maxsize) } else { return "text" diff --git a/vendor/github.com/mattermost/gorp/go.mod b/vendor/github.com/mattermost/gorp/go.mod new file mode 100644 index 0000000000..e183a2dbf7 --- /dev/null +++ b/vendor/github.com/mattermost/gorp/go.mod @@ -0,0 +1,13 @@ +module github.com/mattermost/gorp + +go 1.13 + +require ( + github.com/go-sql-driver/mysql v1.5.0 + github.com/lib/pq v1.3.0 + github.com/mattn/go-sqlite3 v2.0.3+incompatible + github.com/onsi/ginkgo v1.13.0 + github.com/onsi/gomega v1.10.1 + github.com/ziutek/mymysql v1.5.4 + golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 // indirect +) diff --git a/vendor/github.com/mattermost/gorp/go.sum b/vendor/github.com/mattermost/gorp/go.sum new file mode 100644 index 0000000000..441b96dc58 --- /dev/null +++ b/vendor/github.com/mattermost/gorp/go.sum @@ -0,0 +1,79 @@ +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +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/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +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 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +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 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU= +github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +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/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.13.0 h1:M76yO2HkZASFjXL0HSoZJ1AYEmQxNJmY41Jx1zNUq1Y= +github.com/onsi/ginkgo v1.13.0/go.mod h1:+REjRxOmWfHCjfv9TTWB1jD1Frx4XydAD3zm1lskyM0= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw= +github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs= +github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7 h1:AeiKBIuRw3UomYXSbLy0Mc2dDLfdtbT/IVn4keq83P0= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/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-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e h1:N7DeIrjYszNmSW409R3frPPwglRwMkXSBzwVbkOjLLA= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 h1:DYfZAGf2WMFjMxbgTjaC+2HC7NkNAQs+6Q8b9WEB/F4= +golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 h1:ogLJMz+qpzav7lGMh10LMvAkM/fAoGlaiiHYiFYdm80= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= +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/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +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 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/mattermost/gorp/gorp.go b/vendor/github.com/mattermost/gorp/gorp.go index a83b255201..8dc5bde71d 100644 --- a/vendor/github.com/mattermost/gorp/gorp.go +++ b/vendor/github.com/mattermost/gorp/gorp.go @@ -257,15 +257,15 @@ func columnToFieldIndex(m *DbMap, t reflect.Type, name string, cols []string) ([ cArguments := strings.Split(field.Tag.Get("db"), ",") fieldName = cArguments[0] - if tableMapped { - colMap := colMapOrNil(table, fieldName) - if colMap != nil { - fieldName = colMap.ColumnName - } - } if fieldName == "" || fieldName == "-" { fieldName = field.Name } + if tableMapped { + colMap := colMapOrNil(table, fieldName) + if colMap != nil && colMap.ColumnName != "-" { + fieldName = colMap.ColumnName + } + } return colName == strings.ToLower(fieldName) }) if found { diff --git a/vendor/github.com/mattermost/gorp/nulltypes.go b/vendor/github.com/mattermost/gorp/nulltypes.go index 8707703727..8dee1d408e 100644 --- a/vendor/github.com/mattermost/gorp/nulltypes.go +++ b/vendor/github.com/mattermost/gorp/nulltypes.go @@ -28,22 +28,34 @@ func (nt *NullTime) Scan(value interface{}) error { case time.Time: nt.Time, nt.Valid = t, true case []byte: - nt.Valid = false - for _, dtfmt := range []string{ - "2006-01-02 15:04:05.999999999", - "2006-01-02T15:04:05.999999999", - "2006-01-02 15:04:05", - "2006-01-02T15:04:05", - "2006-01-02 15:04", - "2006-01-02T15:04", - "2006-01-02", - "2006-01-02 15:04:05-07:00", - } { - var err error - if nt.Time, err = time.Parse(dtfmt, string(t)); err == nil { - nt.Valid = true - break - } + v := strToTime(string(t)) + if v != nil { + nt.Valid = true + nt.Time = *v + } + case string: + v := strToTime(t) + if v != nil { + nt.Valid = true + nt.Time = *v + } + } + return nil +} + +func strToTime(v string) *time.Time { + for _, dtfmt := range []string{ + "2006-01-02 15:04:05.999999999", + "2006-01-02T15:04:05.999999999", + "2006-01-02 15:04:05", + "2006-01-02T15:04:05", + "2006-01-02 15:04", + "2006-01-02T15:04", + "2006-01-02", + "2006-01-02 15:04:05-07:00", + } { + if t, err := time.Parse(dtfmt, v); err == nil { + return &t } } return nil diff --git a/vendor/github.com/mattermost/gorp/table.go b/vendor/github.com/mattermost/gorp/table.go index 138f761ec9..53783a07ce 100644 --- a/vendor/github.com/mattermost/gorp/table.go +++ b/vendor/github.com/mattermost/gorp/table.go @@ -12,7 +12,6 @@ package gorp import ( - "bytes" "fmt" "reflect" "strings" @@ -189,7 +188,7 @@ func (t *TableMap) SetVersionCol(field string) *ColumnMap { // SqlForCreateTable gets a sequence of SQL commands that will create // the specified table and any associated schema func (t *TableMap) SqlForCreate(ifNotExists bool) string { - s := bytes.Buffer{} + s := strings.Builder{} dialect := t.dbmap.Dialect if strings.TrimSpace(t.SchemaName) != "" { diff --git a/vendor/github.com/mattermost/gorp/table_bindings.go b/vendor/github.com/mattermost/gorp/table_bindings.go index 5b049a3600..2b1f6c2348 100644 --- a/vendor/github.com/mattermost/gorp/table_bindings.go +++ b/vendor/github.com/mattermost/gorp/table_bindings.go @@ -12,9 +12,9 @@ package gorp import ( - "bytes" "fmt" "reflect" + "strings" "sync" ) @@ -113,8 +113,8 @@ func (t *TableMap) bindInsert(elem reflect.Value) (bindInstance, error) { plan.once.Do(func() { plan.autoIncrIdx = -1 - s := bytes.Buffer{} - s2 := bytes.Buffer{} + s := strings.Builder{} + s2 := strings.Builder{} s.WriteString(fmt.Sprintf("insert into %s (", t.dbmap.Dialect.QuotedTableForQuery(t.SchemaName, t.TableName))) x := 0 @@ -175,7 +175,7 @@ func (t *TableMap) bindUpdate(elem reflect.Value, colFilter ColumnFilter) (bindI plan := &t.updatePlan plan.once.Do(func() { - s := bytes.Buffer{} + s := strings.Builder{} s.WriteString(fmt.Sprintf("update %s set ", t.dbmap.Dialect.QuotedTableForQuery(t.SchemaName, t.TableName))) x := 0 @@ -231,7 +231,7 @@ func (t *TableMap) bindUpdate(elem reflect.Value, colFilter ColumnFilter) (bindI func (t *TableMap) bindDelete(elem reflect.Value) (bindInstance, error) { plan := &t.deletePlan plan.once.Do(func() { - s := bytes.Buffer{} + s := strings.Builder{} s.WriteString(fmt.Sprintf("delete from %s", t.dbmap.Dialect.QuotedTableForQuery(t.SchemaName, t.TableName))) for y := range t.Columns { @@ -275,7 +275,7 @@ func (t *TableMap) bindDelete(elem reflect.Value) (bindInstance, error) { func (t *TableMap) bindGet() *bindPlan { plan := &t.getPlan plan.once.Do(func() { - s := bytes.Buffer{} + s := strings.Builder{} s.WriteString("select ") x := 0 diff --git a/vendor/github.com/mattermost/gorp/test_all.sh b/vendor/github.com/mattermost/gorp/test_all.sh deleted file mode 100644 index 4c99584efd..0000000000 --- a/vendor/github.com/mattermost/gorp/test_all.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -e - -# on macs, you may need to: -# export GOBUILDFLAG=-ldflags -linkmode=external - -coveralls_testflags="-v -covermode=count -coverprofile=coverage.out" - -echo "Running unit tests" -ginkgo -r -race -randomizeAllSpecs -keepGoing -- -test.run TestGorp - -echo "Testing against mysql" -export GORP_TEST_DSN=gorptest/gorptest/gorptest -export GORP_TEST_DIALECT=mysql -go test $coveralls_testflags $GOBUILDFLAG $@ . - -echo "Testing against gomysql" -export GORP_TEST_DSN=gorptest:gorptest@/gorptest -export GORP_TEST_DIALECT=gomysql -go test $coveralls_testflags $GOBUILDFLAG $@ . - -echo "Testing against postgres" -export GORP_TEST_DSN="user=gorptest password=gorptest dbname=gorptest sslmode=disable" -export GORP_TEST_DIALECT=postgres -go test $coveralls_testflags $GOBUILDFLAG $@ . - -echo "Testing against sqlite" -export GORP_TEST_DSN=/tmp/gorptest.bin -export GORP_TEST_DIALECT=sqlite -go test $coveralls_testflags $GOBUILDFLAG $@ . -rm -f /tmp/gorptest.bin - -case $(go version) in - *go1.4*) - if [ "$(type -p goveralls)" != "" ]; then - goveralls -covermode=count -coverprofile=coverage.out -service=travis-ci - elif [ -x $HOME/gopath/bin/goveralls ]; then - $HOME/gopath/bin/goveralls -covermode=count -coverprofile=coverage.out -service=travis-ci - fi - ;; - *) ;; -esac diff --git a/vendor/github.com/tinylib/msgp/.gitignore b/vendor/github.com/tinylib/msgp/.gitignore deleted file mode 100644 index 1acaf6cdd5..0000000000 --- a/vendor/github.com/tinylib/msgp/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -_generated/generated.go -_generated/generated_test.go -_generated/*_gen.go -_generated/*_gen_test.go -_generated/embeddedStruct/*_gen.go -_generated/embeddedStruct/*_gen_test.go -msgp/defgen_test.go -msgp/cover.out -*~ -*.coverprofile diff --git a/vendor/github.com/tinylib/msgp/.travis.yml b/vendor/github.com/tinylib/msgp/.travis.yml deleted file mode 100644 index 5f574c093b..0000000000 --- a/vendor/github.com/tinylib/msgp/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: go - -go: - - 1.12.x - - tip - -env: - - GIMME_ARCH=amd64 - - GIMME_ARCH=386 - -script: "make travis" diff --git a/vendor/github.com/tinylib/msgp/Makefile b/vendor/github.com/tinylib/msgp/Makefile deleted file mode 100644 index 4cc2dd281d..0000000000 --- a/vendor/github.com/tinylib/msgp/Makefile +++ /dev/null @@ -1,52 +0,0 @@ - -# NOTE: This Makefile is only necessary if you -# plan on developing the msgp tool and library. -# Installation can still be performed with a -# normal `go install`. - -# generated integration test files -GGEN = ./_generated/generated.go ./_generated/generated_test.go -# generated unit test files -MGEN = ./msgp/defgen_test.go - -SHELL := /bin/bash - -BIN = $(GOBIN)/msgp - -.PHONY: clean wipe install get-deps bench all - -$(BIN): */*.go - @go install ./... - -install: $(BIN) - -$(GGEN): ./_generated/def.go - go generate ./_generated - -$(MGEN): ./msgp/defs_test.go - go generate ./msgp - -test: all - go test ./... ./_generated - -bench: all - go test -bench ./... - -clean: - $(RM) $(GGEN) $(MGEN) - -wipe: clean - $(RM) $(BIN) - -get-deps: - go get -d -t ./... - -all: install $(GGEN) $(MGEN) - -# travis CI enters here -travis: - go get -d -t ./... - go build -o "$${GOPATH%%:*}/bin/msgp" . - go generate ./msgp - go generate ./_generated - go test -v ./... ./_generated diff --git a/vendor/github.com/tinylib/msgp/README.md b/vendor/github.com/tinylib/msgp/README.md deleted file mode 100644 index 1328ccafe4..0000000000 --- a/vendor/github.com/tinylib/msgp/README.md +++ /dev/null @@ -1,102 +0,0 @@ -MessagePack Code Generator [![Build Status](https://travis-ci.org/tinylib/msgp.svg?branch=master)](https://travis-ci.org/tinylib/msgp) -======= - -This is a code generation tool and serialization library for [MessagePack](http://msgpack.org). You can read more about MessagePack [in the wiki](http://github.com/tinylib/msgp/wiki), or at [msgpack.org](http://msgpack.org). - -### Why? - -- Use Go as your schema language -- Performance -- [JSON interop](http://godoc.org/github.com/tinylib/msgp/msgp#CopyToJSON) -- [User-defined extensions](http://github.com/tinylib/msgp/wiki/Using-Extensions) -- Type safety -- Encoding flexibility - -### Quickstart - -In a source file, include the following directive: - -```go -//go:generate msgp -``` - -The `msgp` command will generate serialization methods for all exported type declarations in the file. - -You can [read more about the code generation options here](http://github.com/tinylib/msgp/wiki/Using-the-Code-Generator). - -### Use - -Field names can be set in much the same way as the `encoding/json` package. For example: - -```go -type Person struct { - Name string `msg:"name"` - Address string `msg:"address"` - Age int `msg:"age"` - Hidden string `msg:"-"` // this field is ignored - unexported bool // this field is also ignored -} -``` - -By default, the code generator will satisfy `msgp.Sizer`, `msgp.Encodable`, `msgp.Decodable`, -`msgp.Marshaler`, and `msgp.Unmarshaler`. Carefully-designed applications can use these methods to do -marshalling/unmarshalling with zero heap allocations. - -While `msgp.Marshaler` and `msgp.Unmarshaler` are quite similar to the standard library's -`json.Marshaler` and `json.Unmarshaler`, `msgp.Encodable` and `msgp.Decodable` are useful for -stream serialization. (`*msgp.Writer` and `*msgp.Reader` are essentially protocol-aware versions -of `*bufio.Writer` and `*bufio.Reader`, respectively.) - -### Features - - - Extremely fast generated code - - Test and benchmark generation - - JSON interoperability (see `msgp.CopyToJSON() and msgp.UnmarshalAsJSON()`) - - Support for complex type declarations - - Native support for Go's `time.Time`, `complex64`, and `complex128` types - - Generation of both `[]byte`-oriented and `io.Reader/io.Writer`-oriented methods - - Support for arbitrary type system extensions - - [Preprocessor directives](http://github.com/tinylib/msgp/wiki/Preprocessor-Directives) - - File-based dependency model means fast codegen regardless of source tree size. - -Consider the following: -```go -const Eight = 8 -type MyInt int -type Data []byte - -type Struct struct { - Which map[string]*MyInt `msg:"which"` - Other Data `msg:"other"` - Nums [Eight]float64 `msg:"nums"` -} -``` -As long as the declarations of `MyInt` and `Data` are in the same file as `Struct`, the parser will determine that the type information for `MyInt` and `Data` can be passed into the definition of `Struct` before its methods are generated. - -#### Extensions - -MessagePack supports defining your own types through "extensions," which are just a tuple of -the data "type" (`int8`) and the raw binary. You [can see a worked example in the wiki.](http://github.com/tinylib/msgp/wiki/Using-Extensions) - -### Status - -Mostly stable, in that no breaking changes have been made to the `/msgp` library in more than a year. Newer versions -of the code may generate different code than older versions for performance reasons. I (@philhofer) am aware of a -number of stability-critical commercial applications that use this code with good results. But, caveat emptor. - -You can read more about how `msgp` maps MessagePack types onto Go types [in the wiki](http://github.com/tinylib/msgp/wiki). - -Here some of the known limitations/restrictions: - -- Identifiers from outside the processed source file are assumed (optimistically) to satisfy the generator's interfaces. If this isn't the case, your code will fail to compile. -- Like most serializers, `chan` and `func` fields are ignored, as well as non-exported fields. -- Encoding of `interface{}` is limited to built-ins or types that have explicit encoding methods. -- _Maps must have `string` keys._ This is intentional (as it preserves JSON interop.) Although non-string map keys are not forbidden by the MessagePack standard, many serializers impose this restriction. (It also means *any* well-formed `struct` can be de-serialized into a `map[string]interface{}`.) The only exception to this rule is that the deserializers will allow you to read map keys encoded as `bin` types, due to the fact that some legacy encodings permitted this. (However, those values will still be cast to Go `string`s, and they will be converted to `str` types when re-encoded. It is the responsibility of the user to ensure that map keys are UTF-8 safe in this case.) The same rules hold true for JSON translation. - -If the output compiles, then there's a pretty good chance things are fine. (Plus, we generate tests for you.) *Please, please, please* file an issue if you think the generator is writing broken code. - -### Performance - -If you like benchmarks, see [here](http://bravenewgeek.com/so-you-wanna-go-fast/) and [here](https://github.com/alecthomas/go_serialization_benchmarks). - -As one might expect, the generated methods that deal with `[]byte` are faster for small objects, but the `io.Reader/Writer` methods are generally more memory-efficient (and, at some point, faster) for large (> 2KB) objects. diff --git a/vendor/github.com/tinylib/msgp/gen/decode.go b/vendor/github.com/tinylib/msgp/gen/decode.go deleted file mode 100644 index 10f3fd8af5..0000000000 --- a/vendor/github.com/tinylib/msgp/gen/decode.go +++ /dev/null @@ -1,231 +0,0 @@ -package gen - -import ( - "io" - "strconv" -) - -func decode(w io.Writer) *decodeGen { - return &decodeGen{ - p: printer{w: w}, - hasfield: false, - } -} - -type decodeGen struct { - passes - p printer - hasfield bool - ctx *Context -} - -func (d *decodeGen) Method() Method { return Decode } - -func (d *decodeGen) needsField() { - if d.hasfield { - return - } - d.p.print("\nvar field []byte; _ = field") - d.hasfield = true -} - -func (d *decodeGen) Execute(p Elem) error { - p = d.applyall(p) - if p == nil { - return nil - } - d.hasfield = false - if !d.p.ok() { - return d.p.err - } - - if !IsPrintable(p) { - return nil - } - - d.ctx = &Context{} - - d.p.comment("DecodeMsg implements msgp.Decodable") - - d.p.printf("\nfunc (%s %s) DecodeMsg(dc *msgp.Reader) (err error) {", p.Varname(), methodReceiver(p)) - next(d, p) - d.p.nakedReturn() - unsetReceiver(p) - return d.p.err -} - -func (d *decodeGen) gStruct(s *Struct) { - if !d.p.ok() { - return - } - if s.AsTuple { - d.structAsTuple(s) - } else { - d.structAsMap(s) - } - return -} - -func (d *decodeGen) assignAndCheck(name string, typ string) { - if !d.p.ok() { - return - } - d.p.printf("\n%s, err = dc.Read%s()", name, typ) - d.p.wrapErrCheck(d.ctx.ArgsStr()) -} - -func (d *decodeGen) structAsTuple(s *Struct) { - nfields := len(s.Fields) - - sz := randIdent() - d.p.declare(sz, u32) - d.assignAndCheck(sz, arrayHeader) - d.p.arrayCheck(strconv.Itoa(nfields), sz) - for i := range s.Fields { - if !d.p.ok() { - return - } - d.ctx.PushString(s.Fields[i].FieldName) - next(d, s.Fields[i].FieldElem) - d.ctx.Pop() - } -} - -func (d *decodeGen) structAsMap(s *Struct) { - d.needsField() - sz := randIdent() - d.p.declare(sz, u32) - d.assignAndCheck(sz, mapHeader) - - d.p.printf("\nfor %s > 0 {\n%s--", sz, sz) - d.assignAndCheck("field", mapKey) - d.p.print("\nswitch msgp.UnsafeString(field) {") - for i := range s.Fields { - d.ctx.PushString(s.Fields[i].FieldName) - d.p.printf("\ncase \"%s\":", s.Fields[i].FieldTag) - next(d, s.Fields[i].FieldElem) - d.ctx.Pop() - if !d.p.ok() { - return - } - } - d.p.print("\ndefault:\nerr = dc.Skip()") - d.p.wrapErrCheck(d.ctx.ArgsStr()) - - d.p.closeblock() // close switch - d.p.closeblock() // close for loop -} - -func (d *decodeGen) gBase(b *BaseElem) { - if !d.p.ok() { - return - } - - // open block for 'tmp' - var tmp string - if b.Convert { - tmp = randIdent() - d.p.printf("\n{ var %s %s", tmp, b.BaseType()) - } - - vname := b.Varname() // e.g. "z.FieldOne" - bname := b.BaseName() // e.g. "Float64" - - // handle special cases - // for object type. - switch b.Value { - case Bytes: - if b.Convert { - d.p.printf("\n%s, err = dc.ReadBytes([]byte(%s))", tmp, vname) - } else { - d.p.printf("\n%s, err = dc.ReadBytes(%s)", vname, vname) - } - case IDENT: - d.p.printf("\nerr = %s.DecodeMsg(dc)", vname) - case Ext: - d.p.printf("\nerr = dc.ReadExtension(%s)", vname) - default: - if b.Convert { - d.p.printf("\n%s, err = dc.Read%s()", tmp, bname) - } else { - d.p.printf("\n%s, err = dc.Read%s()", vname, bname) - } - } - d.p.wrapErrCheck(d.ctx.ArgsStr()) - - // close block for 'tmp' - if b.Convert { - if b.ShimMode == Cast { - d.p.printf("\n%s = %s(%s)\n}", vname, b.FromBase(), tmp) - } else { - d.p.printf("\n%s, err = %s(%s)\n}", vname, b.FromBase(), tmp) - d.p.wrapErrCheck(d.ctx.ArgsStr()) - } - } -} - -func (d *decodeGen) gMap(m *Map) { - if !d.p.ok() { - return - } - sz := randIdent() - - // resize or allocate map - d.p.declare(sz, u32) - d.assignAndCheck(sz, mapHeader) - d.p.resizeMap(sz, m) - - // for element in map, read string/value - // pair and assign - d.p.printf("\nfor %s > 0 {\n%s--", sz, sz) - d.p.declare(m.Keyidx, "string") - d.p.declare(m.Validx, m.Value.TypeName()) - d.assignAndCheck(m.Keyidx, stringTyp) - d.ctx.PushVar(m.Keyidx) - next(d, m.Value) - d.p.mapAssign(m) - d.ctx.Pop() - d.p.closeblock() -} - -func (d *decodeGen) gSlice(s *Slice) { - if !d.p.ok() { - return - } - sz := randIdent() - d.p.declare(sz, u32) - d.assignAndCheck(sz, arrayHeader) - d.p.resizeSlice(sz, s) - d.p.rangeBlock(d.ctx, s.Index, s.Varname(), d, s.Els) -} - -func (d *decodeGen) gArray(a *Array) { - if !d.p.ok() { - return - } - - // special case if we have [const]byte - if be, ok := a.Els.(*BaseElem); ok && (be.Value == Byte || be.Value == Uint8) { - d.p.printf("\nerr = dc.ReadExactBytes((%s)[:])", a.Varname()) - d.p.wrapErrCheck(d.ctx.ArgsStr()) - return - } - sz := randIdent() - d.p.declare(sz, u32) - d.assignAndCheck(sz, arrayHeader) - d.p.arrayCheck(coerceArraySize(a.Size), sz) - d.p.rangeBlock(d.ctx, a.Index, a.Varname(), d, a.Els) -} - -func (d *decodeGen) gPtr(p *Ptr) { - if !d.p.ok() { - return - } - d.p.print("\nif dc.IsNil() {") - d.p.print("\nerr = dc.ReadNil()") - d.p.wrapErrCheck(d.ctx.ArgsStr()) - d.p.printf("\n%s = nil\n} else {", p.Varname()) - d.p.initPtr(p) - next(d, p.Value) - d.p.closeblock() -} diff --git a/vendor/github.com/tinylib/msgp/gen/elem.go b/vendor/github.com/tinylib/msgp/gen/elem.go deleted file mode 100644 index 50f07e79e5..0000000000 --- a/vendor/github.com/tinylib/msgp/gen/elem.go +++ /dev/null @@ -1,739 +0,0 @@ -package gen - -import ( - "fmt" - "strings" -) - -var ( - identNext = 0 - identPrefix = "za" -) - -func resetIdent(prefix string) { - identPrefix = prefix - identNext = 0 -} - -// generate a random identifier name -func randIdent() string { - identNext++ - return fmt.Sprintf("%s%04d", identPrefix, identNext) -} - -// This code defines the type declaration tree. -// -// Consider the following: -// -// type Marshaler struct { -// Thing1 *float64 `msg:"thing1"` -// Body []byte `msg:"body"` -// } -// -// A parser using this generator as a backend -// should parse the above into: -// -// var val Elem = &Ptr{ -// name: "z", -// Value: &Struct{ -// Name: "Marshaler", -// Fields: []StructField{ -// { -// FieldTag: "thing1", -// FieldElem: &Ptr{ -// name: "z.Thing1", -// Value: &BaseElem{ -// name: "*z.Thing1", -// Value: Float64, -// Convert: false, -// }, -// }, -// }, -// { -// FieldTag: "body", -// FieldElem: &BaseElem{ -// name: "z.Body", -// Value: Bytes, -// Convert: false, -// }, -// }, -// }, -// }, -// } - -// Base is one of the -// base types -type Primitive uint8 - -// this is effectively the -// list of currently available -// ReadXxxx / WriteXxxx methods. -const ( - Invalid Primitive = iota - Bytes - String - Float32 - Float64 - Complex64 - Complex128 - Uint - Uint8 - Uint16 - Uint32 - Uint64 - Byte - Int - Int8 - Int16 - Int32 - Int64 - Bool - Intf // interface{} - Time // time.Time - Ext // extension - - IDENT // IDENT means an unrecognized identifier -) - -// all of the recognized identities -// that map to primitive types -var primitives = map[string]Primitive{ - "[]byte": Bytes, - "string": String, - "float32": Float32, - "float64": Float64, - "complex64": Complex64, - "complex128": Complex128, - "uint": Uint, - "uint8": Uint8, - "uint16": Uint16, - "uint32": Uint32, - "uint64": Uint64, - "byte": Byte, - "rune": Int32, - "int": Int, - "int8": Int8, - "int16": Int16, - "int32": Int32, - "int64": Int64, - "bool": Bool, - "interface{}": Intf, - "time.Time": Time, - "msgp.Extension": Ext, -} - -// types built into the library -// that satisfy all of the -// interfaces. -var builtins = map[string]struct{}{ - "msgp.Raw": struct{}{}, - "msgp.Number": struct{}{}, -} - -// common data/methods for every Elem -type common struct{ vname, alias string } - -func (c *common) SetVarname(s string) { c.vname = s } -func (c *common) Varname() string { return c.vname } -func (c *common) Alias(typ string) { c.alias = typ } -func (c *common) hidden() {} - -func IsPrintable(e Elem) bool { - if be, ok := e.(*BaseElem); ok && !be.Printable() { - return false - } - return true -} - -// Elem is a go type capable of being -// serialized into MessagePack. It is -// implemented by *Ptr, *Struct, *Array, -// *Slice, *Map, and *BaseElem. -type Elem interface { - // SetVarname sets this nodes - // variable name and recursively - // sets the names of all its children. - // In general, this should only be - // called on the parent of the tree. - SetVarname(s string) - - // Varname returns the variable - // name of the element. - Varname() string - - // TypeName is the canonical - // go type name of the node - // e.g. "string", "int", "map[string]float64" - // OR the alias name, if it has been set. - TypeName() string - - // Alias sets a type (alias) name - Alias(typ string) - - // Copy should perform a deep copy of the object - Copy() Elem - - // Complexity returns a measure of the - // complexity of element (greater than - // or equal to 1.) - Complexity() int - - // ZeroExpr returns the expression for the correct zero/empty - // value. Can be used for assignment. - // Returns "" if zero/empty not supported for this Elem. - ZeroExpr() string - - // IfZeroExpr returns the expression to compare to zero/empty - // for this type. It is meant to be used in an if statement - // and may include the simple statement form followed by - // semicolon and then the expression. - // Returns "" if zero/empty not supported for this Elem. - IfZeroExpr() string - - hidden() -} - -// Ident returns the *BaseElem that corresponds -// to the provided identity. -func Ident(id string) *BaseElem { - p, ok := primitives[id] - if ok { - return &BaseElem{Value: p} - } - be := &BaseElem{Value: IDENT} - be.Alias(id) - return be -} - -type Array struct { - common - Index string // index variable name - Size string // array size - Els Elem // child -} - -func (a *Array) SetVarname(s string) { - a.common.SetVarname(s) -ridx: - a.Index = randIdent() - - // try to avoid using the same - // index as a parent slice - if strings.Contains(a.Varname(), a.Index) { - goto ridx - } - - a.Els.SetVarname(fmt.Sprintf("%s[%s]", a.Varname(), a.Index)) -} - -func (a *Array) TypeName() string { - if a.common.alias != "" { - return a.common.alias - } - a.common.Alias(fmt.Sprintf("[%s]%s", a.Size, a.Els.TypeName())) - return a.common.alias -} - -func (a *Array) Copy() Elem { - b := *a - b.Els = a.Els.Copy() - return &b -} - -func (a *Array) Complexity() int { return 1 + a.Els.Complexity() } - -// ZeroExpr returns the zero/empty expression or empty string if not supported. Unsupported for this case. -func (a *Array) ZeroExpr() string { return "" } - -// IfZeroExpr unsupported -func (a *Array) IfZeroExpr() string { return "" } - -// Map is a map[string]Elem -type Map struct { - common - Keyidx string // key variable name - Validx string // value variable name - Value Elem // value element -} - -func (m *Map) SetVarname(s string) { - m.common.SetVarname(s) -ridx: - m.Keyidx = randIdent() - m.Validx = randIdent() - - // just in case - if m.Keyidx == m.Validx { - goto ridx - } - - m.Value.SetVarname(m.Validx) -} - -func (m *Map) TypeName() string { - if m.common.alias != "" { - return m.common.alias - } - m.common.Alias("map[string]" + m.Value.TypeName()) - return m.common.alias -} - -func (m *Map) Copy() Elem { - g := *m - g.Value = m.Value.Copy() - return &g -} - -func (m *Map) Complexity() int { return 2 + m.Value.Complexity() } - -// ZeroExpr returns the zero/empty expression or empty string if not supported. Always "nil" for this case. -func (m *Map) ZeroExpr() string { return "nil" } - -// IfZeroExpr returns the expression to compare to zero/empty. -func (m *Map) IfZeroExpr() string { return m.Varname() + " == nil" } - -type Slice struct { - common - Index string - Els Elem // The type of each element -} - -func (s *Slice) SetVarname(a string) { - s.common.SetVarname(a) - s.Index = randIdent() - varName := s.Varname() - if varName[0] == '*' { - // Pointer-to-slice requires parenthesis for slicing. - varName = "(" + varName + ")" - } - s.Els.SetVarname(fmt.Sprintf("%s[%s]", varName, s.Index)) -} - -func (s *Slice) TypeName() string { - if s.common.alias != "" { - return s.common.alias - } - s.common.Alias("[]" + s.Els.TypeName()) - return s.common.alias -} - -func (s *Slice) Copy() Elem { - z := *s - z.Els = s.Els.Copy() - return &z -} - -func (s *Slice) Complexity() int { - return 1 + s.Els.Complexity() -} - -// ZeroExpr returns the zero/empty expression or empty string if not supported. Always "nil" for this case. -func (s *Slice) ZeroExpr() string { return "nil" } - -// IfZeroExpr returns the expression to compare to zero/empty. -func (s *Slice) IfZeroExpr() string { return s.Varname() + " == nil" } - -type Ptr struct { - common - Value Elem -} - -func (s *Ptr) SetVarname(a string) { - s.common.SetVarname(a) - - // struct fields are dereferenced - // automatically... - switch x := s.Value.(type) { - case *Struct: - // struct fields are automatically dereferenced - x.SetVarname(a) - return - - case *BaseElem: - // identities have pointer receivers - if x.Value == IDENT { - x.SetVarname(a) - } else { - x.SetVarname("*" + a) - } - return - - default: - s.Value.SetVarname("*" + a) - return - } -} - -func (s *Ptr) TypeName() string { - if s.common.alias != "" { - return s.common.alias - } - s.common.Alias("*" + s.Value.TypeName()) - return s.common.alias -} - -func (s *Ptr) Copy() Elem { - v := *s - v.Value = s.Value.Copy() - return &v -} - -func (s *Ptr) Complexity() int { return 1 + s.Value.Complexity() } - -func (s *Ptr) Needsinit() bool { - if be, ok := s.Value.(*BaseElem); ok && be.needsref { - return false - } - return true -} - -// ZeroExpr returns the zero/empty expression or empty string if not supported. Always "nil" for this case. -func (s *Ptr) ZeroExpr() string { return "nil" } - -// IfZeroExpr returns the expression to compare to zero/empty. -func (s *Ptr) IfZeroExpr() string { return s.Varname() + " == nil" } - -type Struct struct { - common - Fields []StructField // field list - AsTuple bool // write as an array instead of a map -} - -func (s *Struct) TypeName() string { - if s.common.alias != "" { - return s.common.alias - } - str := "struct{\n" - for i := range s.Fields { - str += s.Fields[i].FieldName + - " " + s.Fields[i].FieldElem.TypeName() + - " " + s.Fields[i].RawTag + ";\n" - } - str += "}" - s.common.Alias(str) - return s.common.alias -} - -func (s *Struct) SetVarname(a string) { - s.common.SetVarname(a) - writeStructFields(s.Fields, a) -} - -func (s *Struct) Copy() Elem { - g := *s - g.Fields = make([]StructField, len(s.Fields)) - copy(g.Fields, s.Fields) - for i := range s.Fields { - g.Fields[i].FieldElem = s.Fields[i].FieldElem.Copy() - } - return &g -} - -func (s *Struct) Complexity() int { - c := 1 - for i := range s.Fields { - c += s.Fields[i].FieldElem.Complexity() - } - return c -} - -// ZeroExpr returns the zero/empty expression or empty string if not supported. -func (s *Struct) ZeroExpr() string { - if s.alias == "" { - return "" // structs with no names not supported (for now) - } - return "(" + s.TypeName() + "{})" -} - -// IfZeroExpr returns the expression to compare to zero/empty. -func (s *Struct) IfZeroExpr() string { - if s.alias == "" { - return "" // structs with no names not supported (for now) - } - return s.Varname() + " == " + s.ZeroExpr() -} - -// AnyHasTagPart returns true if HasTagPart(p) is true for any field. -func (s *Struct) AnyHasTagPart(pname string) bool { - for _, sf := range s.Fields { - if sf.HasTagPart(pname) { - return true - } - } - return false -} - -type StructField struct { - FieldTag string // the string inside the `msg:""` tag up to the first comma - FieldTagParts []string // the string inside the `msg:""` tag split by commas - RawTag string // the full struct tag - FieldName string // the name of the struct field - FieldElem Elem // the field type -} - -// HasTagPart returns true if the specified tag part (option) is present. -func (sf *StructField) HasTagPart(pname string) bool { - if len(sf.FieldTagParts) < 2 { - return false - } - for _, p := range sf.FieldTagParts[1:] { - if p == pname { - return true - } - } - return false -} - -type ShimMode int - -const ( - Cast ShimMode = iota - Convert -) - -// BaseElem is an element that -// can be represented by a primitive -// MessagePack type. -type BaseElem struct { - common - ShimMode ShimMode // Method used to shim - ShimToBase string // shim to base type, or empty - ShimFromBase string // shim from base type, or empty - Value Primitive // Type of element - Convert bool // should we do an explicit conversion? - mustinline bool // must inline; not printable - needsref bool // needs reference for shim -} - -func (s *BaseElem) Printable() bool { return !s.mustinline } - -func (s *BaseElem) Alias(typ string) { - s.common.Alias(typ) - if s.Value != IDENT { - s.Convert = true - } - if strings.Contains(typ, ".") { - s.mustinline = true - } -} - -func (s *BaseElem) SetVarname(a string) { - // extensions whose parents - // are not pointers need to - // be explicitly referenced - if s.Value == Ext || s.needsref { - if strings.HasPrefix(a, "*") { - s.common.SetVarname(a[1:]) - return - } - s.common.SetVarname("&" + a) - return - } - - s.common.SetVarname(a) -} - -// TypeName returns the syntactically correct Go -// type name for the base element. -func (s *BaseElem) TypeName() string { - if s.common.alias != "" { - return s.common.alias - } - s.common.Alias(s.BaseType()) - return s.common.alias -} - -// ToBase, used if Convert==true, is used as tmp = {{ToBase}}({{Varname}}) -func (s *BaseElem) ToBase() string { - if s.ShimToBase != "" { - return s.ShimToBase - } - return s.BaseType() -} - -// FromBase, used if Convert==true, is used as {{Varname}} = {{FromBase}}(tmp) -func (s *BaseElem) FromBase() string { - if s.ShimFromBase != "" { - return s.ShimFromBase - } - return s.TypeName() -} - -// BaseName returns the string form of the -// base type (e.g. Float64, Ident, etc) -func (s *BaseElem) BaseName() string { - // time is a special case; - // we strip the package prefix - if s.Value == Time { - return "Time" - } - return s.Value.String() -} - -func (s *BaseElem) BaseType() string { - switch s.Value { - case IDENT: - return s.TypeName() - - // exceptions to the naming/capitalization - // rule: - case Intf: - return "interface{}" - case Bytes: - return "[]byte" - case Time: - return "time.Time" - case Ext: - return "msgp.Extension" - - // everything else is base.String() with - // the first letter as lowercase - default: - return strings.ToLower(s.BaseName()) - } -} - -func (s *BaseElem) Needsref(b bool) { - s.needsref = b -} - -func (s *BaseElem) Copy() Elem { - g := *s - return &g -} - -func (s *BaseElem) Complexity() int { - if s.Convert && !s.mustinline { - return 2 - } - // we need to return 1 if !printable(), - // in order to make sure that stuff gets - // inlined appropriately - return 1 -} - -// Resolved returns whether or not -// the type of the element is -// a primitive or a builtin provided -// by the package. -func (s *BaseElem) Resolved() bool { - if s.Value == IDENT { - _, ok := builtins[s.TypeName()] - return ok - } - return true -} - -// ZeroExpr returns the zero/empty expression or empty string if not supported. -func (s *BaseElem) ZeroExpr() string { - - switch s.Value { - case Bytes: - return "nil" - case String: - return "\"\"" - case Complex64, Complex128: - return "complex(0,0)" - case Float32, - Float64, - Uint, - Uint8, - Uint16, - Uint32, - Uint64, - Byte, - Int, - Int8, - Int16, - Int32, - Int64: - return "0" - case Bool: - return "false" - - case Time: - return "(time.Time{})" - - } - - return "" -} - -// IfZeroExpr returns the expression to compare to zero/empty. -func (s *BaseElem) IfZeroExpr() string { - z := s.ZeroExpr() - if z == "" { - return "" - } - return s.Varname() + " == " + z -} - -func (k Primitive) String() string { - switch k { - case String: - return "String" - case Bytes: - return "Bytes" - case Float32: - return "Float32" - case Float64: - return "Float64" - case Complex64: - return "Complex64" - case Complex128: - return "Complex128" - case Uint: - return "Uint" - case Uint8: - return "Uint8" - case Uint16: - return "Uint16" - case Uint32: - return "Uint32" - case Uint64: - return "Uint64" - case Byte: - return "Byte" - case Int: - return "Int" - case Int8: - return "Int8" - case Int16: - return "Int16" - case Int32: - return "Int32" - case Int64: - return "Int64" - case Bool: - return "Bool" - case Intf: - return "Intf" - case Time: - return "time.Time" - case Ext: - return "Extension" - case IDENT: - return "Ident" - default: - return "INVALID" - } -} - -// writeStructFields is a trampoline for writeBase for -// all of the fields in a struct -func writeStructFields(s []StructField, name string) { - for i := range s { - s[i].FieldElem.SetVarname(fmt.Sprintf("%s.%s", name, s[i].FieldName)) - } -} - -// coerceArraySize ensures we can compare constant array lengths. -// -// msgpack array headers are 32 bit unsigned, which is reflected in the -// ArrayHeader implementation in this library using uint32. On the Go side, we -// can declare array lengths as any constant integer width, which breaks when -// attempting a direct comparison to an array header's uint32. -// -func coerceArraySize(asz string) string { - return fmt.Sprintf("uint32(%s)", asz) -} diff --git a/vendor/github.com/tinylib/msgp/gen/encode.go b/vendor/github.com/tinylib/msgp/gen/encode.go deleted file mode 100644 index a1d0b30739..0000000000 --- a/vendor/github.com/tinylib/msgp/gen/encode.go +++ /dev/null @@ -1,270 +0,0 @@ -package gen - -import ( - "fmt" - "io" - "strings" - - "github.com/tinylib/msgp/msgp" -) - -func encode(w io.Writer) *encodeGen { - return &encodeGen{ - p: printer{w: w}, - } -} - -type encodeGen struct { - passes - p printer - fuse []byte - ctx *Context -} - -func (e *encodeGen) Method() Method { return Encode } - -func (e *encodeGen) Apply(dirs []string) error { - return nil -} - -func (e *encodeGen) writeAndCheck(typ string, argfmt string, arg interface{}) { - e.p.printf("\nerr = en.Write%s(%s)", typ, fmt.Sprintf(argfmt, arg)) - e.p.wrapErrCheck(e.ctx.ArgsStr()) -} - -func (e *encodeGen) fuseHook() { - if len(e.fuse) > 0 { - e.appendraw(e.fuse) - e.fuse = e.fuse[:0] - } -} - -func (e *encodeGen) Fuse(b []byte) { - if len(e.fuse) > 0 { - e.fuse = append(e.fuse, b...) - } else { - e.fuse = b - } -} - -func (e *encodeGen) Execute(p Elem) error { - if !e.p.ok() { - return e.p.err - } - p = e.applyall(p) - if p == nil { - return nil - } - if !IsPrintable(p) { - return nil - } - - e.ctx = &Context{} - - e.p.comment("EncodeMsg implements msgp.Encodable") - - e.p.printf("\nfunc (%s %s) EncodeMsg(en *msgp.Writer) (err error) {", p.Varname(), imutMethodReceiver(p)) - next(e, p) - e.p.nakedReturn() - return e.p.err -} - -func (e *encodeGen) gStruct(s *Struct) { - if !e.p.ok() { - return - } - if s.AsTuple { - e.tuple(s) - } else { - e.structmap(s) - } - return -} - -func (e *encodeGen) tuple(s *Struct) { - nfields := len(s.Fields) - data := msgp.AppendArrayHeader(nil, uint32(nfields)) - e.p.printf("\n// array header, size %d", nfields) - e.Fuse(data) - if len(s.Fields) == 0 { - e.fuseHook() - } - for i := range s.Fields { - if !e.p.ok() { - return - } - e.ctx.PushString(s.Fields[i].FieldName) - next(e, s.Fields[i].FieldElem) - e.ctx.Pop() - } -} - -func (e *encodeGen) appendraw(bts []byte) { - e.p.print("\nerr = en.Append(") - for i, b := range bts { - if i != 0 { - e.p.print(", ") - } - e.p.printf("0x%x", b) - } - e.p.print(")\nif err != nil { return }") -} - -func (e *encodeGen) structmap(s *Struct) { - - oeIdentPrefix := randIdent() - - var data []byte - nfields := len(s.Fields) - bm := bmask{ - bitlen: nfields, - varname: oeIdentPrefix + "Mask", - } - - omitempty := s.AnyHasTagPart("omitempty") - var fieldNVar string - if omitempty { - - fieldNVar = oeIdentPrefix + "Len" - - e.p.printf("\n// omitempty: check for empty values") - e.p.printf("\n%s := uint32(%d)", fieldNVar, nfields) - e.p.printf("\n%s", bm.typeDecl()) - for i, sf := range s.Fields { - if !e.p.ok() { - return - } - if ize := sf.FieldElem.IfZeroExpr(); ize != "" && sf.HasTagPart("omitempty") { - e.p.printf("\nif %s {", ize) - e.p.printf("\n%s--", fieldNVar) - e.p.printf("\n%s", bm.setStmt(i)) - e.p.printf("\n}") - } - } - - e.p.printf("\n// variable map header, size %s", fieldNVar) - e.p.varWriteMapHeader("en", fieldNVar, nfields) - e.p.print("\nif err != nil { return }") - if !e.p.ok() { - return - } - - // quick return for the case where the entire thing is empty, but only at the top level - if !strings.Contains(s.Varname(), ".") { - e.p.printf("\nif %s == 0 { return }", fieldNVar) - } - - } else { - - // non-omitempty version - data = msgp.AppendMapHeader(nil, uint32(nfields)) - e.p.printf("\n// map header, size %d", nfields) - e.Fuse(data) - if len(s.Fields) == 0 { - e.fuseHook() - } - - } - - for i := range s.Fields { - if !e.p.ok() { - return - } - - // if field is omitempty, wrap with if statement based on the emptymask - oeField := s.Fields[i].HasTagPart("omitempty") && s.Fields[i].FieldElem.IfZeroExpr() != "" - if oeField { - e.p.printf("\nif %s == 0 { // if not empty", bm.readExpr(i)) - } - - data = msgp.AppendString(nil, s.Fields[i].FieldTag) - e.p.printf("\n// write %q", s.Fields[i].FieldTag) - e.Fuse(data) - e.fuseHook() - - e.ctx.PushString(s.Fields[i].FieldName) - next(e, s.Fields[i].FieldElem) - e.ctx.Pop() - - if oeField { - e.p.print("\n}") // close if statement - } - - } -} - -func (e *encodeGen) gMap(m *Map) { - if !e.p.ok() { - return - } - e.fuseHook() - vname := m.Varname() - e.writeAndCheck(mapHeader, lenAsUint32, vname) - - e.p.printf("\nfor %s, %s := range %s {", m.Keyidx, m.Validx, vname) - e.writeAndCheck(stringTyp, literalFmt, m.Keyidx) - e.ctx.PushVar(m.Keyidx) - next(e, m.Value) - e.ctx.Pop() - e.p.closeblock() -} - -func (e *encodeGen) gPtr(s *Ptr) { - if !e.p.ok() { - return - } - e.fuseHook() - e.p.printf("\nif %s == nil { err = en.WriteNil(); if err != nil { return; } } else {", s.Varname()) - next(e, s.Value) - e.p.closeblock() -} - -func (e *encodeGen) gSlice(s *Slice) { - if !e.p.ok() { - return - } - e.fuseHook() - e.writeAndCheck(arrayHeader, lenAsUint32, s.Varname()) - e.p.rangeBlock(e.ctx, s.Index, s.Varname(), e, s.Els) -} - -func (e *encodeGen) gArray(a *Array) { - if !e.p.ok() { - return - } - e.fuseHook() - // shortcut for [const]byte - if be, ok := a.Els.(*BaseElem); ok && (be.Value == Byte || be.Value == Uint8) { - e.p.printf("\nerr = en.WriteBytes((%s)[:])", a.Varname()) - e.p.wrapErrCheck(e.ctx.ArgsStr()) - return - } - - e.writeAndCheck(arrayHeader, literalFmt, coerceArraySize(a.Size)) - e.p.rangeBlock(e.ctx, a.Index, a.Varname(), e, a.Els) -} - -func (e *encodeGen) gBase(b *BaseElem) { - if !e.p.ok() { - return - } - e.fuseHook() - vname := b.Varname() - if b.Convert { - if b.ShimMode == Cast { - vname = tobaseConvert(b) - } else { - vname = randIdent() - e.p.printf("\nvar %s %s", vname, b.BaseType()) - e.p.printf("\n%s, err = %s", vname, tobaseConvert(b)) - e.p.wrapErrCheck(e.ctx.ArgsStr()) - } - } - - if b.Value == IDENT { // unknown identity - e.p.printf("\nerr = %s.EncodeMsg(en)", vname) - e.p.wrapErrCheck(e.ctx.ArgsStr()) - } else { // typical case - e.writeAndCheck(b.BaseName(), literalFmt, vname) - } -} diff --git a/vendor/github.com/tinylib/msgp/gen/marshal.go b/vendor/github.com/tinylib/msgp/gen/marshal.go deleted file mode 100644 index 9a969ffeb0..0000000000 --- a/vendor/github.com/tinylib/msgp/gen/marshal.go +++ /dev/null @@ -1,283 +0,0 @@ -package gen - -import ( - "fmt" - "io" - "strings" - - "github.com/tinylib/msgp/msgp" -) - -func marshal(w io.Writer) *marshalGen { - return &marshalGen{ - p: printer{w: w}, - } -} - -type marshalGen struct { - passes - p printer - fuse []byte - ctx *Context -} - -func (m *marshalGen) Method() Method { return Marshal } - -func (m *marshalGen) Apply(dirs []string) error { - return nil -} - -func (m *marshalGen) Execute(p Elem) error { - if !m.p.ok() { - return m.p.err - } - p = m.applyall(p) - if p == nil { - return nil - } - if !IsPrintable(p) { - return nil - } - - m.ctx = &Context{} - - m.p.comment("MarshalMsg implements msgp.Marshaler") - - // save the vname before - // calling methodReceiver so - // that z.Msgsize() is printed correctly - c := p.Varname() - - m.p.printf("\nfunc (%s %s) MarshalMsg(b []byte) (o []byte, err error) {", p.Varname(), imutMethodReceiver(p)) - m.p.printf("\no = msgp.Require(b, %s.Msgsize())", c) - next(m, p) - m.p.nakedReturn() - return m.p.err -} - -func (m *marshalGen) rawAppend(typ string, argfmt string, arg interface{}) { - m.p.printf("\no = msgp.Append%s(o, %s)", typ, fmt.Sprintf(argfmt, arg)) -} - -func (m *marshalGen) fuseHook() { - if len(m.fuse) > 0 { - m.rawbytes(m.fuse) - m.fuse = m.fuse[:0] - } -} - -func (m *marshalGen) Fuse(b []byte) { - if len(m.fuse) == 0 { - m.fuse = b - } else { - m.fuse = append(m.fuse, b...) - } -} - -func (m *marshalGen) gStruct(s *Struct) { - if !m.p.ok() { - return - } - - if s.AsTuple { - m.tuple(s) - } else { - m.mapstruct(s) - } - return -} - -func (m *marshalGen) tuple(s *Struct) { - data := make([]byte, 0, 5) - data = msgp.AppendArrayHeader(data, uint32(len(s.Fields))) - m.p.printf("\n// array header, size %d", len(s.Fields)) - m.Fuse(data) - if len(s.Fields) == 0 { - m.fuseHook() - } - for i := range s.Fields { - if !m.p.ok() { - return - } - m.ctx.PushString(s.Fields[i].FieldName) - next(m, s.Fields[i].FieldElem) - m.ctx.Pop() - } -} - -func (m *marshalGen) mapstruct(s *Struct) { - - oeIdentPrefix := randIdent() - - var data []byte - nfields := len(s.Fields) - bm := bmask{ - bitlen: nfields, - varname: oeIdentPrefix + "Mask", - } - - omitempty := s.AnyHasTagPart("omitempty") - var fieldNVar string - if omitempty { - - fieldNVar = oeIdentPrefix + "Len" - - m.p.printf("\n// omitempty: check for empty values") - m.p.printf("\n%s := uint32(%d)", fieldNVar, nfields) - m.p.printf("\n%s", bm.typeDecl()) - for i, sf := range s.Fields { - if !m.p.ok() { - return - } - if ize := sf.FieldElem.IfZeroExpr(); ize != "" && sf.HasTagPart("omitempty") { - m.p.printf("\nif %s {", ize) - m.p.printf("\n%s--", fieldNVar) - m.p.printf("\n%s", bm.setStmt(i)) - m.p.printf("\n}") - } - } - - m.p.printf("\n// variable map header, size %s", fieldNVar) - m.p.varAppendMapHeader("o", fieldNVar, nfields) - if !m.p.ok() { - return - } - - // quick return for the case where the entire thing is empty, but only at the top level - if !strings.Contains(s.Varname(), ".") { - m.p.printf("\nif %s == 0 { return }", fieldNVar) - } - - } else { - - // non-omitempty version - data = make([]byte, 0, 64) - data = msgp.AppendMapHeader(data, uint32(len(s.Fields))) - m.p.printf("\n// map header, size %d", len(s.Fields)) - m.Fuse(data) - if len(s.Fields) == 0 { - m.fuseHook() - } - - } - - for i := range s.Fields { - if !m.p.ok() { - return - } - - // if field is omitempty, wrap with if statement based on the emptymask - oeField := s.Fields[i].HasTagPart("omitempty") && s.Fields[i].FieldElem.IfZeroExpr() != "" - if oeField { - m.p.printf("\nif %s == 0 { // if not empty", bm.readExpr(i)) - } - - data = msgp.AppendString(nil, s.Fields[i].FieldTag) - - m.p.printf("\n// string %q", s.Fields[i].FieldTag) - m.Fuse(data) - m.fuseHook() - - m.ctx.PushString(s.Fields[i].FieldName) - next(m, s.Fields[i].FieldElem) - m.ctx.Pop() - - if oeField { - m.p.printf("\n}") // close if statement - } - - } -} - -// append raw data -func (m *marshalGen) rawbytes(bts []byte) { - m.p.print("\no = append(o, ") - for _, b := range bts { - m.p.printf("0x%x,", b) - } - m.p.print(")") -} - -func (m *marshalGen) gMap(s *Map) { - if !m.p.ok() { - return - } - m.fuseHook() - vname := s.Varname() - m.rawAppend(mapHeader, lenAsUint32, vname) - m.p.printf("\nfor %s, %s := range %s {", s.Keyidx, s.Validx, vname) - m.rawAppend(stringTyp, literalFmt, s.Keyidx) - m.ctx.PushVar(s.Keyidx) - next(m, s.Value) - m.ctx.Pop() - m.p.closeblock() -} - -func (m *marshalGen) gSlice(s *Slice) { - if !m.p.ok() { - return - } - m.fuseHook() - vname := s.Varname() - m.rawAppend(arrayHeader, lenAsUint32, vname) - m.p.rangeBlock(m.ctx, s.Index, vname, m, s.Els) -} - -func (m *marshalGen) gArray(a *Array) { - if !m.p.ok() { - return - } - m.fuseHook() - if be, ok := a.Els.(*BaseElem); ok && be.Value == Byte { - m.rawAppend("Bytes", "(%s)[:]", a.Varname()) - return - } - - m.rawAppend(arrayHeader, literalFmt, coerceArraySize(a.Size)) - m.p.rangeBlock(m.ctx, a.Index, a.Varname(), m, a.Els) -} - -func (m *marshalGen) gPtr(p *Ptr) { - if !m.p.ok() { - return - } - m.fuseHook() - m.p.printf("\nif %s == nil {\no = msgp.AppendNil(o)\n} else {", p.Varname()) - next(m, p.Value) - m.p.closeblock() -} - -func (m *marshalGen) gBase(b *BaseElem) { - if !m.p.ok() { - return - } - m.fuseHook() - vname := b.Varname() - - if b.Convert { - if b.ShimMode == Cast { - vname = tobaseConvert(b) - } else { - vname = randIdent() - m.p.printf("\nvar %s %s", vname, b.BaseType()) - m.p.printf("\n%s, err = %s", vname, tobaseConvert(b)) - m.p.wrapErrCheck(m.ctx.ArgsStr()) - } - } - - var echeck bool - switch b.Value { - case IDENT: - echeck = true - m.p.printf("\no, err = %s.MarshalMsg(o)", vname) - case Intf, Ext: - echeck = true - m.p.printf("\no, err = msgp.Append%s(o, %s)", b.BaseName(), vname) - default: - m.rawAppend(b.BaseName(), literalFmt, vname) - } - - if echeck { - m.p.wrapErrCheck(m.ctx.ArgsStr()) - } -} diff --git a/vendor/github.com/tinylib/msgp/gen/size.go b/vendor/github.com/tinylib/msgp/gen/size.go deleted file mode 100644 index e96e03198c..0000000000 --- a/vendor/github.com/tinylib/msgp/gen/size.go +++ /dev/null @@ -1,292 +0,0 @@ -package gen - -import ( - "fmt" - "io" - "strconv" - - "github.com/tinylib/msgp/msgp" -) - -type sizeState uint8 - -const ( - // need to write "s = ..." - assign sizeState = iota - - // need to write "s += ..." - add - - // can just append "+ ..." - expr -) - -func sizes(w io.Writer) *sizeGen { - return &sizeGen{ - p: printer{w: w}, - state: assign, - } -} - -type sizeGen struct { - passes - p printer - state sizeState - ctx *Context -} - -func (s *sizeGen) Method() Method { return Size } - -func (s *sizeGen) Apply(dirs []string) error { - return nil -} - -func builtinSize(typ string) string { - return "msgp." + typ + "Size" -} - -// this lets us chain together addition -// operations where possible -func (s *sizeGen) addConstant(sz string) { - if !s.p.ok() { - return - } - - switch s.state { - case assign: - s.p.print("\ns = " + sz) - s.state = expr - return - case add: - s.p.print("\ns += " + sz) - s.state = expr - return - case expr: - s.p.print(" + " + sz) - return - } - - panic("unknown size state") -} - -func (s *sizeGen) Execute(p Elem) error { - if !s.p.ok() { - return s.p.err - } - p = s.applyall(p) - if p == nil { - return nil - } - if !IsPrintable(p) { - return nil - } - - s.ctx = &Context{} - s.ctx.PushString(p.TypeName()) - - s.p.comment("Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message") - - s.p.printf("\nfunc (%s %s) Msgsize() (s int) {", p.Varname(), imutMethodReceiver(p)) - s.state = assign - next(s, p) - s.p.nakedReturn() - return s.p.err -} - -func (s *sizeGen) gStruct(st *Struct) { - if !s.p.ok() { - return - } - - nfields := uint32(len(st.Fields)) - - if st.AsTuple { - data := msgp.AppendArrayHeader(nil, nfields) - s.addConstant(strconv.Itoa(len(data))) - for i := range st.Fields { - if !s.p.ok() { - return - } - next(s, st.Fields[i].FieldElem) - } - } else { - data := msgp.AppendMapHeader(nil, nfields) - s.addConstant(strconv.Itoa(len(data))) - for i := range st.Fields { - data = data[:0] - data = msgp.AppendString(data, st.Fields[i].FieldTag) - s.addConstant(strconv.Itoa(len(data))) - next(s, st.Fields[i].FieldElem) - } - } -} - -func (s *sizeGen) gPtr(p *Ptr) { - s.state = add // inner must use add - s.p.printf("\nif %s == nil {\ns += msgp.NilSize\n} else {", p.Varname()) - next(s, p.Value) - s.state = add // closing block; reset to add - s.p.closeblock() -} - -func (s *sizeGen) gSlice(sl *Slice) { - if !s.p.ok() { - return - } - - s.addConstant(builtinSize(arrayHeader)) - - // if the slice's element is a fixed size - // (e.g. float64, [32]int, etc.), then - // print the length times the element size directly - if str, ok := fixedsizeExpr(sl.Els); ok { - s.addConstant(fmt.Sprintf("(%s * (%s))", lenExpr(sl), str)) - return - } - - // add inside the range block, and immediately after - s.state = add - s.p.rangeBlock(s.ctx, sl.Index, sl.Varname(), s, sl.Els) - s.state = add -} - -func (s *sizeGen) gArray(a *Array) { - if !s.p.ok() { - return - } - - s.addConstant(builtinSize(arrayHeader)) - - // if the array's children are a fixed - // size, we can compile an expression - // that always represents the array's wire size - if str, ok := fixedsizeExpr(a); ok { - s.addConstant(str) - return - } - - s.state = add - s.p.rangeBlock(s.ctx, a.Index, a.Varname(), s, a.Els) - s.state = add -} - -func (s *sizeGen) gMap(m *Map) { - s.addConstant(builtinSize(mapHeader)) - vn := m.Varname() - s.p.printf("\nif %s != nil {", vn) - s.p.printf("\nfor %s, %s := range %s {", m.Keyidx, m.Validx, vn) - s.p.printf("\n_ = %s", m.Validx) // we may not use the value - s.p.printf("\ns += msgp.StringPrefixSize + len(%s)", m.Keyidx) - s.state = expr - s.ctx.PushVar(m.Keyidx) - next(s, m.Value) - s.ctx.Pop() - s.p.closeblock() - s.p.closeblock() - s.state = add -} - -func (s *sizeGen) gBase(b *BaseElem) { - if !s.p.ok() { - return - } - if b.Convert && b.ShimMode == Convert { - s.state = add - vname := randIdent() - s.p.printf("\nvar %s %s", vname, b.BaseType()) - - // ensure we don't get "unused variable" warnings from outer slice iterations - s.p.printf("\n_ = %s", b.Varname()) - - s.p.printf("\ns += %s", basesizeExpr(b.Value, vname, b.BaseName())) - s.state = expr - - } else { - vname := b.Varname() - if b.Convert { - vname = tobaseConvert(b) - } - s.addConstant(basesizeExpr(b.Value, vname, b.BaseName())) - } -} - -// returns "len(slice)" -func lenExpr(sl *Slice) string { - return "len(" + sl.Varname() + ")" -} - -// is a given primitive always the same (max) -// size on the wire? -func fixedSize(p Primitive) bool { - switch p { - case Intf, Ext, IDENT, Bytes, String: - return false - default: - return true - } -} - -// strip reference from string -func stripRef(s string) string { - if s[0] == '&' { - return s[1:] - } - return s -} - -// return a fixed-size expression, if possible. -// only possible for *BaseElem and *Array. -// returns (expr, ok) -func fixedsizeExpr(e Elem) (string, bool) { - switch e := e.(type) { - case *Array: - if str, ok := fixedsizeExpr(e.Els); ok { - return fmt.Sprintf("(%s * (%s))", e.Size, str), true - } - case *BaseElem: - if fixedSize(e.Value) { - return builtinSize(e.BaseName()), true - } - case *Struct: - var str string - for _, f := range e.Fields { - if fs, ok := fixedsizeExpr(f.FieldElem); ok { - if str == "" { - str = fs - } else { - str += "+" + fs - } - } else { - return "", false - } - } - var hdrlen int - mhdr := msgp.AppendMapHeader(nil, uint32(len(e.Fields))) - hdrlen += len(mhdr) - var strbody []byte - for _, f := range e.Fields { - strbody = msgp.AppendString(strbody[:0], f.FieldTag) - hdrlen += len(strbody) - } - return fmt.Sprintf("%d + %s", hdrlen, str), true - } - return "", false -} - -// print size expression of a variable name -func basesizeExpr(value Primitive, vname, basename string) string { - switch value { - case Ext: - return "msgp.ExtensionPrefixSize + " + stripRef(vname) + ".Len()" - case Intf: - return "msgp.GuessSize(" + vname + ")" - case IDENT: - return vname + ".Msgsize()" - case Bytes: - return "msgp.BytesPrefixSize + len(" + vname + ")" - case String: - return "msgp.StringPrefixSize + len(" + vname + ")" - default: - return builtinSize(basename) - } -} diff --git a/vendor/github.com/tinylib/msgp/gen/spec.go b/vendor/github.com/tinylib/msgp/gen/spec.go deleted file mode 100644 index f3d5818b1d..0000000000 --- a/vendor/github.com/tinylib/msgp/gen/spec.go +++ /dev/null @@ -1,519 +0,0 @@ -package gen - -import ( - "bytes" - "fmt" - "io" -) - -const ( - lenAsUint32 = "uint32(len(%s))" - literalFmt = "%s" - intFmt = "%d" - quotedFmt = `"%s"` - mapHeader = "MapHeader" - arrayHeader = "ArrayHeader" - mapKey = "MapKeyPtr" - stringTyp = "String" - u32 = "uint32" -) - -// Method is a bitfield representing something that the -// generator knows how to print. -type Method uint8 - -// are the bits in 'f' set in 'm'? -func (m Method) isset(f Method) bool { return (m&f == f) } - -// String implements fmt.Stringer -func (m Method) String() string { - switch m { - case 0, invalidmeth: - return "" - case Decode: - return "decode" - case Encode: - return "encode" - case Marshal: - return "marshal" - case Unmarshal: - return "unmarshal" - case Size: - return "size" - case Test: - return "test" - default: - // return e.g. "decode+encode+test" - modes := [...]Method{Decode, Encode, Marshal, Unmarshal, Size, Test} - any := false - nm := "" - for _, mm := range modes { - if m.isset(mm) { - if any { - nm += "+" + mm.String() - } else { - nm += mm.String() - any = true - } - } - } - return nm - - } -} - -func strtoMeth(s string) Method { - switch s { - case "encode": - return Encode - case "decode": - return Decode - case "marshal": - return Marshal - case "unmarshal": - return Unmarshal - case "size": - return Size - case "test": - return Test - default: - return 0 - } -} - -const ( - Decode Method = 1 << iota // msgp.Decodable - Encode // msgp.Encodable - Marshal // msgp.Marshaler - Unmarshal // msgp.Unmarshaler - Size // msgp.Sizer - Test // generate tests - invalidmeth // this isn't a method - encodetest = Encode | Decode | Test // tests for Encodable and Decodable - marshaltest = Marshal | Unmarshal | Test // tests for Marshaler and Unmarshaler -) - -type Printer struct { - gens []generator -} - -func NewPrinter(m Method, out io.Writer, tests io.Writer) *Printer { - if m.isset(Test) && tests == nil { - panic("cannot print tests with 'nil' tests argument!") - } - gens := make([]generator, 0, 7) - if m.isset(Decode) { - gens = append(gens, decode(out)) - } - if m.isset(Encode) { - gens = append(gens, encode(out)) - } - if m.isset(Marshal) { - gens = append(gens, marshal(out)) - } - if m.isset(Unmarshal) { - gens = append(gens, unmarshal(out)) - } - if m.isset(Size) { - gens = append(gens, sizes(out)) - } - if m.isset(marshaltest) { - gens = append(gens, mtest(tests)) - } - if m.isset(encodetest) { - gens = append(gens, etest(tests)) - } - if len(gens) == 0 { - panic("NewPrinter called with invalid method flags") - } - return &Printer{gens: gens} -} - -// TransformPass is a pass that transforms individual -// elements. (Note that if the returned is different from -// the argument, it should not point to the same objects.) -type TransformPass func(Elem) Elem - -// IgnoreTypename is a pass that just ignores -// types of a given name. -func IgnoreTypename(name string) TransformPass { - return func(e Elem) Elem { - if e.TypeName() == name { - return nil - } - return e - } -} - -// ApplyDirective applies a directive to a named pass -// and all of its dependents. -func (p *Printer) ApplyDirective(pass Method, t TransformPass) { - for _, g := range p.gens { - if g.Method().isset(pass) { - g.Add(t) - } - } -} - -// Print prints an Elem. -func (p *Printer) Print(e Elem) error { - for _, g := range p.gens { - // Elem.SetVarname() is called before the Print() step in parse.FileSet.PrintTo(). - // Elem.SetVarname() generates identifiers as it walks the Elem. This can cause - // collisions between idents created during SetVarname and idents created during Print, - // hence the separate prefixes. - resetIdent("zb") - err := g.Execute(e) - resetIdent("za") - - if err != nil { - return err - } - } - return nil -} - -type contextItem interface { - Arg() string -} - -type contextString string - -func (c contextString) Arg() string { - return fmt.Sprintf("%q", c) -} - -type contextVar string - -func (c contextVar) Arg() string { - return string(c) -} - -type Context struct { - path []contextItem -} - -func (c *Context) PushString(s string) { - c.path = append(c.path, contextString(s)) -} - -func (c *Context) PushVar(s string) { - c.path = append(c.path, contextVar(s)) -} - -func (c *Context) Pop() { - c.path = c.path[:len(c.path)-1] -} - -func (c *Context) ArgsStr() string { - var out string - for idx, p := range c.path { - if idx > 0 { - out += ", " - } - out += p.Arg() - } - return out -} - -// generator is the interface through -// which code is generated. -type generator interface { - Method() Method - Add(p TransformPass) - Execute(Elem) error // execute writes the method for the provided object. -} - -type passes []TransformPass - -func (p *passes) Add(t TransformPass) { - *p = append(*p, t) -} - -func (p *passes) applyall(e Elem) Elem { - for _, t := range *p { - e = t(e) - if e == nil { - return nil - } - } - return e -} - -type traversal interface { - gMap(*Map) - gSlice(*Slice) - gArray(*Array) - gPtr(*Ptr) - gBase(*BaseElem) - gStruct(*Struct) -} - -// type-switch dispatch to the correct -// method given the type of 'e' -func next(t traversal, e Elem) { - switch e := e.(type) { - case *Map: - t.gMap(e) - case *Struct: - t.gStruct(e) - case *Slice: - t.gSlice(e) - case *Array: - t.gArray(e) - case *Ptr: - t.gPtr(e) - case *BaseElem: - t.gBase(e) - default: - panic("bad element type") - } -} - -// possibly-immutable method receiver -func imutMethodReceiver(p Elem) string { - switch e := p.(type) { - case *Struct: - // TODO(HACK): actually do real math here. - if len(e.Fields) <= 3 { - for i := range e.Fields { - if be, ok := e.Fields[i].FieldElem.(*BaseElem); !ok || (be.Value == IDENT || be.Value == Bytes) { - goto nope - } - } - return p.TypeName() - } - nope: - return "*" + p.TypeName() - - // gets dereferenced automatically - case *Array: - return "*" + p.TypeName() - - // everything else can be - // by-value. - default: - return p.TypeName() - } -} - -// if necessary, wraps a type -// so that its method receiver -// is of the write type. -func methodReceiver(p Elem) string { - switch p.(type) { - - // structs and arrays are - // dereferenced automatically, - // so no need to alter varname - case *Struct, *Array: - return "*" + p.TypeName() - // set variable name to - // *varname - default: - p.SetVarname("(*" + p.Varname() + ")") - return "*" + p.TypeName() - } -} - -func unsetReceiver(p Elem) { - switch p.(type) { - case *Struct, *Array: - default: - p.SetVarname("z") - } -} - -// shared utility for generators -type printer struct { - w io.Writer - err error -} - -// writes "var {{name}} {{typ}};" -func (p *printer) declare(name string, typ string) { - p.printf("\nvar %s %s", name, typ) -} - -// does: -// -// if m == nil { -// m = make(type, size) -// } else if len(m) > 0 { -// for key := range m { delete(m, key) } -// } -// -func (p *printer) resizeMap(size string, m *Map) { - vn := m.Varname() - if !p.ok() { - return - } - p.printf("\nif %s == nil {", vn) - p.printf("\n%s = make(%s, %s)", vn, m.TypeName(), size) - p.printf("\n} else if len(%s) > 0 {", vn) - p.clearMap(vn) - p.closeblock() -} - -// assign key to value based on varnames -func (p *printer) mapAssign(m *Map) { - if !p.ok() { - return - } - p.printf("\n%s[%s] = %s", m.Varname(), m.Keyidx, m.Validx) -} - -// clear map keys -func (p *printer) clearMap(name string) { - p.printf("\nfor key := range %[1]s { delete(%[1]s, key) }", name) -} - -func (p *printer) wrapErrCheck(ctx string) { - p.print("\nif err != nil {") - p.printf("\nerr = msgp.WrapError(err, %s)", ctx) - p.printf("\nreturn") - p.print("\n}") -} - -func (p *printer) resizeSlice(size string, s *Slice) { - p.printf("\nif cap(%[1]s) >= int(%[2]s) { %[1]s = (%[1]s)[:%[2]s] } else { %[1]s = make(%[3]s, %[2]s) }", s.Varname(), size, s.TypeName()) -} - -func (p *printer) arrayCheck(want string, got string) { - p.printf("\nif %[1]s != %[2]s { err = msgp.ArrayError{Wanted: %[2]s, Got: %[1]s}; return }", got, want) -} - -func (p *printer) closeblock() { p.print("\n}") } - -// does: -// -// for idx := range iter { -// {{generate inner}} -// } -// -func (p *printer) rangeBlock(ctx *Context, idx string, iter string, t traversal, inner Elem) { - ctx.PushVar(idx) - p.printf("\n for %s := range %s {", idx, iter) - next(t, inner) - p.closeblock() - ctx.Pop() -} - -func (p *printer) nakedReturn() { - if p.ok() { - p.print("\nreturn\n}\n") - } -} - -func (p *printer) comment(s string) { - p.print("\n// " + s) -} - -func (p *printer) printf(format string, args ...interface{}) { - if p.err == nil { - _, p.err = fmt.Fprintf(p.w, format, args...) - } -} - -func (p *printer) print(format string) { - if p.err == nil { - _, p.err = io.WriteString(p.w, format) - } -} - -func (p *printer) initPtr(pt *Ptr) { - if pt.Needsinit() { - vname := pt.Varname() - p.printf("\nif %s == nil { %s = new(%s); }", vname, vname, pt.Value.TypeName()) - } -} - -func (p *printer) ok() bool { return p.err == nil } - -func tobaseConvert(b *BaseElem) string { - return b.ToBase() + "(" + b.Varname() + ")" -} - -func (p *printer) varWriteMapHeader(receiver string, sizeVarname string, maxSize int) { - if maxSize <= 15 { - p.printf("\nerr = %s.Append(0x80 | uint8(%s))", receiver, sizeVarname) - } else { - p.printf("\nerr = %s.WriteMapHeader(%s)", receiver, sizeVarname) - } -} - -func (p *printer) varAppendMapHeader(sliceVarname string, sizeVarname string, maxSize int) { - if maxSize <= 15 { - p.printf("\n%s = append(%s, 0x80 | uint8(%s))", sliceVarname, sliceVarname, sizeVarname) - } else { - p.printf("\n%s = msgp.AppendMapHeader(%s, %s)", sliceVarname, sliceVarname, sizeVarname) - } -} - -// bmask is a bitmask of a the specified number of bits -type bmask struct { - bitlen int - varname string -} - -// typeDecl returns the variable declaration as a var statement -func (b *bmask) typeDecl() string { - return fmt.Sprintf("var %s %s /* %d bits */", b.varname, b.typeName(), b.bitlen) -} - -// typeName returns the type, e.g. "uint8" or "[2]uint64" -func (b *bmask) typeName() string { - - if b.bitlen <= 8 { - return "uint8" - } - if b.bitlen <= 16 { - return "uint16" - } - if b.bitlen <= 32 { - return "uint32" - } - if b.bitlen <= 64 { - return "uint64" - } - - return fmt.Sprintf("[%d]uint64", (b.bitlen+64-1)/64) -} - -// readExpr returns the expression to read from a position in the bitmask. -// Compare ==0 for false or !=0 for true. -func (b *bmask) readExpr(bitoffset int) string { - - if bitoffset < 0 || bitoffset >= b.bitlen { - panic(fmt.Errorf("bitoffset %d out of range for bitlen %d", bitoffset, b.bitlen)) - } - - var buf bytes.Buffer - buf.Grow(len(b.varname) + 16) - buf.WriteByte('(') - buf.WriteString(b.varname) - if b.bitlen > 64 { - fmt.Fprintf(&buf, "[%d]", (bitoffset / 64)) - } - buf.WriteByte('&') - fmt.Fprintf(&buf, "0x%X", (uint64(1) << (uint64(bitoffset) % 64))) - buf.WriteByte(')') - - return buf.String() - -} - -// setStmt returns the statement to set the specified bit in the bitmask. -func (b *bmask) setStmt(bitoffset int) string { - - var buf bytes.Buffer - buf.Grow(len(b.varname) + 16) - buf.WriteString(b.varname) - if b.bitlen > 64 { - fmt.Fprintf(&buf, "[%d]", (bitoffset / 64)) - } - fmt.Fprintf(&buf, " |= 0x%X", (uint64(1) << (uint64(bitoffset) % 64))) - - return buf.String() - -} diff --git a/vendor/github.com/tinylib/msgp/gen/testgen.go b/vendor/github.com/tinylib/msgp/gen/testgen.go deleted file mode 100644 index a80151bc5f..0000000000 --- a/vendor/github.com/tinylib/msgp/gen/testgen.go +++ /dev/null @@ -1,182 +0,0 @@ -package gen - -import ( - "io" - "text/template" -) - -var ( - marshalTestTempl = template.New("MarshalTest") - encodeTestTempl = template.New("EncodeTest") -) - -// TODO(philhofer): -// for simplicity's sake, right now -// we can only generate tests for types -// that can be initialized with the -// "Type{}" syntax. -// we should support all the types. - -func mtest(w io.Writer) *mtestGen { - return &mtestGen{w: w} -} - -type mtestGen struct { - passes - w io.Writer -} - -func (m *mtestGen) Execute(p Elem) error { - p = m.applyall(p) - if p != nil && IsPrintable(p) { - switch p.(type) { - case *Struct, *Array, *Slice, *Map: - return marshalTestTempl.Execute(m.w, p) - } - } - return nil -} - -func (m *mtestGen) Method() Method { return marshaltest } - -type etestGen struct { - passes - w io.Writer -} - -func etest(w io.Writer) *etestGen { - return &etestGen{w: w} -} - -func (e *etestGen) Execute(p Elem) error { - p = e.applyall(p) - if p != nil && IsPrintable(p) { - switch p.(type) { - case *Struct, *Array, *Slice, *Map: - return encodeTestTempl.Execute(e.w, p) - } - } - return nil -} - -func (e *etestGen) Method() Method { return encodetest } - -func init() { - template.Must(marshalTestTempl.Parse(`func TestMarshalUnmarshal{{.TypeName}}(t *testing.T) { - v := {{.TypeName}}{} - bts, err := v.MarshalMsg(nil) - if err != nil { - t.Fatal(err) - } - left, err := v.UnmarshalMsg(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left) - } - - left, err = msgp.Skip(bts) - if err != nil { - t.Fatal(err) - } - if len(left) > 0 { - t.Errorf("%d bytes left over after Skip(): %q", len(left), left) - } -} - -func BenchmarkMarshalMsg{{.TypeName}}(b *testing.B) { - v := {{.TypeName}}{} - b.ReportAllocs() - b.ResetTimer() - for i:=0; i m { - t.Log("WARNING: TestEncodeDecode{{.TypeName}} Msgsize() is inaccurate") - } - - vn := {{.TypeName}}{} - err := msgp.Decode(&buf, &vn) - if err != nil { - t.Error(err) - } - - buf.Reset() - msgp.Encode(&buf, &v) - err = msgp.NewReader(&buf).Skip() - if err != nil { - t.Error(err) - } -} - -func BenchmarkEncode{{.TypeName}}(b *testing.B) { - v := {{.TypeName}}{} - var buf bytes.Buffer - msgp.Encode(&buf, &v) - b.SetBytes(int64(buf.Len())) - en := msgp.NewWriter(msgp.Nowhere) - b.ReportAllocs() - b.ResetTimer() - for i:=0; i 0 {", sz) - u.p.printf("\n%s--; field, bts, err = msgp.ReadMapKeyZC(bts)", sz) - u.p.wrapErrCheck(u.ctx.ArgsStr()) - u.p.print("\nswitch msgp.UnsafeString(field) {") - for i := range s.Fields { - if !u.p.ok() { - return - } - u.p.printf("\ncase \"%s\":", s.Fields[i].FieldTag) - u.ctx.PushString(s.Fields[i].FieldName) - next(u, s.Fields[i].FieldElem) - u.ctx.Pop() - } - u.p.print("\ndefault:\nbts, err = msgp.Skip(bts)") - u.p.wrapErrCheck(u.ctx.ArgsStr()) - u.p.print("\n}\n}") // close switch and for loop -} - -func (u *unmarshalGen) gBase(b *BaseElem) { - if !u.p.ok() { - return - } - - refname := b.Varname() // assigned to - lowered := b.Varname() // passed as argument - if b.Convert { - // begin 'tmp' block - refname = randIdent() - lowered = b.ToBase() + "(" + lowered + ")" - u.p.printf("\n{\nvar %s %s", refname, b.BaseType()) - } - - switch b.Value { - case Bytes: - u.p.printf("\n%s, bts, err = msgp.ReadBytesBytes(bts, %s)", refname, lowered) - case Ext: - u.p.printf("\nbts, err = msgp.ReadExtensionBytes(bts, %s)", lowered) - case IDENT: - u.p.printf("\nbts, err = %s.UnmarshalMsg(bts)", lowered) - default: - u.p.printf("\n%s, bts, err = msgp.Read%sBytes(bts)", refname, b.BaseName()) - } - u.p.wrapErrCheck(u.ctx.ArgsStr()) - - if b.Convert { - // close 'tmp' block - if b.ShimMode == Cast { - u.p.printf("\n%s = %s(%s)\n", b.Varname(), b.FromBase(), refname) - } else { - u.p.printf("\n%s, err = %s(%s)", b.Varname(), b.FromBase(), refname) - u.p.wrapErrCheck(u.ctx.ArgsStr()) - } - u.p.printf("}") - } -} - -func (u *unmarshalGen) gArray(a *Array) { - if !u.p.ok() { - return - } - - // special case for [const]byte objects - // see decode.go for symmetry - if be, ok := a.Els.(*BaseElem); ok && be.Value == Byte { - u.p.printf("\nbts, err = msgp.ReadExactBytes(bts, (%s)[:])", a.Varname()) - u.p.wrapErrCheck(u.ctx.ArgsStr()) - return - } - - sz := randIdent() - u.p.declare(sz, u32) - u.assignAndCheck(sz, arrayHeader) - u.p.arrayCheck(coerceArraySize(a.Size), sz) - u.p.rangeBlock(u.ctx, a.Index, a.Varname(), u, a.Els) -} - -func (u *unmarshalGen) gSlice(s *Slice) { - if !u.p.ok() { - return - } - sz := randIdent() - u.p.declare(sz, u32) - u.assignAndCheck(sz, arrayHeader) - u.p.resizeSlice(sz, s) - u.p.rangeBlock(u.ctx, s.Index, s.Varname(), u, s.Els) -} - -func (u *unmarshalGen) gMap(m *Map) { - if !u.p.ok() { - return - } - sz := randIdent() - u.p.declare(sz, u32) - u.assignAndCheck(sz, mapHeader) - - // allocate or clear map - u.p.resizeMap(sz, m) - - // loop and get key,value - u.p.printf("\nfor %s > 0 {", sz) - u.p.printf("\nvar %s string; var %s %s; %s--", m.Keyidx, m.Validx, m.Value.TypeName(), sz) - u.assignAndCheck(m.Keyidx, stringTyp) - u.ctx.PushVar(m.Keyidx) - next(u, m.Value) - u.ctx.Pop() - u.p.mapAssign(m) - u.p.closeblock() -} - -func (u *unmarshalGen) gPtr(p *Ptr) { - u.p.printf("\nif msgp.IsNil(bts) { bts, err = msgp.ReadNilBytes(bts); if err != nil { return }; %s = nil; } else { ", p.Varname()) - u.p.initPtr(p) - next(u, p.Value) - u.p.closeblock() -} diff --git a/vendor/github.com/tinylib/msgp/main.go b/vendor/github.com/tinylib/msgp/main.go deleted file mode 100644 index 4369d739a2..0000000000 --- a/vendor/github.com/tinylib/msgp/main.go +++ /dev/null @@ -1,119 +0,0 @@ -// msgp is a code generation tool for -// creating methods to serialize and de-serialize -// Go data structures to and from MessagePack. -// -// This package is targeted at the `go generate` tool. -// To use it, include the following directive in a -// go source file with types requiring source generation: -// -// //go:generate msgp -// -// The go generate tool should set the proper environment variables for -// the generator to execute without any command-line flags. However, the -// following options are supported, if you need them: -// -// -o = output file name (default is {input}_gen.go) -// -file = input file name (or directory; default is $GOFILE, which is set by the `go generate` command) -// -io = satisfy the `msgp.Decodable` and `msgp.Encodable` interfaces (default is true) -// -marshal = satisfy the `msgp.Marshaler` and `msgp.Unmarshaler` interfaces (default is true) -// -tests = generate tests and benchmarks (default is true) -// -// For more information, please read README.md, and the wiki at github.com/tinylib/msgp -// -package main - -import ( - "flag" - "fmt" - "os" - "path/filepath" - "strings" - - "github.com/tinylib/msgp/gen" - "github.com/tinylib/msgp/parse" - "github.com/tinylib/msgp/printer" - "github.com/ttacon/chalk" -) - -var ( - out = flag.String("o", "", "output file") - file = flag.String("file", "", "input file") - encode = flag.Bool("io", true, "create Encode and Decode methods") - marshal = flag.Bool("marshal", true, "create Marshal and Unmarshal methods") - tests = flag.Bool("tests", true, "create tests and benchmarks") - unexported = flag.Bool("unexported", false, "also process unexported types") -) - -func main() { - flag.Parse() - - // GOFILE is set by go generate - if *file == "" { - *file = os.Getenv("GOFILE") - if *file == "" { - fmt.Println(chalk.Red.Color("No file to parse.")) - os.Exit(1) - } - } - - var mode gen.Method - if *encode { - mode |= (gen.Encode | gen.Decode | gen.Size) - } - if *marshal { - mode |= (gen.Marshal | gen.Unmarshal | gen.Size) - } - if *tests { - mode |= gen.Test - } - - if mode&^gen.Test == 0 { - fmt.Println(chalk.Red.Color("No methods to generate; -io=false && -marshal=false")) - os.Exit(1) - } - - if err := Run(*file, mode, *unexported); err != nil { - fmt.Println(chalk.Red.Color(err.Error())) - os.Exit(1) - } -} - -// Run writes all methods using the associated file or path, e.g. -// -// err := msgp.Run("path/to/myfile.go", gen.Size|gen.Marshal|gen.Unmarshal|gen.Test, false) -// -func Run(gofile string, mode gen.Method, unexported bool) error { - if mode&^gen.Test == 0 { - return nil - } - fmt.Println(chalk.Magenta.Color("======== MessagePack Code Generator =======")) - fmt.Printf(chalk.Magenta.Color(">>> Input: \"%s\"\n"), gofile) - fs, err := parse.File(gofile, unexported) - if err != nil { - return err - } - - if len(fs.Identities) == 0 { - fmt.Println(chalk.Magenta.Color("No types requiring code generation were found!")) - return nil - } - - return printer.PrintFile(newFilename(gofile, fs.Package), fs, mode) -} - -// picks a new file name based on input flags and input filename(s). -func newFilename(old string, pkg string) string { - if *out != "" { - if pre := strings.TrimPrefix(*out, old); len(pre) > 0 && - !strings.HasSuffix(*out, ".go") { - return filepath.Join(old, *out) - } - return *out - } - - if fi, err := os.Stat(old); err == nil && fi.IsDir() { - old = filepath.Join(old, pkg) - } - // new file name is old file name + _gen.go - return strings.TrimSuffix(old, ".go") + "_gen.go" -} diff --git a/vendor/github.com/tinylib/msgp/parse/directives.go b/vendor/github.com/tinylib/msgp/parse/directives.go deleted file mode 100644 index 73e441eff2..0000000000 --- a/vendor/github.com/tinylib/msgp/parse/directives.go +++ /dev/null @@ -1,130 +0,0 @@ -package parse - -import ( - "fmt" - "go/ast" - "strings" - - "github.com/tinylib/msgp/gen" -) - -const linePrefix = "//msgp:" - -// func(args, fileset) -type directive func([]string, *FileSet) error - -// func(passName, args, printer) -type passDirective func(gen.Method, []string, *gen.Printer) error - -// map of all recognized directives -// -// to add a directive, define a func([]string, *FileSet) error -// and then add it to this list. -var directives = map[string]directive{ - "shim": applyShim, - "ignore": ignore, - "tuple": astuple, -} - -var passDirectives = map[string]passDirective{ - "ignore": passignore, -} - -func passignore(m gen.Method, text []string, p *gen.Printer) error { - pushstate(m.String()) - for _, a := range text { - p.ApplyDirective(m, gen.IgnoreTypename(a)) - infof("ignoring %s\n", a) - } - popstate() - return nil -} - -// find all comment lines that begin with //msgp: -func yieldComments(c []*ast.CommentGroup) []string { - var out []string - for _, cg := range c { - for _, line := range cg.List { - if strings.HasPrefix(line.Text, linePrefix) { - out = append(out, strings.TrimPrefix(line.Text, linePrefix)) - } - } - } - return out -} - -//msgp:shim {Type} as:{Newtype} using:{toFunc/fromFunc} mode:{Mode} -func applyShim(text []string, f *FileSet) error { - if len(text) < 4 || len(text) > 5 { - return fmt.Errorf("shim directive should have 3 or 4 arguments; found %d", len(text)-1) - } - - name := text[1] - be := gen.Ident(strings.TrimPrefix(strings.TrimSpace(text[2]), "as:")) // parse as::{base} - if name[0] == '*' { - name = name[1:] - be.Needsref(true) - } - be.Alias(name) - - usestr := strings.TrimPrefix(strings.TrimSpace(text[3]), "using:") // parse using::{method/method} - - methods := strings.Split(usestr, "/") - if len(methods) != 2 { - return fmt.Errorf("expected 2 using::{} methods; found %d (%q)", len(methods), text[3]) - } - - be.ShimToBase = methods[0] - be.ShimFromBase = methods[1] - - if len(text) == 5 { - modestr := strings.TrimPrefix(strings.TrimSpace(text[4]), "mode:") // parse mode::{mode} - switch modestr { - case "cast": - be.ShimMode = gen.Cast - case "convert": - be.ShimMode = gen.Convert - default: - return fmt.Errorf("invalid shim mode; found %s, expected 'cast' or 'convert", modestr) - } - } - - infof("%s -> %s\n", name, be.Value.String()) - f.findShim(name, be) - - return nil -} - -//msgp:ignore {TypeA} {TypeB}... -func ignore(text []string, f *FileSet) error { - if len(text) < 2 { - return nil - } - for _, item := range text[1:] { - name := strings.TrimSpace(item) - if _, ok := f.Identities[name]; ok { - delete(f.Identities, name) - infof("ignoring %s\n", name) - } - } - return nil -} - -//msgp:tuple {TypeA} {TypeB}... -func astuple(text []string, f *FileSet) error { - if len(text) < 2 { - return nil - } - for _, item := range text[1:] { - name := strings.TrimSpace(item) - if el, ok := f.Identities[name]; ok { - if st, ok := el.(*gen.Struct); ok { - st.AsTuple = true - infoln(name) - } else { - warnf("%s: only structs can be tuples\n", name) - } - } - } - return nil -} diff --git a/vendor/github.com/tinylib/msgp/parse/getast.go b/vendor/github.com/tinylib/msgp/parse/getast.go deleted file mode 100644 index f9e1d03910..0000000000 --- a/vendor/github.com/tinylib/msgp/parse/getast.go +++ /dev/null @@ -1,617 +0,0 @@ -package parse - -import ( - "fmt" - "go/ast" - "go/parser" - "go/token" - "os" - "reflect" - "sort" - "strings" - - "github.com/tinylib/msgp/gen" - "github.com/ttacon/chalk" -) - -// A FileSet is the in-memory representation of a -// parsed file. -type FileSet struct { - Package string // package name - Specs map[string]ast.Expr // type specs in file - Identities map[string]gen.Elem // processed from specs - Directives []string // raw preprocessor directives - Imports []*ast.ImportSpec // imports -} - -// File parses a file at the relative path -// provided and produces a new *FileSet. -// If you pass in a path to a directory, the entire -// directory will be parsed. -// If unexport is false, only exported identifiers are included in the FileSet. -// If the resulting FileSet would be empty, an error is returned. -func File(name string, unexported bool) (*FileSet, error) { - pushstate(name) - defer popstate() - fs := &FileSet{ - Specs: make(map[string]ast.Expr), - Identities: make(map[string]gen.Elem), - } - - fset := token.NewFileSet() - finfo, err := os.Stat(name) - if err != nil { - return nil, err - } - if finfo.IsDir() { - pkgs, err := parser.ParseDir(fset, name, nil, parser.ParseComments) - if err != nil { - return nil, err - } - if len(pkgs) != 1 { - return nil, fmt.Errorf("multiple packages in directory: %s", name) - } - var one *ast.Package - for _, nm := range pkgs { - one = nm - break - } - fs.Package = one.Name - for _, fl := range one.Files { - pushstate(fl.Name.Name) - fs.Directives = append(fs.Directives, yieldComments(fl.Comments)...) - if !unexported { - ast.FileExports(fl) - } - fs.getTypeSpecs(fl) - popstate() - } - } else { - f, err := parser.ParseFile(fset, name, nil, parser.ParseComments) - if err != nil { - return nil, err - } - fs.Package = f.Name.Name - fs.Directives = yieldComments(f.Comments) - if !unexported { - ast.FileExports(f) - } - fs.getTypeSpecs(f) - } - - if len(fs.Specs) == 0 { - return nil, fmt.Errorf("no definitions in %s", name) - } - - fs.process() - fs.applyDirectives() - fs.propInline() - - return fs, nil -} - -// applyDirectives applies all of the directives that -// are known to the parser. additional method-specific -// directives remain in f.Directives -func (f *FileSet) applyDirectives() { - newdirs := make([]string, 0, len(f.Directives)) - for _, d := range f.Directives { - chunks := strings.Split(d, " ") - if len(chunks) > 0 { - if fn, ok := directives[chunks[0]]; ok { - pushstate(chunks[0]) - err := fn(chunks, f) - if err != nil { - warnln(err.Error()) - } - popstate() - } else { - newdirs = append(newdirs, d) - } - } - } - f.Directives = newdirs -} - -// A linkset is a graph of unresolved -// identities. -// -// Since gen.Ident can only represent -// one level of type indirection (e.g. Foo -> uint8), -// type declarations like `type Foo Bar` -// aren't resolve-able until we've processed -// everything else. -// -// The goal of this dependency resolution -// is to distill the type declaration -// into just one level of indirection. -// In other words, if we have: -// -// type A uint64 -// type B A -// type C B -// type D C -// -// ... then we want to end up -// figuring out that D is just a uint64. -type linkset map[string]*gen.BaseElem - -func (f *FileSet) resolve(ls linkset) { - progress := true - for progress && len(ls) > 0 { - progress = false - for name, elem := range ls { - real, ok := f.Identities[elem.TypeName()] - if ok { - // copy the old type descriptor, - // alias it to the new value, - // and insert it into the resolved - // identities list - progress = true - nt := real.Copy() - nt.Alias(name) - f.Identities[name] = nt - delete(ls, name) - } - } - } - - // what's left can't be resolved - for name, elem := range ls { - warnf("couldn't resolve type %s (%s)\n", name, elem.TypeName()) - } -} - -// process takes the contents of f.Specs and -// uses them to populate f.Identities -func (f *FileSet) process() { - - deferred := make(linkset) -parse: - for name, def := range f.Specs { - pushstate(name) - el := f.parseExpr(def) - if el == nil { - warnln("failed to parse") - popstate() - continue parse - } - // push unresolved identities into - // the graph of links and resolve after - // we've handled every possible named type. - if be, ok := el.(*gen.BaseElem); ok && be.Value == gen.IDENT { - deferred[name] = be - popstate() - continue parse - } - el.Alias(name) - f.Identities[name] = el - popstate() - } - - if len(deferred) > 0 { - f.resolve(deferred) - } -} - -func strToMethod(s string) gen.Method { - switch s { - case "encode": - return gen.Encode - case "decode": - return gen.Decode - case "test": - return gen.Test - case "size": - return gen.Size - case "marshal": - return gen.Marshal - case "unmarshal": - return gen.Unmarshal - default: - return 0 - } -} - -func (f *FileSet) applyDirs(p *gen.Printer) { - // apply directives of the form - // - // //msgp:encode ignore {{TypeName}} - // -loop: - for _, d := range f.Directives { - chunks := strings.Split(d, " ") - if len(chunks) > 1 { - for i := range chunks { - chunks[i] = strings.TrimSpace(chunks[i]) - } - m := strToMethod(chunks[0]) - if m == 0 { - warnf("unknown pass name: %q\n", chunks[0]) - continue loop - } - if fn, ok := passDirectives[chunks[1]]; ok { - pushstate(chunks[1]) - err := fn(m, chunks[2:], p) - if err != nil { - warnf("error applying directive: %s\n", err) - } - popstate() - } else { - warnf("unrecognized directive %q\n", chunks[1]) - } - } else { - warnf("empty directive: %q\n", d) - } - } -} - -func (f *FileSet) PrintTo(p *gen.Printer) error { - f.applyDirs(p) - names := make([]string, 0, len(f.Identities)) - for name := range f.Identities { - names = append(names, name) - } - sort.Strings(names) - for _, name := range names { - el := f.Identities[name] - el.SetVarname("z") - pushstate(el.TypeName()) - err := p.Print(el) - popstate() - if err != nil { - return err - } - } - return nil -} - -// getTypeSpecs extracts all of the *ast.TypeSpecs in the file -// into fs.Identities, but does not set the actual element -func (fs *FileSet) getTypeSpecs(f *ast.File) { - - // collect all imports... - fs.Imports = append(fs.Imports, f.Imports...) - - // check all declarations... - for i := range f.Decls { - - // for GenDecls... - if g, ok := f.Decls[i].(*ast.GenDecl); ok { - - // and check the specs... - for _, s := range g.Specs { - - // for ast.TypeSpecs.... - if ts, ok := s.(*ast.TypeSpec); ok { - switch ts.Type.(type) { - - // this is the list of parse-able - // type specs - case *ast.StructType, - *ast.ArrayType, - *ast.StarExpr, - *ast.MapType, - *ast.Ident: - fs.Specs[ts.Name.Name] = ts.Type - - } - } - } - } - } -} - -func fieldName(f *ast.Field) string { - switch len(f.Names) { - case 0: - return stringify(f.Type) - case 1: - return f.Names[0].Name - default: - return f.Names[0].Name + " (and others)" - } -} - -func (fs *FileSet) parseFieldList(fl *ast.FieldList) []gen.StructField { - if fl == nil || fl.NumFields() == 0 { - return nil - } - out := make([]gen.StructField, 0, fl.NumFields()) - for _, field := range fl.List { - pushstate(fieldName(field)) - fds := fs.getField(field) - if len(fds) > 0 { - out = append(out, fds...) - } else { - warnln("ignored.") - } - popstate() - } - return out -} - -// translate *ast.Field into []gen.StructField -func (fs *FileSet) getField(f *ast.Field) []gen.StructField { - sf := make([]gen.StructField, 1) - var extension, flatten bool - // parse tag; otherwise field name is field tag - if f.Tag != nil { - body := reflect.StructTag(strings.Trim(f.Tag.Value, "`")).Get("msg") - if body == "" { - body = reflect.StructTag(strings.Trim(f.Tag.Value, "`")).Get("msgpack") - } - tags := strings.Split(body, ",") - if len(tags) >= 2 { - switch tags[1] { - case "extension": - extension = true - case "flatten": - flatten = true - } - } - // ignore "-" fields - if tags[0] == "-" { - return nil - } - sf[0].FieldTag = tags[0] - sf[0].FieldTagParts = tags - sf[0].RawTag = f.Tag.Value - } - - ex := fs.parseExpr(f.Type) - if ex == nil { - return nil - } - - // parse field name - switch len(f.Names) { - case 0: - if flatten { - return fs.getFieldsFromEmbeddedStruct(f.Type) - } else { - sf[0].FieldName = embedded(f.Type) - } - case 1: - sf[0].FieldName = f.Names[0].Name - default: - // this is for a multiple in-line declaration, - // e.g. type A struct { One, Two int } - sf = sf[0:0] - for _, nm := range f.Names { - sf = append(sf, gen.StructField{ - FieldTag: nm.Name, - FieldName: nm.Name, - FieldElem: ex.Copy(), - }) - } - return sf - } - sf[0].FieldElem = ex - if sf[0].FieldTag == "" { - sf[0].FieldTag = sf[0].FieldName - sf[0].FieldTagParts = []string{sf[0].FieldName} - } - - // validate extension - if extension { - switch ex := ex.(type) { - case *gen.Ptr: - if b, ok := ex.Value.(*gen.BaseElem); ok { - b.Value = gen.Ext - } else { - warnln("couldn't cast to extension.") - return nil - } - case *gen.BaseElem: - ex.Value = gen.Ext - default: - warnln("couldn't cast to extension.") - return nil - } - } - return sf -} - -func (fs *FileSet) getFieldsFromEmbeddedStruct(f ast.Expr) []gen.StructField { - switch f := f.(type) { - case *ast.Ident: - s := fs.Specs[f.Name] - switch s := s.(type) { - case *ast.StructType: - return fs.parseFieldList(s.Fields) - default: - return nil - } - default: - // other possibilities are disallowed - return nil - } -} - -// extract embedded field name -// -// so, for a struct like -// -// type A struct { -// io.Writer -// } -// -// we want "Writer" -func embedded(f ast.Expr) string { - switch f := f.(type) { - case *ast.Ident: - return f.Name - case *ast.StarExpr: - return embedded(f.X) - case *ast.SelectorExpr: - return f.Sel.Name - default: - // other possibilities are disallowed - return "" - } -} - -// stringify a field type name -func stringify(e ast.Expr) string { - switch e := e.(type) { - case *ast.Ident: - return e.Name - case *ast.StarExpr: - return "*" + stringify(e.X) - case *ast.SelectorExpr: - return stringify(e.X) + "." + e.Sel.Name - case *ast.ArrayType: - if e.Len == nil { - return "[]" + stringify(e.Elt) - } - return fmt.Sprintf("[%s]%s", stringify(e.Len), stringify(e.Elt)) - case *ast.InterfaceType: - if e.Methods == nil || e.Methods.NumFields() == 0 { - return "interface{}" - } - } - return "" -} - -// recursively translate ast.Expr to gen.Elem; nil means type not supported -// expected input types: -// - *ast.MapType (map[T]J) -// - *ast.Ident (name) -// - *ast.ArrayType ([(sz)]T) -// - *ast.StarExpr (*T) -// - *ast.StructType (struct {}) -// - *ast.SelectorExpr (a.B) -// - *ast.InterfaceType (interface {}) -func (fs *FileSet) parseExpr(e ast.Expr) gen.Elem { - switch e := e.(type) { - - case *ast.MapType: - if k, ok := e.Key.(*ast.Ident); ok && k.Name == "string" { - if in := fs.parseExpr(e.Value); in != nil { - return &gen.Map{Value: in} - } - } - return nil - - case *ast.Ident: - b := gen.Ident(e.Name) - - // work to resove this expression - // can be done later, once we've resolved - // everything else. - if b.Value == gen.IDENT { - if _, ok := fs.Specs[e.Name]; !ok { - warnf("non-local identifier: %s\n", e.Name) - } - } - return b - - case *ast.ArrayType: - - // special case for []byte - if e.Len == nil { - if i, ok := e.Elt.(*ast.Ident); ok && i.Name == "byte" { - return &gen.BaseElem{Value: gen.Bytes} - } - } - - // return early if we don't know - // what the slice element type is - els := fs.parseExpr(e.Elt) - if els == nil { - return nil - } - - // array and not a slice - if e.Len != nil { - switch s := e.Len.(type) { - case *ast.BasicLit: - return &gen.Array{ - Size: s.Value, - Els: els, - } - - case *ast.Ident: - return &gen.Array{ - Size: s.String(), - Els: els, - } - - case *ast.SelectorExpr: - return &gen.Array{ - Size: stringify(s), - Els: els, - } - - default: - return nil - } - } - return &gen.Slice{Els: els} - - case *ast.StarExpr: - if v := fs.parseExpr(e.X); v != nil { - return &gen.Ptr{Value: v} - } - return nil - - case *ast.StructType: - return &gen.Struct{Fields: fs.parseFieldList(e.Fields)} - - case *ast.SelectorExpr: - return gen.Ident(stringify(e)) - - case *ast.InterfaceType: - // support `interface{}` - if len(e.Methods.List) == 0 { - return &gen.BaseElem{Value: gen.Intf} - } - return nil - - default: // other types not supported - return nil - } -} - -func infof(s string, v ...interface{}) { - pushstate(s) - fmt.Printf(chalk.Green.Color(strings.Join(logctx, ": ")), v...) - popstate() -} - -func infoln(s string) { - pushstate(s) - fmt.Println(chalk.Green.Color(strings.Join(logctx, ": "))) - popstate() -} - -func warnf(s string, v ...interface{}) { - pushstate(s) - fmt.Printf(chalk.Yellow.Color(strings.Join(logctx, ": ")), v...) - popstate() -} - -func warnln(s string) { - pushstate(s) - fmt.Println(chalk.Yellow.Color(strings.Join(logctx, ": "))) - popstate() -} - -func fatalf(s string, v ...interface{}) { - pushstate(s) - fmt.Printf(chalk.Red.Color(strings.Join(logctx, ": ")), v...) - popstate() -} - -var logctx []string - -// push logging state -func pushstate(s string) { - logctx = append(logctx, s) -} - -// pop logging state -func popstate() { - logctx = logctx[:len(logctx)-1] -} diff --git a/vendor/github.com/tinylib/msgp/parse/inline.go b/vendor/github.com/tinylib/msgp/parse/inline.go deleted file mode 100644 index 469793be3e..0000000000 --- a/vendor/github.com/tinylib/msgp/parse/inline.go +++ /dev/null @@ -1,169 +0,0 @@ -package parse - -import ( - "sort" - - "github.com/tinylib/msgp/gen" -) - -// This file defines when and how we -// propagate type information from -// one type declaration to another. -// After the processing pass, every -// non-primitive type is marshalled/unmarshalled/etc. -// through a function call. Here, we propagate -// the type information into the caller's type -// tree *if* the child type is simple enough. -// -// For example, types like -// -// type A [4]int -// -// will get pushed into parent methods, -// whereas types like -// -// type B [3]map[string]struct{A, B [4]string} -// -// will not. - -// this is an approximate measure -// of the number of children in a node -const maxComplex = 5 - -// begin recursive search for identities with the -// given name and replace them with be -func (f *FileSet) findShim(id string, be *gen.BaseElem) { - for name, el := range f.Identities { - pushstate(name) - switch el := el.(type) { - case *gen.Struct: - for i := range el.Fields { - f.nextShim(&el.Fields[i].FieldElem, id, be) - } - case *gen.Array: - f.nextShim(&el.Els, id, be) - case *gen.Slice: - f.nextShim(&el.Els, id, be) - case *gen.Map: - f.nextShim(&el.Value, id, be) - case *gen.Ptr: - f.nextShim(&el.Value, id, be) - } - popstate() - } - // we'll need this at the top level as well - f.Identities[id] = be -} - -func (f *FileSet) nextShim(ref *gen.Elem, id string, be *gen.BaseElem) { - if (*ref).TypeName() == id { - vn := (*ref).Varname() - *ref = be.Copy() - (*ref).SetVarname(vn) - } else { - switch el := (*ref).(type) { - case *gen.Struct: - for i := range el.Fields { - f.nextShim(&el.Fields[i].FieldElem, id, be) - } - case *gen.Array: - f.nextShim(&el.Els, id, be) - case *gen.Slice: - f.nextShim(&el.Els, id, be) - case *gen.Map: - f.nextShim(&el.Value, id, be) - case *gen.Ptr: - f.nextShim(&el.Value, id, be) - } - } -} - -// propInline identifies and inlines candidates -func (f *FileSet) propInline() { - type gelem struct { - name string - el gen.Elem - } - - all := make([]gelem, 0, len(f.Identities)) - - for name, el := range f.Identities { - all = append(all, gelem{name: name, el: el}) - } - - // make sure we process inlining determinstically: - // start with the least-complex elems; - // use identifier names as a tie-breaker - sort.Slice(all, func(i, j int) bool { - ig, jg := &all[i], &all[j] - ic, jc := ig.el.Complexity(), jg.el.Complexity() - return ic < jc || (ic == jc && ig.name < jg.name) - }) - - for i := range all { - name := all[i].name - pushstate(name) - switch el := all[i].el.(type) { - case *gen.Struct: - for i := range el.Fields { - f.nextInline(&el.Fields[i].FieldElem, name) - } - case *gen.Array: - f.nextInline(&el.Els, name) - case *gen.Slice: - f.nextInline(&el.Els, name) - case *gen.Map: - f.nextInline(&el.Value, name) - case *gen.Ptr: - f.nextInline(&el.Value, name) - } - popstate() - } -} - -const fatalloop = `detected infinite recursion in inlining loop! -Please file a bug at github.com/tinylib/msgp/issues! -Thanks! -` - -func (f *FileSet) nextInline(ref *gen.Elem, root string) { - switch el := (*ref).(type) { - case *gen.BaseElem: - // ensure that we're not inlining - // a type into itself - typ := el.TypeName() - if el.Value == gen.IDENT && typ != root { - if node, ok := f.Identities[typ]; ok && node.Complexity() < maxComplex { - infof("inlining %s\n", typ) - - // This should never happen; it will cause - // infinite recursion. - if node == *ref { - panic(fatalloop) - } - - *ref = node.Copy() - f.nextInline(ref, node.TypeName()) - } else if !ok && !el.Resolved() { - // this is the point at which we're sure that - // we've got a type that isn't a primitive, - // a library builtin, or a processed type - warnf("unresolved identifier: %s\n", typ) - } - } - case *gen.Struct: - for i := range el.Fields { - f.nextInline(&el.Fields[i].FieldElem, root) - } - case *gen.Array: - f.nextInline(&el.Els, root) - case *gen.Slice: - f.nextInline(&el.Els, root) - case *gen.Map: - f.nextInline(&el.Value, root) - case *gen.Ptr: - f.nextInline(&el.Value, root) - default: - panic("bad elem type") - } -} diff --git a/vendor/github.com/tinylib/msgp/printer/print.go b/vendor/github.com/tinylib/msgp/printer/print.go deleted file mode 100644 index 9d1dde4a34..0000000000 --- a/vendor/github.com/tinylib/msgp/printer/print.go +++ /dev/null @@ -1,132 +0,0 @@ -package printer - -import ( - "bytes" - "fmt" - "io" - "io/ioutil" - "strings" - - "github.com/tinylib/msgp/gen" - "github.com/tinylib/msgp/parse" - "github.com/ttacon/chalk" - "golang.org/x/tools/imports" -) - -func infof(s string, v ...interface{}) { - fmt.Printf(chalk.Magenta.Color(s), v...) -} - -// PrintFile prints the methods for the provided list -// of elements to the given file name and canonical -// package path. -func PrintFile(file string, f *parse.FileSet, mode gen.Method) error { - out, tests, err := generate(f, mode) - if err != nil { - return err - } - - // we'll run goimports on the main file - // in another goroutine, and run it here - // for the test file. empirically, this - // takes about the same amount of time as - // doing them in serial when GOMAXPROCS=1, - // and faster otherwise. - res := goformat(file, out.Bytes()) - if tests != nil { - testfile := strings.TrimSuffix(file, ".go") + "_test.go" - err = format(testfile, tests.Bytes()) - if err != nil { - return err - } - infof(">>> Wrote and formatted \"%s\"\n", testfile) - } - err = <-res - if err != nil { - return err - } - return nil -} - -func format(file string, data []byte) error { - out, err := imports.Process(file, data, nil) - if err != nil { - return err - } - return ioutil.WriteFile(file, out, 0600) -} - -func goformat(file string, data []byte) <-chan error { - out := make(chan error, 1) - go func(file string, data []byte, end chan error) { - end <- format(file, data) - infof(">>> Wrote and formatted \"%s\"\n", file) - }(file, data, out) - return out -} - -func dedupImports(imp []string) []string { - m := make(map[string]struct{}) - for i := range imp { - m[imp[i]] = struct{}{} - } - r := []string{} - for k := range m { - r = append(r, k) - } - return r -} - -func generate(f *parse.FileSet, mode gen.Method) (*bytes.Buffer, *bytes.Buffer, error) { - outbuf := bytes.NewBuffer(make([]byte, 0, 4096)) - writePkgHeader(outbuf, f.Package) - - myImports := []string{"github.com/tinylib/msgp/msgp"} - for _, imp := range f.Imports { - if imp.Name != nil { - // have an alias, include it. - myImports = append(myImports, imp.Name.Name+` `+imp.Path.Value) - } else { - myImports = append(myImports, imp.Path.Value) - } - } - dedup := dedupImports(myImports) - writeImportHeader(outbuf, dedup...) - - var testbuf *bytes.Buffer - var testwr io.Writer - if mode&gen.Test == gen.Test { - testbuf = bytes.NewBuffer(make([]byte, 0, 4096)) - writePkgHeader(testbuf, f.Package) - if mode&(gen.Encode|gen.Decode) != 0 { - writeImportHeader(testbuf, "bytes", "github.com/tinylib/msgp/msgp", "testing") - } else { - writeImportHeader(testbuf, "github.com/tinylib/msgp/msgp", "testing") - } - testwr = testbuf - } - return outbuf, testbuf, f.PrintTo(gen.NewPrinter(mode, outbuf, testwr)) -} - -func writePkgHeader(b *bytes.Buffer, name string) { - b.WriteString("package ") - b.WriteString(name) - b.WriteByte('\n') - // write generated code marker - // https://github.com/tinylib/msgp/issues/229 - // https://golang.org/s/generatedcode - b.WriteString("// Code generated by github.com/tinylib/msgp DO NOT EDIT.\n\n") -} - -func writeImportHeader(b *bytes.Buffer, imports ...string) { - b.WriteString("import (\n") - for _, im := range imports { - if im[len(im)-1] == '"' { - // support aliased imports - fmt.Fprintf(b, "\t%s\n", im) - } else { - fmt.Fprintf(b, "\t%q\n", im) - } - } - b.WriteString(")\n\n") -} diff --git a/vendor/github.com/ttacon/chalk/.gitignore b/vendor/github.com/ttacon/chalk/.gitignore deleted file mode 100644 index 836562412f..0000000000 --- a/vendor/github.com/ttacon/chalk/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test diff --git a/vendor/github.com/ttacon/chalk/LICENSE b/vendor/github.com/ttacon/chalk/LICENSE deleted file mode 100644 index 949ba5de0f..0000000000 --- a/vendor/github.com/ttacon/chalk/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Trey Tacon - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/vendor/github.com/ttacon/chalk/README.md b/vendor/github.com/ttacon/chalk/README.md deleted file mode 100644 index a85f1d4ae3..0000000000 --- a/vendor/github.com/ttacon/chalk/README.md +++ /dev/null @@ -1,67 +0,0 @@ -chalk -============= - -Chalk is a go package for styling console/terminal output. - -Check out godoc for some example usage: -http://godoc.org/github.com/ttacon/chalk - -The api is pretty clean, there are default Colors and TextStyles -which can be mixed to create more intense Styles. Styles and Colors -can be printed in normal strings (i.e. ```fmt.Sprintf(chalk.Red)```), but -Styles, Colors and TextStyles are more meant to be used to style specific -text segments (i.e. ```fmt.Println(chalk.Red.Color("this is red")```) or -```fmt.Println(myStyle.Style("this is blue text that is underlined"))```). - -Examples -============= - -There are a few examples in the examples directory if you want to see a very -simplified version of what you can do with chalk. - -The following code: -```go -package main - -import ( - "fmt" - - "github.com/ttacon/chalk" -) - -func main() { - // You can just use colors - fmt.Println(chalk.Red, "Writing in colors", chalk.Cyan, "is so much fun", chalk.Reset) - fmt.Println(chalk.Magenta.Color("You can use colors to color specific phrases")) - - // You can just use text styles - fmt.Println(chalk.Bold.TextStyle("We can have bold text")) - fmt.Println(chalk.Underline.TextStyle("We can have underlined text")) - fmt.Println(chalk.Bold, "But text styles don't work quite like colors :(") - - // Or you can use styles - blueOnWhite := chalk.Blue.NewStyle().WithBackground(chalk.White) - fmt.Printf("%s%s%s\n", blueOnWhite, "And they also have backgrounds!", chalk.Reset) - fmt.Println( - blueOnWhite.Style("You can style strings the same way you can color them!")) - fmt.Println( - blueOnWhite.WithTextStyle(chalk.Bold). - Style("You can mix text styles with colors, too!")) - - // You can also easily make styling functions thanks to go's functional side - lime := chalk.Green.NewStyle(). - WithBackground(chalk.Black). - WithTextStyle(chalk.Bold). - Style - fmt.Println(lime("look at this cool lime text!")) -} - -``` -Outputs -![screenshot](https://raw.githubusercontent.com/ttacon/chalk/master/img/chalk_example.png) - - -WARNING -============= - -This package should be pretty stable (I don't forsee backwards incompatible changes), but I'm not making any promises :) diff --git a/vendor/github.com/ttacon/chalk/chalk.go b/vendor/github.com/ttacon/chalk/chalk.go deleted file mode 100644 index 8003678568..0000000000 --- a/vendor/github.com/ttacon/chalk/chalk.go +++ /dev/null @@ -1,162 +0,0 @@ -package chalk - -import "fmt" - -// Color represents one of the ANSI color escape codes. -// http://en.wikipedia.org/wiki/ANSI_escape_code#Colors -type Color struct { - value int -} - -// Value returns the individual value for this color -// (Actually it's really just its index in the list -// of color escape codes with the list being -// [black, red, green, yellow, blue, magenta, cyan, white]. -func (c Color) Value() int { - return c.value -} - -// Color colors the foreground of the given string -// (whatever the previous background color was, it is -// left alone). -func (c Color) Color(val string) string { - return fmt.Sprintf("%s%s%s", c, val, ResetColor) -} - -func (c Color) String() string { - return fmt.Sprintf("\u001b[%dm", 30+c.value) -} - -// NewStyle creates a style with a foreground of the -// color we're creating the style from. -func (c Color) NewStyle() Style { - return &style{foreground: c} -} - -type textStyleDemarcation int - -func (t textStyleDemarcation) String() string { - return fmt.Sprintf("\u001b[%dm", t) -} - -// A TextStyle represents the ways we can style the text: -// bold, dim, italic, underline, inverse, hidden or strikethrough. -type TextStyle struct { - start, stop textStyleDemarcation -} - -// TextStyle styles the given string using the desired text style. -func (t TextStyle) TextStyle(val string) string { - if t == emptyTextStyle { - return val - } - return fmt.Sprintf("%s%s%s", t.start, val, t.stop) -} - -// NOTE: this function specifically does not work as desired because -// text styles must be wrapped around the text they are meant to style. -// As such, use TextStyle() or Style.Style() instead. -func (t TextStyle) String() string { - return fmt.Sprintf("%s%s", t.start, t.stop) -} - -// NewStyle creates a style starting with the current TextStyle -// as its text style. -func (t TextStyle) NewStyle() Style { - return &style{textStyle: t} -} - -// A Style is how we want our text to look in the console. -// Consequently, we can set the foreground and background -// to specific colors, we can style specific strings and -// can also use this style in a builder pattern should we -// wish (these will be more useful once styles such as -// italics are supported). -type Style interface { - // Foreground sets the foreground of the style to the specific color. - Foreground(Color) - // Background sets the background of the style to the specific color. - Background(Color) - // Style styles the given string with the current style. - Style(string) string - // WithBackground allows us to set the background in a builder - // pattern style. - WithBackground(Color) Style - // WithForeground allows us to set the foreground in a builder - // pattern style. - WithForeground(Color) Style - // WithStyle allows us to set the text style in a builder pattern - // style. - WithTextStyle(TextStyle) Style - String() string -} - -type style struct { - foreground Color - background Color - textStyle TextStyle -} - -func (s *style) WithBackground(col Color) Style { - s.Background(col) - return s -} - -func (s *style) WithForeground(col Color) Style { - s.Foreground(col) - return s -} - -func (s *style) String() string { - var toReturn string - toReturn = fmt.Sprintf("\u001b[%dm", 40+s.background.Value()) - return toReturn + fmt.Sprintf("\u001b[%dm", 30+s.foreground.Value()) -} - -func (s *style) Style(val string) string { - return fmt.Sprintf("%s%s%s", s, s.textStyle.TextStyle(val), Reset) -} - -func (s *style) Foreground(col Color) { - s.foreground = col -} - -func (s *style) Background(col Color) { - s.background = col -} - -func (s *style) WithTextStyle(textStyle TextStyle) Style { - s.textStyle = textStyle - return s -} - -var ( - // Colors - - Black = Color{0} - Red = Color{1} - Green = Color{2} - Yellow = Color{3} - Blue = Color{4} - Magenta = Color{5} - Cyan = Color{6} - White = Color{7} - ResetColor = Color{9} - - // Text Styles - - Bold = TextStyle{1, 22} - Dim = TextStyle{2, 22} - Italic = TextStyle{3, 23} - Underline = TextStyle{4, 24} - Inverse = TextStyle{7, 27} - Hidden = TextStyle{8, 28} - Strikethrough = TextStyle{9, 29} - - Reset = &style{ - foreground: ResetColor, - background: ResetColor, - } - - emptyTextStyle = TextStyle{} -) diff --git a/vendor/github.com/ttacon/chalk/doc.go b/vendor/github.com/ttacon/chalk/doc.go deleted file mode 100644 index d5e4e091d8..0000000000 --- a/vendor/github.com/ttacon/chalk/doc.go +++ /dev/null @@ -1,59 +0,0 @@ -// Package chalk is a package for styling terminal/console output. -// There are three main components: -// -// -// Colors -// -// There are eight default colors: black, red, green, yellow, blue, -// magenta, cyan and white. You can use them in two main ways -// (note the need for the reset color if you don't use Color()): -// -// fmt.Println(chalk.Red, "this is red text", chalk.ResetColor) -// fmt.Println(chalk.Red.Color("this is red text") -// -// -// TextStyles -// -// There are seven default text styles: bold, dim, italic, underline, -// inverse, hidden and strikethrough. Unlike colors, you should only -// really use TextStyles in the following manner: -// -// fmt.Println(chalk.Bold.TextStyle("this is bold text")) -// -// -// Styles -// -// Styles are where all the business really is. Styles can have a -// foreground color, a background color and a text style (sweet!). -// They're also pretty simply to make, you just need a starting point: -// -// blue := chalk.Blue.NewStyle() -// bold := chalk.Bold.NewStyle() -// -// When a color is your starting point for a style, it will be the -// foreground color, when a style is your starting point, well, yeah, -// it's your style's text style. You can also alter a style's foreground, -// background or text style in a builder-esque pattern. -// -// blueOnWhite := blue.WithBackground(chalk.White) -// awesomeness := blueOnWhite.WithTextStyle(chalk.Underline).WithForeground(chalk.Green) -// -// Like both Colors and TextStyles you can style specific segments of text -// with: -// -// fmt.Println(awesomeness.Style("this is so pretty!")) -// -// Like Colors, you can also print styles explicitly, but you'll need to -// reset your console's colors with chalk.Reset if you use them this way: -// -// fmt.Println(awesomeness, "this is so pretty", chalk.Reset) -// -// Be aware though, that this (second) way of using styles will not add the -// text style (as text styles require more specific end codes). So if you want -// to fully utilize styles, use myStyle.Style() (unless you only care about -// print your text with a specific foreground and background, then printing -// the style is awesome too!). -// -// Have fun! -// -package chalk diff --git a/vendor/go.etcd.io/bbolt/README.md b/vendor/go.etcd.io/bbolt/README.md index c9e64b1a61..2dff3761da 100644 --- a/vendor/go.etcd.io/bbolt/README.md +++ b/vendor/go.etcd.io/bbolt/README.md @@ -152,12 +152,11 @@ are not thread safe. To work with data in multiple goroutines you must start a transaction for each one or use locking to ensure only one goroutine accesses a transaction at a time. Creating transaction from the `DB` is thread safe. -Transactions should not depend on one another and generally shouldn't be opened -simultaneously in the same goroutine. This can cause a deadlock as the read-write -transaction needs to periodically re-map the data file but it cannot do so while -any read-only transaction is open. Even a nested read-only transaction can cause -a deadlock, as the child transaction can block the parent transaction from releasing -its resources. +Read-only transactions and read-write transactions should not depend on one +another and generally shouldn't be opened simultaneously in the same goroutine. +This can cause a deadlock as the read-write transaction needs to periodically +re-map the data file but it cannot do so while a read-only transaction is open. + #### Read-write transactions diff --git a/vendor/go.etcd.io/bbolt/freelist.go b/vendor/go.etcd.io/bbolt/freelist.go index 697a46968b..d441b69256 100644 --- a/vendor/go.etcd.io/bbolt/freelist.go +++ b/vendor/go.etcd.io/bbolt/freelist.go @@ -2,6 +2,7 @@ package bbolt import ( "fmt" + "reflect" "sort" "unsafe" ) @@ -93,8 +94,24 @@ func (f *freelist) pending_count() int { return count } -// copyall copies a list of all free ids and all pending ids in one sorted list. +// copyallunsafe copies a list of all free ids and all pending ids in one sorted list. // f.count returns the minimum length required for dst. +func (f *freelist) copyallunsafe(dstptr unsafe.Pointer) { // dstptr is []pgid data pointer + m := make(pgids, 0, f.pending_count()) + for _, txp := range f.pending { + m = append(m, txp.ids...) + } + sort.Sort(m) + fpgids := f.getFreePageIDs() + sz := len(fpgids) + len(m) + dst := *(*[]pgid)(unsafe.Pointer(&reflect.SliceHeader{ + Data: uintptr(dstptr), + Len: sz, + Cap: sz, + })) + mergepgids(dst, fpgids, m) +} + func (f *freelist) copyall(dst []pgid) { m := make(pgids, 0, f.pending_count()) for _, txp := range f.pending { @@ -267,23 +284,21 @@ func (f *freelist) read(p *page) { } // If the page.count is at the max uint16 value (64k) then it's considered // an overflow and the size of the freelist is stored as the first element. - var idx, count = 0, int(p.count) + var idx, count uintptr = 0, uintptr(p.count) if count == 0xFFFF { idx = 1 - c := *(*pgid)(unsafeAdd(unsafe.Pointer(p), unsafe.Sizeof(*p))) - count = int(c) - if count < 0 { - panic(fmt.Sprintf("leading element count %d overflows int", c)) - } + count = uintptr(*(*pgid)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + unsafe.Sizeof(*p)))) } // Copy the list of page ids from the freelist. if count == 0 { f.ids = nil } else { - var ids []pgid - data := unsafeIndex(unsafe.Pointer(p), unsafe.Sizeof(*p), unsafe.Sizeof(ids[0]), idx) - unsafeSlice(unsafe.Pointer(&ids), data, count) + ids := *(*[]pgid)(unsafe.Pointer(&reflect.SliceHeader{ + Data: uintptr(unsafe.Pointer(p)) + unsafe.Sizeof(*p) + idx*unsafe.Sizeof(pgid(0)), + Len: int(count), + Cap: int(count), + })) // copy the ids, so we don't modify on the freelist page directly idsCopy := make([]pgid, count) @@ -316,22 +331,16 @@ func (f *freelist) write(p *page) error { // The page.count can only hold up to 64k elements so if we overflow that // number then we handle it by putting the size in the first element. - l := f.count() - if l == 0 { - p.count = uint16(l) - } else if l < 0xFFFF { - p.count = uint16(l) - var ids []pgid - data := unsafeAdd(unsafe.Pointer(p), unsafe.Sizeof(*p)) - unsafeSlice(unsafe.Pointer(&ids), data, l) - f.copyall(ids) + lenids := f.count() + if lenids == 0 { + p.count = uint16(lenids) + } else if lenids < 0xFFFF { + p.count = uint16(lenids) + f.copyallunsafe(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + unsafe.Sizeof(*p))) } else { p.count = 0xFFFF - var ids []pgid - data := unsafeAdd(unsafe.Pointer(p), unsafe.Sizeof(*p)) - unsafeSlice(unsafe.Pointer(&ids), data, l+1) - ids[0] = pgid(l) - f.copyall(ids[1:]) + *(*pgid)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + unsafe.Sizeof(*p))) = pgid(lenids) + f.copyallunsafe(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + unsafe.Sizeof(*p) + unsafe.Sizeof(pgid(0)))) } return nil diff --git a/vendor/go.etcd.io/bbolt/node.go b/vendor/go.etcd.io/bbolt/node.go index 73988b5c4c..1690eef3f7 100644 --- a/vendor/go.etcd.io/bbolt/node.go +++ b/vendor/go.etcd.io/bbolt/node.go @@ -3,6 +3,7 @@ package bbolt import ( "bytes" "fmt" + "reflect" "sort" "unsafe" ) @@ -207,32 +208,36 @@ func (n *node) write(p *page) { } // Loop over each item and write it to the page. - // off tracks the offset into p of the start of the next data. - off := unsafe.Sizeof(*p) + n.pageElementSize()*uintptr(len(n.inodes)) + bp := uintptr(unsafe.Pointer(p)) + unsafe.Sizeof(*p) + n.pageElementSize()*uintptr(len(n.inodes)) for i, item := range n.inodes { _assert(len(item.key) > 0, "write: zero-length inode key") - // Create a slice to write into of needed size and advance - // byte pointer for next iteration. - sz := len(item.key) + len(item.value) - b := unsafeByteSlice(unsafe.Pointer(p), off, 0, sz) - off += uintptr(sz) - // Write the page element. if n.isLeaf { elem := p.leafPageElement(uint16(i)) - elem.pos = uint32(uintptr(unsafe.Pointer(&b[0])) - uintptr(unsafe.Pointer(elem))) + elem.pos = uint32(bp - uintptr(unsafe.Pointer(elem))) elem.flags = item.flags elem.ksize = uint32(len(item.key)) elem.vsize = uint32(len(item.value)) } else { elem := p.branchPageElement(uint16(i)) - elem.pos = uint32(uintptr(unsafe.Pointer(&b[0])) - uintptr(unsafe.Pointer(elem))) + elem.pos = uint32(bp - uintptr(unsafe.Pointer(elem))) elem.ksize = uint32(len(item.key)) elem.pgid = item.pgid _assert(elem.pgid != p.id, "write: circular dependency occurred") } + // Create a slice to write into of needed size and advance + // byte pointer for next iteration. + klen, vlen := len(item.key), len(item.value) + sz := klen + vlen + b := *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{ + Data: bp, + Len: sz, + Cap: sz, + })) + bp += uintptr(sz) + // Write data for the element to the end of the page. l := copy(b, item.key) copy(b[l:], item.value) diff --git a/vendor/go.etcd.io/bbolt/page.go b/vendor/go.etcd.io/bbolt/page.go index c9a158fb06..b5c1699789 100644 --- a/vendor/go.etcd.io/bbolt/page.go +++ b/vendor/go.etcd.io/bbolt/page.go @@ -3,6 +3,7 @@ package bbolt import ( "fmt" "os" + "reflect" "sort" "unsafe" ) @@ -50,13 +51,13 @@ func (p *page) typ() string { // meta returns a pointer to the metadata section of the page. func (p *page) meta() *meta { - return (*meta)(unsafeAdd(unsafe.Pointer(p), unsafe.Sizeof(*p))) + return (*meta)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + unsafe.Sizeof(*p))) } // leafPageElement retrieves the leaf node by index func (p *page) leafPageElement(index uint16) *leafPageElement { - return (*leafPageElement)(unsafeIndex(unsafe.Pointer(p), unsafe.Sizeof(*p), - leafPageElementSize, int(index))) + off := uintptr(index) * unsafe.Sizeof(leafPageElement{}) + return (*leafPageElement)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + unsafe.Sizeof(*p) + off)) } // leafPageElements retrieves a list of leaf nodes. @@ -64,16 +65,17 @@ func (p *page) leafPageElements() []leafPageElement { if p.count == 0 { return nil } - var elems []leafPageElement - data := unsafeAdd(unsafe.Pointer(p), unsafe.Sizeof(*p)) - unsafeSlice(unsafe.Pointer(&elems), data, int(p.count)) - return elems + return *(*[]leafPageElement)(unsafe.Pointer(&reflect.SliceHeader{ + Data: uintptr(unsafe.Pointer(p)) + unsafe.Sizeof(*p), + Len: int(p.count), + Cap: int(p.count), + })) } // branchPageElement retrieves the branch node by index func (p *page) branchPageElement(index uint16) *branchPageElement { - return (*branchPageElement)(unsafeIndex(unsafe.Pointer(p), unsafe.Sizeof(*p), - unsafe.Sizeof(branchPageElement{}), int(index))) + off := uintptr(index) * unsafe.Sizeof(branchPageElement{}) + return (*branchPageElement)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + unsafe.Sizeof(*p) + off)) } // branchPageElements retrieves a list of branch nodes. @@ -81,15 +83,20 @@ func (p *page) branchPageElements() []branchPageElement { if p.count == 0 { return nil } - var elems []branchPageElement - data := unsafeAdd(unsafe.Pointer(p), unsafe.Sizeof(*p)) - unsafeSlice(unsafe.Pointer(&elems), data, int(p.count)) - return elems + return *(*[]branchPageElement)(unsafe.Pointer(&reflect.SliceHeader{ + Data: uintptr(unsafe.Pointer(p)) + unsafe.Sizeof(*p), + Len: int(p.count), + Cap: int(p.count), + })) } // dump writes n bytes of the page to STDERR as hex output. func (p *page) hexdump(n int) { - buf := unsafeByteSlice(unsafe.Pointer(p), 0, 0, n) + buf := *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{ + Data: uintptr(unsafe.Pointer(p)), + Len: n, + Cap: n, + })) fmt.Fprintf(os.Stderr, "%x\n", buf) } @@ -108,7 +115,11 @@ type branchPageElement struct { // key returns a byte slice of the node key. func (n *branchPageElement) key() []byte { - return unsafeByteSlice(unsafe.Pointer(n), 0, int(n.pos), int(n.pos)+int(n.ksize)) + return *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{ + Data: uintptr(unsafe.Pointer(n)) + uintptr(n.pos), + Len: int(n.ksize), + Cap: int(n.ksize), + })) } // leafPageElement represents a node on a leaf page. @@ -121,16 +132,20 @@ type leafPageElement struct { // key returns a byte slice of the node key. func (n *leafPageElement) key() []byte { - i := int(n.pos) - j := i + int(n.ksize) - return unsafeByteSlice(unsafe.Pointer(n), 0, i, j) + return *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{ + Data: uintptr(unsafe.Pointer(n)) + uintptr(n.pos), + Len: int(n.ksize), + Cap: int(n.ksize), + })) } // value returns a byte slice of the node value. func (n *leafPageElement) value() []byte { - i := int(n.pos) + int(n.ksize) - j := i + int(n.vsize) - return unsafeByteSlice(unsafe.Pointer(n), 0, i, j) + return *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{ + Data: uintptr(unsafe.Pointer(n)) + uintptr(n.pos) + uintptr(n.ksize), + Len: int(n.vsize), + Cap: int(n.vsize), + })) } // PageInfo represents human readable information about a page. diff --git a/vendor/go.etcd.io/bbolt/tx.go b/vendor/go.etcd.io/bbolt/tx.go index 4b1a64a8b8..13937cdbf6 100644 --- a/vendor/go.etcd.io/bbolt/tx.go +++ b/vendor/go.etcd.io/bbolt/tx.go @@ -4,6 +4,7 @@ import ( "fmt" "io" "os" + "reflect" "sort" "strings" "time" @@ -523,18 +524,24 @@ func (tx *Tx) write() error { // Write pages to disk in order. for _, p := range pages { - rem := (uint64(p.overflow) + 1) * uint64(tx.db.pageSize) + size := (int(p.overflow) + 1) * tx.db.pageSize offset := int64(p.id) * int64(tx.db.pageSize) - var written uintptr // Write out page in "max allocation" sized chunks. + ptr := uintptr(unsafe.Pointer(p)) for { - sz := rem + // Limit our write to our max allocation size. + sz := size if sz > maxAllocSize-1 { sz = maxAllocSize - 1 } - buf := unsafeByteSlice(unsafe.Pointer(p), written, 0, int(sz)) + // Write chunk to disk. + buf := *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{ + Data: ptr, + Len: sz, + Cap: sz, + })) if _, err := tx.db.ops.writeAt(buf, offset); err != nil { return err } @@ -543,14 +550,14 @@ func (tx *Tx) write() error { tx.stats.Write++ // Exit inner for loop if we've written all the chunks. - rem -= sz - if rem == 0 { + size -= sz + if size == 0 { break } // Otherwise move offset forward and move pointer to next chunk. offset += int64(sz) - written += uintptr(sz) + ptr += uintptr(sz) } } @@ -569,7 +576,11 @@ func (tx *Tx) write() error { continue } - buf := unsafeByteSlice(unsafe.Pointer(p), 0, 0, tx.db.pageSize) + buf := *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{ + Data: uintptr(unsafe.Pointer(p)), + Len: tx.db.pageSize, + Cap: tx.db.pageSize, + })) // See https://go.googlesource.com/go/+/f03c9202c43e0abb130669852082117ca50aa9b1 for i := range buf { diff --git a/vendor/go.etcd.io/bbolt/unsafe.go b/vendor/go.etcd.io/bbolt/unsafe.go deleted file mode 100644 index c0e5037500..0000000000 --- a/vendor/go.etcd.io/bbolt/unsafe.go +++ /dev/null @@ -1,39 +0,0 @@ -package bbolt - -import ( - "reflect" - "unsafe" -) - -func unsafeAdd(base unsafe.Pointer, offset uintptr) unsafe.Pointer { - return unsafe.Pointer(uintptr(base) + offset) -} - -func unsafeIndex(base unsafe.Pointer, offset uintptr, elemsz uintptr, n int) unsafe.Pointer { - return unsafe.Pointer(uintptr(base) + offset + uintptr(n)*elemsz) -} - -func unsafeByteSlice(base unsafe.Pointer, offset uintptr, i, j int) []byte { - // See: https://github.com/golang/go/wiki/cgo#turning-c-arrays-into-go-slices - // - // This memory is not allocated from C, but it is unmanaged by Go's - // garbage collector and should behave similarly, and the compiler - // should produce similar code. Note that this conversion allows a - // subslice to begin after the base address, with an optional offset, - // while the URL above does not cover this case and only slices from - // index 0. However, the wiki never says that the address must be to - // the beginning of a C allocation (or even that malloc was used at - // all), so this is believed to be correct. - return (*[maxAllocSize]byte)(unsafeAdd(base, offset))[i:j:j] -} - -// unsafeSlice modifies the data, len, and cap of a slice variable pointed to by -// the slice parameter. This helper should be used over other direct -// manipulation of reflect.SliceHeader to prevent misuse, namely, converting -// from reflect.SliceHeader to a Go slice type. -func unsafeSlice(slice, data unsafe.Pointer, len int) { - s := (*reflect.SliceHeader)(slice) - s.Data = uintptr(data) - s.Cap = len - s.Len = len -} diff --git a/vendor/gopkg.in/yaml.v3/.travis.yml b/vendor/gopkg.in/yaml.v3/.travis.yml index a130fe883c..04d4dae09c 100644 --- a/vendor/gopkg.in/yaml.v3/.travis.yml +++ b/vendor/gopkg.in/yaml.v3/.travis.yml @@ -11,7 +11,6 @@ go: - "1.11.x" - "1.12.x" - "1.13.x" - - "1.14.x" - "tip" go_import_path: gopkg.in/yaml.v3 diff --git a/vendor/gopkg.in/yaml.v3/apic.go b/vendor/gopkg.in/yaml.v3/apic.go index ae7d049f18..65846e6749 100644 --- a/vendor/gopkg.in/yaml.v3/apic.go +++ b/vendor/gopkg.in/yaml.v3/apic.go @@ -108,7 +108,6 @@ func yaml_emitter_initialize(emitter *yaml_emitter_t) { raw_buffer: make([]byte, 0, output_raw_buffer_size), states: make([]yaml_emitter_state_t, 0, initial_stack_size), events: make([]yaml_event_t, 0, initial_queue_size), - best_width: -1, } } diff --git a/vendor/gopkg.in/yaml.v3/decode.go b/vendor/gopkg.in/yaml.v3/decode.go index 21c0dacfdf..be63169b71 100644 --- a/vendor/gopkg.in/yaml.v3/decode.go +++ b/vendor/gopkg.in/yaml.v3/decode.go @@ -35,7 +35,6 @@ type parser struct { doc *Node anchors map[string]*Node doneInit bool - textless bool } func newParser(b []byte) *parser { @@ -109,18 +108,14 @@ func (p *parser) peek() yaml_event_type_t { func (p *parser) fail() { var where string var line int - if p.parser.context_mark.line != 0 { - line = p.parser.context_mark.line - // Scanner errors don't iterate line before returning error - if p.parser.error == yaml_SCANNER_ERROR { - line++ - } - } else if p.parser.problem_mark.line != 0 { + if p.parser.problem_mark.line != 0 { line = p.parser.problem_mark.line // Scanner errors don't iterate line before returning error if p.parser.error == yaml_SCANNER_ERROR { line++ } + } else if p.parser.context_mark.line != 0 { + line = p.parser.context_mark.line } if line != 0 { where = "line " + strconv.Itoa(line) + ": " @@ -174,20 +169,17 @@ func (p *parser) node(kind Kind, defaultTag, tag, value string) *Node { } else if kind == ScalarNode { tag, _ = resolve("", value) } - n := &Node{ - Kind: kind, - Tag: tag, - Value: value, - Style: style, + return &Node{ + Kind: kind, + Tag: tag, + Value: value, + Style: style, + Line: p.event.start_mark.line + 1, + Column: p.event.start_mark.column + 1, + HeadComment: string(p.event.head_comment), + LineComment: string(p.event.line_comment), + FootComment: string(p.event.foot_comment), } - if !p.textless { - n.Line = p.event.start_mark.line + 1 - n.Column = p.event.start_mark.column + 1 - n.HeadComment = string(p.event.head_comment) - n.LineComment = string(p.event.line_comment) - n.FootComment = string(p.event.foot_comment) - } - return n } func (p *parser) parseChild(parent *Node) *Node { @@ -399,7 +391,7 @@ func (d *decoder) callObsoleteUnmarshaler(n *Node, u obsoleteUnmarshaler) (good // // If n holds a null value, prepare returns before doing anything. func (d *decoder) prepare(n *Node, out reflect.Value) (newout reflect.Value, unmarshaled, good bool) { - if n.ShortTag() == nullTag || n.Kind == 0 && n.IsZero() { + if n.ShortTag() == nullTag { return out, false, false } again := true @@ -505,13 +497,8 @@ func (d *decoder) unmarshal(n *Node, out reflect.Value) (good bool) { good = d.mapping(n, out) case SequenceNode: good = d.sequence(n, out) - case 0: - if n.IsZero() { - return d.null(out) - } - fallthrough default: - failf("cannot decode node with unknown kind %d", n.Kind) + panic("internal error: unknown node kind: " + strconv.Itoa(int(n.Kind))) } return good } @@ -546,17 +533,6 @@ func resetMap(out reflect.Value) { } } -func (d *decoder) null(out reflect.Value) bool { - if out.CanAddr() { - switch out.Kind() { - case reflect.Interface, reflect.Ptr, reflect.Map, reflect.Slice: - out.Set(reflect.Zero(out.Type())) - return true - } - } - return false -} - func (d *decoder) scalar(n *Node, out reflect.Value) bool { var tag string var resolved interface{} @@ -574,7 +550,14 @@ func (d *decoder) scalar(n *Node, out reflect.Value) bool { } } if resolved == nil { - return d.null(out) + if out.CanAddr() { + switch out.Kind() { + case reflect.Interface, reflect.Ptr, reflect.Map, reflect.Slice: + out.Set(reflect.Zero(out.Type())) + return true + } + } + return false } if resolvedv := reflect.ValueOf(resolved); out.Type() == resolvedv.Type() { // We've resolved to exactly the type we want, so use that. diff --git a/vendor/gopkg.in/yaml.v3/emitterc.go b/vendor/gopkg.in/yaml.v3/emitterc.go index c29217ef54..ab2a066194 100644 --- a/vendor/gopkg.in/yaml.v3/emitterc.go +++ b/vendor/gopkg.in/yaml.v3/emitterc.go @@ -235,13 +235,10 @@ func yaml_emitter_increase_indent(emitter *yaml_emitter_t, flow, indentless bool emitter.indent = 0 } } else if !indentless { - // [Go] This was changed so that indentations are more regular. - if emitter.states[len(emitter.states)-1] == yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE { - // The first indent inside a sequence will just skip the "- " indicator. - emitter.indent += 2 - } else { - // Everything else aligns to the chosen indentation. - emitter.indent = emitter.best_indent*((emitter.indent+emitter.best_indent)/emitter.best_indent) + emitter.indent += emitter.best_indent + // [Go] If inside a block sequence item, discount the space taken by the indicator. + if emitter.best_indent > 2 && emitter.states[len(emitter.states)-1] == yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE { + emitter.indent -= 2 } } return true @@ -728,9 +725,16 @@ func yaml_emitter_emit_flow_mapping_value(emitter *yaml_emitter_t, event *yaml_e // Expect a block item node. func yaml_emitter_emit_block_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { if first { - if !yaml_emitter_increase_indent(emitter, false, false) { + // [Go] The original logic here would not indent the sequence when inside a mapping. + // In Go we always indent it, but take the sequence indicator out of the indentation. + indentless := emitter.best_indent == 2 && emitter.mapping_context && (emitter.column == 0 || !emitter.indention) + original := emitter.indent + if !yaml_emitter_increase_indent(emitter, false, indentless) { return false } + if emitter.indent > original+2 { + emitter.indent -= 2 + } } if event.typ == yaml_SEQUENCE_END_EVENT { emitter.indent = emitter.indents[len(emitter.indents)-1] @@ -781,13 +785,6 @@ func yaml_emitter_emit_block_mapping_key(emitter *yaml_emitter_t, event *yaml_ev if !yaml_emitter_write_indent(emitter) { return false } - if len(emitter.line_comment) > 0 { - // [Go] A line comment was provided for the key. That's unusual as the - // scanner associates line comments with the value. Either way, - // save the line comment and render it appropriately later. - emitter.key_line_comment = emitter.line_comment - emitter.line_comment = nil - } if yaml_emitter_check_simple_key(emitter) { emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE) return yaml_emitter_emit_node(emitter, event, false, false, true, true) @@ -813,29 +810,6 @@ func yaml_emitter_emit_block_mapping_value(emitter *yaml_emitter_t, event *yaml_ return false } } - if len(emitter.key_line_comment) > 0 { - // [Go] A line comment was previously provided for the key. Handle it before - // the value so the inline comments are placed correctly. - if yaml_emitter_silent_nil_event(emitter, event) && len(emitter.line_comment) == 0 { - // Nothing other than the line comment will be written on the line. - emitter.line_comment = emitter.key_line_comment - emitter.key_line_comment = nil - } else { - // An actual value is coming, so emit the comment line. - emitter.line_comment, emitter.key_line_comment = emitter.key_line_comment, emitter.line_comment - if !yaml_emitter_process_line_comment(emitter) { - return false - } - emitter.line_comment, emitter.key_line_comment = emitter.key_line_comment, emitter.line_comment - // Indent in unless it's a block that will reindent anyway. - if event.sequence_style() == yaml_FLOW_SEQUENCE_STYLE || (event.typ != yaml_MAPPING_START_EVENT && event.typ != yaml_SEQUENCE_START_EVENT) { - emitter.indent = emitter.best_indent*((emitter.indent+emitter.best_indent)/emitter.best_indent) - if !yaml_emitter_write_indent(emitter) { - return false - } - } - } - } emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_KEY_STATE) if !yaml_emitter_emit_node(emitter, event, false, false, true, false) { return false @@ -849,10 +823,6 @@ func yaml_emitter_emit_block_mapping_value(emitter *yaml_emitter_t, event *yaml_ return true } -func yaml_emitter_silent_nil_event(emitter *yaml_emitter_t, event *yaml_event_t) bool { - return event.typ == yaml_SCALAR_EVENT && event.implicit && !emitter.canonical && len(emitter.scalar_data.value) == 0 -} - // Expect a node. func yaml_emitter_emit_node(emitter *yaml_emitter_t, event *yaml_event_t, root bool, sequence bool, mapping bool, simple_key bool) bool { diff --git a/vendor/gopkg.in/yaml.v3/encode.go b/vendor/gopkg.in/yaml.v3/encode.go index 45e8d1e1b9..1f37271ce4 100644 --- a/vendor/gopkg.in/yaml.v3/encode.go +++ b/vendor/gopkg.in/yaml.v3/encode.go @@ -119,9 +119,6 @@ func (e *encoder) marshal(tag string, in reflect.Value) { case *Node: e.nodev(in) return - case Node: - e.nodev(in.Addr()) - return case time.Time: e.timev(tag, in) return @@ -425,23 +422,18 @@ func (e *encoder) nodev(in reflect.Value) { } func (e *encoder) node(node *Node, tail string) { - // Zero nodes behave as nil. - if node.Kind == 0 && node.IsZero() { - e.nilv() - return - } - // If the tag was not explicitly requested, and dropping it won't change the // implicit tag of the value, don't include it in the presentation. var tag = node.Tag var stag = shortTag(tag) + var rtag string var forceQuoting bool if tag != "" && node.Style&TaggedStyle == 0 { if node.Kind == ScalarNode { if stag == strTag && node.Style&(SingleQuotedStyle|DoubleQuotedStyle|LiteralStyle|FoldedStyle) != 0 { tag = "" } else { - rtag, _ := resolve("", node.Value) + rtag, _ = resolve("", node.Value) if rtag == stag { tag = "" } else if stag == strTag { @@ -450,7 +442,6 @@ func (e *encoder) node(node *Node, tail string) { } } } else { - var rtag string switch node.Kind { case MappingNode: rtag = mapTag @@ -480,7 +471,7 @@ func (e *encoder) node(node *Node, tail string) { if node.Style&FlowStyle != 0 { style = yaml_FLOW_SEQUENCE_STYLE } - e.must(yaml_sequence_start_event_initialize(&e.event, []byte(node.Anchor), []byte(longTag(tag)), tag == "", style)) + e.must(yaml_sequence_start_event_initialize(&e.event, []byte(node.Anchor), []byte(tag), tag == "", style)) e.event.head_comment = []byte(node.HeadComment) e.emit() for _, node := range node.Content { @@ -496,7 +487,7 @@ func (e *encoder) node(node *Node, tail string) { if node.Style&FlowStyle != 0 { style = yaml_FLOW_MAPPING_STYLE } - yaml_mapping_start_event_initialize(&e.event, []byte(node.Anchor), []byte(longTag(tag)), tag == "", style) + yaml_mapping_start_event_initialize(&e.event, []byte(node.Anchor), []byte(tag), tag == "", style) e.event.tail_comment = []byte(tail) e.event.head_comment = []byte(node.HeadComment) e.emit() @@ -537,11 +528,11 @@ func (e *encoder) node(node *Node, tail string) { case ScalarNode: value := node.Value if !utf8.ValidString(value) { - if stag == binaryTag { + if tag == binaryTag { failf("explicitly tagged !!binary data must be base64-encoded") } - if stag != "" { - failf("cannot marshal invalid UTF-8 data as %s", stag) + if tag != "" { + failf("cannot marshal invalid UTF-8 data as %s", shortTag(tag)) } // It can't be encoded directly as YAML so use a binary tag // and encode it as base64. @@ -566,7 +557,5 @@ func (e *encoder) node(node *Node, tail string) { } e.emitScalar(value, node.Anchor, tag, style, []byte(node.HeadComment), []byte(node.LineComment), []byte(node.FootComment), []byte(tail)) - default: - failf("cannot encode node with unknown kind %d", node.Kind) } } diff --git a/vendor/gopkg.in/yaml.v3/parserc.go b/vendor/gopkg.in/yaml.v3/parserc.go index ac66fccc05..aea9050b83 100644 --- a/vendor/gopkg.in/yaml.v3/parserc.go +++ b/vendor/gopkg.in/yaml.v3/parserc.go @@ -648,10 +648,6 @@ func yaml_parser_parse_node(parser *yaml_parser_t, event *yaml_event_t, block, i implicit: implicit, style: yaml_style_t(yaml_BLOCK_MAPPING_STYLE), } - if parser.stem_comment != nil { - event.head_comment = parser.stem_comment - parser.stem_comment = nil - } return true } if len(anchor) > 0 || len(tag) > 0 { @@ -698,13 +694,25 @@ func yaml_parser_parse_block_sequence_entry(parser *yaml_parser_t, event *yaml_e if token.typ == yaml_BLOCK_ENTRY_TOKEN { mark := token.end_mark - prior_head_len := len(parser.head_comment) + prior_head := len(parser.head_comment) skip_token(parser) - yaml_parser_split_stem_comment(parser, prior_head_len) token = peek_token(parser) if token == nil { return false } + if prior_head > 0 && token.typ == yaml_BLOCK_SEQUENCE_START_TOKEN { + // [Go] It's a sequence under a sequence entry, so the former head comment + // is for the list itself, not the first list item under it. + parser.stem_comment = parser.head_comment[:prior_head] + if len(parser.head_comment) == prior_head { + parser.head_comment = nil + } else { + // Copy suffix to prevent very strange bugs if someone ever appends + // further bytes to the prefix in the stem_comment slice above. + parser.head_comment = append([]byte(nil), parser.head_comment[prior_head+1:]...) + } + + } if token.typ != yaml_BLOCK_ENTRY_TOKEN && token.typ != yaml_BLOCK_END_TOKEN { parser.states = append(parser.states, yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE) return yaml_parser_parse_node(parser, event, true, false) @@ -746,9 +754,7 @@ func yaml_parser_parse_indentless_sequence_entry(parser *yaml_parser_t, event *y if token.typ == yaml_BLOCK_ENTRY_TOKEN { mark := token.end_mark - prior_head_len := len(parser.head_comment) skip_token(parser) - yaml_parser_split_stem_comment(parser, prior_head_len) token = peek_token(parser) if token == nil { return false @@ -774,32 +780,6 @@ func yaml_parser_parse_indentless_sequence_entry(parser *yaml_parser_t, event *y return true } -// Split stem comment from head comment. -// -// When a sequence or map is found under a sequence entry, the former head comment -// is assigned to the underlying sequence or map as a whole, not the individual -// sequence or map entry as would be expected otherwise. To handle this case the -// previous head comment is moved aside as the stem comment. -func yaml_parser_split_stem_comment(parser *yaml_parser_t, stem_len int) { - if stem_len == 0 { - return - } - - token := peek_token(parser) - if token.typ != yaml_BLOCK_SEQUENCE_START_TOKEN && token.typ != yaml_BLOCK_MAPPING_START_TOKEN { - return - } - - parser.stem_comment = parser.head_comment[:stem_len] - if len(parser.head_comment) == stem_len { - parser.head_comment = nil - } else { - // Copy suffix to prevent very strange bugs if someone ever appends - // further bytes to the prefix in the stem_comment slice above. - parser.head_comment = append([]byte(nil), parser.head_comment[stem_len+1:]...) - } -} - // Parse the productions: // block_mapping ::= BLOCK-MAPPING_START // ******************* diff --git a/vendor/gopkg.in/yaml.v3/scannerc.go b/vendor/gopkg.in/yaml.v3/scannerc.go index d9a539c39a..57e954ca53 100644 --- a/vendor/gopkg.in/yaml.v3/scannerc.go +++ b/vendor/gopkg.in/yaml.v3/scannerc.go @@ -749,11 +749,6 @@ func yaml_parser_fetch_next_token(parser *yaml_parser_t) (ok bool) { if !ok { return } - if len(parser.tokens) > 0 && parser.tokens[len(parser.tokens)-1].typ == yaml_BLOCK_ENTRY_TOKEN { - // Sequence indicators alone have no line comments. It becomes - // a head comment for whatever follows. - return - } if !yaml_parser_scan_line_comment(parser, comment_mark) { ok = false return @@ -2861,12 +2856,13 @@ func yaml_parser_scan_line_comment(parser *yaml_parser_t, token_mark yaml_mark_t return false } skip_line(parser) - } else if parser.mark.index >= seen { - if len(text) == 0 { - start_mark = parser.mark - } - text = read(parser, text) } else { + if parser.mark.index >= seen { + if len(text) == 0 { + start_mark = parser.mark + } + text = append(text, parser.buffer[parser.buffer_pos]) + } skip(parser) } } @@ -3003,9 +2999,10 @@ func yaml_parser_scan_comments(parser *yaml_parser_t, scan_mark yaml_mark_t) boo return false } skip_line(parser) - } else if parser.mark.index >= seen { - text = read(parser, text) } else { + if parser.mark.index >= seen { + text = append(text, parser.buffer[parser.buffer_pos]) + } skip(parser) } } diff --git a/vendor/gopkg.in/yaml.v3/yaml.go b/vendor/gopkg.in/yaml.v3/yaml.go index 56e8a84903..b5d35a50de 100644 --- a/vendor/gopkg.in/yaml.v3/yaml.go +++ b/vendor/gopkg.in/yaml.v3/yaml.go @@ -89,7 +89,7 @@ func Unmarshal(in []byte, out interface{}) (err error) { return unmarshal(in, out, false) } -// A Decoder reads and decodes YAML values from an input stream. +// A Decorder reads and decodes YAML values from an input stream. type Decoder struct { parser *parser knownFields bool @@ -194,7 +194,7 @@ func unmarshal(in []byte, out interface{}, strict bool) (err error) { // Zero valued structs will be omitted if all their public // fields are zero, unless they implement an IsZero // method (see the IsZeroer interface type), in which -// case the field will be excluded if IsZero returns true. +// case the field will be included if that method returns true. // // flow Marshal using a flow style (useful for structs, // sequences and maps). @@ -252,24 +252,6 @@ func (e *Encoder) Encode(v interface{}) (err error) { return nil } -// Encode encodes value v and stores its representation in n. -// -// See the documentation for Marshal for details about the -// conversion of Go values into YAML. -func (n *Node) Encode(v interface{}) (err error) { - defer handleErr(&err) - e := newEncoder() - defer e.destroy() - e.marshalDoc("", reflect.ValueOf(v)) - e.finish() - p := newParser(e.out) - p.textless = true - defer p.destroy() - doc := p.parse() - *n = *doc.Content[0] - return nil -} - // SetIndent changes the used indentation used when encoding. func (e *Encoder) SetIndent(spaces int) { if spaces < 0 { @@ -346,12 +328,6 @@ const ( // and maps, Node is an intermediate representation that allows detailed // control over the content being decoded or encoded. // -// It's worth noting that although Node offers access into details such as -// line numbers, colums, and comments, the content when re-encoded will not -// have its original textual representation preserved. An effort is made to -// render the data plesantly, and to preserve comments near the data they -// describe, though. -// // Values that make use of the Node type interact with the yaml package in the // same way any other type would do, by encoding and decoding yaml data // directly or indirectly into them. @@ -415,13 +391,6 @@ type Node struct { Column int } -// IsZero returns whether the node has all of its fields unset. -func (n *Node) IsZero() bool { - return n.Kind == 0 && n.Style == 0 && n.Tag == "" && n.Value == "" && n.Anchor == "" && n.Alias == nil && n.Content == nil && - n.HeadComment == "" && n.LineComment == "" && n.FootComment == "" && n.Line == 0 && n.Column == 0 -} - - // LongTag returns the long form of the tag that indicates the data type for // the node. If the Tag field isn't explicitly defined, one will be computed // based on the node properties. diff --git a/vendor/gopkg.in/yaml.v3/yamlh.go b/vendor/gopkg.in/yaml.v3/yamlh.go index 7c6d007706..2719cfbb0b 100644 --- a/vendor/gopkg.in/yaml.v3/yamlh.go +++ b/vendor/gopkg.in/yaml.v3/yamlh.go @@ -787,8 +787,6 @@ type yaml_emitter_t struct { foot_comment []byte tail_comment []byte - key_line_comment []byte - // Dumper stuff opened bool // If the stream was already opened? diff --git a/vendor/modules.txt b/vendor/modules.txt index db82d76695..bd603c06a0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -115,6 +115,7 @@ github.com/dyatlov/go-opengraph/opengraph # github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 ## explicit # github.com/fatih/color v1.9.0 +## explicit github.com/fatih/color # github.com/fortytw2/leaktest v1.3.0 ## explicit @@ -134,8 +135,6 @@ github.com/glycerine/go-unsnap-stream # github.com/go-asn1-ber/asn1-ber v1.5.1 ## explicit github.com/go-asn1-ber/asn1-ber -# github.com/go-gorp/gorp v2.2.0+incompatible -## explicit # github.com/go-sql-driver/mysql v1.5.0 ## explicit github.com/go-sql-driver/mysql @@ -272,7 +271,7 @@ github.com/mattermost/go-i18n/i18n github.com/mattermost/go-i18n/i18n/bundle github.com/mattermost/go-i18n/i18n/language github.com/mattermost/go-i18n/i18n/translation -# github.com/mattermost/gorp v2.0.1-0.20200527092429-d62b7b9cadfc+incompatible +# github.com/mattermost/gorp v1.6.2-0.20200624165429-2595d5e54111 ## explicit github.com/mattermost/gorp # github.com/mattermost/gosaml2 v0.3.2 @@ -360,10 +359,6 @@ github.com/olekukonko/tablewriter ## explicit github.com/olivere/elastic/config github.com/olivere/elastic/uritemplates -# github.com/onsi/ginkgo v1.12.0 -## explicit -# github.com/onsi/gomega v1.9.0 -## explicit # github.com/oov/psd v0.0.0-20200705094106-99303fb2511f ## explicit github.com/oov/psd @@ -386,8 +381,6 @@ github.com/philhofer/fwd github.com/pkg/errors # github.com/pmezard/go-difflib v1.0.0 github.com/pmezard/go-difflib/difflib -# github.com/poy/onpar v1.0.0 -## explicit # github.com/prometheus/client_golang v1.7.1 ## explicit github.com/prometheus/client_golang/prometheus @@ -471,14 +464,7 @@ github.com/throttled/throttled github.com/throttled/throttled/store/memstore # github.com/tinylib/msgp v1.1.2 ## explicit -github.com/tinylib/msgp -github.com/tinylib/msgp/gen github.com/tinylib/msgp/msgp -github.com/tinylib/msgp/parse -github.com/tinylib/msgp/printer -# github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31 -## explicit -github.com/ttacon/chalk # github.com/tylerb/graceful v1.2.15 ## explicit github.com/tylerb/graceful @@ -529,10 +515,7 @@ github.com/willf/bitset # github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c ## explicit github.com/xtgo/uuid -# github.com/ziutek/mymysql v1.5.4 -## explicit -# go.etcd.io/bbolt v1.3.5 -## explicit +# go.etcd.io/bbolt v1.3.4 go.etcd.io/bbolt # go.uber.org/atomic v1.6.0 go.uber.org/atomic @@ -762,8 +745,7 @@ gopkg.in/olivere/elastic.v6 # gopkg.in/yaml.v2 v2.3.0 ## explicit gopkg.in/yaml.v2 -# gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 -## explicit +# gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c gopkg.in/yaml.v3 # honnef.co/go/tools v0.0.1-2020.1.3 ## explicit