commit aad9ec9ca157f798a33a8539eff8bca9aae37fa5 Author: Aleksander Cynarski Date: Sat Nov 2 13:54:10 2019 +0100 gin funn and testing diff --git a/REVISION b/REVISION new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/REVISION @@ -0,0 +1 @@ +1.0.0 diff --git a/conf/app.ini b/conf/app.ini new file mode 100644 index 0000000..05ae27c --- /dev/null +++ b/conf/app.ini @@ -0,0 +1,25 @@ +[app] +PageSize = 10 +JwtSecret = 233 +PrefixUrl = http://127.0.0.1:8000 +RuntimeRootPath = runtime/ +LogSavePath = logs/ +LogSaveName = log +LogFileExt = log +TimeFormat = 20060102 + +[server] +#debug or release +RunMode = debug +HttpPort = 8000 +ReadTimeout = 60 +WriteTimeout = 60 + +[database] +Type = mysql +User = root +Password = dupa.8 + +Host = db-gintest.service.dev.consul:3306 +Name = gintest +TablePrefix = test_ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8d44f7c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,28 @@ +version: '3.1' +services: + mariadb: + image: 'mariadb:10.1' + container_name: gintest-mariadb + hostname: gintest-mariadb + working_dir: /application + environment: + - MYSQL_ROOT_PASSWORD=dupa.8 + - MYSQL_DATABASE=gintest + - MYSQL_USER=gintest + - SERVICE_NAME=db-gintest + - SERVICE_TAG=db + + phpmyadmin: + container_name: gintest-phpadmin + image: phpmyadmin/phpmyadmin + hostname: gintest-phpmyadmin + environment: + - PMA_HOST=gintest-mariadb + - SERVICE_80_NAME=myadmin-gintest + - SERVICE_9000_NAME=myadmin-gintest + + redis: + image: redis + container_name: gintest-cache + expose: + - 6379 \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..e941b4d --- /dev/null +++ b/go.mod @@ -0,0 +1,16 @@ +module gin-server + +go 1.13 + +require ( + github.com/appleboy/gin-revision-middleware v0.0.0-20160722161421-cc548e45b51a + github.com/astaxie/beego v1.12.0 + github.com/dgrijalva/jwt-go v3.2.0+incompatible + github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6 // indirect + github.com/gin-gonic/gin v1.4.0 + github.com/go-ini/ini v1.49.0 + github.com/jinzhu/gorm v1.9.11 + github.com/smartystreets/goconvey v1.6.4 // indirect + github.com/swaggo/gin-swagger v1.2.0 + gopkg.in/ini.v1 v1.49.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..4ea5149 --- /dev/null +++ b/go.sum @@ -0,0 +1,267 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.37.4 h1:glPeL3BQJsbF6aIIYfZizMwc5LTYz250bDMjttbBGAU= +cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= +github.com/OwnLocal/goes v1.0.0/go.mod h1:8rIFjBGTue3lCU0wplczcUgt9Gxgrkkrw7etMIcn8TM= +github.com/PuerkitoBio/purell v1.1.0 h1:rmGxhojJlM0tuKtfdvliR84CFHljx9ag64t2xmVkjK4= +github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +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/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/appleboy/gin-revision-middleware v0.0.0-20160722161421-cc548e45b51a h1:MwEWQAUP9dL1nGiIhyhExQTkDUGyALwhuybwSN4CRT8= +github.com/appleboy/gin-revision-middleware v0.0.0-20160722161421-cc548e45b51a/go.mod h1:okrDeI1aJ7Mr80J8rWjCK+yZjiKGvOl4H+kGMMiKSlA= +github.com/astaxie/beego v1.12.0 h1:MRhVoeeye5N+Flul5PoVfD9CslfdoH+xqC/xvSQ5u2Y= +github.com/astaxie/beego v1.12.0/go.mod h1:fysx+LZNZKnvh4GED/xND7jWtjCR6HzydR2Hh2Im57o= +github.com/beego/goyaml2 v0.0.0-20130207012346-5545475820dd/go.mod h1:1b+Y/CofkYwXMUU0OhQqGvsY2Bvgr4j6jfT699wyZKQ= +github.com/beego/x2j v0.0.0-20131220205130-a0352aadc542/go.mod h1:kSeGC/p1AbBiEp5kat81+DSQrZenVBZXklMLaELspWU= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60= +github.com/casbin/casbin v1.7.0/go.mod h1:c67qKN6Oum3UF5Q1+BByfFxkwKvhwW57ITjqwtzR1KE= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80= +github.com/couchbase/go-couchbase v0.0.0-20181122212707-3e9b6e1258bb/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U= +github.com/couchbase/gomemcached v0.0.0-20181122193126-5125a94a666c/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c= +github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs= +github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/denisenkom/go-mssqldb v0.0.0-20190515213511-eb9f6a1743f3 h1:tkum0XDgfR0jcVVXuTsYv/erY2NnEDqwRojbxR1rBYA= +github.com/denisenkom/go-mssqldb v0.0.0-20190515213511-eb9f6a1743f3/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM= +github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= +github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= +github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= +github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y= +github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6 h1:6VSn3hB5U5GeA6kQw4TwWIWbOhtvR2hmbBJnTOtqTWc= +github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6/go.mod h1:YxOVT5+yHzKvwhsiSIWmbAYM3Dr9AEEbER2dVayfBkg= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gin-contrib/gzip v0.0.1 h1:ezvKOL6jH+jlzdHNE4h9h8q8uMpDQjyl0NN0Jd7jozc= +github.com/gin-contrib/gzip v0.0.1/go.mod h1:fGBJBCdt6qCZuCAOwWuFhBB4OOq9EFqlo5dEaFhhu5w= +github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= +github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3 h1:t8FVkw33L+wilf2QiWkw0UV77qRpcH/JHPKGpKa2E8g= +github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= +github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.3.0/go.mod h1:7cKuhb5qV2ggCFctp2fJQ+ErvciLZrIeoOSOm6mUr7Y= +github.com/gin-gonic/gin v1.4.0 h1:3tMoCCfM7ppqsR0ptz/wi1impNpT7/9wQtMZ8lr1mCQ= +github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM= +github.com/go-ini/ini v1.49.0 h1:ymWFBUkwN3JFPjvjcJJ5TSTwh84M66QrH+8vOytLgRY= +github.com/go-ini/ini v1.49.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-openapi/jsonpointer v0.17.0 h1:nH6xp8XdXHx8dqveo0ZuJBluCO2qGrPbDNZ0dwoRHP0= +github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= +github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= +github.com/go-openapi/jsonreference v0.19.0 h1:BqWKpV1dFd+AuiKlgtddwVIFQsuMpxfBDBHGfM2yNpk= +github.com/go-openapi/jsonreference v0.19.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= +github.com/go-openapi/spec v0.19.0 h1:A4SZ6IWh3lnjH0rG0Z5lkxazMGBECtrZcbyYQi+64k4= +github.com/go-openapi/spec v0.19.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= +github.com/go-openapi/swag v0.17.0 h1:iqrgMg7Q7SvtbWLlltPrkMs0UBJI6oTSs79JFRUi880= +github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= +github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= +github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA= +github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/jinzhu/gorm v1.9.11 h1:gaHGvE+UnWGlbWG4Y3FUwY1EcZ5n6S9WtqBA/uySMLE= +github.com/jinzhu/gorm v1.9.11/go.mod h1:bu/pK8szGZ2puuErfU0RwyeNdsf3e6nCX/noXaVxkfw= +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.0.1 h1:HjfetcXq097iXP0uoPCdnM4Efp5/9MsM0/M+XOTeR3M= +github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4= +github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3bUBu+FXuk2pFbkN6tcwi/pjyaDic= +github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.7 h1:UvyT9uN+3r7yLEYSlJsbQGdsaB/a0DlgWP3pql6iwOc= +github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= +github.com/mattn/go-sqlite3 v1.11.0 h1:LDdKkqtYlom37fkvqs8rMPFKAMe8+SgjbwZ6ex1/A/Q= +github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= +github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +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/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw= +github.com/siddontang/ledisdb v0.0.0-20181029004158-becf5f38d373/go.mod h1:mF1DpOSOUiJRMR+FDqaqu3EBqrybQtrDDszLUZ6oxPg= +github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/swaggo/gin-swagger v1.2.0 h1:YskZXEiv51fjOMTsXrOetAjrMDfFaXD79PEoQBOe2W0= +github.com/swaggo/gin-swagger v1.2.0/go.mod h1:qlH2+W7zXGZkczuL+r2nEBR2JTT+/lX05Nn6vPhc7OI= +github.com/swaggo/swag v1.5.1 h1:2Agm8I4K5qb00620mHq0VJ05/KT4FtmALPIcQR9lEZM= +github.com/swaggo/swag v1.5.1/go.mod h1:1Bl9F/ZBpVWh22nY0zmYyASPO1lI/zIwRDrpZU+tv8Y= +github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0= +github.com/ugorji/go v1.1.4 h1:j4s+tAvLfL3bZyefP2SEWmhBzmuIlH/eqNuPdFPgngw= +github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= +github.com/ugorji/go v1.1.5-pre h1:jyJKFOSEbdOc2HODrf2qcCkYOdq7zzXqA9bhW5oV4fM= +github.com/ugorji/go v1.1.5-pre/go.mod h1:FwP/aQVg39TXzItUBMwnWp9T9gPQnXw4Poh4/oBQZ/0= +github.com/ugorji/go/codec v0.0.0-20181022190402-e5e69e061d4f/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/ugorji/go/codec v1.1.5-pre h1:5YV9PsFAN+ndcCtTM7s60no7nY7eTG3LPtxhSwuxzCs= +github.com/ugorji/go/codec v1.1.5-pre/go.mod h1:tULtS6Gy1AE1yCENaw4Vb//HLH5njI2tfCQDUqRd8fI= +github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc= +go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181127143415-eb0de9b17e85/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c h1:Vj5n4GlwjmQteupaxJ9+0FNOmBrHfq7vN4btdGoDZgI= +golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190611141213-3f473d35a33a h1:+KkCgOMgnKSgenxTBoiwkMqTiouMIy/3o8RLdmSbGoY= +golang.org/x/net v0.0.0-20190611141213-3f473d35a33a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/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-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae h1:xiXzMMEQdQcric9hXtr1QU98MHunKK7OTtsoU6bYWs4= +golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/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/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190606050223-4d9ae51c2468/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b h1:/mJ+GKieZA6hFDQGdWZrjj4AXPl5ylY+5HusG80roy0= +golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= +gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= +gopkg.in/go-playground/validator.v8 v8.18.2 h1:lFB4DoMU6B626w8ny76MV7VX6W2VHct2GVOI3xgiMrQ= +gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= +gopkg.in/ini.v1 v1.49.0 h1:MW0aLMiezbm/Ray0gJJ+nQFE2uOC9EpK2p5zPN3NqpM= +gopkg.in/ini.v1 v1.49.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/lib/app/form.go b/lib/app/form.go new file mode 100644 index 0000000..2583fc0 --- /dev/null +++ b/lib/app/form.go @@ -0,0 +1,29 @@ +package app + +import ( + "github.com/gin-gonic/gin" + "gin-server/lib/messages" + "github.com/astaxie/beego/validation" + "net/http" +) + +// BindAndValid binds and validates data +func BindAndValid(c *gin.Context, form interface{}) (int, int) { + err := c.Bind(form) + if err != nil { + return http.StatusBadRequest, messages.INVALID_PARAMS + } + + valid := validation.Validation{} + check, err := valid.Valid(form) + if err != nil { + return http.StatusInternalServerError, messages.ERROR + } + if !check { + MarkErrors(valid.Errors) + return http.StatusBadRequest, messages.INVALID_PARAMS + } + + return http.StatusOK, messages.SUCCESS +} + diff --git a/lib/app/request.go b/lib/app/request.go new file mode 100644 index 0000000..7f8b783 --- /dev/null +++ b/lib/app/request.go @@ -0,0 +1,15 @@ +package app + +import ( + "github.com/astaxie/beego/validation" + "gin-server/lib/logging" +) + +// MarkErrors logs error logs +func MarkErrors(errors []*validation.Error) { + for _, err := range errors { + logging.Info(err.Key, err.Message) + } + + return +} diff --git a/lib/app/response.go b/lib/app/response.go new file mode 100644 index 0000000..b00d1f6 --- /dev/null +++ b/lib/app/response.go @@ -0,0 +1,26 @@ +package app + +import ( + "github.com/gin-gonic/gin" + "gin-server/lib/messages" +) + +type Gin struct { + C *gin.Context +} + +type Response struct { + Code int `json:"code"` + Msg string `json:"msg"` + Data interface{} `json:"data"` +} + +// Response setting gin.JSON +func (g *Gin) Response(httpCode, errCode int, data interface{}) { + g.C.JSON(httpCode, Response{ + Code: errCode, + Msg: messages.GetMsg(errCode), + Data: data, + }) + return +} diff --git a/lib/file/file.go b/lib/file/file.go new file mode 100644 index 0000000..073961a --- /dev/null +++ b/lib/file/file.go @@ -0,0 +1,93 @@ +package file + + +import ( + "fmt" + "io/ioutil" + "mime/multipart" + "os" + "path" +) + +// GetSize get the file size +func GetSize(f multipart.File) (int, error) { + content, err := ioutil.ReadAll(f) + + return len(content), err +} + +// GetExt get the file ext +func GetExt(fileName string) string { + return path.Ext(fileName) +} + +// CheckNotExist check if the file exists +func CheckNotExist(src string) bool { + _, err := os.Stat(src) + + return os.IsNotExist(err) +} + +// CheckPermission check if the file has permission +func CheckPermission(src string) bool { + _, err := os.Stat(src) + + return os.IsPermission(err) +} + +// IsNotExistMkDir create a directory if it does not exist +func IsNotExistMkDir(src string) error { + if notExist := CheckNotExist(src); notExist == true { + if err := MkDir(src); err != nil { + return err + } + } + + return nil +} + +// MkDir create a directory +func MkDir(src string) error { + err := os.MkdirAll(src, os.ModePerm) + if err != nil { + return err + } + + return nil +} + +// Open a file according to a specific mode +func Open(name string, flag int, perm os.FileMode) (*os.File, error) { + f, err := os.OpenFile(name, flag, perm) + if err != nil { + return nil, err + } + + return f, nil +} + +// MustOpen maximize trying to open the file +func MustOpen(fileName, filePath string) (*os.File, error) { + dir, err := os.Getwd() + if err != nil { + return nil, fmt.Errorf("os.Getwd err: %v", err) + } + + src := dir + "/" + filePath + perm := CheckPermission(src) + if perm == true { + return nil, fmt.Errorf("file.CheckPermission Permission denied src: %s", src) + } + + err = IsNotExistMkDir(src) + if err != nil { + return nil, fmt.Errorf("file.IsNotExistMkDir src: %s, err: %v", src, err) + } + + f, err := Open(src+fileName, os.O_APPEND|os.O_CREATE|os.O_RDWR, 0644) + if err != nil { + return nil, fmt.Errorf("Fail to OpenFile :%v", err) + } + + return f, nil +} diff --git a/lib/logging/file.go b/lib/logging/file.go new file mode 100644 index 0000000..284b32b --- /dev/null +++ b/lib/logging/file.go @@ -0,0 +1,24 @@ +package logging + +import ( + "fmt" + "time" + + "gin-server/lib/setting" +) + +// getLogFilePath get the log file save path +func getLogFilePath() string { + return fmt.Sprintf("%s%s", setting.AppSetting.RuntimeRootPath, setting.AppSetting.LogSavePath) +} + +// getLogFileName get the save name of the log file +func getLogFileName() string { + return fmt.Sprintf("%s%s.%s", + setting.AppSetting.LogSaveName, + time.Now().Format(setting.AppSetting.TimeFormat), + setting.AppSetting.LogFileExt, + ) +} + + diff --git a/lib/logging/log.go b/lib/logging/log.go new file mode 100644 index 0000000..1c65799 --- /dev/null +++ b/lib/logging/log.go @@ -0,0 +1,87 @@ +package logging + + +import ( + "fmt" + "gin-server/lib/file" + "log" + "os" + "path/filepath" + "runtime" +) + +type Level int + +var ( + F *os.File + + DefaultPrefix = "" + DefaultCallerDepth = 2 + + logger *log.Logger + logPrefix = "" + levelFlags = []string{"DEBUG", "INFO", "WARN", "ERROR", "FATAL"} +) + +const ( + DEBUG Level = iota + INFO + WARNING + ERROR + FATAL +) + +// Setup initialize the log instance +func Setup() { + var err error + filePath := getLogFilePath() + fileName := getLogFileName() + F, err = file.MustOpen(fileName, filePath) + if err != nil { + log.Fatalf("logging.Setup err: %v", err) + } + + logger = log.New(F, DefaultPrefix, log.LstdFlags) +} + +// Debug output logs at debug level +func Debug(v ...interface{}) { + setPrefix(DEBUG) + logger.Println(v) +} + +// Info output logs at info level +func Info(v ...interface{}) { + setPrefix(INFO) + logger.Println(v) +} + +// Warn output logs at warn level +func Warn(v ...interface{}) { + setPrefix(WARNING) + logger.Println(v) +} + +// Error output logs at error level +func Error(v ...interface{}) { + setPrefix(ERROR) + logger.Println(v) +} + +// Fatal output logs at fatal level +func Fatal(v ...interface{}) { + setPrefix(FATAL) + logger.Fatalln(v) +} + +// setPrefix set the prefix of the log output +func setPrefix(level Level) { + _, file, line, ok := runtime.Caller(DefaultCallerDepth) + if ok { + logPrefix = fmt.Sprintf("[%s][%s:%d]", levelFlags[level], filepath.Base(file), line) + } else { + logPrefix = fmt.Sprintf("[%s]", levelFlags[level]) + } + + logger.SetPrefix(logPrefix) +} diff --git a/lib/messages/code.go b/lib/messages/code.go new file mode 100644 index 0000000..3d11cf4 --- /dev/null +++ b/lib/messages/code.go @@ -0,0 +1,11 @@ +package messages + +const ( + SUCCESS = 200 + ERROR = 500 + INVALID_PARAMS = 400 + ERROR_AUTH_CHECK_TOKEN_FAIL = 20001 + ERROR_AUTH_CHECK_TOKEN_TIMEOUT = 20002 + ERROR_AUTH_TOKEN = 20003 + ERROR_AUTH = 20004 +) diff --git a/lib/messages/messages.go b/lib/messages/messages.go new file mode 100644 index 0000000..2b67a1f --- /dev/null +++ b/lib/messages/messages.go @@ -0,0 +1,22 @@ +package messages + +var MsgFlags = map[int]string{ + SUCCESS: "ok", + ERROR: "fail", + INVALID_PARAMS: "Invalid parameters", + ERROR_AUTH_CHECK_TOKEN_FAIL: "Token fail", + ERROR_AUTH_CHECK_TOKEN_TIMEOUT: "Token timeout", + ERROR_AUTH_TOKEN: "Bad token", + ERROR_AUTH: "Token error", +} + +// GetMsg get error information based on Code +func GetMsg(code int) string { + msg, ok := MsgFlags[code] + if ok { + return msg + } + + return MsgFlags[ERROR] +} + diff --git a/lib/setting/setting.go b/lib/setting/setting.go new file mode 100644 index 0000000..8df2fcd --- /dev/null +++ b/lib/setting/setting.go @@ -0,0 +1,81 @@ +package setting + +import ( + "log" + "time" + + "github.com/go-ini/ini" +) + +type App struct { + JwtSecret string + PageSize int + PrefixUrl string + + RuntimeRootPath string + + LogSavePath string + LogSaveName string + LogFileExt string + TimeFormat string +} + +var AppSetting = &App{} + +type Server struct { + RunMode string + HttpPort int + ReadTimeout time.Duration + WriteTimeout time.Duration +} + +var ServerSetting = &Server{} + +type Database struct { + Type string + User string + Password string + Host string + Name string + TablePrefix string +} + +var DatabaseSetting = &Database{} + +type Redis struct { + Host string + Password string + MaxIdle int + MaxActive int + IdleTimeout time.Duration +} + +var RedisSetting = &Redis{} + +var cfg *ini.File + +// Setup initialize the configuration instance +func Setup() { + var err error + cfg, err = ini.Load("conf/app.ini") + if err != nil { + log.Fatalf("setting.Setup, fail to parse 'conf/app.ini': %v", err) + } + + mapTo("app", AppSetting) + mapTo("server", ServerSetting) + mapTo("database", DatabaseSetting) + mapTo("redis", RedisSetting) + + ServerSetting.ReadTimeout = ServerSetting.ReadTimeout * time.Second + ServerSetting.WriteTimeout = ServerSetting.WriteTimeout * time.Second + RedisSetting.IdleTimeout = RedisSetting.IdleTimeout * time.Second +} + +// mapTo map section +func mapTo(section string, v interface{}) { + err := cfg.Section(section).MapTo(v) + if err != nil { + log.Fatalf("Cfg.MapTo %s err: %v", section, err) + } +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..f28011b --- /dev/null +++ b/main.go @@ -0,0 +1,57 @@ +package main + +import ( + "fmt" + "gin-server/models" + "gin-server/routers" + "log" + "net/http" + + "gin-server/lib/setting" + "github.com/gin-gonic/gin" +) + +func init() { + setting.Setup() + models.Setup() +} + +// @title Gin server example +// @version 1.0 +// @description An example of gin server +func main() { + gin.SetMode(setting.ServerSetting.RunMode) + + routersInit := routers.InitRouter() + readTimeout := setting.ServerSetting.ReadTimeout + writeTimeout := setting.ServerSetting.WriteTimeout + + endPoint := fmt.Sprintf(":%d", setting.ServerSetting.HttpPort) + maxHeaderBytes := 1 << 20 + + server := &http.Server{ + Addr: endPoint, + Handler: routersInit, + ReadTimeout: readTimeout, + WriteTimeout: writeTimeout, + MaxHeaderBytes: maxHeaderBytes, + } + + log.Printf("[info] start http server listening %s", endPoint) + + server.ListenAndServe() + + // If you want Graceful Restart, you need a Unix system and download github.com/fvbock/endless + //endless.DefaultReadTimeOut = readTimeout + //endless.DefaultWriteTimeOut = writeTimeout + //endless.DefaultMaxHeaderBytes = maxHeaderBytes + //server := endless.NewServer(endPoint, routersInit) + //server.BeforeBegin = func(add string) { + // log.Printf("Actual pid is %d", syscall.Getpid()) + //} + // + //err := server.ListenAndServe() + //if err != nil { + // log.Printf("Server err: %v", err) + //} +} diff --git a/models/auth.go b/models/auth.go new file mode 100644 index 0000000..683781b --- /dev/null +++ b/models/auth.go @@ -0,0 +1,25 @@ +package models + +import "github.com/jinzhu/gorm" + +type Auth struct { + ID int `gorm:"primary_key" json:"id"` + Username string `json:"username"` + Password string `json:"password"` +} + +// CheckAuth checks if authentication information exists +func CheckAuth(username, password string) (bool, error) { + var auth Auth + err := db.Select("id").Where(Auth{Username: username, Password: password}).First(&auth).Error + if err != nil && err != gorm.ErrRecordNotFound { + return false, err + } + + if auth.ID > 0 { + return true, nil + } + + return false, nil +} + diff --git a/models/models.go b/models/models.go new file mode 100644 index 0000000..e894eaa --- /dev/null +++ b/models/models.go @@ -0,0 +1,115 @@ +package models + +import ( + "fmt" + "log" + + "github.com/jinzhu/gorm" + _ "github.com/jinzhu/gorm/dialects/mysql" + + "gin-server/lib/setting" + "time" +) + +var db *gorm.DB + +type Model struct { + ID int `gorm:"primary_key" json:"id"` + CreatedOn int `json:"created_on"` + ModifiedOn int `json:"modified_on"` + DeletedOn int `json:"deleted_on"` +} + +// Setup initializes the database instance +func Setup() { + var err error + db, err = gorm.Open(setting.DatabaseSetting.Type, fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8&parseTime=True&loc=Local", + setting.DatabaseSetting.User, + setting.DatabaseSetting.Password, + setting.DatabaseSetting.Host, + setting.DatabaseSetting.Name)) + + if err != nil { + log.Fatalf("models.Setup err: %v", err) + } + + gorm.DefaultTableNameHandler = func(db *gorm.DB, defaultTableName string) string { + return setting.DatabaseSetting.TablePrefix + defaultTableName + } + + db.SingularTable(true) + db.Callback().Create().Replace("gorm:update_time_stamp", updateTimeStampForCreateCallback) + db.Callback().Update().Replace("gorm:update_time_stamp", updateTimeStampForUpdateCallback) + db.Callback().Delete().Replace("gorm:delete", deleteCallback) + db.DB().SetMaxIdleConns(10) + db.DB().SetMaxOpenConns(100) + db.AutoMigrate(&Auth{}) +} + +// CloseDB closes database connection (unnecessary) +func CloseDB() { + defer db.Close() +} + +// updateTimeStampForCreateCallback will set `CreatedOn`, `ModifiedOn` when creating +func updateTimeStampForCreateCallback(scope *gorm.Scope) { + if !scope.HasError() { + nowTime := time.Now().Unix() + if createTimeField, ok := scope.FieldByName("CreatedOn"); ok { + if createTimeField.IsBlank { + createTimeField.Set(nowTime) + } + } + + if modifyTimeField, ok := scope.FieldByName("ModifiedOn"); ok { + if modifyTimeField.IsBlank { + modifyTimeField.Set(nowTime) + } + } + } +} + +// updateTimeStampForUpdateCallback will set `ModifiedOn` when updating +func updateTimeStampForUpdateCallback(scope *gorm.Scope) { + if _, ok := scope.Get("gorm:update_column"); !ok { + scope.SetColumn("ModifiedOn", time.Now().Unix()) + } +} + +// deleteCallback will set `DeletedOn` where deleting +func deleteCallback(scope *gorm.Scope) { + if !scope.HasError() { + var extraOption string + if str, ok := scope.Get("gorm:delete_option"); ok { + extraOption = fmt.Sprint(str) + } + + deletedOnField, hasDeletedOnField := scope.FieldByName("DeletedOn") + + if !scope.Search.Unscoped && hasDeletedOnField { + scope.Raw(fmt.Sprintf( + "UPDATE %v SET %v=%v%v%v", + scope.QuotedTableName(), + scope.Quote(deletedOnField.DBName), + scope.AddToVars(time.Now().Unix()), + addExtraSpaceIfExist(scope.CombinedConditionSql()), + addExtraSpaceIfExist(extraOption), + )).Exec() + } else { + scope.Raw(fmt.Sprintf( + "DELETE FROM %v%v%v", + scope.QuotedTableName(), + addExtraSpaceIfExist(scope.CombinedConditionSql()), + addExtraSpaceIfExist(extraOption), + )).Exec() + } + } +} + +// addExtraSpaceIfExist adds a separator +func addExtraSpaceIfExist(str string) string { + if str != "" { + return " " + str + } + return "" +} diff --git a/routers/router.go b/routers/router.go new file mode 100644 index 0000000..2945cc9 --- /dev/null +++ b/routers/router.go @@ -0,0 +1,22 @@ +package routers + +import ( + "gin-server/security/controller" + "github.com/appleboy/gin-revision-middleware" + "github.com/gin-gonic/gin" + "github.com/swaggo/gin-swagger" + "github.com/swaggo/gin-swagger/swaggerFiles" +) + +// InitRouter initialize routing information +func InitRouter() *gin.Engine { + r := gin.New() + r.Use(gin.Logger()) + r.Use(gin.Recovery()) + r.Use(revision.Middleware()) + + r.GET("/auth", controller.GetAuth) + r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) + + return r +} diff --git a/security/controller/auth.go b/security/controller/auth.go new file mode 100644 index 0000000..2d3feff --- /dev/null +++ b/security/controller/auth.go @@ -0,0 +1,62 @@ +package controller + +import ( + "gin-server/lib/messages" + "gin-server/security" + "github.com/astaxie/beego/validation" + "github.com/gin-gonic/gin" + "gin-server/security/service" + "gin-server/lib/app" + "net/http" +) + +type auth struct { + Username string `valid:"Required; MaxSize(50)"` + Password string `valid:"Required; MaxSize(50)"` +} + +// @Summary Get Auth +// @Produce json +// @Param username query string true "userName" +// @Param password query string true "password" +// @Success 200 {object} app.Response +// @Failure 500 {object} app.Response +// @Router /auth [get] +func GetAuth(c *gin.Context) { + appG := app.Gin{C: c} + valid := validation.Validation{} + + username := c.Query("username") + password := c.Query("password") + + a := auth{Username: username, Password: password} + ok, _ := valid.Valid(&a) + + if !ok { + app.MarkErrors(valid.Errors) + appG.Response(http.StatusBadRequest, messages.INVALID_PARAMS, nil) + return + } + + authService := service.Auth{Username: username, Password: password} + isExist, err := authService.Check() + if err != nil { + appG.Response(http.StatusInternalServerError, messages.ERROR_AUTH_CHECK_TOKEN_FAIL, nil) + return + } + + if !isExist { + appG.Response(http.StatusUnauthorized, messages.ERROR_AUTH, nil) + return + } + + token, err := security.GenerateToken(username, password) + if err != nil { + appG.Response(http.StatusInternalServerError, messages.ERROR_AUTH_TOKEN, nil) + return + } + + appG.Response(http.StatusOK, messages.SUCCESS, map[string]string{ + "token": token, + }) +} diff --git a/security/jwt.go b/security/jwt.go new file mode 100644 index 0000000..79ff9fc --- /dev/null +++ b/security/jwt.go @@ -0,0 +1,61 @@ +package security + +import ( + "crypto/md5" + "encoding/hex" + "time" + + "github.com/dgrijalva/jwt-go" +) + +var jwtSecret []byte + +type Claims struct { + Username string `json:"username"` + Password string `json:"password"` + jwt.StandardClaims +} + +// EncodeMD5 md5 encryption +func EncodeMD5(value string) string { + m := md5.New() + m.Write([]byte(value)) + + return hex.EncodeToString(m.Sum(nil)) +} + +// GenerateToken generate tokens used for auth +func GenerateToken(username, password string) (string, error) { + nowTime := time.Now() + expireTime := nowTime.Add(3 * time.Hour) + + claims := Claims{ + EncodeMD5(username), + EncodeMD5(password), + jwt.StandardClaims{ + ExpiresAt: expireTime.Unix(), + Issuer: "gin-server", + }, + } + + tokenClaims := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) + token, err := tokenClaims.SignedString(jwtSecret) + + return token, err +} + +// ParseToken parsing token +func ParseToken(token string) (*Claims, error) { + tokenClaims, err := jwt.ParseWithClaims(token, &Claims{}, func(token *jwt.Token) (interface{}, error) { + return jwtSecret, nil + }) + + if tokenClaims != nil { + if claims, ok := tokenClaims.Claims.(*Claims); ok && tokenClaims.Valid { + return claims, nil + } + } + + return nil, err +} + diff --git a/security/middleware/jwt/jwt.go b/security/middleware/jwt/jwt.go new file mode 100644 index 0000000..04dcdd0 --- /dev/null +++ b/security/middleware/jwt/jwt.go @@ -0,0 +1,46 @@ +package jwt + +import ( + "github.com/dgrijalva/jwt-go" + "github.com/gin-gonic/gin" + "gin-server/lib/messages" + "gin-server/security" + "net/http" +) + +// JWT is jwt middleware +func JWT() gin.HandlerFunc { + return func(c *gin.Context) { + var code int + var data interface{} + + code = messages.SUCCESS + token := c.Query("token") + if token == "" { + code = messages.INVALID_PARAMS + } else { + _, err := security.ParseToken(token) + if err != nil { + switch err.(*jwt.ValidationError).Errors { + case jwt.ValidationErrorExpired: + code = messages.ERROR_AUTH_CHECK_TOKEN_TIMEOUT + default: + code = messages.ERROR_AUTH_CHECK_TOKEN_FAIL + } + } + } + + if code != messages.SUCCESS { + c.JSON(http.StatusUnauthorized, gin.H{ + "code": code, + "msg": messages.GetMsg(code), + "data": data, + }) + + c.Abort() + return + } + + c.Next() + } +} diff --git a/security/service/auth_service.go b/security/service/auth_service.go new file mode 100644 index 0000000..f7c5d5e --- /dev/null +++ b/security/service/auth_service.go @@ -0,0 +1,12 @@ +package service + +import "gin-server/models" + +type Auth struct { + Username string + Password string +} + +func (a *Auth) Check() (bool, error) { + return models.CheckAuth(a.Username, a.Password) +}