summaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src
diff options
context:
space:
mode:
Diffstat (limited to 'Godeps/_workspace/src')
-rw-r--r--Godeps/_workspace/src/github.com/NYTimes/gziphandler/LICENSE.md13
-rw-r--r--Godeps/_workspace/src/github.com/NYTimes/gziphandler/README.md52
-rw-r--r--Godeps/_workspace/src/github.com/NYTimes/gziphandler/gzip.go140
-rw-r--r--Godeps/_workspace/src/github.com/alecthomas/log4go/.gitignore2
-rw-r--r--Godeps/_workspace/src/github.com/alecthomas/log4go/LICENSE13
-rw-r--r--Godeps/_workspace/src/github.com/alecthomas/log4go/README12
-rw-r--r--Godeps/_workspace/src/github.com/alecthomas/log4go/config.go288
-rw-r--r--Godeps/_workspace/src/github.com/alecthomas/log4go/examples/ConsoleLogWriter_Manual.go14
-rw-r--r--Godeps/_workspace/src/github.com/alecthomas/log4go/examples/FileLogWriter_Manual.go57
-rw-r--r--Godeps/_workspace/src/github.com/alecthomas/log4go/examples/SimpleNetLogServer.go42
-rw-r--r--Godeps/_workspace/src/github.com/alecthomas/log4go/examples/SocketLogWriter_Manual.go18
-rw-r--r--Godeps/_workspace/src/github.com/alecthomas/log4go/examples/XMLConfigurationExample.go13
-rw-r--r--Godeps/_workspace/src/github.com/alecthomas/log4go/examples/example.xml47
-rw-r--r--Godeps/_workspace/src/github.com/alecthomas/log4go/filelog.go264
-rw-r--r--Godeps/_workspace/src/github.com/alecthomas/log4go/log4go.go484
-rw-r--r--Godeps/_workspace/src/github.com/alecthomas/log4go/pattlog.go126
-rw-r--r--Godeps/_workspace/src/github.com/alecthomas/log4go/socklog.go57
-rw-r--r--Godeps/_workspace/src/github.com/alecthomas/log4go/termlog.go49
-rw-r--r--Godeps/_workspace/src/github.com/alecthomas/log4go/wrapper.go278
-rw-r--r--Godeps/_workspace/src/github.com/braintree/manners/LICENSE19
-rw-r--r--Godeps/_workspace/src/github.com/braintree/manners/README.md36
-rw-r--r--Godeps/_workspace/src/github.com/braintree/manners/interfaces.go7
-rw-r--r--Godeps/_workspace/src/github.com/braintree/manners/server.go272
-rw-r--r--Godeps/_workspace/src/github.com/braintree/manners/static.go35
-rw-r--r--Godeps/_workspace/src/github.com/braintree/manners/test_helpers/certs.go29
-rw-r--r--Godeps/_workspace/src/github.com/braintree/manners/test_helpers/conn.go13
-rw-r--r--Godeps/_workspace/src/github.com/braintree/manners/test_helpers/listener.go34
-rw-r--r--Godeps/_workspace/src/github.com/braintree/manners/test_helpers/temp_file.go27
-rw-r--r--Godeps/_workspace/src/github.com/braintree/manners/test_helpers/wait_group.go33
-rw-r--r--Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/.travis.yml11
-rw-r--r--Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/LICENSE201
-rw-r--r--Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/README.md44
-rw-r--r--Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/ci/scripts/windows-64-test.bat5
-rw-r--r--Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/jibber_jabber.go22
-rw-r--r--Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/jibber_jabber_unix.go57
-rw-r--r--Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/jibber_jabber_windows.go114
-rw-r--r--Godeps/_workspace/src/github.com/dgryski/dgoogauth/.travis.yml1
-rw-r--r--Godeps/_workspace/src/github.com/dgryski/dgoogauth/README.md15
-rw-r--r--Godeps/_workspace/src/github.com/dgryski/dgoogauth/googauth.go199
-rw-r--r--Godeps/_workspace/src/github.com/dgryski/dgoogauth/googauth_test.go251
-rw-r--r--Godeps/_workspace/src/github.com/disintegration/imaging/LICENSE21
-rw-r--r--Godeps/_workspace/src/github.com/disintegration/imaging/README.md194
-rw-r--r--Godeps/_workspace/src/github.com/disintegration/imaging/adjust.go200
-rw-r--r--Godeps/_workspace/src/github.com/disintegration/imaging/effects.go187
-rw-r--r--Godeps/_workspace/src/github.com/disintegration/imaging/helpers.go400
-rw-r--r--Godeps/_workspace/src/github.com/disintegration/imaging/resize.go583
-rw-r--r--Godeps/_workspace/src/github.com/disintegration/imaging/tools.go182
-rw-r--r--Godeps/_workspace/src/github.com/disintegration/imaging/transform.go201
-rw-r--r--Godeps/_workspace/src/github.com/disintegration/imaging/utils.go77
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/LICENSE175
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/internal/commandinfo.go54
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/internal/redistest/testdb.go68
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/conn.go567
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/doc.go169
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/log.go117
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/pool.go393
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/pubsub.go144
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/redis.go44
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/reply.go393
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/scan.go555
-rw-r--r--Godeps/_workspace/src/github.com/garyburd/redigo/redis/script.go86
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/.gitignore8
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/.travis.yml28
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/LICENSE22
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/README.md745
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/column.go83
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/db.go619
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/dialect.go111
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/dialect_mysql.go171
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/dialect_oracle.go146
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/dialect_postgres.go147
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/dialect_sqlite.go119
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/dialect_sqlserver.go152
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/errors.go38
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/gorp.go558
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/hooks.go49
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/index.go56
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/lockerror.go63
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/logging.go44
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/nulltypes.go58
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/select.go351
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/table.go247
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/table_bindings.go317
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/test_all.sh38
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/transaction.go193
-rw-r--r--Godeps/_workspace/src/github.com/go-ldap/ldap/.gitignore0
-rw-r--r--Godeps/_workspace/src/github.com/go-ldap/ldap/.travis.yml15
-rw-r--r--Godeps/_workspace/src/github.com/go-ldap/ldap/LICENSE27
-rw-r--r--Godeps/_workspace/src/github.com/go-ldap/ldap/README.md55
-rw-r--r--Godeps/_workspace/src/github.com/go-ldap/ldap/add.go104
-rw-r--r--Godeps/_workspace/src/github.com/go-ldap/ldap/bind.go135
-rw-r--r--Godeps/_workspace/src/github.com/go-ldap/ldap/client.go23
-rw-r--r--Godeps/_workspace/src/github.com/go-ldap/ldap/compare.go85
-rw-r--r--Godeps/_workspace/src/github.com/go-ldap/ldap/conn.go369
-rw-r--r--Godeps/_workspace/src/github.com/go-ldap/ldap/control.go332
-rw-r--r--Godeps/_workspace/src/github.com/go-ldap/ldap/debug.go24
-rw-r--r--Godeps/_workspace/src/github.com/go-ldap/ldap/del.go79
-rw-r--r--Godeps/_workspace/src/github.com/go-ldap/ldap/dn.go155
-rw-r--r--Godeps/_workspace/src/github.com/go-ldap/ldap/doc.go4
-rw-r--r--Godeps/_workspace/src/github.com/go-ldap/ldap/error.go137
-rw-r--r--Godeps/_workspace/src/github.com/go-ldap/ldap/filter.go456
-rw-r--r--Godeps/_workspace/src/github.com/go-ldap/ldap/ldap.go286
-rw-r--r--Godeps/_workspace/src/github.com/go-ldap/ldap/modify.go156
-rw-r--r--Godeps/_workspace/src/github.com/go-ldap/ldap/passwdmodify.go137
-rw-r--r--Godeps/_workspace/src/github.com/go-ldap/ldap/search.go403
-rw-r--r--Godeps/_workspace/src/github.com/go-sql-driver/mysql/.gitignore8
-rw-r--r--Godeps/_workspace/src/github.com/go-sql-driver/mysql/.travis.yml10
-rw-r--r--Godeps/_workspace/src/github.com/go-sql-driver/mysql/AUTHORS46
-rw-r--r--Godeps/_workspace/src/github.com/go-sql-driver/mysql/CHANGELOG.md92
-rw-r--r--Godeps/_workspace/src/github.com/go-sql-driver/mysql/CONTRIBUTING.md40
-rw-r--r--Godeps/_workspace/src/github.com/go-sql-driver/mysql/LICENSE373
-rw-r--r--Godeps/_workspace/src/github.com/go-sql-driver/mysql/README.md386
-rw-r--r--Godeps/_workspace/src/github.com/go-sql-driver/mysql/appengine.go19
-rw-r--r--Godeps/_workspace/src/github.com/go-sql-driver/mysql/buffer.go136
-rw-r--r--Godeps/_workspace/src/github.com/go-sql-driver/mysql/collations.go250
-rw-r--r--Godeps/_workspace/src/github.com/go-sql-driver/mysql/connection.go403
-rw-r--r--Godeps/_workspace/src/github.com/go-sql-driver/mysql/const.go162
-rw-r--r--Godeps/_workspace/src/github.com/go-sql-driver/mysql/driver.go149
-rw-r--r--Godeps/_workspace/src/github.com/go-sql-driver/mysql/errors.go131
-rw-r--r--Godeps/_workspace/src/github.com/go-sql-driver/mysql/infile.go182
-rw-r--r--Godeps/_workspace/src/github.com/go-sql-driver/mysql/packets.go1182
-rw-r--r--Godeps/_workspace/src/github.com/go-sql-driver/mysql/result.go22
-rw-r--r--Godeps/_workspace/src/github.com/go-sql-driver/mysql/rows.go106
-rw-r--r--Godeps/_workspace/src/github.com/go-sql-driver/mysql/statement.go150
-rw-r--r--Godeps/_workspace/src/github.com/go-sql-driver/mysql/transaction.go31
-rw-r--r--Godeps/_workspace/src/github.com/go-sql-driver/mysql/utils.go973
-rw-r--r--Godeps/_workspace/src/github.com/goamz/goamz/LICENSE185
-rw-r--r--Godeps/_workspace/src/github.com/goamz/goamz/aws/attempt.go74
-rw-r--r--Godeps/_workspace/src/github.com/goamz/goamz/aws/aws.go432
-rw-r--r--Godeps/_workspace/src/github.com/goamz/goamz/aws/client.go124
-rw-r--r--Godeps/_workspace/src/github.com/goamz/goamz/aws/regions.go254
-rw-r--r--Godeps/_workspace/src/github.com/goamz/goamz/aws/sign.go357
-rw-r--r--Godeps/_workspace/src/github.com/goamz/goamz/s3/multi.go439
-rw-r--r--Godeps/_workspace/src/github.com/goamz/goamz/s3/s3.go1155
-rw-r--r--Godeps/_workspace/src/github.com/goamz/goamz/s3/s3test/server.go633
-rw-r--r--Godeps/_workspace/src/github.com/goamz/goamz/s3/sign.go141
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/AUTHORS18
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/CONTRIBUTORS36
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/LICENSE12
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/README21
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/cmd/print-glyph-points/main.c87
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/example/drawer/main.go157
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/example/freetype/main.go149
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/example/gamma/main.go85
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/example/raster/main.go184
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/example/round/main.go109
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/example/truetype/main.go80
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/freetype.go341
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/licenses/ftl.txt169
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/licenses/gpl.txt340
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/raster/geom.go245
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/raster/paint.go287
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/raster/raster.go601
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/raster/stroke.go483
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/truetype/face.go495
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/truetype/glyph.go517
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/truetype/hint.go1763
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/truetype/opcodes.go289
-rw-r--r--Godeps/_workspace/src/github.com/golang/freetype/truetype/truetype.go639
-rw-r--r--Godeps/_workspace/src/github.com/golang/groupcache/LICENSE191
-rw-r--r--Godeps/_workspace/src/github.com/golang/groupcache/lru/lru.go121
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/context/.travis.yml8
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/context/LICENSE27
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/context/README.md7
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/context/context.go143
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/context/doc.go82
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/handlers/.travis.yml17
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/handlers/LICENSE22
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/handlers/README.md53
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/handlers/canonical.go74
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/handlers/compress.go145
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/handlers/cors.go317
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/handlers/doc.go9
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/handlers/handlers.go403
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/handlers/proxy_headers.go113
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/handlers/recovery.go86
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/mux/.travis.yml14
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/mux/LICENSE27
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/mux/README.md235
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/mux/doc.go206
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/mux/mux.go474
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/mux/regexp.go317
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/mux/route.go595
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/.gitignore22
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/.travis.yml6
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/AUTHORS8
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/LICENSE22
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/README.md61
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/client.go341
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/conn.go831
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/doc.go151
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/examples/autobahn/README.md13
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/examples/autobahn/fuzzingclient.json14
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/examples/autobahn/server.go246
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/examples/chat/README.md20
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/examples/chat/conn.go102
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/examples/chat/home.html92
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/examples/chat/hub.go51
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/examples/chat/main.go39
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/examples/command/README.md19
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/examples/command/home.html96
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/examples/command/main.go188
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/examples/echo/README.md17
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/examples/echo/client.go81
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/examples/echo/server.go132
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/examples/filewatch/README.md9
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/examples/filewatch/main.go193
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/json.go55
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/server.go250
-rw-r--r--Godeps/_workspace/src/github.com/gorilla/websocket/util.go44
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/.gitignore4
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/.travis.yml69
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/CONTRIBUTING.md29
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/LICENSE.md8
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/README.md103
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/buf.go91
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/certs/README3
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/certs/postgresql.crt69
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/certs/postgresql.key15
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/certs/root.crt24
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/certs/server.crt81
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/certs/server.key27
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/conn.go1777
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/copy.go267
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/doc.go210
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/encode.go538
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/error.go508
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/hstore/hstore.go118
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/listen_example/doc.go102
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/notify.go766
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/oid/doc.go6
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/oid/gen.go74
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/oid/types.go161
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/url.go76
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/user_posix.go24
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/user_windows.go27
-rw-r--r--Godeps/_workspace/src/github.com/mattermost/rsc/gf256/Makefile8
-rw-r--r--Godeps/_workspace/src/github.com/mattermost/rsc/gf256/blog_test.go85
-rw-r--r--Godeps/_workspace/src/github.com/mattermost/rsc/gf256/gf256.go241
-rw-r--r--Godeps/_workspace/src/github.com/mattermost/rsc/gf256/gf256_test.go194
-rw-r--r--Godeps/_workspace/src/github.com/mattermost/rsc/qr/Makefile4
-rw-r--r--Godeps/_workspace/src/github.com/mattermost/rsc/qr/coding/Makefile7
-rw-r--r--Godeps/_workspace/src/github.com/mattermost/rsc/qr/coding/gen.go149
-rw-r--r--Godeps/_workspace/src/github.com/mattermost/rsc/qr/coding/qr.go815
-rw-r--r--Godeps/_workspace/src/github.com/mattermost/rsc/qr/coding/qr_test.go133
-rw-r--r--Godeps/_workspace/src/github.com/mattermost/rsc/qr/libqrencode/Makefile4
-rw-r--r--Godeps/_workspace/src/github.com/mattermost/rsc/qr/libqrencode/qrencode.go149
-rw-r--r--Godeps/_workspace/src/github.com/mattermost/rsc/qr/png.go400
-rw-r--r--Godeps/_workspace/src/github.com/mattermost/rsc/qr/png_test.go73
-rw-r--r--Godeps/_workspace/src/github.com/mattermost/rsc/qr/qr.go116
-rw-r--r--Godeps/_workspace/src/github.com/mattermost/rsc/qr/web/pic.go506
-rw-r--r--Godeps/_workspace/src/github.com/mattermost/rsc/qr/web/play.go1118
-rw-r--r--Godeps/_workspace/src/github.com/mattermost/rsc/qr/web/resize/resize.go152
-rw-r--r--Godeps/_workspace/src/github.com/mssola/user_agent/.travis.yml12
-rw-r--r--Godeps/_workspace/src/github.com/mssola/user_agent/LICENSE20
-rw-r--r--Godeps/_workspace/src/github.com/mssola/user_agent/README.md51
-rw-r--r--Godeps/_workspace/src/github.com/mssola/user_agent/bot.go122
-rw-r--r--Godeps/_workspace/src/github.com/mssola/user_agent/browser.go129
-rw-r--r--Godeps/_workspace/src/github.com/mssola/user_agent/operating_systems.go260
-rw-r--r--Godeps/_workspace/src/github.com/mssola/user_agent/user_agent.go169
-rw-r--r--Godeps/_workspace/src/github.com/nicksnyder/go-i18n/LICENSE19
-rw-r--r--Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/bundle/bundle.go315
-rw-r--r--Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/i18n.go152
-rw-r--r--Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/language.go99
-rw-r--r--Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/operands.go119
-rw-r--r--Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/plural.go40
-rw-r--r--Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/pluralspec.go74
-rw-r--r--Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/language/pluralspec_gen.go567
-rw-r--r--Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/translation/plural_translation.go78
-rw-r--r--Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/translation/single_translation.go57
-rw-r--r--Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/translation/template.go61
-rw-r--r--Godeps/_workspace/src/github.com/nicksnyder/go-i18n/i18n/translation/translation.go83
-rw-r--r--Godeps/_workspace/src/github.com/pborman/uuid/CONTRIBUTORS1
-rw-r--r--Godeps/_workspace/src/github.com/pborman/uuid/LICENSE27
-rw-r--r--Godeps/_workspace/src/github.com/pborman/uuid/dce.go84
-rw-r--r--Godeps/_workspace/src/github.com/pborman/uuid/doc.go8
-rw-r--r--Godeps/_workspace/src/github.com/pborman/uuid/hash.go53
-rw-r--r--Godeps/_workspace/src/github.com/pborman/uuid/json.go30
-rw-r--r--Godeps/_workspace/src/github.com/pborman/uuid/node.go101
-rw-r--r--Godeps/_workspace/src/github.com/pborman/uuid/sql.go48
-rw-r--r--Godeps/_workspace/src/github.com/pborman/uuid/time.go132
-rw-r--r--Godeps/_workspace/src/github.com/pborman/uuid/util.go43
-rw-r--r--Godeps/_workspace/src/github.com/pborman/uuid/uuid.go163
-rw-r--r--Godeps/_workspace/src/github.com/pborman/uuid/version1.go41
-rw-r--r--Godeps/_workspace/src/github.com/pborman/uuid/version4.go25
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/LICENSE24
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/README.md4
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/corrupt/huge_tag_exif.jpgbin65536 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/corrupt/infinite_loop_exif.jpgbin3738 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/corrupt/max_uint32_exif.jpgbin65536 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/exif.go619
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/fields.go293
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/regen_regress.go79
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/sample1.jpgbin80603 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2004-01-11-22-45-15-sep-2004-01-11-22-45-15a.jpgbin4586 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2006-08-03-16-29-38-sep-2006-08-03-16-29-38a.jpgbin9735 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2006-11-11-19-17-56-sep-2006-11-11-19-17-56a.jpgbin35406 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2006-12-10-23-58-20-sep-2006-12-10-23-58-20a.jpgbin8711 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2006-12-17-07-09-14-sep-2006-12-17-07-09-14a.jpgbin38252 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2006-12-21-15-55-26-sep-2006-12-21-15-55-26a.jpgbin16072 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2007-01-01-12-00-00-sep-2007-01-01-12-00-00a.jpgbin17301 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2007-01-17-21-49-44-sep-2007-01-17-21-49-44a.jpgbin7999 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2007-02-02-18-13-29-sep-2007-02-02-18-13-29a.jpgbin39915 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2007-05-02-17-02-21-sep-2007-05-02-17-02-21a.jpgbin11783 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2007-05-12-08-19-07-sep-2007-05-12-08-19-07a.jpgbin35771 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2007-05-26-04-49-45-sep-2007-05-26-04-49-45a.jpgbin35406 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2007-05-30-14-28-01-sep-2007-05-30-14-28-01a.jpgbin35406 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2007-06-06-16-15-25-sep-2007-06-06-16-15-25a.jpgbin35406 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2007-06-26-10-13-04-sep-2007-06-26-10-13-04a.jpgbin7615 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2007-07-13-17-02-30-sep-2007-07-13-17-02-30a.jpgbin21719 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2007-08-15-14-42-46-sep-2007-08-15-14-42-46a.jpgbin11549 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2007-08-24-02-40-42-sep-2007-08-24-02-40-42a.jpgbin7687 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2007-11-07-11-40-44-sep-2007-11-07-11-40-44a.jpgbin11223 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2008-06-02-10-03-57-sep-2008-06-02-10-03-57a.jpgbin9745 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2008-06-06-13-29-29-sep-2008-06-06-13-29-29a.jpgbin11783 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2008-06-17-01-21-30-sep-2008-06-17-01-21-30a.jpgbin14564 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2008-09-02-17-43-48-sep-2008-09-02-17-43-48a.jpgbin5406 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2009-03-26-09-23-20-sep-2009-03-26-09-23-20a.jpgbin10759 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2009-04-11-03-01-38-sep-2009-04-11-03-01-38a.jpgbin43374 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2009-04-23-07-21-35-sep-2009-04-23-07-21-35a.jpgbin37208 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2009-06-11-19-23-18-sep-2009-06-11-19-23-18a.jpgbin7791 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2009-06-20-07-59-05-sep-2009-06-20-07-59-05a.jpgbin13618 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2009-08-05-08-11-31-sep-2009-08-05-08-11-31a.jpgbin9919 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2010-06-08-04-44-24-sep-2010-06-08-04-44-24a.jpgbin10939 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2010-06-20-20-07-39-sep-2010-06-20-20-07-39a.jpgbin8551 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2010-09-02-08-43-02-sep-2010-09-02-08-43-02a.jpgbin19534 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2011-01-24-22-06-02-sep-2011-01-24-22-06-02a.jpgbin29003 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2011-03-07-09-28-03-sep-2011-03-07-09-28-03a.jpgbin10529 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2011-05-07-13-02-49-sep-2011-05-07-13-02-49a.jpgbin23743 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2011-08-07-19-22-57-sep-2011-08-07-19-22-57a.jpgbin9936 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2011-10-28-17-50-18-sep-2011-10-28-17-50-18a.jpgbin7487 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2011-10-28-18-25-43-sep-2011-10-28-18-25-43.jpgbin7433 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2011-11-18-15-38-34-sep-Photo11181538.jpgbin12885 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2012-06-02-10-12-28-sep-2012-06-02-10-12-28.jpgbin32165 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2012-09-21-22-07-34-sep-2012-09-21-22-07-34.jpgbin10247 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2012-12-19-21-38-40-sep-temple_square1.jpgbin39182 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2012-12-21-11-15-19-sep-IMG_0001.jpgbin25269 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2013-02-05-23-12-09-sep-DSCI0001.jpgbin10854 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2099-08-12-19-59-29-sep-2099-08-12-19-59-29a.jpgbin37491 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/2216-11-15-11-46-51-sep-2216-11-15-11-46-51a.jpgbin23011 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/FailedHash-NoDate-sep-remembory.jpgbin935 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/f1-exif.jpgbin992 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/f2-exif.jpgbin994 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/f3-exif.jpgbin992 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/f4-exif.jpgbin994 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/f5-exif.jpgbin980 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/f6-exif.jpgbin982 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/f7-exif.jpgbin980 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/f8-exif.jpgbin982 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/geodegrees_as_string.jpgbin22420 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/samples/has-lens-info.jpgbin22493 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/tiff/sample1.tifbin18382 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/tiff/tag.go438
-rw-r--r--Godeps/_workspace/src/github.com/rwcarlsen/goexif/tiff/tiff.go153
-rw-r--r--Godeps/_workspace/src/github.com/vaughan0/go-ini/LICENSE14
-rw-r--r--Godeps/_workspace/src/github.com/vaughan0/go-ini/README.md70
-rw-r--r--Godeps/_workspace/src/github.com/vaughan0/go-ini/ini.go123
-rw-r--r--Godeps/_workspace/src/github.com/vaughan0/go-ini/test.ini2
-rw-r--r--Godeps/_workspace/src/golang.org/x/crypto/LICENSE27
-rw-r--r--Godeps/_workspace/src/golang.org/x/crypto/PATENTS22
-rw-r--r--Godeps/_workspace/src/golang.org/x/crypto/bcrypt/base64.go35
-rw-r--r--Godeps/_workspace/src/golang.org/x/crypto/bcrypt/bcrypt.go294
-rw-r--r--Godeps/_workspace/src/golang.org/x/crypto/blowfish/block.go159
-rw-r--r--Godeps/_workspace/src/golang.org/x/crypto/blowfish/cipher.go91
-rw-r--r--Godeps/_workspace/src/golang.org/x/crypto/blowfish/const.go199
-rw-r--r--Godeps/_workspace/src/golang.org/x/image/LICENSE27
-rw-r--r--Godeps/_workspace/src/golang.org/x/image/PATENTS22
-rw-r--r--Godeps/_workspace/src/golang.org/x/image/bmp/reader.go199
-rw-r--r--Godeps/_workspace/src/golang.org/x/image/bmp/writer.go166
-rw-r--r--Godeps/_workspace/src/golang.org/x/image/font/basicfont/basicfont.go113
-rw-r--r--Godeps/_workspace/src/golang.org/x/image/font/basicfont/data.go1456
-rw-r--r--Godeps/_workspace/src/golang.org/x/image/font/basicfont/gen.go115
-rw-r--r--Godeps/_workspace/src/golang.org/x/image/font/font.go202
-rw-r--r--Godeps/_workspace/src/golang.org/x/image/font/plan9font/plan9font.go556
-rw-r--r--Godeps/_workspace/src/golang.org/x/image/math/fixed/fixed.go172
-rw-r--r--Godeps/_workspace/src/golang.org/x/image/tiff/buffer.go69
-rw-r--r--Godeps/_workspace/src/golang.org/x/image/tiff/compress.go58
-rw-r--r--Godeps/_workspace/src/golang.org/x/image/tiff/consts.go133
-rw-r--r--Godeps/_workspace/src/golang.org/x/image/tiff/lzw/reader.go277
-rw-r--r--Godeps/_workspace/src/golang.org/x/image/tiff/reader.go681
-rw-r--r--Godeps/_workspace/src/golang.org/x/image/tiff/writer.go438
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/.travis.yml15
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/LICENSE27
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/README.md24
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/ber.go504
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/content_int.go25
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/header.go29
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/identifier.go103
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/length.go71
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc1.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc10.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc11.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc12.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc13.berbin11 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc14.berbin7 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc15.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc16.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc17.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc18.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc19.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc2.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc20.berbin11 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc21.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc22.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc23.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc24.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc25.berbin5 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc26.berbin5 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc27.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc28.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc29.berbin3 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc3.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc30.berbin5 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc31.berbin4 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc32.berbin2 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc33.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc34.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc35.berbin16 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc36.berbin20 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc37.berbin14 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc38.berbin16 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc39.berbin2 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc4.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc40.berbin2 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc41.berbin16 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc42.berbin14 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc43.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc44.berbin2 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc45.berbin2 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc46.berbin11 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc47.berbin16 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc48.berbin16 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc5.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc6.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc7.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc8.berbin5 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/tests/tc9.ber1
-rw-r--r--Godeps/_workspace/src/gopkg.in/asn1-ber.v1/util.go24
-rw-r--r--Godeps/_workspace/src/gopkg.in/fsnotify.v1/.gitignore6
-rw-r--r--Godeps/_workspace/src/gopkg.in/fsnotify.v1/.travis.yml20
-rw-r--r--Godeps/_workspace/src/gopkg.in/fsnotify.v1/AUTHORS39
-rw-r--r--Godeps/_workspace/src/gopkg.in/fsnotify.v1/CHANGELOG.md274
-rw-r--r--Godeps/_workspace/src/gopkg.in/fsnotify.v1/CONTRIBUTING.md77
-rw-r--r--Godeps/_workspace/src/gopkg.in/fsnotify.v1/LICENSE28
-rw-r--r--Godeps/_workspace/src/gopkg.in/fsnotify.v1/README.md64
-rw-r--r--Godeps/_workspace/src/gopkg.in/fsnotify.v1/fsnotify.go62
-rw-r--r--Godeps/_workspace/src/gopkg.in/fsnotify.v1/inotify.go324
-rw-r--r--Godeps/_workspace/src/gopkg.in/fsnotify.v1/inotify_poller.go186
-rw-r--r--Godeps/_workspace/src/gopkg.in/fsnotify.v1/kqueue.go481
-rw-r--r--Godeps/_workspace/src/gopkg.in/fsnotify.v1/open_mode_bsd.go11
-rw-r--r--Godeps/_workspace/src/gopkg.in/fsnotify.v1/open_mode_darwin.go12
-rw-r--r--Godeps/_workspace/src/gopkg.in/fsnotify.v1/windows.go561
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/.gitignore10
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/.travis.yml10
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/LICENSE12
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/README.md82
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/delayer.go109
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/doc.go77
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/examples/README.md12
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/examples/custom/main.go90
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/examples/interval-many/main.go79
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/examples/interval-vary/main.go74
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/examples/interval-vary/siege-urls4
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/examples/interval/main.go69
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/examples/memstats/main.go97
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/examples/memstats/test-filebin65536 -> 0 bytes
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/examples/rate-limit/main.go101
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/interval.go164
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/memstats.go214
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/misc/pre-commit38
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/rate.go116
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/store.go31
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/store/doc.go2
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/store/mem.go90
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/store/redis.go85
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/throttler.go86
-rw-r--r--Godeps/_workspace/src/gopkg.in/throttled/throttled.v1/varyby.go78
-rw-r--r--Godeps/_workspace/src/gopkg.in/yaml.v2/LICENSE188
-rw-r--r--Godeps/_workspace/src/gopkg.in/yaml.v2/LICENSE.libyaml31
-rw-r--r--Godeps/_workspace/src/gopkg.in/yaml.v2/README.md131
-rw-r--r--Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go742
-rw-r--r--Godeps/_workspace/src/gopkg.in/yaml.v2/decode.go683
-rw-r--r--Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go1685
-rw-r--r--Godeps/_workspace/src/gopkg.in/yaml.v2/encode.go306
-rw-r--r--Godeps/_workspace/src/gopkg.in/yaml.v2/parserc.go1096
-rw-r--r--Godeps/_workspace/src/gopkg.in/yaml.v2/readerc.go394
-rw-r--r--Godeps/_workspace/src/gopkg.in/yaml.v2/resolve.go203
-rw-r--r--Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go2710
-rw-r--r--Godeps/_workspace/src/gopkg.in/yaml.v2/sorter.go104
-rw-r--r--Godeps/_workspace/src/gopkg.in/yaml.v2/writerc.go89
-rw-r--r--Godeps/_workspace/src/gopkg.in/yaml.v2/yaml.go346
-rw-r--r--Godeps/_workspace/src/gopkg.in/yaml.v2/yamlh.go716
-rw-r--r--Godeps/_workspace/src/gopkg.in/yaml.v2/yamlprivateh.go173
493 files changed, 0 insertions, 72253 deletions
diff --git a/Godeps/_workspace/src/github.com/NYTimes/gziphandler/LICENSE.md b/Godeps/_workspace/src/github.com/NYTimes/gziphandler/LICENSE.md
deleted file mode 100644
index b7e2ecb63..000000000
--- a/Godeps/_workspace/src/github.com/NYTimes/gziphandler/LICENSE.md
+++ /dev/null
@@ -1,13 +0,0 @@
-Copyright (c) 2015 The New York Times Company
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this library except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/Godeps/_workspace/src/github.com/NYTimes/gziphandler/README.md b/Godeps/_workspace/src/github.com/NYTimes/gziphandler/README.md
deleted file mode 100644
index b1d55e26e..000000000
--- a/Godeps/_workspace/src/github.com/NYTimes/gziphandler/README.md
+++ /dev/null
@@ -1,52 +0,0 @@
-Gzip Handler
-============
-
-This is a tiny Go package which wraps HTTP handlers to transparently gzip the
-response body, for clients which support it. Although it's usually simpler to
-leave that to a reverse proxy (like nginx or Varnish), this package is useful
-when that's undesirable.
-
-
-## Usage
-
-Call `GzipHandler` with any handler (an object which implements the
-`http.Handler` interface), and it'll return a new handler which gzips the
-response. For example:
-
-```go
-package main
-
-import (
- "io"
- "net/http"
- "github.com/NYTimes/gziphandler"
-)
-
-func main() {
- withoutGz := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- w.Header().Set("Content-Type", "text/plain")
- io.WriteString(w, "Hello, World")
- })
-
- withGz := gziphandler.GzipHandler(withoutGz)
-
- http.Handle("/", withGz)
- http.ListenAndServe("0.0.0.0:8000", nil)
-}
-```
-
-
-## Documentation
-
-The docs can be found at [godoc.org] [docs], as usual.
-
-
-## License
-
-[Apache 2.0] [license].
-
-
-
-
-[docs]: https://godoc.org/github.com/nytimes/gziphandler
-[license]: https://github.com/nytimes/gziphandler/blob/master/LICENSE.md
diff --git a/Godeps/_workspace/src/github.com/NYTimes/gziphandler/gzip.go b/Godeps/_workspace/src/github.com/NYTimes/gziphandler/gzip.go
deleted file mode 100644
index d0c85c6d3..000000000
--- a/Godeps/_workspace/src/github.com/NYTimes/gziphandler/gzip.go
+++ /dev/null
@@ -1,140 +0,0 @@
-package gziphandler
-
-import (
- "compress/gzip"
- "fmt"
- "net/http"
- "strconv"
- "strings"
- "sync"
-)
-
-const (
- vary = "Vary"
- acceptEncoding = "Accept-Encoding"
- contentEncoding = "Content-Encoding"
-)
-
-type codings map[string]float64
-
-// The default qvalue to assign to an encoding if no explicit qvalue is set.
-// This is actually kind of ambiguous in RFC 2616, so hopefully it's correct.
-// The examples seem to indicate that it is.
-const DEFAULT_QVALUE = 1.0
-
-var gzipWriterPool = sync.Pool{
- New: func() interface{} { return gzip.NewWriter(nil) },
-}
-
-// GzipResponseWriter provides an http.ResponseWriter interface, which gzips
-// bytes before writing them to the underlying response. This doesn't set the
-// Content-Encoding header, nor close the writers, so don't forget to do that.
-type GzipResponseWriter struct {
- gw *gzip.Writer
- http.ResponseWriter
-}
-
-// Write appends data to the gzip writer.
-func (w GzipResponseWriter) Write(b []byte) (int, error) {
- return w.gw.Write(b)
-}
-
-// Flush flushes the underlying *gzip.Writer and then the underlying
-// http.ResponseWriter if it is an http.Flusher. This makes GzipResponseWriter
-// an http.Flusher.
-func (w GzipResponseWriter) Flush() {
- w.gw.Flush()
- if fw, ok := w.ResponseWriter.(http.Flusher); ok {
- fw.Flush()
- }
-}
-
-// GzipHandler wraps an HTTP handler, to transparently gzip the response body if
-// the client supports it (via the Accept-Encoding header).
-func GzipHandler(h http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- w.Header().Add(vary, acceptEncoding)
-
- if acceptsGzip(r) {
- // Bytes written during ServeHTTP are redirected to this gzip writer
- // before being written to the underlying response.
- gzw := gzipWriterPool.Get().(*gzip.Writer)
- defer gzipWriterPool.Put(gzw)
- gzw.Reset(w)
- defer gzw.Close()
-
- w.Header().Set(contentEncoding, "gzip")
- h.ServeHTTP(GzipResponseWriter{gzw, w}, r)
- } else {
- h.ServeHTTP(w, r)
- }
- })
-}
-
-// acceptsGzip returns true if the given HTTP request indicates that it will
-// accept a gzippped response.
-func acceptsGzip(r *http.Request) bool {
- acceptedEncodings, _ := parseEncodings(r.Header.Get(acceptEncoding))
- return acceptedEncodings["gzip"] > 0.0
-}
-
-// parseEncodings attempts to parse a list of codings, per RFC 2616, as might
-// appear in an Accept-Encoding header. It returns a map of content-codings to
-// quality values, and an error containing the errors encounted. It's probably
-// safe to ignore those, because silently ignoring errors is how the internet
-// works.
-//
-// See: http://tools.ietf.org/html/rfc2616#section-14.3
-func parseEncodings(s string) (codings, error) {
- c := make(codings)
- e := make([]string, 0)
-
- for _, ss := range strings.Split(s, ",") {
- coding, qvalue, err := parseCoding(ss)
-
- if err != nil {
- e = append(e, err.Error())
-
- } else {
- c[coding] = qvalue
- }
- }
-
- // TODO (adammck): Use a proper multi-error struct, so the individual errors
- // can be extracted if anyone cares.
- if len(e) > 0 {
- return c, fmt.Errorf("errors while parsing encodings: %s", strings.Join(e, ", "))
- }
-
- return c, nil
-}
-
-// parseCoding parses a single conding (content-coding with an optional qvalue),
-// as might appear in an Accept-Encoding header. It attempts to forgive minor
-// formatting errors.
-func parseCoding(s string) (coding string, qvalue float64, err error) {
- for n, part := range strings.Split(s, ";") {
- part = strings.TrimSpace(part)
- qvalue = DEFAULT_QVALUE
-
- if n == 0 {
- coding = strings.ToLower(part)
-
- } else if strings.HasPrefix(part, "q=") {
- qvalue, err = strconv.ParseFloat(strings.TrimPrefix(part, "q="), 64)
-
- if qvalue < 0.0 {
- qvalue = 0.0
-
- } else if qvalue > 1.0 {
- qvalue = 1.0
- }
- }
- }
-
- if coding == "" {
- err = fmt.Errorf("empty content-coding")
- }
-
- return
-}
diff --git a/Godeps/_workspace/src/github.com/alecthomas/log4go/.gitignore b/Godeps/_workspace/src/github.com/alecthomas/log4go/.gitignore
deleted file mode 100644
index f6207cd8a..000000000
--- a/Godeps/_workspace/src/github.com/alecthomas/log4go/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*.sw[op]
-.DS_Store
diff --git a/Godeps/_workspace/src/github.com/alecthomas/log4go/LICENSE b/Godeps/_workspace/src/github.com/alecthomas/log4go/LICENSE
deleted file mode 100644
index 7093402bf..000000000
--- a/Godeps/_workspace/src/github.com/alecthomas/log4go/LICENSE
+++ /dev/null
@@ -1,13 +0,0 @@
-Copyright (c) 2010, Kyle Lemons <kyle@kylelemons.net>. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Godeps/_workspace/src/github.com/alecthomas/log4go/README b/Godeps/_workspace/src/github.com/alecthomas/log4go/README
deleted file mode 100644
index 16d80ecb7..000000000
--- a/Godeps/_workspace/src/github.com/alecthomas/log4go/README
+++ /dev/null
@@ -1,12 +0,0 @@
-Please see http://log4go.googlecode.com/
-
-Installation:
-- Run `goinstall log4go.googlecode.com/hg`
-
-Usage:
-- Add the following import:
-import l4g "log4go.googlecode.com/hg"
-
-Acknowledgements:
-- pomack
- For providing awesome patches to bring log4go up to the latest Go spec
diff --git a/Godeps/_workspace/src/github.com/alecthomas/log4go/config.go b/Godeps/_workspace/src/github.com/alecthomas/log4go/config.go
deleted file mode 100644
index 577c3eb2f..000000000
--- a/Godeps/_workspace/src/github.com/alecthomas/log4go/config.go
+++ /dev/null
@@ -1,288 +0,0 @@
-// Copyright (C) 2010, Kyle Lemons <kyle@kylelemons.net>. All rights reserved.
-
-package log4go
-
-import (
- "encoding/xml"
- "fmt"
- "io/ioutil"
- "os"
- "strconv"
- "strings"
-)
-
-type xmlProperty struct {
- Name string `xml:"name,attr"`
- Value string `xml:",chardata"`
-}
-
-type xmlFilter struct {
- Enabled string `xml:"enabled,attr"`
- Tag string `xml:"tag"`
- Level string `xml:"level"`
- Type string `xml:"type"`
- Property []xmlProperty `xml:"property"`
-}
-
-type xmlLoggerConfig struct {
- Filter []xmlFilter `xml:"filter"`
-}
-
-// Load XML configuration; see examples/example.xml for documentation
-func (log Logger) LoadConfiguration(filename string) {
- log.Close()
-
- // Open the configuration file
- fd, err := os.Open(filename)
- if err != nil {
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Could not open %q for reading: %s\n", filename, err)
- os.Exit(1)
- }
-
- contents, err := ioutil.ReadAll(fd)
- if err != nil {
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Could not read %q: %s\n", filename, err)
- os.Exit(1)
- }
-
- xc := new(xmlLoggerConfig)
- if err := xml.Unmarshal(contents, xc); err != nil {
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Could not parse XML configuration in %q: %s\n", filename, err)
- os.Exit(1)
- }
-
- for _, xmlfilt := range xc.Filter {
- var filt LogWriter
- var lvl Level
- bad, good, enabled := false, true, false
-
- // Check required children
- if len(xmlfilt.Enabled) == 0 {
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Required attribute %s for filter missing in %s\n", "enabled", filename)
- bad = true
- } else {
- enabled = xmlfilt.Enabled != "false"
- }
- if len(xmlfilt.Tag) == 0 {
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Required child <%s> for filter missing in %s\n", "tag", filename)
- bad = true
- }
- if len(xmlfilt.Type) == 0 {
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Required child <%s> for filter missing in %s\n", "type", filename)
- bad = true
- }
- if len(xmlfilt.Level) == 0 {
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Required child <%s> for filter missing in %s\n", "level", filename)
- bad = true
- }
-
- switch xmlfilt.Level {
- case "FINEST":
- lvl = FINEST
- case "FINE":
- lvl = FINE
- case "DEBUG":
- lvl = DEBUG
- case "TRACE":
- lvl = TRACE
- case "INFO":
- lvl = INFO
- case "WARNING":
- lvl = WARNING
- case "ERROR":
- lvl = ERROR
- case "CRITICAL":
- lvl = CRITICAL
- default:
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Required child <%s> for filter has unknown value in %s: %s\n", "level", filename, xmlfilt.Level)
- bad = true
- }
-
- // Just so all of the required attributes are errored at the same time if missing
- if bad {
- os.Exit(1)
- }
-
- switch xmlfilt.Type {
- case "console":
- filt, good = xmlToConsoleLogWriter(filename, xmlfilt.Property, enabled)
- case "file":
- filt, good = xmlToFileLogWriter(filename, xmlfilt.Property, enabled)
- case "xml":
- filt, good = xmlToXMLLogWriter(filename, xmlfilt.Property, enabled)
- case "socket":
- filt, good = xmlToSocketLogWriter(filename, xmlfilt.Property, enabled)
- default:
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Could not load XML configuration in %s: unknown filter type \"%s\"\n", filename, xmlfilt.Type)
- os.Exit(1)
- }
-
- // Just so all of the required params are errored at the same time if wrong
- if !good {
- os.Exit(1)
- }
-
- // If we're disabled (syntax and correctness checks only), don't add to logger
- if !enabled {
- continue
- }
-
- log[xmlfilt.Tag] = &Filter{lvl, filt}
- }
-}
-
-func xmlToConsoleLogWriter(filename string, props []xmlProperty, enabled bool) (*ConsoleLogWriter, bool) {
- // Parse properties
- for _, prop := range props {
- switch prop.Name {
- default:
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Warning: Unknown property \"%s\" for console filter in %s\n", prop.Name, filename)
- }
- }
-
- // If it's disabled, we're just checking syntax
- if !enabled {
- return nil, true
- }
-
- return NewConsoleLogWriter(), true
-}
-
-// Parse a number with K/M/G suffixes based on thousands (1000) or 2^10 (1024)
-func strToNumSuffix(str string, mult int) int {
- num := 1
- if len(str) > 1 {
- switch str[len(str)-1] {
- case 'G', 'g':
- num *= mult
- fallthrough
- case 'M', 'm':
- num *= mult
- fallthrough
- case 'K', 'k':
- num *= mult
- str = str[0 : len(str)-1]
- }
- }
- parsed, _ := strconv.Atoi(str)
- return parsed * num
-}
-func xmlToFileLogWriter(filename string, props []xmlProperty, enabled bool) (*FileLogWriter, bool) {
- file := ""
- format := "[%D %T] [%L] (%S) %M"
- maxlines := 0
- maxsize := 0
- daily := false
- rotate := false
-
- // Parse properties
- for _, prop := range props {
- switch prop.Name {
- case "filename":
- file = strings.Trim(prop.Value, " \r\n")
- case "format":
- format = strings.Trim(prop.Value, " \r\n")
- case "maxlines":
- maxlines = strToNumSuffix(strings.Trim(prop.Value, " \r\n"), 1000)
- case "maxsize":
- maxsize = strToNumSuffix(strings.Trim(prop.Value, " \r\n"), 1024)
- case "daily":
- daily = strings.Trim(prop.Value, " \r\n") != "false"
- case "rotate":
- rotate = strings.Trim(prop.Value, " \r\n") != "false"
- default:
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Warning: Unknown property \"%s\" for file filter in %s\n", prop.Name, filename)
- }
- }
-
- // Check properties
- if len(file) == 0 {
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Required property \"%s\" for file filter missing in %s\n", "filename", filename)
- return nil, false
- }
-
- // If it's disabled, we're just checking syntax
- if !enabled {
- return nil, true
- }
-
- flw := NewFileLogWriter(file, rotate)
- flw.SetFormat(format)
- flw.SetRotateLines(maxlines)
- flw.SetRotateSize(maxsize)
- flw.SetRotateDaily(daily)
- return flw, true
-}
-
-func xmlToXMLLogWriter(filename string, props []xmlProperty, enabled bool) (*FileLogWriter, bool) {
- file := ""
- maxrecords := 0
- maxsize := 0
- daily := false
- rotate := false
-
- // Parse properties
- for _, prop := range props {
- switch prop.Name {
- case "filename":
- file = strings.Trim(prop.Value, " \r\n")
- case "maxrecords":
- maxrecords = strToNumSuffix(strings.Trim(prop.Value, " \r\n"), 1000)
- case "maxsize":
- maxsize = strToNumSuffix(strings.Trim(prop.Value, " \r\n"), 1024)
- case "daily":
- daily = strings.Trim(prop.Value, " \r\n") != "false"
- case "rotate":
- rotate = strings.Trim(prop.Value, " \r\n") != "false"
- default:
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Warning: Unknown property \"%s\" for xml filter in %s\n", prop.Name, filename)
- }
- }
-
- // Check properties
- if len(file) == 0 {
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Required property \"%s\" for xml filter missing in %s\n", "filename", filename)
- return nil, false
- }
-
- // If it's disabled, we're just checking syntax
- if !enabled {
- return nil, true
- }
-
- xlw := NewXMLLogWriter(file, rotate)
- xlw.SetRotateLines(maxrecords)
- xlw.SetRotateSize(maxsize)
- xlw.SetRotateDaily(daily)
- return xlw, true
-}
-
-func xmlToSocketLogWriter(filename string, props []xmlProperty, enabled bool) (SocketLogWriter, bool) {
- endpoint := ""
- protocol := "udp"
-
- // Parse properties
- for _, prop := range props {
- switch prop.Name {
- case "endpoint":
- endpoint = strings.Trim(prop.Value, " \r\n")
- case "protocol":
- protocol = strings.Trim(prop.Value, " \r\n")
- default:
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Warning: Unknown property \"%s\" for file filter in %s\n", prop.Name, filename)
- }
- }
-
- // Check properties
- if len(endpoint) == 0 {
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Required property \"%s\" for file filter missing in %s\n", "endpoint", filename)
- return nil, false
- }
-
- // If it's disabled, we're just checking syntax
- if !enabled {
- return nil, true
- }
-
- return NewSocketLogWriter(protocol, endpoint), true
-}
diff --git a/Godeps/_workspace/src/github.com/alecthomas/log4go/examples/ConsoleLogWriter_Manual.go b/Godeps/_workspace/src/github.com/alecthomas/log4go/examples/ConsoleLogWriter_Manual.go
deleted file mode 100644
index 698dd332d..000000000
--- a/Godeps/_workspace/src/github.com/alecthomas/log4go/examples/ConsoleLogWriter_Manual.go
+++ /dev/null
@@ -1,14 +0,0 @@
-package main
-
-import (
- "time"
-)
-
-import l4g "code.google.com/p/log4go"
-
-func main() {
- log := l4g.NewLogger()
- defer log.Close()
- log.AddFilter("stdout", l4g.DEBUG, l4g.NewConsoleLogWriter())
- log.Info("The time is now: %s", time.Now().Format("15:04:05 MST 2006/01/02"))
-}
diff --git a/Godeps/_workspace/src/github.com/alecthomas/log4go/examples/FileLogWriter_Manual.go b/Godeps/_workspace/src/github.com/alecthomas/log4go/examples/FileLogWriter_Manual.go
deleted file mode 100644
index efd596aa6..000000000
--- a/Godeps/_workspace/src/github.com/alecthomas/log4go/examples/FileLogWriter_Manual.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package main
-
-import (
- "bufio"
- "fmt"
- "io"
- "os"
- "time"
-)
-
-import l4g "code.google.com/p/log4go"
-
-const (
- filename = "flw.log"
-)
-
-func main() {
- // Get a new logger instance
- log := l4g.NewLogger()
-
- // Create a default logger that is logging messages of FINE or higher
- log.AddFilter("file", l4g.FINE, l4g.NewFileLogWriter(filename, false))
- log.Close()
-
- /* Can also specify manually via the following: (these are the defaults) */
- flw := l4g.NewFileLogWriter(filename, false)
- flw.SetFormat("[%D %T] [%L] (%S) %M")
- flw.SetRotate(false)
- flw.SetRotateSize(0)
- flw.SetRotateLines(0)
- flw.SetRotateDaily(false)
- log.AddFilter("file", l4g.FINE, flw)
-
- // Log some experimental messages
- log.Finest("Everything is created now (notice that I will not be printing to the file)")
- log.Info("The time is now: %s", time.Now().Format("15:04:05 MST 2006/01/02"))
- log.Critical("Time to close out!")
-
- // Close the log
- log.Close()
-
- // Print what was logged to the file (yes, I know I'm skipping error checking)
- fd, _ := os.Open(filename)
- in := bufio.NewReader(fd)
- fmt.Print("Messages logged to file were: (line numbers not included)\n")
- for lineno := 1; ; lineno++ {
- line, err := in.ReadString('\n')
- if err == io.EOF {
- break
- }
- fmt.Printf("%3d:\t%s", lineno, line)
- }
- fd.Close()
-
- // Remove the file so it's not lying around
- os.Remove(filename)
-}
diff --git a/Godeps/_workspace/src/github.com/alecthomas/log4go/examples/SimpleNetLogServer.go b/Godeps/_workspace/src/github.com/alecthomas/log4go/examples/SimpleNetLogServer.go
deleted file mode 100644
index 83c80ad12..000000000
--- a/Godeps/_workspace/src/github.com/alecthomas/log4go/examples/SimpleNetLogServer.go
+++ /dev/null
@@ -1,42 +0,0 @@
-package main
-
-import (
- "flag"
- "fmt"
- "net"
- "os"
-)
-
-var (
- port = flag.String("p", "12124", "Port number to listen on")
-)
-
-func e(err error) {
- if err != nil {
- fmt.Printf("Erroring out: %s\n", err)
- os.Exit(1)
- }
-}
-
-func main() {
- flag.Parse()
-
- // Bind to the port
- bind, err := net.ResolveUDPAddr("0.0.0.0:" + *port)
- e(err)
-
- // Create listener
- listener, err := net.ListenUDP("udp", bind)
- e(err)
-
- fmt.Printf("Listening to port %s...\n", *port)
- for {
- // read into a new buffer
- buffer := make([]byte, 1024)
- _, _, err := listener.ReadFrom(buffer)
- e(err)
-
- // log to standard output
- fmt.Println(string(buffer))
- }
-}
diff --git a/Godeps/_workspace/src/github.com/alecthomas/log4go/examples/SocketLogWriter_Manual.go b/Godeps/_workspace/src/github.com/alecthomas/log4go/examples/SocketLogWriter_Manual.go
deleted file mode 100644
index 400b698ca..000000000
--- a/Godeps/_workspace/src/github.com/alecthomas/log4go/examples/SocketLogWriter_Manual.go
+++ /dev/null
@@ -1,18 +0,0 @@
-package main
-
-import (
- "time"
-)
-
-import l4g "code.google.com/p/log4go"
-
-func main() {
- log := l4g.NewLogger()
- log.AddFilter("network", l4g.FINEST, l4g.NewSocketLogWriter("udp", "192.168.1.255:12124"))
-
- // Run `nc -u -l -p 12124` or similar before you run this to see the following message
- log.Info("The time is now: %s", time.Now().Format("15:04:05 MST 2006/01/02"))
-
- // This makes sure the output stream buffer is written
- log.Close()
-}
diff --git a/Godeps/_workspace/src/github.com/alecthomas/log4go/examples/XMLConfigurationExample.go b/Godeps/_workspace/src/github.com/alecthomas/log4go/examples/XMLConfigurationExample.go
deleted file mode 100644
index 164c2add4..000000000
--- a/Godeps/_workspace/src/github.com/alecthomas/log4go/examples/XMLConfigurationExample.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package main
-
-import l4g "code.google.com/p/log4go"
-
-func main() {
- // Load the configuration (isn't this easy?)
- l4g.LoadConfiguration("example.xml")
-
- // And now we're ready!
- l4g.Finest("This will only go to those of you really cool UDP kids! If you change enabled=true.")
- l4g.Debug("Oh no! %d + %d = %d!", 2, 2, 2+2)
- l4g.Info("About that time, eh chaps?")
-}
diff --git a/Godeps/_workspace/src/github.com/alecthomas/log4go/examples/example.xml b/Godeps/_workspace/src/github.com/alecthomas/log4go/examples/example.xml
deleted file mode 100644
index e791278ce..000000000
--- a/Godeps/_workspace/src/github.com/alecthomas/log4go/examples/example.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<logging>
- <filter enabled="true">
- <tag>stdout</tag>
- <type>console</type>
- <!-- level is (:?FINEST|FINE|DEBUG|TRACE|INFO|WARNING|ERROR) -->
- <level>DEBUG</level>
- </filter>
- <filter enabled="true">
- <tag>file</tag>
- <type>file</type>
- <level>FINEST</level>
- <property name="filename">test.log</property>
- <!--
- %T - Time (15:04:05 MST)
- %t - Time (15:04)
- %D - Date (2006/01/02)
- %d - Date (01/02/06)
- %L - Level (FNST, FINE, DEBG, TRAC, WARN, EROR, CRIT)
- %S - Source
- %M - Message
- It ignores unknown format strings (and removes them)
- Recommended: "[%D %T] [%L] (%S) %M"
- -->
- <property name="format">[%D %T] [%L] (%S) %M</property>
- <property name="rotate">false</property> <!-- true enables log rotation, otherwise append -->
- <property name="maxsize">0M</property> <!-- \d+[KMG]? Suffixes are in terms of 2**10 -->
- <property name="maxlines">0K</property> <!-- \d+[KMG]? Suffixes are in terms of thousands -->
- <property name="daily">true</property> <!-- Automatically rotates when a log message is written after midnight -->
- </filter>
- <filter enabled="true">
- <tag>xmllog</tag>
- <type>xml</type>
- <level>TRACE</level>
- <property name="filename">trace.xml</property>
- <property name="rotate">true</property> <!-- true enables log rotation, otherwise append -->
- <property name="maxsize">100M</property> <!-- \d+[KMG]? Suffixes are in terms of 2**10 -->
- <property name="maxrecords">6K</property> <!-- \d+[KMG]? Suffixes are in terms of thousands -->
- <property name="daily">false</property> <!-- Automatically rotates when a log message is written after midnight -->
- </filter>
- <filter enabled="false"><!-- enabled=false means this logger won't actually be created -->
- <tag>donotopen</tag>
- <type>socket</type>
- <level>FINEST</level>
- <property name="endpoint">192.168.1.255:12124</property> <!-- recommend UDP broadcast -->
- <property name="protocol">udp</property> <!-- tcp or udp -->
- </filter>
-</logging>
diff --git a/Godeps/_workspace/src/github.com/alecthomas/log4go/filelog.go b/Godeps/_workspace/src/github.com/alecthomas/log4go/filelog.go
deleted file mode 100644
index ee0ab0c04..000000000
--- a/Godeps/_workspace/src/github.com/alecthomas/log4go/filelog.go
+++ /dev/null
@@ -1,264 +0,0 @@
-// Copyright (C) 2010, Kyle Lemons <kyle@kylelemons.net>. All rights reserved.
-
-package log4go
-
-import (
- "fmt"
- "os"
- "time"
-)
-
-// This log writer sends output to a file
-type FileLogWriter struct {
- rec chan *LogRecord
- rot chan bool
-
- // The opened file
- filename string
- file *os.File
-
- // The logging format
- format string
-
- // File header/trailer
- header, trailer string
-
- // Rotate at linecount
- maxlines int
- maxlines_curlines int
-
- // Rotate at size
- maxsize int
- maxsize_cursize int
-
- // Rotate daily
- daily bool
- daily_opendate int
-
- // Keep old logfiles (.001, .002, etc)
- rotate bool
- maxbackup int
-}
-
-// This is the FileLogWriter's output method
-func (w *FileLogWriter) LogWrite(rec *LogRecord) {
- w.rec <- rec
-}
-
-func (w *FileLogWriter) Close() {
- close(w.rec)
- w.file.Sync()
-}
-
-// NewFileLogWriter creates a new LogWriter which writes to the given file and
-// has rotation enabled if rotate is true.
-//
-// If rotate is true, any time a new log file is opened, the old one is renamed
-// with a .### extension to preserve it. The various Set* methods can be used
-// to configure log rotation based on lines, size, and daily.
-//
-// The standard log-line format is:
-// [%D %T] [%L] (%S) %M
-func NewFileLogWriter(fname string, rotate bool) *FileLogWriter {
- w := &FileLogWriter{
- rec: make(chan *LogRecord, LogBufferLength),
- rot: make(chan bool),
- filename: fname,
- format: "[%D %T] [%L] (%S) %M",
- rotate: rotate,
- maxbackup: 999,
- }
-
- // open the file for the first time
- if err := w.intRotate(); err != nil {
- fmt.Fprintf(os.Stderr, "FileLogWriter(%q): %s\n", w.filename, err)
- return nil
- }
-
- go func() {
- defer func() {
- if w.file != nil {
- fmt.Fprint(w.file, FormatLogRecord(w.trailer, &LogRecord{Created: time.Now()}))
- w.file.Close()
- }
- }()
-
- for {
- select {
- case <-w.rot:
- if err := w.intRotate(); err != nil {
- fmt.Fprintf(os.Stderr, "FileLogWriter(%q): %s\n", w.filename, err)
- return
- }
- case rec, ok := <-w.rec:
- if !ok {
- return
- }
- now := time.Now()
- if (w.maxlines > 0 && w.maxlines_curlines >= w.maxlines) ||
- (w.maxsize > 0 && w.maxsize_cursize >= w.maxsize) ||
- (w.daily && now.Day() != w.daily_opendate) {
- if err := w.intRotate(); err != nil {
- fmt.Fprintf(os.Stderr, "FileLogWriter(%q): %s\n", w.filename, err)
- return
- }
- }
-
- // Perform the write
- n, err := fmt.Fprint(w.file, FormatLogRecord(w.format, rec))
- if err != nil {
- fmt.Fprintf(os.Stderr, "FileLogWriter(%q): %s\n", w.filename, err)
- return
- }
-
- // Update the counts
- w.maxlines_curlines++
- w.maxsize_cursize += n
- }
- }
- }()
-
- return w
-}
-
-// Request that the logs rotate
-func (w *FileLogWriter) Rotate() {
- w.rot <- true
-}
-
-// If this is called in a threaded context, it MUST be synchronized
-func (w *FileLogWriter) intRotate() error {
- // Close any log file that may be open
- if w.file != nil {
- fmt.Fprint(w.file, FormatLogRecord(w.trailer, &LogRecord{Created: time.Now()}))
- w.file.Close()
- }
-
- // If we are keeping log files, move it to the next available number
- if w.rotate {
- _, err := os.Lstat(w.filename)
- if err == nil { // file exists
- // Find the next available number
- num := 1
- fname := ""
- if w.daily && time.Now().Day() != w.daily_opendate {
- yesterday := time.Now().AddDate(0, 0, -1).Format("2006-01-02")
-
- for ; err == nil && num <= 999; num++ {
- fname = w.filename + fmt.Sprintf(".%s.%03d", yesterday, num)
- _, err = os.Lstat(fname)
- }
- // return error if the last file checked still existed
- if err == nil {
- return fmt.Errorf("Rotate: Cannot find free log number to rename %s\n", w.filename)
- }
- } else {
- num = w.maxbackup - 1
- for ; num >= 1; num-- {
- fname = w.filename + fmt.Sprintf(".%d", num)
- nfname := w.filename + fmt.Sprintf(".%d", num+1)
- _, err = os.Lstat(fname)
- if err == nil {
- os.Rename(fname, nfname)
- }
- }
- }
-
- w.file.Close()
- // Rename the file to its newfound home
- err = os.Rename(w.filename, fname)
- if err != nil {
- return fmt.Errorf("Rotate: %s\n", err)
- }
- }
- }
-
- // Open the log file
- fd, err := os.OpenFile(w.filename, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0660)
- if err != nil {
- return err
- }
- w.file = fd
-
- now := time.Now()
- fmt.Fprint(w.file, FormatLogRecord(w.header, &LogRecord{Created: now}))
-
- // Set the daily open date to the current date
- w.daily_opendate = now.Day()
-
- // initialize rotation values
- w.maxlines_curlines = 0
- w.maxsize_cursize = 0
-
- return nil
-}
-
-// Set the logging format (chainable). Must be called before the first log
-// message is written.
-func (w *FileLogWriter) SetFormat(format string) *FileLogWriter {
- w.format = format
- return w
-}
-
-// Set the logfile header and footer (chainable). Must be called before the first log
-// message is written. These are formatted similar to the FormatLogRecord (e.g.
-// you can use %D and %T in your header/footer for date and time).
-func (w *FileLogWriter) SetHeadFoot(head, foot string) *FileLogWriter {
- w.header, w.trailer = head, foot
- if w.maxlines_curlines == 0 {
- fmt.Fprint(w.file, FormatLogRecord(w.header, &LogRecord{Created: time.Now()}))
- }
- return w
-}
-
-// Set rotate at linecount (chainable). Must be called before the first log
-// message is written.
-func (w *FileLogWriter) SetRotateLines(maxlines int) *FileLogWriter {
- //fmt.Fprintf(os.Stderr, "FileLogWriter.SetRotateLines: %v\n", maxlines)
- w.maxlines = maxlines
- return w
-}
-
-// Set rotate at size (chainable). Must be called before the first log message
-// is written.
-func (w *FileLogWriter) SetRotateSize(maxsize int) *FileLogWriter {
- //fmt.Fprintf(os.Stderr, "FileLogWriter.SetRotateSize: %v\n", maxsize)
- w.maxsize = maxsize
- return w
-}
-
-// Set rotate daily (chainable). Must be called before the first log message is
-// written.
-func (w *FileLogWriter) SetRotateDaily(daily bool) *FileLogWriter {
- //fmt.Fprintf(os.Stderr, "FileLogWriter.SetRotateDaily: %v\n", daily)
- w.daily = daily
- return w
-}
-
-// Set max backup files. Must be called before the first log message
-// is written.
-func (w *FileLogWriter) SetRotateMaxBackup(maxbackup int) *FileLogWriter {
- w.maxbackup = maxbackup
- return w
-}
-
-// SetRotate changes whether or not the old logs are kept. (chainable) Must be
-// called before the first log message is written. If rotate is false, the
-// files are overwritten; otherwise, they are rotated to another file before the
-// new log is opened.
-func (w *FileLogWriter) SetRotate(rotate bool) *FileLogWriter {
- //fmt.Fprintf(os.Stderr, "FileLogWriter.SetRotate: %v\n", rotate)
- w.rotate = rotate
- return w
-}
-
-// NewXMLLogWriter is a utility method for creating a FileLogWriter set up to
-// output XML record log messages instead of line-based ones.
-func NewXMLLogWriter(fname string, rotate bool) *FileLogWriter {
- return NewFileLogWriter(fname, rotate).SetFormat(
- ` <record level="%L">
- <timestamp>%D %T</timestamp>
- <source>%S</source>
- <message>%M</message>
- </record>`).SetHeadFoot("<log created=\"%D %T\">", "</log>")
-}
diff --git a/Godeps/_workspace/src/github.com/alecthomas/log4go/log4go.go b/Godeps/_workspace/src/github.com/alecthomas/log4go/log4go.go
deleted file mode 100644
index 822e890cc..000000000
--- a/Godeps/_workspace/src/github.com/alecthomas/log4go/log4go.go
+++ /dev/null
@@ -1,484 +0,0 @@
-// Copyright (C) 2010, Kyle Lemons <kyle@kylelemons.net>. All rights reserved.
-
-// Package log4go provides level-based and highly configurable logging.
-//
-// Enhanced Logging
-//
-// This is inspired by the logging functionality in Java. Essentially, you create a Logger
-// object and create output filters for it. You can send whatever you want to the Logger,
-// and it will filter that based on your settings and send it to the outputs. This way, you
-// can put as much debug code in your program as you want, and when you're done you can filter
-// out the mundane messages so only the important ones show up.
-//
-// Utility functions are provided to make life easier. Here is some example code to get started:
-//
-// log := log4go.NewLogger()
-// log.AddFilter("stdout", log4go.DEBUG, log4go.NewConsoleLogWriter())
-// log.AddFilter("log", log4go.FINE, log4go.NewFileLogWriter("example.log", true))
-// log.Info("The time is now: %s", time.LocalTime().Format("15:04:05 MST 2006/01/02"))
-//
-// The first two lines can be combined with the utility NewDefaultLogger:
-//
-// log := log4go.NewDefaultLogger(log4go.DEBUG)
-// log.AddFilter("log", log4go.FINE, log4go.NewFileLogWriter("example.log", true))
-// log.Info("The time is now: %s", time.LocalTime().Format("15:04:05 MST 2006/01/02"))
-//
-// Usage notes:
-// - The ConsoleLogWriter does not display the source of the message to standard
-// output, but the FileLogWriter does.
-// - The utility functions (Info, Debug, Warn, etc) derive their source from the
-// calling function, and this incurs extra overhead.
-//
-// Changes from 2.0:
-// - The external interface has remained mostly stable, but a lot of the
-// internals have been changed, so if you depended on any of this or created
-// your own LogWriter, then you will probably have to update your code. In
-// particular, Logger is now a map and ConsoleLogWriter is now a channel
-// behind-the-scenes, and the LogWrite method no longer has return values.
-//
-// Future work: (please let me know if you think I should work on any of these particularly)
-// - Log file rotation
-// - Logging configuration files ala log4j
-// - Have the ability to remove filters?
-// - Have GetInfoChannel, GetDebugChannel, etc return a chan string that allows
-// for another method of logging
-// - Add an XML filter type
-package log4go
-
-import (
- "errors"
- "fmt"
- "os"
- "runtime"
- "strings"
- "time"
-)
-
-// Version information
-const (
- L4G_VERSION = "log4go-v3.0.1"
- L4G_MAJOR = 3
- L4G_MINOR = 0
- L4G_BUILD = 1
-)
-
-/****** Constants ******/
-
-// These are the integer logging levels used by the logger
-type Level int
-
-const (
- FINEST Level = iota
- FINE
- DEBUG
- TRACE
- INFO
- WARNING
- ERROR
- CRITICAL
-)
-
-// Logging level strings
-var (
- levelStrings = [...]string{"FNST", "FINE", "DEBG", "TRAC", "INFO", "WARN", "EROR", "CRIT"}
-)
-
-func (l Level) String() string {
- if l < 0 || int(l) > len(levelStrings) {
- return "UNKNOWN"
- }
- return levelStrings[int(l)]
-}
-
-/****** Variables ******/
-var (
- // LogBufferLength specifies how many log messages a particular log4go
- // logger can buffer at a time before writing them.
- LogBufferLength = 32
-)
-
-/****** LogRecord ******/
-
-// A LogRecord contains all of the pertinent information for each message
-type LogRecord struct {
- Level Level // The log level
- Created time.Time // The time at which the log message was created (nanoseconds)
- Source string // The message source
- Message string // The log message
-}
-
-/****** LogWriter ******/
-
-// This is an interface for anything that should be able to write logs
-type LogWriter interface {
- // This will be called to log a LogRecord message.
- LogWrite(rec *LogRecord)
-
- // This should clean up anything lingering about the LogWriter, as it is called before
- // the LogWriter is removed. LogWrite should not be called after Close.
- Close()
-}
-
-/****** Logger ******/
-
-// A Filter represents the log level below which no log records are written to
-// the associated LogWriter.
-type Filter struct {
- Level Level
- LogWriter
-}
-
-// A Logger represents a collection of Filters through which log messages are
-// written.
-type Logger map[string]*Filter
-
-// Create a new logger.
-//
-// DEPRECATED: Use make(Logger) instead.
-func NewLogger() Logger {
- os.Stderr.WriteString("warning: use of deprecated NewLogger\n")
- return make(Logger)
-}
-
-// Create a new logger with a "stdout" filter configured to send log messages at
-// or above lvl to standard output.
-//
-// DEPRECATED: use NewDefaultLogger instead.
-func NewConsoleLogger(lvl Level) Logger {
- os.Stderr.WriteString("warning: use of deprecated NewConsoleLogger\n")
- return Logger{
- "stdout": &Filter{lvl, NewConsoleLogWriter()},
- }
-}
-
-// Create a new logger with a "stdout" filter configured to send log messages at
-// or above lvl to standard output.
-func NewDefaultLogger(lvl Level) Logger {
- return Logger{
- "stdout": &Filter{lvl, NewConsoleLogWriter()},
- }
-}
-
-// Closes all log writers in preparation for exiting the program or a
-// reconfiguration of logging. Calling this is not really imperative, unless
-// you want to guarantee that all log messages are written. Close removes
-// all filters (and thus all LogWriters) from the logger.
-func (log Logger) Close() {
- // Close all open loggers
- for name, filt := range log {
- filt.Close()
- delete(log, name)
- }
-}
-
-// Add a new LogWriter to the Logger which will only log messages at lvl or
-// higher. This function should not be called from multiple goroutines.
-// Returns the logger for chaining.
-func (log Logger) AddFilter(name string, lvl Level, writer LogWriter) Logger {
- log[name] = &Filter{lvl, writer}
- return log
-}
-
-/******* Logging *******/
-// Send a formatted log message internally
-func (log Logger) intLogf(lvl Level, format string, args ...interface{}) {
- skip := true
-
- // Determine if any logging will be done
- for _, filt := range log {
- if lvl >= filt.Level {
- skip = false
- break
- }
- }
- if skip {
- return
- }
-
- // Determine caller func
- pc, _, lineno, ok := runtime.Caller(2)
- src := ""
- if ok {
- src = fmt.Sprintf("%s:%d", runtime.FuncForPC(pc).Name(), lineno)
- }
-
- msg := format
- if len(args) > 0 {
- msg = fmt.Sprintf(format, args...)
- }
-
- // Make the log record
- rec := &LogRecord{
- Level: lvl,
- Created: time.Now(),
- Source: src,
- Message: msg,
- }
-
- // Dispatch the logs
- for _, filt := range log {
- if lvl < filt.Level {
- continue
- }
- filt.LogWrite(rec)
- }
-}
-
-// Send a closure log message internally
-func (log Logger) intLogc(lvl Level, closure func() string) {
- skip := true
-
- // Determine if any logging will be done
- for _, filt := range log {
- if lvl >= filt.Level {
- skip = false
- break
- }
- }
- if skip {
- return
- }
-
- // Determine caller func
- pc, _, lineno, ok := runtime.Caller(2)
- src := ""
- if ok {
- src = fmt.Sprintf("%s:%d", runtime.FuncForPC(pc).Name(), lineno)
- }
-
- // Make the log record
- rec := &LogRecord{
- Level: lvl,
- Created: time.Now(),
- Source: src,
- Message: closure(),
- }
-
- // Dispatch the logs
- for _, filt := range log {
- if lvl < filt.Level {
- continue
- }
- filt.LogWrite(rec)
- }
-}
-
-// Send a log message with manual level, source, and message.
-func (log Logger) Log(lvl Level, source, message string) {
- skip := true
-
- // Determine if any logging will be done
- for _, filt := range log {
- if lvl >= filt.Level {
- skip = false
- break
- }
- }
- if skip {
- return
- }
-
- // Make the log record
- rec := &LogRecord{
- Level: lvl,
- Created: time.Now(),
- Source: source,
- Message: message,
- }
-
- // Dispatch the logs
- for _, filt := range log {
- if lvl < filt.Level {
- continue
- }
- filt.LogWrite(rec)
- }
-}
-
-// Logf logs a formatted log message at the given log level, using the caller as
-// its source.
-func (log Logger) Logf(lvl Level, format string, args ...interface{}) {
- log.intLogf(lvl, format, args...)
-}
-
-// Logc logs a string returned by the closure at the given log level, using the caller as
-// its source. If no log message would be written, the closure is never called.
-func (log Logger) Logc(lvl Level, closure func() string) {
- log.intLogc(lvl, closure)
-}
-
-// Finest logs a message at the finest log level.
-// See Debug for an explanation of the arguments.
-func (log Logger) Finest(arg0 interface{}, args ...interface{}) {
- const (
- lvl = FINEST
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- log.intLogf(lvl, first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- log.intLogc(lvl, first)
- default:
- // Build a format string so that it will be similar to Sprint
- log.intLogf(lvl, fmt.Sprint(arg0)+strings.Repeat(" %v", len(args)), args...)
- }
-}
-
-// Fine logs a message at the fine log level.
-// See Debug for an explanation of the arguments.
-func (log Logger) Fine(arg0 interface{}, args ...interface{}) {
- const (
- lvl = FINE
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- log.intLogf(lvl, first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- log.intLogc(lvl, first)
- default:
- // Build a format string so that it will be similar to Sprint
- log.intLogf(lvl, fmt.Sprint(arg0)+strings.Repeat(" %v", len(args)), args...)
- }
-}
-
-// Debug is a utility method for debug log messages.
-// The behavior of Debug depends on the first argument:
-// - arg0 is a string
-// When given a string as the first argument, this behaves like Logf but with
-// the DEBUG log level: the first argument is interpreted as a format for the
-// latter arguments.
-// - arg0 is a func()string
-// When given a closure of type func()string, this logs the string returned by
-// the closure iff it will be logged. The closure runs at most one time.
-// - arg0 is interface{}
-// When given anything else, the log message will be each of the arguments
-// formatted with %v and separated by spaces (ala Sprint).
-func (log Logger) Debug(arg0 interface{}, args ...interface{}) {
- const (
- lvl = DEBUG
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- log.intLogf(lvl, first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- log.intLogc(lvl, first)
- default:
- // Build a format string so that it will be similar to Sprint
- log.intLogf(lvl, fmt.Sprint(arg0)+strings.Repeat(" %v", len(args)), args...)
- }
-}
-
-// Trace logs a message at the trace log level.
-// See Debug for an explanation of the arguments.
-func (log Logger) Trace(arg0 interface{}, args ...interface{}) {
- const (
- lvl = TRACE
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- log.intLogf(lvl, first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- log.intLogc(lvl, first)
- default:
- // Build a format string so that it will be similar to Sprint
- log.intLogf(lvl, fmt.Sprint(arg0)+strings.Repeat(" %v", len(args)), args...)
- }
-}
-
-// Info logs a message at the info log level.
-// See Debug for an explanation of the arguments.
-func (log Logger) Info(arg0 interface{}, args ...interface{}) {
- const (
- lvl = INFO
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- log.intLogf(lvl, first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- log.intLogc(lvl, first)
- default:
- // Build a format string so that it will be similar to Sprint
- log.intLogf(lvl, fmt.Sprint(arg0)+strings.Repeat(" %v", len(args)), args...)
- }
-}
-
-// Warn logs a message at the warning log level and returns the formatted error.
-// At the warning level and higher, there is no performance benefit if the
-// message is not actually logged, because all formats are processed and all
-// closures are executed to format the error message.
-// See Debug for further explanation of the arguments.
-func (log Logger) Warn(arg0 interface{}, args ...interface{}) error {
- const (
- lvl = WARNING
- )
- var msg string
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- msg = fmt.Sprintf(first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- msg = first()
- default:
- // Build a format string so that it will be similar to Sprint
- msg = fmt.Sprintf(fmt.Sprint(first)+strings.Repeat(" %v", len(args)), args...)
- }
- log.intLogf(lvl, msg)
- return errors.New(msg)
-}
-
-// Error logs a message at the error log level and returns the formatted error,
-// See Warn for an explanation of the performance and Debug for an explanation
-// of the parameters.
-func (log Logger) Error(arg0 interface{}, args ...interface{}) error {
- const (
- lvl = ERROR
- )
- var msg string
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- msg = fmt.Sprintf(first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- msg = first()
- default:
- // Build a format string so that it will be similar to Sprint
- msg = fmt.Sprintf(fmt.Sprint(first)+strings.Repeat(" %v", len(args)), args...)
- }
- log.intLogf(lvl, msg)
- return errors.New(msg)
-}
-
-// Critical logs a message at the critical log level and returns the formatted error,
-// See Warn for an explanation of the performance and Debug for an explanation
-// of the parameters.
-func (log Logger) Critical(arg0 interface{}, args ...interface{}) error {
- const (
- lvl = CRITICAL
- )
- var msg string
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- msg = fmt.Sprintf(first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- msg = first()
- default:
- // Build a format string so that it will be similar to Sprint
- msg = fmt.Sprintf(fmt.Sprint(first)+strings.Repeat(" %v", len(args)), args...)
- }
- log.intLogf(lvl, msg)
- return errors.New(msg)
-}
diff --git a/Godeps/_workspace/src/github.com/alecthomas/log4go/pattlog.go b/Godeps/_workspace/src/github.com/alecthomas/log4go/pattlog.go
deleted file mode 100644
index 82b4e36b1..000000000
--- a/Godeps/_workspace/src/github.com/alecthomas/log4go/pattlog.go
+++ /dev/null
@@ -1,126 +0,0 @@
-// Copyright (C) 2010, Kyle Lemons <kyle@kylelemons.net>. All rights reserved.
-
-package log4go
-
-import (
- "bytes"
- "fmt"
- "io"
- "strings"
-)
-
-const (
- FORMAT_DEFAULT = "[%D %T] [%L] (%S) %M"
- FORMAT_SHORT = "[%t %d] [%L] %M"
- FORMAT_ABBREV = "[%L] %M"
-)
-
-type formatCacheType struct {
- LastUpdateSeconds int64
- shortTime, shortDate string
- longTime, longDate string
-}
-
-var formatCache = &formatCacheType{}
-
-// Known format codes:
-// %T - Time (15:04:05 MST)
-// %t - Time (15:04)
-// %D - Date (2006/01/02)
-// %d - Date (01/02/06)
-// %L - Level (FNST, FINE, DEBG, TRAC, WARN, EROR, CRIT)
-// %S - Source
-// %M - Message
-// Ignores unknown formats
-// Recommended: "[%D %T] [%L] (%S) %M"
-func FormatLogRecord(format string, rec *LogRecord) string {
- if rec == nil {
- return "<nil>"
- }
- if len(format) == 0 {
- return ""
- }
-
- out := bytes.NewBuffer(make([]byte, 0, 64))
- secs := rec.Created.UnixNano() / 1e9
-
- cache := *formatCache
- if cache.LastUpdateSeconds != secs {
- month, day, year := rec.Created.Month(), rec.Created.Day(), rec.Created.Year()
- hour, minute, second := rec.Created.Hour(), rec.Created.Minute(), rec.Created.Second()
- zone, _ := rec.Created.Zone()
- updated := &formatCacheType{
- LastUpdateSeconds: secs,
- shortTime: fmt.Sprintf("%02d:%02d", hour, minute),
- shortDate: fmt.Sprintf("%02d/%02d/%02d", day, month, year%100),
- longTime: fmt.Sprintf("%02d:%02d:%02d %s", hour, minute, second, zone),
- longDate: fmt.Sprintf("%04d/%02d/%02d", year, month, day),
- }
- cache = *updated
- formatCache = updated
- }
-
- // Split the string into pieces by % signs
- pieces := bytes.Split([]byte(format), []byte{'%'})
-
- // Iterate over the pieces, replacing known formats
- for i, piece := range pieces {
- if i > 0 && len(piece) > 0 {
- switch piece[0] {
- case 'T':
- out.WriteString(cache.longTime)
- case 't':
- out.WriteString(cache.shortTime)
- case 'D':
- out.WriteString(cache.longDate)
- case 'd':
- out.WriteString(cache.shortDate)
- case 'L':
- out.WriteString(levelStrings[rec.Level])
- case 'S':
- out.WriteString(rec.Source)
- case 's':
- slice := strings.Split(rec.Source, "/")
- out.WriteString(slice[len(slice)-1])
- case 'M':
- out.WriteString(rec.Message)
- }
- if len(piece) > 1 {
- out.Write(piece[1:])
- }
- } else if len(piece) > 0 {
- out.Write(piece)
- }
- }
- out.WriteByte('\n')
-
- return out.String()
-}
-
-// This is the standard writer that prints to standard output.
-type FormatLogWriter chan *LogRecord
-
-// This creates a new FormatLogWriter
-func NewFormatLogWriter(out io.Writer, format string) FormatLogWriter {
- records := make(FormatLogWriter, LogBufferLength)
- go records.run(out, format)
- return records
-}
-
-func (w FormatLogWriter) run(out io.Writer, format string) {
- for rec := range w {
- fmt.Fprint(out, FormatLogRecord(format, rec))
- }
-}
-
-// This is the FormatLogWriter's output method. This will block if the output
-// buffer is full.
-func (w FormatLogWriter) LogWrite(rec *LogRecord) {
- w <- rec
-}
-
-// Close stops the logger from sending messages to standard output. Attempts to
-// send log messages to this logger after a Close have undefined behavior.
-func (w FormatLogWriter) Close() {
- close(w)
-}
diff --git a/Godeps/_workspace/src/github.com/alecthomas/log4go/socklog.go b/Godeps/_workspace/src/github.com/alecthomas/log4go/socklog.go
deleted file mode 100644
index 1d224a99d..000000000
--- a/Godeps/_workspace/src/github.com/alecthomas/log4go/socklog.go
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (C) 2010, Kyle Lemons <kyle@kylelemons.net>. All rights reserved.
-
-package log4go
-
-import (
- "encoding/json"
- "fmt"
- "net"
- "os"
-)
-
-// This log writer sends output to a socket
-type SocketLogWriter chan *LogRecord
-
-// This is the SocketLogWriter's output method
-func (w SocketLogWriter) LogWrite(rec *LogRecord) {
- w <- rec
-}
-
-func (w SocketLogWriter) Close() {
- close(w)
-}
-
-func NewSocketLogWriter(proto, hostport string) SocketLogWriter {
- sock, err := net.Dial(proto, hostport)
- if err != nil {
- fmt.Fprintf(os.Stderr, "NewSocketLogWriter(%q): %s\n", hostport, err)
- return nil
- }
-
- w := SocketLogWriter(make(chan *LogRecord, LogBufferLength))
-
- go func() {
- defer func() {
- if sock != nil && proto == "tcp" {
- sock.Close()
- }
- }()
-
- for rec := range w {
- // Marshall into JSON
- js, err := json.Marshal(rec)
- if err != nil {
- fmt.Fprint(os.Stderr, "SocketLogWriter(%q): %s", hostport, err)
- return
- }
-
- _, err = sock.Write(js)
- if err != nil {
- fmt.Fprint(os.Stderr, "SocketLogWriter(%q): %s", hostport, err)
- return
- }
- }
- }()
-
- return w
-}
diff --git a/Godeps/_workspace/src/github.com/alecthomas/log4go/termlog.go b/Godeps/_workspace/src/github.com/alecthomas/log4go/termlog.go
deleted file mode 100644
index 8a941e269..000000000
--- a/Godeps/_workspace/src/github.com/alecthomas/log4go/termlog.go
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (C) 2010, Kyle Lemons <kyle@kylelemons.net>. All rights reserved.
-
-package log4go
-
-import (
- "fmt"
- "io"
- "os"
- "time"
-)
-
-var stdout io.Writer = os.Stdout
-
-// This is the standard writer that prints to standard output.
-type ConsoleLogWriter struct {
- format string
- w chan *LogRecord
-}
-
-// This creates a new ConsoleLogWriter
-func NewConsoleLogWriter() *ConsoleLogWriter {
- consoleWriter := &ConsoleLogWriter{
- format: "[%T %D] [%L] (%S) %M",
- w: make(chan *LogRecord, LogBufferLength),
- }
- go consoleWriter.run(stdout)
- return consoleWriter
-}
-func (c *ConsoleLogWriter) SetFormat(format string) {
- c.format = format
-}
-func (c *ConsoleLogWriter) run(out io.Writer) {
- for rec := range c.w {
- fmt.Fprint(out, FormatLogRecord(c.format, rec))
- }
-}
-
-// This is the ConsoleLogWriter's output method. This will block if the output
-// buffer is full.
-func (c *ConsoleLogWriter) LogWrite(rec *LogRecord) {
- c.w <- rec
-}
-
-// Close stops the logger from sending messages to standard output. Attempts to
-// send log messages to this logger after a Close have undefined behavior.
-func (c *ConsoleLogWriter) Close() {
- close(c.w)
- time.Sleep(50 * time.Millisecond) // Try to give console I/O time to complete
-}
diff --git a/Godeps/_workspace/src/github.com/alecthomas/log4go/wrapper.go b/Godeps/_workspace/src/github.com/alecthomas/log4go/wrapper.go
deleted file mode 100644
index 2ae222b0c..000000000
--- a/Godeps/_workspace/src/github.com/alecthomas/log4go/wrapper.go
+++ /dev/null
@@ -1,278 +0,0 @@
-// Copyright (C) 2010, Kyle Lemons <kyle@kylelemons.net>. All rights reserved.
-
-package log4go
-
-import (
- "errors"
- "fmt"
- "os"
- "strings"
-)
-
-var (
- Global Logger
-)
-
-func init() {
- Global = NewDefaultLogger(DEBUG)
-}
-
-// Wrapper for (*Logger).LoadConfiguration
-func LoadConfiguration(filename string) {
- Global.LoadConfiguration(filename)
-}
-
-// Wrapper for (*Logger).AddFilter
-func AddFilter(name string, lvl Level, writer LogWriter) {
- Global.AddFilter(name, lvl, writer)
-}
-
-// Wrapper for (*Logger).Close (closes and removes all logwriters)
-func Close() {
- Global.Close()
-}
-
-func Crash(args ...interface{}) {
- if len(args) > 0 {
- Global.intLogf(CRITICAL, strings.Repeat(" %v", len(args))[1:], args...)
- }
- panic(args)
-}
-
-// Logs the given message and crashes the program
-func Crashf(format string, args ...interface{}) {
- Global.intLogf(CRITICAL, format, args...)
- Global.Close() // so that hopefully the messages get logged
- panic(fmt.Sprintf(format, args...))
-}
-
-// Compatibility with `log`
-func Exit(args ...interface{}) {
- if len(args) > 0 {
- Global.intLogf(ERROR, strings.Repeat(" %v", len(args))[1:], args...)
- }
- Global.Close() // so that hopefully the messages get logged
- os.Exit(0)
-}
-
-// Compatibility with `log`
-func Exitf(format string, args ...interface{}) {
- Global.intLogf(ERROR, format, args...)
- Global.Close() // so that hopefully the messages get logged
- os.Exit(0)
-}
-
-// Compatibility with `log`
-func Stderr(args ...interface{}) {
- if len(args) > 0 {
- Global.intLogf(ERROR, strings.Repeat(" %v", len(args))[1:], args...)
- }
-}
-
-// Compatibility with `log`
-func Stderrf(format string, args ...interface{}) {
- Global.intLogf(ERROR, format, args...)
-}
-
-// Compatibility with `log`
-func Stdout(args ...interface{}) {
- if len(args) > 0 {
- Global.intLogf(INFO, strings.Repeat(" %v", len(args))[1:], args...)
- }
-}
-
-// Compatibility with `log`
-func Stdoutf(format string, args ...interface{}) {
- Global.intLogf(INFO, format, args...)
-}
-
-// Send a log message manually
-// Wrapper for (*Logger).Log
-func Log(lvl Level, source, message string) {
- Global.Log(lvl, source, message)
-}
-
-// Send a formatted log message easily
-// Wrapper for (*Logger).Logf
-func Logf(lvl Level, format string, args ...interface{}) {
- Global.intLogf(lvl, format, args...)
-}
-
-// Send a closure log message
-// Wrapper for (*Logger).Logc
-func Logc(lvl Level, closure func() string) {
- Global.intLogc(lvl, closure)
-}
-
-// Utility for finest log messages (see Debug() for parameter explanation)
-// Wrapper for (*Logger).Finest
-func Finest(arg0 interface{}, args ...interface{}) {
- const (
- lvl = FINEST
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- Global.intLogf(lvl, first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- Global.intLogc(lvl, first)
- default:
- // Build a format string so that it will be similar to Sprint
- Global.intLogf(lvl, fmt.Sprint(arg0)+strings.Repeat(" %v", len(args)), args...)
- }
-}
-
-// Utility for fine log messages (see Debug() for parameter explanation)
-// Wrapper for (*Logger).Fine
-func Fine(arg0 interface{}, args ...interface{}) {
- const (
- lvl = FINE
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- Global.intLogf(lvl, first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- Global.intLogc(lvl, first)
- default:
- // Build a format string so that it will be similar to Sprint
- Global.intLogf(lvl, fmt.Sprint(arg0)+strings.Repeat(" %v", len(args)), args...)
- }
-}
-
-// Utility for debug log messages
-// When given a string as the first argument, this behaves like Logf but with the DEBUG log level (e.g. the first argument is interpreted as a format for the latter arguments)
-// When given a closure of type func()string, this logs the string returned by the closure iff it will be logged. The closure runs at most one time.
-// When given anything else, the log message will be each of the arguments formatted with %v and separated by spaces (ala Sprint).
-// Wrapper for (*Logger).Debug
-func Debug(arg0 interface{}, args ...interface{}) {
- const (
- lvl = DEBUG
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- Global.intLogf(lvl, first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- Global.intLogc(lvl, first)
- default:
- // Build a format string so that it will be similar to Sprint
- Global.intLogf(lvl, fmt.Sprint(arg0)+strings.Repeat(" %v", len(args)), args...)
- }
-}
-
-// Utility for trace log messages (see Debug() for parameter explanation)
-// Wrapper for (*Logger).Trace
-func Trace(arg0 interface{}, args ...interface{}) {
- const (
- lvl = TRACE
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- Global.intLogf(lvl, first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- Global.intLogc(lvl, first)
- default:
- // Build a format string so that it will be similar to Sprint
- Global.intLogf(lvl, fmt.Sprint(arg0)+strings.Repeat(" %v", len(args)), args...)
- }
-}
-
-// Utility for info log messages (see Debug() for parameter explanation)
-// Wrapper for (*Logger).Info
-func Info(arg0 interface{}, args ...interface{}) {
- const (
- lvl = INFO
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- Global.intLogf(lvl, first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- Global.intLogc(lvl, first)
- default:
- // Build a format string so that it will be similar to Sprint
- Global.intLogf(lvl, fmt.Sprint(arg0)+strings.Repeat(" %v", len(args)), args...)
- }
-}
-
-// Utility for warn log messages (returns an error for easy function returns) (see Debug() for parameter explanation)
-// These functions will execute a closure exactly once, to build the error message for the return
-// Wrapper for (*Logger).Warn
-func Warn(arg0 interface{}, args ...interface{}) error {
- const (
- lvl = WARNING
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- Global.intLogf(lvl, first, args...)
- return errors.New(fmt.Sprintf(first, args...))
- case func() string:
- // Log the closure (no other arguments used)
- str := first()
- Global.intLogf(lvl, "%s", str)
- return errors.New(str)
- default:
- // Build a format string so that it will be similar to Sprint
- Global.intLogf(lvl, fmt.Sprint(first)+strings.Repeat(" %v", len(args)), args...)
- return errors.New(fmt.Sprint(first) + fmt.Sprintf(strings.Repeat(" %v", len(args)), args...))
- }
- return nil
-}
-
-// Utility for error log messages (returns an error for easy function returns) (see Debug() for parameter explanation)
-// These functions will execute a closure exactly once, to build the error message for the return
-// Wrapper for (*Logger).Error
-func Error(arg0 interface{}, args ...interface{}) error {
- const (
- lvl = ERROR
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- Global.intLogf(lvl, first, args...)
- return errors.New(fmt.Sprintf(first, args...))
- case func() string:
- // Log the closure (no other arguments used)
- str := first()
- Global.intLogf(lvl, "%s", str)
- return errors.New(str)
- default:
- // Build a format string so that it will be similar to Sprint
- Global.intLogf(lvl, fmt.Sprint(first)+strings.Repeat(" %v", len(args)), args...)
- return errors.New(fmt.Sprint(first) + fmt.Sprintf(strings.Repeat(" %v", len(args)), args...))
- }
- return nil
-}
-
-// Utility for critical log messages (returns an error for easy function returns) (see Debug() for parameter explanation)
-// These functions will execute a closure exactly once, to build the error message for the return
-// Wrapper for (*Logger).Critical
-func Critical(arg0 interface{}, args ...interface{}) error {
- const (
- lvl = CRITICAL
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- Global.intLogf(lvl, first, args...)
- return errors.New(fmt.Sprintf(first, args...))
- case func() string:
- // Log the closure (no other arguments used)
- str := first()
- Global.intLogf(lvl, "%s", str)
- return errors.New(str)
- default:
- // Build a format string so that it will be similar to Sprint
- Global.intLogf(lvl, fmt.Sprint(first)+strings.Repeat(" %v", len(args)), args...)
- return errors.New(fmt.Sprint(first) + fmt.Sprintf(strings.Repeat(" %v", len(args)), args...))
- }
- return nil
-}
diff --git a/Godeps/_workspace/src/github.com/braintree/manners/LICENSE b/Godeps/_workspace/src/github.com/braintree/manners/LICENSE
deleted file mode 100644
index 91ef5beed..000000000
--- a/Godeps/_workspace/src/github.com/braintree/manners/LICENSE
+++ /dev/null
@@ -1,19 +0,0 @@
-Copyright (c) 2014 Braintree, a division of PayPal, Inc.
-
-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.
diff --git a/Godeps/_workspace/src/github.com/braintree/manners/README.md b/Godeps/_workspace/src/github.com/braintree/manners/README.md
deleted file mode 100644
index 09f6f9693..000000000
--- a/Godeps/_workspace/src/github.com/braintree/manners/README.md
+++ /dev/null
@@ -1,36 +0,0 @@
-# Manners
-
-A *polite* webserver for Go.
-
-Manners allows you to shut your Go webserver down gracefully, without dropping any requests. It can act as a drop-in replacement for the standard library's http.ListenAndServe function:
-
-```go
-func main() {
- handler := MyHTTPHandler()
- manners.ListenAndServe(":7000", handler)
-}
-```
-
-Then, when you want to shut the server down:
-
-```go
-manners.Close()
-```
-
-(Note that this does not block until all the requests are finished. Rather, the call to manners.ListenAndServe will stop blocking when all the requests are finished.)
-
-Manners ensures that all requests are served by incrementing a WaitGroup when a request comes in and decrementing it when the request finishes.
-
-If your request handler spawns Goroutines that are not guaranteed to finish with the request, you can ensure they are also completed with the `StartRoutine` and `FinishRoutine` functions on the server.
-
-### Known Issues
-
-Manners does not correctly shut down long-lived keepalive connections when issued a shutdown command. Clients on an idle keepalive connection may see a connection reset error rather than a close. See https://github.com/braintree/manners/issues/13 for details.
-
-### Compatability
-
-Manners 0.3.0 and above uses standard library functionality introduced in Go 1.3.
-
-### Installation
-
-`go get github.com/braintree/manners`
diff --git a/Godeps/_workspace/src/github.com/braintree/manners/interfaces.go b/Godeps/_workspace/src/github.com/braintree/manners/interfaces.go
deleted file mode 100644
index fd0732857..000000000
--- a/Godeps/_workspace/src/github.com/braintree/manners/interfaces.go
+++ /dev/null
@@ -1,7 +0,0 @@
-package manners
-
-type waitGroup interface {
- Add(int)
- Done()
- Wait()
-}
diff --git a/Godeps/_workspace/src/github.com/braintree/manners/server.go b/Godeps/_workspace/src/github.com/braintree/manners/server.go
deleted file mode 100644
index e45f5c64b..000000000
--- a/Godeps/_workspace/src/github.com/braintree/manners/server.go
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
-Package manners provides a wrapper for a standard net/http server that
-ensures all active HTTP client have completed their current request
-before the server shuts down.
-
-It can be used a drop-in replacement for the standard http package,
-or can wrap a pre-configured Server.
-
-eg.
-
- http.Handle("/hello", func(w http.ResponseWriter, r *http.Request) {
- w.Write([]byte("Hello\n"))
- })
-
- log.Fatal(manners.ListenAndServe(":8080", nil))
-
-or for a customized server:
-
- s := manners.NewWithServer(&http.Server{
- Addr: ":8080",
- Handler: myHandler,
- ReadTimeout: 10 * time.Second,
- WriteTimeout: 10 * time.Second,
- MaxHeaderBytes: 1 << 20,
- })
- log.Fatal(s.ListenAndServe())
-
-The server will shut down cleanly when the Close() method is called:
-
- go func() {
- sigchan := make(chan os.Signal, 1)
- signal.Notify(sigchan, os.Interrupt, os.Kill)
- <-sigchan
- log.Info("Shutting down...")
- manners.Close()
- }()
-
- http.Handle("/hello", myHandler)
- log.Fatal(manners.ListenAndServe(":8080", nil))
-*/
-package manners
-
-import (
- "crypto/tls"
- "net"
- "net/http"
- "sync"
- "sync/atomic"
-)
-
-// A GracefulServer maintains a WaitGroup that counts how many in-flight
-// requests the server is handling. When it receives a shutdown signal,
-// it stops accepting new requests but does not actually shut down until
-// all in-flight requests terminate.
-//
-// GracefulServer embeds the underlying net/http.Server making its non-override
-// methods and properties avaiable.
-//
-// It must be initialized by calling NewWithServer.
-type GracefulServer struct {
- *http.Server
-
- shutdown chan bool
- shutdownFinished chan bool
- wg waitGroup
-
- lcsmu sync.RWMutex
- connections map[net.Conn]bool
-
- up chan net.Listener // Only used by test code.
-}
-
-// NewWithServer wraps an existing http.Server object and returns a
-// GracefulServer that supports all of the original Server operations.
-func NewWithServer(s *http.Server) *GracefulServer {
- return &GracefulServer{
- Server: s,
- shutdown: make(chan bool),
- shutdownFinished: make(chan bool, 1),
- wg: new(sync.WaitGroup),
- connections: make(map[net.Conn]bool),
- }
-}
-
-// Close stops the server from accepting new requets and begins shutting down.
-// It returns true if it's the first time Close is called.
-func (s *GracefulServer) Close() bool {
- return <-s.shutdown
-}
-
-// BlockingClose is similar to Close, except that it blocks until the last
-// connection has been closed.
-func (s *GracefulServer) BlockingClose() bool {
- result := s.Close()
- <-s.shutdownFinished
- return result
-}
-
-// ListenAndServe provides a graceful equivalent of net/http.Serve.ListenAndServe.
-func (s *GracefulServer) ListenAndServe() error {
- addr := s.Addr
- if addr == "" {
- addr = ":http"
- }
- listener, err := net.Listen("tcp", addr)
- if err != nil {
- return err
- }
-
- return s.Serve(listener)
-}
-
-// ListenAndServeTLS provides a graceful equivalent of net/http.Serve.ListenAndServeTLS.
-func (s *GracefulServer) ListenAndServeTLS(certFile, keyFile string) error {
- // direct lift from net/http/server.go
- addr := s.Addr
- if addr == "" {
- addr = ":https"
- }
- config := &tls.Config{}
- if s.TLSConfig != nil {
- *config = *s.TLSConfig
- }
- if config.NextProtos == nil {
- config.NextProtos = []string{"http/1.1"}
- }
-
- var err error
- config.Certificates = make([]tls.Certificate, 1)
- config.Certificates[0], err = tls.LoadX509KeyPair(certFile, keyFile)
- if err != nil {
- return err
- }
-
- ln, err := net.Listen("tcp", addr)
- if err != nil {
- return err
- }
-
- return s.Serve(tls.NewListener(ln, config))
-}
-
-// Serve provides a graceful equivalent net/http.Server.Serve.
-func (s *GracefulServer) Serve(listener net.Listener) error {
- // Wrap the server HTTP handler into graceful one, that will close kept
- // alive connections if a new request is received after shutdown.
- gracefulHandler := newGracefulHandler(s.Server.Handler)
- s.Server.Handler = gracefulHandler
-
- // Start a goroutine that waits for a shutdown signal and will stop the
- // listener when it receives the signal. That in turn will result in
- // unblocking of the http.Serve call.
- go func() {
- s.shutdown <- true
- close(s.shutdown)
- gracefulHandler.Close()
- s.Server.SetKeepAlivesEnabled(false)
- listener.Close()
- }()
-
- originalConnState := s.Server.ConnState
-
- // s.ConnState is invoked by the net/http.Server every time a connection
- // changes state. It keeps track of each connection's state over time,
- // enabling manners to handle persisted connections correctly.
- s.ConnState = func(conn net.Conn, newState http.ConnState) {
- s.lcsmu.RLock()
- protected := s.connections[conn]
- s.lcsmu.RUnlock()
-
- switch newState {
-
- case http.StateNew:
- // New connection -> StateNew
- protected = true
- s.StartRoutine()
-
- case http.StateActive:
- // (StateNew, StateIdle) -> StateActive
- if gracefulHandler.IsClosed() {
- conn.Close()
- break
- }
-
- if !protected {
- protected = true
- s.StartRoutine()
- }
-
- default:
- // (StateNew, StateActive) -> (StateIdle, StateClosed, StateHiJacked)
- if protected {
- s.FinishRoutine()
- protected = false
- }
- }
-
- s.lcsmu.Lock()
- if newState == http.StateClosed || newState == http.StateHijacked {
- delete(s.connections, conn)
- } else {
- s.connections[conn] = protected
- }
- s.lcsmu.Unlock()
-
- if originalConnState != nil {
- originalConnState(conn, newState)
- }
- }
-
- // A hook to allow the server to notify others when it is ready to receive
- // requests; only used by tests.
- if s.up != nil {
- s.up <- listener
- }
-
- err := s.Server.Serve(listener)
- // An error returned on shutdown is not worth reporting.
- if err != nil && gracefulHandler.IsClosed() {
- err = nil
- }
-
- // Wait for pending requests to complete regardless the Serve result.
- s.wg.Wait()
- s.shutdownFinished <- true
- return err
-}
-
-// StartRoutine increments the server's WaitGroup. Use this if a web request
-// starts more goroutines and these goroutines are not guaranteed to finish
-// before the request.
-func (s *GracefulServer) StartRoutine() {
- s.wg.Add(1)
-}
-
-// FinishRoutine decrements the server's WaitGroup. Use this to complement
-// StartRoutine().
-func (s *GracefulServer) FinishRoutine() {
- s.wg.Done()
-}
-
-// gracefulHandler is used by GracefulServer to prevent calling ServeHTTP on
-// to be closed kept-alive connections during the server shutdown.
-type gracefulHandler struct {
- closed int32 // accessed atomically.
- wrapped http.Handler
-}
-
-func newGracefulHandler(wrapped http.Handler) *gracefulHandler {
- return &gracefulHandler{
- wrapped: wrapped,
- }
-}
-
-func (gh *gracefulHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- if atomic.LoadInt32(&gh.closed) == 0 {
- gh.wrapped.ServeHTTP(w, r)
- return
- }
- r.Body.Close()
- // Server is shutting down at this moment, and the connection that this
- // handler is being called on is about to be closed. So we do not need to
- // actually execute the handler logic.
-}
-
-func (gh *gracefulHandler) Close() {
- atomic.StoreInt32(&gh.closed, 1)
-}
-
-func (gh *gracefulHandler) IsClosed() bool {
- return atomic.LoadInt32(&gh.closed) == 1
-}
diff --git a/Godeps/_workspace/src/github.com/braintree/manners/static.go b/Godeps/_workspace/src/github.com/braintree/manners/static.go
deleted file mode 100644
index 2a74b094b..000000000
--- a/Godeps/_workspace/src/github.com/braintree/manners/static.go
+++ /dev/null
@@ -1,35 +0,0 @@
-package manners
-
-import (
- "net"
- "net/http"
-)
-
-var defaultServer *GracefulServer
-
-// ListenAndServe provides a graceful version of the function provided by the
-// net/http package. Call Close() to stop the server.
-func ListenAndServe(addr string, handler http.Handler) error {
- defaultServer = NewWithServer(&http.Server{Addr: addr, Handler: handler})
- return defaultServer.ListenAndServe()
-}
-
-// ListenAndServeTLS provides a graceful version of the function provided by the
-// net/http package. Call Close() to stop the server.
-func ListenAndServeTLS(addr string, certFile string, keyFile string, handler http.Handler) error {
- defaultServer = NewWithServer(&http.Server{Addr: addr, Handler: handler})
- return defaultServer.ListenAndServeTLS(certFile, keyFile)
-}
-
-// Serve provides a graceful version of the function provided by the net/http
-// package. Call Close() to stop the server.
-func Serve(l net.Listener, handler http.Handler) error {
- defaultServer = NewWithServer(&http.Server{Handler: handler})
- return defaultServer.Serve(l)
-}
-
-// Shuts down the default server used by ListenAndServe, ListenAndServeTLS and
-// Serve. It returns true if it's the first time Close is called.
-func Close() bool {
- return defaultServer.Close()
-}
diff --git a/Godeps/_workspace/src/github.com/braintree/manners/test_helpers/certs.go b/Godeps/_workspace/src/github.com/braintree/manners/test_helpers/certs.go
deleted file mode 100644
index ede248b3d..000000000
--- a/Godeps/_workspace/src/github.com/braintree/manners/test_helpers/certs.go
+++ /dev/null
@@ -1,29 +0,0 @@
-package test_helpers
-
-// A PEM-encoded TLS cert with SAN IPs "127.0.0.1" and "[::1]", expiring at the
-// last second of 2049 (the end of ASN.1 time).
-
-// generated from src/pkg/crypto/tls:
-// go run generate_cert.go --rsa-bits 512 --host 127.0.0.1,::1,example.com --ca --start-date "Jan 1 00:00:00 1970" --duration=1000000h
-var (
- Cert = []byte(`-----BEGIN CERTIFICATE-----
-MIIBdzCCASOgAwIBAgIBADALBgkqhkiG9w0BAQUwEjEQMA4GA1UEChMHQWNtZSBD
-bzAeFw03MDAxMDEwMDAwMDBaFw00OTEyMzEyMzU5NTlaMBIxEDAOBgNVBAoTB0Fj
-bWUgQ28wWjALBgkqhkiG9w0BAQEDSwAwSAJBAN55NcYKZeInyTuhcCwFMhDHCmwa
-IUSdtXdcbItRB/yfXGBhiex00IaLXQnSU+QZPRZWYqeTEbFSgihqi1PUDy8CAwEA
-AaNoMGYwDgYDVR0PAQH/BAQDAgCkMBMGA1UdJQQMMAoGCCsGAQUFBwMBMA8GA1Ud
-EwEB/wQFMAMBAf8wLgYDVR0RBCcwJYILZXhhbXBsZS5jb22HBH8AAAGHEAAAAAAA
-AAAAAAAAAAAAAAEwCwYJKoZIhvcNAQEFA0EAAoQn/ytgqpiLcZu9XKbCJsJcvkgk
-Se6AbGXgSlq+ZCEVo0qIwSgeBqmsJxUu7NCSOwVJLYNEBO2DtIxoYVk+MA==
------END CERTIFICATE-----`)
-
- Key = []byte(`-----BEGIN RSA PRIVATE KEY-----
-MIIBPAIBAAJBAN55NcYKZeInyTuhcCwFMhDHCmwaIUSdtXdcbItRB/yfXGBhiex0
-0IaLXQnSU+QZPRZWYqeTEbFSgihqi1PUDy8CAwEAAQJBAQdUx66rfh8sYsgfdcvV
-NoafYpnEcB5s4m/vSVe6SU7dCK6eYec9f9wpT353ljhDUHq3EbmE4foNzJngh35d
-AekCIQDhRQG5Li0Wj8TM4obOnnXUXf1jRv0UkzE9AHWLG5q3AwIhAPzSjpYUDjVW
-MCUXgckTpKCuGwbJk7424Nb8bLzf3kllAiA5mUBgjfr/WtFSJdWcPQ4Zt9KTMNKD
-EUO0ukpTwEIl6wIhAMbGqZK3zAAFdq8DD2jPx+UJXnh0rnOkZBzDtJ6/iN69AiEA
-1Aq8MJgTaYsDQWyU/hDq5YkDJc9e9DSCvUIzqxQWMQE=
------END RSA PRIVATE KEY-----`)
-)
diff --git a/Godeps/_workspace/src/github.com/braintree/manners/test_helpers/conn.go b/Godeps/_workspace/src/github.com/braintree/manners/test_helpers/conn.go
deleted file mode 100644
index 8c610f58e..000000000
--- a/Godeps/_workspace/src/github.com/braintree/manners/test_helpers/conn.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package test_helpers
-
-import "net"
-
-type Conn struct {
- net.Conn
- CloseCalled bool
-}
-
-func (c *Conn) Close() error {
- c.CloseCalled = true
- return nil
-}
diff --git a/Godeps/_workspace/src/github.com/braintree/manners/test_helpers/listener.go b/Godeps/_workspace/src/github.com/braintree/manners/test_helpers/listener.go
deleted file mode 100644
index e3af35a6e..000000000
--- a/Godeps/_workspace/src/github.com/braintree/manners/test_helpers/listener.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package test_helpers
-
-import (
- "errors"
- "net"
-)
-
-type Listener struct {
- AcceptRelease chan bool
- CloseCalled chan bool
-}
-
-func NewListener() *Listener {
- return &Listener{
- make(chan bool, 1),
- make(chan bool, 1),
- }
-}
-
-func (l *Listener) Addr() net.Addr {
- addr, _ := net.ResolveTCPAddr("tcp", "127.0.0.1:8080")
- return addr
-}
-
-func (l *Listener) Close() error {
- l.CloseCalled <- true
- l.AcceptRelease <- true
- return nil
-}
-
-func (l *Listener) Accept() (net.Conn, error) {
- <-l.AcceptRelease
- return nil, errors.New("connection closed")
-}
diff --git a/Godeps/_workspace/src/github.com/braintree/manners/test_helpers/temp_file.go b/Godeps/_workspace/src/github.com/braintree/manners/test_helpers/temp_file.go
deleted file mode 100644
index c4aa263a0..000000000
--- a/Godeps/_workspace/src/github.com/braintree/manners/test_helpers/temp_file.go
+++ /dev/null
@@ -1,27 +0,0 @@
-package test_helpers
-
-import (
- "io/ioutil"
- "os"
-)
-
-type TempFile struct {
- *os.File
-}
-
-func NewTempFile(content []byte) (*TempFile, error) {
- f, err := ioutil.TempFile("", "graceful-test")
- if err != nil {
- return nil, err
- }
-
- f.Write(content)
- return &TempFile{f}, nil
-}
-
-func (tf *TempFile) Unlink() {
- if tf.File != nil {
- os.Remove(tf.Name())
- tf.File = nil
- }
-}
diff --git a/Godeps/_workspace/src/github.com/braintree/manners/test_helpers/wait_group.go b/Godeps/_workspace/src/github.com/braintree/manners/test_helpers/wait_group.go
deleted file mode 100644
index 1df590db7..000000000
--- a/Godeps/_workspace/src/github.com/braintree/manners/test_helpers/wait_group.go
+++ /dev/null
@@ -1,33 +0,0 @@
-package test_helpers
-
-import "sync"
-
-type WaitGroup struct {
- sync.Mutex
- Count int
- WaitCalled chan int
-}
-
-func NewWaitGroup() *WaitGroup {
- return &WaitGroup{
- WaitCalled: make(chan int, 1),
- }
-}
-
-func (wg *WaitGroup) Add(delta int) {
- wg.Lock()
- wg.Count++
- wg.Unlock()
-}
-
-func (wg *WaitGroup) Done() {
- wg.Lock()
- wg.Count--
- wg.Unlock()
-}
-
-func (wg *WaitGroup) Wait() {
- wg.Lock()
- wg.WaitCalled <- wg.Count
- wg.Unlock()
-}
diff --git a/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/.travis.yml b/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/.travis.yml
deleted file mode 100644
index b19c2e535..000000000
--- a/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/.travis.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-language: go
-go:
- - 1.2
-before_install:
-- go get github.com/onsi/ginkgo/...
-- go get github.com/onsi/gomega/...
-- go install github.com/onsi/ginkgo/ginkgo
-script: PATH=$PATH:$HOME/gopath/bin ginkgo -r .
-branches:
- only:
- - master
diff --git a/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/LICENSE b/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/LICENSE
deleted file mode 100644
index 915b20892..000000000
--- a/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
-Copyright 2014 Pivotal
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/README.md b/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/README.md
deleted file mode 100644
index d696eb6b6..000000000
--- a/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/README.md
+++ /dev/null
@@ -1,44 +0,0 @@
-# Jibber Jabber [![Build Status](https://travis-ci.org/cloudfoundry/jibber_jabber.svg?branch=master)](https://travis-ci.org/cloudfoundry/jibber_jabber)
-Jibber Jabber is a GoLang Library that can be used to detect an operating system's current language.
-
-### OS Support
-
-OSX and Linux via the `LC_ALL` and `LANG` environment variables. These are standard variables that are used in ALL versions of UNIX for language detection.
-
-Windows via [GetUserDefaultLocaleName](http://msdn.microsoft.com/en-us/library/windows/desktop/dd318136.aspx) and [GetSystemDefaultLocaleName](http://msdn.microsoft.com/en-us/library/windows/desktop/dd318122.aspx) system calls. These calls are supported in Windows Vista and up.
-
-# Usage
-Add the following line to your go `import`:
-
-```
- "github.com/cloudfoundry/jibber_jabber"
-```
-
-### DetectIETF
-`DetectIETF` will return the current locale as a string. The format of the locale will be the [ISO 639](http://en.wikipedia.org/wiki/ISO_639) two-letter language code, a DASH, then an [ISO 3166](http://en.wikipedia.org/wiki/ISO_3166-1) two-letter country code.
-
-```
- userLocale, err := jibber_jabber.DetectIETF()
- println("Locale:", userLocale)
-```
-
-### DetectLanguage
-`DetectLanguage` will return the current languge as a string. The format will be the [ISO 639](http://en.wikipedia.org/wiki/ISO_639) two-letter language code.
-
-```
- userLanguage, err := jibber_jabber.DetectLanguage()
- println("Language:", userLanguage)
-```
-
-### DetectTerritory
-`DetectTerritory` will return the current locale territory as a string. The format will be the [ISO 3166](http://en.wikipedia.org/wiki/ISO_3166-1) two-letter country code.
-
-```
- localeTerritory, err := jibber_jabber.DetectTerritory()
- println("Territory:", localeTerritory)
-```
-
-### Errors
-All the Detect commands will return an error if they are unable to read the Locale from the system.
-
-For Windows, additional error information is provided due to the nature of the system call being used.
diff --git a/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/ci/scripts/windows-64-test.bat b/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/ci/scripts/windows-64-test.bat
deleted file mode 100644
index b9a87bf7a..000000000
--- a/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/ci/scripts/windows-64-test.bat
+++ /dev/null
@@ -1,5 +0,0 @@
-git fetch
-git checkout %GIT_COMMIT%
-
-SET GOPATH=%CD%\Godeps\_workspace;c:\Users\Administrator\go
-c:\Go\bin\go test -v .
diff --git a/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/jibber_jabber.go b/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/jibber_jabber.go
deleted file mode 100644
index 45d288ea8..000000000
--- a/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/jibber_jabber.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package jibber_jabber
-
-import (
- "strings"
-)
-
-const (
- COULD_NOT_DETECT_PACKAGE_ERROR_MESSAGE = "Could not detect Language"
-)
-
-func splitLocale(locale string) (string, string) {
- formattedLocale := strings.Split(locale, ".")[0]
- formattedLocale = strings.Replace(formattedLocale, "-", "_", -1)
-
- pieces := strings.Split(formattedLocale, "_")
- language := pieces[0]
- territory := ""
- if len(pieces) > 1 {
- territory = strings.Split(formattedLocale, "_")[1]
- }
- return language, territory
-}
diff --git a/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/jibber_jabber_unix.go b/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/jibber_jabber_unix.go
deleted file mode 100644
index 374d76176..000000000
--- a/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/jibber_jabber_unix.go
+++ /dev/null
@@ -1,57 +0,0 @@
-// +build darwin freebsd linux netbsd openbsd
-
-package jibber_jabber
-
-import (
- "errors"
- "os"
- "strings"
-)
-
-func getLangFromEnv() (locale string) {
- locale = os.Getenv("LC_ALL")
- if locale == "" {
- locale = os.Getenv("LANG")
- }
- return
-}
-
-func getUnixLocale() (unix_locale string, err error) {
- unix_locale = getLangFromEnv()
- if unix_locale == "" {
- err = errors.New(COULD_NOT_DETECT_PACKAGE_ERROR_MESSAGE)
- }
-
- return
-}
-
-func DetectIETF() (locale string, err error) {
- unix_locale, err := getUnixLocale()
- if err == nil {
- language, territory := splitLocale(unix_locale)
- locale = language
- if territory != "" {
- locale = strings.Join([]string{language, territory}, "-")
- }
- }
-
- return
-}
-
-func DetectLanguage() (language string, err error) {
- unix_locale, err := getUnixLocale()
- if err == nil {
- language, _ = splitLocale(unix_locale)
- }
-
- return
-}
-
-func DetectTerritory() (territory string, err error) {
- unix_locale, err := getUnixLocale()
- if err == nil {
- _, territory = splitLocale(unix_locale)
- }
-
- return
-}
diff --git a/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/jibber_jabber_windows.go b/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/jibber_jabber_windows.go
deleted file mode 100644
index 1acd96c38..000000000
--- a/Godeps/_workspace/src/github.com/cloudfoundry/jibber_jabber/jibber_jabber_windows.go
+++ /dev/null
@@ -1,114 +0,0 @@
-// +build windows
-
-package jibber_jabber
-
-import (
- "errors"
- "syscall"
- "unsafe"
-)
-
-const LOCALE_NAME_MAX_LENGTH uint32 = 85
-
-var SUPPORTED_LOCALES = map[uintptr]string{
- 0x0407: "de-DE",
- 0x0409: "en-US",
- 0x0c0a: "es-ES", //or is it 0x040a
- 0x040c: "fr-FR",
- 0x0410: "it-IT",
- 0x0411: "ja-JA",
- 0x0412: "ko_KR",
- 0x0416: "pt-BR",
- //0x0419: "ru_RU", - Will add support for Russian when nicksnyder/go-i18n supports Russian
- 0x0804: "zh-CN",
- 0x0c04: "zh-HK",
- 0x0404: "zh-TW",
-}
-
-func getWindowsLocaleFrom(sysCall string) (locale string, err error) {
- buffer := make([]uint16, LOCALE_NAME_MAX_LENGTH)
-
- dll := syscall.MustLoadDLL("kernel32")
- proc := dll.MustFindProc(sysCall)
- r, _, dllError := proc.Call(uintptr(unsafe.Pointer(&buffer[0])), uintptr(LOCALE_NAME_MAX_LENGTH))
- if r == 0 {
- err = errors.New(COULD_NOT_DETECT_PACKAGE_ERROR_MESSAGE + ":\n" + dllError.Error())
- return
- }
-
- locale = syscall.UTF16ToString(buffer)
-
- return
-}
-
-func getAllWindowsLocaleFrom(sysCall string) (string, error) {
- dll, err := syscall.LoadDLL("kernel32")
- if err != nil {
- return "", errors.New("Could not find kernel32 dll")
- }
-
- proc, err := dll.FindProc(sysCall)
- if err != nil {
- return "", err
- }
-
- locale, _, dllError := proc.Call()
- if locale == 0 {
- return "", errors.New(COULD_NOT_DETECT_PACKAGE_ERROR_MESSAGE + ":\n" + dllError.Error())
- }
-
- return SUPPORTED_LOCALES[locale], nil
-}
-
-func getWindowsLocale() (locale string, err error) {
- dll, err := syscall.LoadDLL("kernel32")
- if err != nil {
- return "", errors.New("Could not find kernel32 dll")
- }
-
- proc, err := dll.FindProc("GetVersion")
- if err != nil {
- return "", err
- }
-
- v, _, _ := proc.Call()
- windowsVersion := byte(v)
- isVistaOrGreater := (windowsVersion >= 6)
-
- if isVistaOrGreater {
- locale, err = getWindowsLocaleFrom("GetUserDefaultLocaleName")
- if err != nil {
- locale, err = getWindowsLocaleFrom("GetSystemDefaultLocaleName")
- }
- } else if !isVistaOrGreater {
- locale, err = getAllWindowsLocaleFrom("GetUserDefaultLCID")
- if err != nil {
- locale, err = getAllWindowsLocaleFrom("GetSystemDefaultLCID")
- }
- } else {
- panic(v)
- }
- return
-}
-func DetectIETF() (locale string, err error) {
- locale, err = getWindowsLocale()
- return
-}
-
-func DetectLanguage() (language string, err error) {
- windows_locale, err := getWindowsLocale()
- if err == nil {
- language, _ = splitLocale(windows_locale)
- }
-
- return
-}
-
-func DetectTerritory() (territory string, err error) {
- windows_locale, err := getWindowsLocale()
- if err == nil {
- _, territory = splitLocale(windows_locale)
- }
-
- return
-}
diff --git a/Godeps/_workspace/src/github.com/dgryski/dgoogauth/.travis.yml b/Godeps/_workspace/src/github.com/dgryski/dgoogauth/.travis.yml
deleted file mode 100644
index 4f2ee4d97..000000000
--- a/Godeps/_workspace/src/github.com/dgryski/dgoogauth/.travis.yml
+++ /dev/null
@@ -1 +0,0 @@
-language: go
diff --git a/Godeps/_workspace/src/github.com/dgryski/dgoogauth/README.md b/Godeps/_workspace/src/github.com/dgryski/dgoogauth/README.md
deleted file mode 100644
index 75fdde78a..000000000
--- a/Godeps/_workspace/src/github.com/dgryski/dgoogauth/README.md
+++ /dev/null
@@ -1,15 +0,0 @@
-This is a Go implementation of the Google Authenticator library.
-
-[![Build Status](https://travis-ci.org/dgryski/dgoogauth.png)](https://travis-ci.org/dgryski/dgoogauth)
-
-Copyright (c) 2012 Damian Gryski <damian@gryski.com>
-This code is licensed under the Apache License, version 2.0
-
-It implements the one-time-password algorithms specified in:
-
-* RFC 4226 (HOTP: An HMAC-Based One-Time Password Algorithm)
-* RFC 6238 (TOTP: Time-Based One-Time Password Algorithm)
-
-You can learn more about the Google Authenticator library at its project page:
-
-* https://github.com/google/google-authenticator
diff --git a/Godeps/_workspace/src/github.com/dgryski/dgoogauth/googauth.go b/Godeps/_workspace/src/github.com/dgryski/dgoogauth/googauth.go
deleted file mode 100644
index 1efddcc20..000000000
--- a/Godeps/_workspace/src/github.com/dgryski/dgoogauth/googauth.go
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
-Package dgoogauth implements the one-time password algorithms supported by Google Authenticator
-
-This package supports the HMAC-Based One-time Password (HOTP) algorithm
-specified in RFC 4226 and the Time-based One-time Password (TOTP) algorithm
-specified in RFC 6238.
-*/
-package dgoogauth
-
-import (
- "crypto/hmac"
- "crypto/sha1"
- "encoding/base32"
- "encoding/binary"
- "errors"
- "net/url"
- "sort"
- "strconv"
- "time"
-)
-
-// Much of this code assumes int == int64, which probably is not the case.
-
-// ComputeCode computes the response code for a 64-bit challenge 'value' using the secret 'secret'.
-// To avoid breaking compatibility with the previous API, it returns an invalid code (-1) when an error occurs,
-// but does not silently ignore them (it forces a mismatch so the code will be rejected).
-func ComputeCode(secret string, value int64) int {
-
- key, err := base32.StdEncoding.DecodeString(secret)
- if err != nil {
- return -1
- }
-
- hash := hmac.New(sha1.New, key)
- err = binary.Write(hash, binary.BigEndian, value)
- if err != nil {
- return -1
- }
- h := hash.Sum(nil)
-
- offset := h[19] & 0x0f
-
- truncated := binary.BigEndian.Uint32(h[offset : offset+4])
-
- truncated &= 0x7fffffff
- code := truncated % 1000000
-
- return int(code)
-}
-
-// ErrInvalidCode indicate the supplied one-time code was not valid
-var ErrInvalidCode = errors.New("invalid code")
-
-// OTPConfig is a one-time-password configuration. This object will be modified by calls to
-// Authenticate and should be saved to ensure the codes are in fact only used
-// once.
-type OTPConfig struct {
- Secret string // 80-bit base32 encoded string of the user's secret
- WindowSize int // valid range: technically 0..100 or so, but beyond 3-5 is probably bad security
- HotpCounter int // the current otp counter. 0 if the user uses time-based codes instead.
- DisallowReuse []int // timestamps in the current window unavailable for re-use
- ScratchCodes []int // an array of 8-digit numeric codes that can be used to log in
- UTC bool // use UTC for the timestamp instead of local time
-}
-
-func (c *OTPConfig) checkScratchCodes(code int) bool {
-
- for i, v := range c.ScratchCodes {
- if code == v {
- // remove this code from the list of valid ones
- l := len(c.ScratchCodes) - 1
- c.ScratchCodes[i] = c.ScratchCodes[l] // copy last element over this element
- c.ScratchCodes = c.ScratchCodes[0:l] // and trim the list length by 1
- return true
- }
- }
-
- return false
-}
-
-func (c *OTPConfig) checkHotpCode(code int) bool {
-
- for i := 0; i < c.WindowSize; i++ {
- if ComputeCode(c.Secret, int64(c.HotpCounter+i)) == code {
- c.HotpCounter += i + 1
- // We don't check for overflow here, which means you can only authenticate 2^63 times
- // After that, the counter is negative and the above 'if' test will fail.
- // This matches the behaviour of the PAM module.
- return true
- }
- }
-
- // we must always advance the counter if we tried to authenticate with it
- c.HotpCounter++
- return false
-}
-
-func (c *OTPConfig) checkTotpCode(t0, code int) bool {
-
- minT := t0 - (c.WindowSize / 2)
- maxT := t0 + (c.WindowSize / 2)
- for t := minT; t <= maxT; t++ {
- if ComputeCode(c.Secret, int64(t)) == code {
-
- if c.DisallowReuse != nil {
- for _, timeCode := range c.DisallowReuse {
- if timeCode == t {
- return false
- }
- }
-
- // code hasn't been used before
- c.DisallowReuse = append(c.DisallowReuse, t)
-
- // remove all time codes outside of the valid window
- sort.Ints(c.DisallowReuse)
- min := 0
- for c.DisallowReuse[min] < minT {
- min++
- }
- // FIXME: check we don't have an off-by-one error here
- c.DisallowReuse = c.DisallowReuse[min:]
- }
-
- return true
- }
- }
-
- return false
-}
-
-// Authenticate a one-time-password against the given OTPConfig
-// Returns true/false if the authentication was successful.
-// Returns error if the password is incorrectly formatted (not a zero-padded 6 or non-zero-padded 8 digit number).
-func (c *OTPConfig) Authenticate(password string) (bool, error) {
-
- var scratch bool
-
- switch {
- case len(password) == 6 && password[0] >= '0' && password[0] <= '9':
- break
- case len(password) == 8 && password[0] >= '1' && password[0] <= '9':
- scratch = true
- break
- default:
- return false, ErrInvalidCode
- }
-
- code, err := strconv.Atoi(password)
-
- if err != nil {
- return false, ErrInvalidCode
- }
-
- if scratch {
- return c.checkScratchCodes(code), nil
- }
-
- // we have a counter value we can use
- if c.HotpCounter > 0 {
- return c.checkHotpCode(code), nil
- }
-
- var t0 int
- // assume we're on Time-based OTP
- if c.UTC {
- t0 = int(time.Now().UTC().Unix() / 30)
- } else {
- t0 = int(time.Now().Unix() / 30)
- }
- return c.checkTotpCode(t0, code), nil
-}
-
-// ProvisionURI generates a URI that can be turned into a QR code to configure
-// a Google Authenticator mobile app.
-func (c *OTPConfig) ProvisionURI(user string) string {
- return c.ProvisionURIWithIssuer(user, "")
-}
-
-// ProvisionURIWithIssuer generates a URI that can be turned into a QR code
-// to configure a Google Authenticator mobile app. It respects the recommendations
-// on how to avoid conflicting accounts.
-//
-// See https://code.google.com/p/google-authenticator/wiki/ConflictingAccounts
-func (c *OTPConfig) ProvisionURIWithIssuer(user string, issuer string) string {
- auth := "totp/"
- q := make(url.Values)
- if c.HotpCounter > 0 {
- auth = "hotp/"
- q.Add("counter", strconv.Itoa(c.HotpCounter))
- }
- q.Add("secret", c.Secret)
- if issuer != "" {
- q.Add("issuer", issuer)
- auth += issuer + ":"
- }
-
- return "otpauth://" + auth + user + "?" + q.Encode()
-}
diff --git a/Godeps/_workspace/src/github.com/dgryski/dgoogauth/googauth_test.go b/Godeps/_workspace/src/github.com/dgryski/dgoogauth/googauth_test.go
deleted file mode 100644
index 031922c47..000000000
--- a/Godeps/_workspace/src/github.com/dgryski/dgoogauth/googauth_test.go
+++ /dev/null
@@ -1,251 +0,0 @@
-package dgoogauth
-
-import (
- "strconv"
- "testing"
- "time"
-)
-
-// Test vectors via:
-// http://code.google.com/p/google-authenticator/source/browse/libpam/pam_google_authenticator_unittest.c
-// https://google-authenticator.googlecode.com/hg/libpam/totp.html
-
-var codeTests = []struct {
- secret string
- value int64
- code int
-}{
- {"2SH3V3GDW7ZNMGYE", 1, 293240},
- {"2SH3V3GDW7ZNMGYE", 5, 932068},
- {"2SH3V3GDW7ZNMGYE", 10000, 50548},
-}
-
-func TestCode(t *testing.T) {
-
- for _, v := range codeTests {
- c := ComputeCode(v.secret, v.value)
-
- if c != v.code {
- t.Errorf("computeCode(%s, %d): got %d expected %d\n", v.secret, v.value, c, v.code)
- }
-
- }
-}
-
-func TestScratchCode(t *testing.T) {
-
- var cotp OTPConfig
-
- cotp.ScratchCodes = []int{11112222, 22223333}
-
- var scratchTests = []struct {
- code int
- result bool
- }{
- {33334444, false},
- {11112222, true},
- {11112222, false},
- {22223333, true},
- {22223333, false},
- {33334444, false},
- }
-
- for _, s := range scratchTests {
- r := cotp.checkScratchCodes(s.code)
- if r != s.result {
- t.Errorf("scratchcode(%d) failed: got %t expected %t", s.code, r, s.result)
- }
- }
-}
-
-func TestHotpCode(t *testing.T) {
-
- var cotp OTPConfig
-
- // reuse our test values from above
- // perhaps create more?
- cotp.Secret = "2SH3V3GDW7ZNMGYE"
- cotp.HotpCounter = 1
- cotp.WindowSize = 3
-
- var counterCodes = []struct {
- code int
- result bool
- counter int
- }{
- { /* 1 */ 293240, true, 2}, // increments on success
- { /* 1 */ 293240, false, 3}, // and failure
- { /* 5 */ 932068, true, 6}, // inside of window
- { /* 10 */ 481725, false, 7}, // outside of window
- { /* 10 */ 481725, false, 8}, // outside of window
- { /* 10 */ 481725, true, 11}, // now inside of window
- }
-
- for i, s := range counterCodes {
- r := cotp.checkHotpCode(s.code)
- if r != s.result {
- t.Errorf("counterCode(%d) (step %d) failed: got %t expected %t", s.code, i, r, s.result)
- }
- if cotp.HotpCounter != s.counter {
- t.Errorf("hotpCounter incremented poorly: got %d expected %d", cotp.HotpCounter, s.counter)
- }
- }
-}
-
-func TestTotpCode(t *testing.T) {
-
- var cotp OTPConfig
-
- // reuse our test values from above
- cotp.Secret = "2SH3V3GDW7ZNMGYE"
- cotp.WindowSize = 5
-
- var windowTest = []struct {
- code int
- t0 int
- result bool
- }{
- {50548, 9997, false},
- {50548, 9998, true},
- {50548, 9999, true},
- {50548, 10000, true},
- {50548, 10001, true},
- {50548, 10002, true},
- {50548, 10003, false},
- }
-
- for i, s := range windowTest {
- r := cotp.checkTotpCode(s.t0, s.code)
- if r != s.result {
- t.Errorf("counterCode(%d) (step %d) failed: got %t expected %t", s.code, i, r, s.result)
- }
- }
-
- cotp.DisallowReuse = make([]int, 0)
- var noreuseTest = []struct {
- code int
- t0 int
- result bool
- disallowed []int
- }{
- {50548 /* 10000 */, 9997, false, []int{}},
- {50548 /* 10000 */, 9998, true, []int{10000}},
- {50548 /* 10000 */, 9999, false, []int{10000}},
- {478726 /* 10001 */, 10001, true, []int{10000, 10001}},
- {646986 /* 10002 */, 10002, true, []int{10000, 10001, 10002}},
- {842639 /* 10003 */, 10003, true, []int{10001, 10002, 10003}},
- }
-
- for i, s := range noreuseTest {
- r := cotp.checkTotpCode(s.t0, s.code)
- if r != s.result {
- t.Errorf("timeCode(%d) (step %d) failed: got %t expected %t", s.code, i, r, s.result)
- }
- if len(cotp.DisallowReuse) != len(s.disallowed) {
- t.Errorf("timeCode(%d) (step %d) failed: disallowReuse len mismatch: got %d expected %d", s.code, i, len(cotp.DisallowReuse), len(s.disallowed))
- } else {
- same := true
- for j := range s.disallowed {
- if s.disallowed[j] != cotp.DisallowReuse[j] {
- same = false
- }
- }
- if !same {
- t.Errorf("timeCode(%d) (step %d) failed: disallowReused: got %v expected %v", s.code, i, cotp.DisallowReuse, s.disallowed)
- }
- }
- }
-}
-
-func TestAuthenticate(t *testing.T) {
-
- otpconf := &OTPConfig{
- Secret: "2SH3V3GDW7ZNMGYE",
- WindowSize: 3,
- HotpCounter: 1,
- ScratchCodes: []int{11112222, 22223333},
- }
-
- type attempt struct {
- code string
- result bool
- }
-
- var attempts = []attempt{
- {"foobar", false}, // not digits
- {"1fooba", false}, // not valid number
- {"1111111", false}, // bad length
- { /* 1 */ "293240", true}, // hopt increments on success
- { /* 1 */ "293240", false}, // hopt failure
- {"33334444", false}, // scratch
- {"11112222", true},
- {"11112222", false},
- }
-
- for _, a := range attempts {
- r, _ := otpconf.Authenticate(a.code)
- if r != a.result {
- t.Errorf("bad result from code=%s: got %t expected %t\n", a.code, r, a.result)
- }
- }
-
- // let's check some time-based codes
- otpconf.HotpCounter = 0
- // I haven't mocked the clock, so we'll just compute one
- var t0 int64
- if otpconf.UTC {
- t0 = int64(time.Now().UTC().Unix() / 30)
- } else {
- t0 = int64(time.Now().Unix() / 30)
- }
- c := ComputeCode(otpconf.Secret, t0)
-
- invalid := c + 1
- attempts = []attempt{
- {strconv.Itoa(invalid), false},
- {strconv.Itoa(c), true},
- }
-
- for _, a := range attempts {
- r, _ := otpconf.Authenticate(a.code)
- if r != a.result {
- t.Errorf("bad result from code=%s: got %t expected %t\n", a.code, r, a.result)
- }
-
- otpconf.UTC = true
- r, _ = otpconf.Authenticate(a.code)
- if r != a.result {
- t.Errorf("bad result from code=%s: got %t expected %t\n", a.code, r, a.result)
- }
- otpconf.UTC = false
- }
-
-}
-
-func TestProvisionURI(t *testing.T) {
- otpconf := OTPConfig{
- Secret: "x",
- }
-
- cases := []struct {
- user, iss string
- hotp bool
- out string
- }{
- {"test", "", false, "otpauth://totp/test?secret=x"},
- {"test", "", true, "otpauth://hotp/test?counter=1&secret=x"},
- {"test", "Company", true, "otpauth://hotp/Company:test?counter=1&issuer=Company&secret=x"},
- {"test", "Company", false, "otpauth://totp/Company:test?issuer=Company&secret=x"},
- }
-
- for i, c := range cases {
- otpconf.HotpCounter = 0
- if c.hotp {
- otpconf.HotpCounter = 1
- }
- got := otpconf.ProvisionURIWithIssuer(c.user, c.iss)
- if got != c.out {
- t.Errorf("%d: want %q, got %q", i, c.out, got)
- }
- }
-}
diff --git a/Godeps/_workspace/src/github.com/disintegration/imaging/LICENSE b/Godeps/_workspace/src/github.com/disintegration/imaging/LICENSE
deleted file mode 100644
index 95ae410c3..000000000
--- a/Godeps/_workspace/src/github.com/disintegration/imaging/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2012-2014 Grigory Dryapak
-
-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/Godeps/_workspace/src/github.com/disintegration/imaging/README.md b/Godeps/_workspace/src/github.com/disintegration/imaging/README.md
deleted file mode 100644
index 25d836cef..000000000
--- a/Godeps/_workspace/src/github.com/disintegration/imaging/README.md
+++ /dev/null
@@ -1,194 +0,0 @@
-# Imaging
-
-Package imaging provides basic image manipulation functions (resize, rotate, flip, crop, etc.).
-This package is based on the standard Go image package and works best along with it.
-
-Image manipulation functions provided by the package take any image type
-that implements `image.Image` interface as an input, and return a new image of
-`*image.NRGBA` type (32bit RGBA colors, not premultiplied by alpha).
-
-## Installation
-
-Imaging requires Go version 1.2 or greater.
-
- go get -u github.com/disintegration/imaging
-
-## Documentation
-
-http://godoc.org/github.com/disintegration/imaging
-
-## Usage examples
-
-A few usage examples can be found below. See the documentation for the full list of supported functions.
-
-### Image resizing
-```go
-// resize srcImage to size = 128x128px using the Lanczos filter
-dstImage128 := imaging.Resize(srcImage, 128, 128, imaging.Lanczos)
-
-// resize srcImage to width = 800px preserving the aspect ratio
-dstImage800 := imaging.Resize(srcImage, 800, 0, imaging.Lanczos)
-
-// scale down srcImage to fit the 800x600px bounding box
-dstImageFit := imaging.Fit(srcImage, 800, 600, imaging.Lanczos)
-
-// resize and crop the srcImage to fill the 100x100px area
-dstImageFill := imaging.Fill(srcImage, 100, 100, imaging.Center, imaging.Lanczos)
-```
-
-Imaging supports image resizing using various resampling filters. The most notable ones:
-- `NearestNeighbor` - Fastest resampling filter, no antialiasing.
-- `Box` - Simple and fast averaging filter appropriate for downscaling. When upscaling it's similar to NearestNeighbor.
-- `Linear` - Bilinear filter, smooth and reasonably fast.
-- `MitchellNetravali` - А smooth bicubic filter.
-- `CatmullRom` - A sharp bicubic filter.
-- `Gaussian` - Blurring filter that uses gaussian function, useful for noise removal.
-- `Lanczos` - High-quality resampling filter for photographic images yielding sharp results, but it's slower than cubic filters.
-
-The full list of supported filters: NearestNeighbor, Box, Linear, Hermite, MitchellNetravali, CatmullRom, BSpline, Gaussian, Lanczos, Hann, Hamming, Blackman, Bartlett, Welch, Cosine. Custom filters can be created using ResampleFilter struct.
-
-**Resampling filters comparison**
-
-Original image. Will be resized from 512x512px to 128x128px.
-
-![srcImage](http://disintegration.github.io/imaging/in_lena_bw_512.png)
-
-Filter | Resize result
----|---
-`imaging.NearestNeighbor` | ![dstImage](http://disintegration.github.io/imaging/out_resize_down_nearest.png)
-`imaging.Box` | ![dstImage](http://disintegration.github.io/imaging/out_resize_down_box.png)
-`imaging.Linear` | ![dstImage](http://disintegration.github.io/imaging/out_resize_down_linear.png)
-`imaging.MitchellNetravali` | ![dstImage](http://disintegration.github.io/imaging/out_resize_down_mitchell.png)
-`imaging.CatmullRom` | ![dstImage](http://disintegration.github.io/imaging/out_resize_down_catrom.png)
-`imaging.Gaussian` | ![dstImage](http://disintegration.github.io/imaging/out_resize_down_gaussian.png)
-`imaging.Lanczos` | ![dstImage](http://disintegration.github.io/imaging/out_resize_down_lanczos.png)
-
-**Resize functions comparison**
-
-Original image:
-
-![srcImage](http://disintegration.github.io/imaging/in.jpg)
-
-Resize the image to width=100px and height=100px:
-
-```go
-dstImage := imaging.Resize(srcImage, 100, 100, imaging.Lanczos)
-```
-![dstImage](http://disintegration.github.io/imaging/out-comp-resize.jpg)
-
-Resize the image to width=100px preserving the aspect ratio:
-
-```go
-dstImage := imaging.Resize(srcImage, 100, 0, imaging.Lanczos)
-```
-![dstImage](http://disintegration.github.io/imaging/out-comp-fit.jpg)
-
-Resize the image to fit the 100x100px boundng box preserving the aspect ratio:
-
-```go
-dstImage := imaging.Fit(srcImage, 100, 100, imaging.Lanczos)
-```
-![dstImage](http://disintegration.github.io/imaging/out-comp-fit.jpg)
-
-Resize and crop the image with a center anchor point to fill the 100x100px area:
-
-```go
-dstImage := imaging.Fill(srcImage, 100, 100, imaging.Center, imaging.Lanczos)
-```
-![dstImage](http://disintegration.github.io/imaging/out-comp-fill.jpg)
-
-### Gaussian Blur
-```go
-dstImage := imaging.Blur(srcImage, 0.5)
-```
-
-Sigma parameter allows to control the strength of the blurring effect.
-
-Original image | Sigma = 0.5 | Sigma = 1.5
----|---|---
-![srcImage](http://disintegration.github.io/imaging/in_lena_bw_128.png) | ![dstImage](http://disintegration.github.io/imaging/out_blur_0.5.png) | ![dstImage](http://disintegration.github.io/imaging/out_blur_1.5.png)
-
-### Sharpening
-```go
-dstImage := imaging.Sharpen(srcImage, 0.5)
-```
-
-Uses gaussian function internally. Sigma parameter allows to control the strength of the sharpening effect.
-
-Original image | Sigma = 0.5 | Sigma = 1.5
----|---|---
-![srcImage](http://disintegration.github.io/imaging/in_lena_bw_128.png) | ![dstImage](http://disintegration.github.io/imaging/out_sharpen_0.5.png) | ![dstImage](http://disintegration.github.io/imaging/out_sharpen_1.5.png)
-
-### Gamma correction
-```go
-dstImage := imaging.AdjustGamma(srcImage, 0.75)
-```
-
-Original image | Gamma = 0.75 | Gamma = 1.25
----|---|---
-![srcImage](http://disintegration.github.io/imaging/in_lena_bw_128.png) | ![dstImage](http://disintegration.github.io/imaging/out_gamma_0.75.png) | ![dstImage](http://disintegration.github.io/imaging/out_gamma_1.25.png)
-
-### Contrast adjustment
-```go
-dstImage := imaging.AdjustContrast(srcImage, 20)
-```
-
-Original image | Contrast = 20 | Contrast = -20
----|---|---
-![srcImage](http://disintegration.github.io/imaging/in_lena_bw_128.png) | ![dstImage](http://disintegration.github.io/imaging/out_contrast_p20.png) | ![dstImage](http://disintegration.github.io/imaging/out_contrast_m20.png)
-
-### Brightness adjustment
-```go
-dstImage := imaging.AdjustBrightness(srcImage, 20)
-```
-
-Original image | Brightness = 20 | Brightness = -20
----|---|---
-![srcImage](http://disintegration.github.io/imaging/in_lena_bw_128.png) | ![dstImage](http://disintegration.github.io/imaging/out_brightness_p20.png) | ![dstImage](http://disintegration.github.io/imaging/out_brightness_m20.png)
-
-
-### Complete code example
-Here is the code example that loads several images, makes thumbnails of them
-and combines them together side-by-side.
-
-```go
-package main
-
-import (
- "image"
- "image/color"
-
- "github.com/disintegration/imaging"
-)
-
-func main() {
-
- // input files
- files := []string{"01.jpg", "02.jpg", "03.jpg"}
-
- // load images and make 100x100 thumbnails of them
- var thumbnails []image.Image
- for _, file := range files {
- img, err := imaging.Open(file)
- if err != nil {
- panic(err)
- }
- thumb := imaging.Thumbnail(img, 100, 100, imaging.CatmullRom)
- thumbnails = append(thumbnails, thumb)
- }
-
- // create a new blank image
- dst := imaging.New(100*len(thumbnails), 100, color.NRGBA{0, 0, 0, 0})
-
- // paste thumbnails into the new image side by side
- for i, thumb := range thumbnails {
- dst = imaging.Paste(dst, thumb, image.Pt(i*100, 0))
- }
-
- // save the combined image to file
- err := imaging.Save(dst, "dst.jpg")
- if err != nil {
- panic(err)
- }
-}
-```
diff --git a/Godeps/_workspace/src/github.com/disintegration/imaging/adjust.go b/Godeps/_workspace/src/github.com/disintegration/imaging/adjust.go
deleted file mode 100644
index 9b1b83a4f..000000000
--- a/Godeps/_workspace/src/github.com/disintegration/imaging/adjust.go
+++ /dev/null
@@ -1,200 +0,0 @@
-package imaging
-
-import (
- "image"
- "image/color"
- "math"
-)
-
-// AdjustFunc applies the fn function to each pixel of the img image and returns the adjusted image.
-//
-// Example:
-//
-// dstImage = imaging.AdjustFunc(
-// srcImage,
-// func(c color.NRGBA) color.NRGBA {
-// // shift the red channel by 16
-// r := int(c.R) + 16
-// if r > 255 {
-// r = 255
-// }
-// return color.NRGBA{uint8(r), c.G, c.B, c.A}
-// }
-// )
-//
-func AdjustFunc(img image.Image, fn func(c color.NRGBA) color.NRGBA) *image.NRGBA {
- src := toNRGBA(img)
- width := src.Bounds().Max.X
- height := src.Bounds().Max.Y
- dst := image.NewNRGBA(image.Rect(0, 0, width, height))
-
- parallel(height, func(partStart, partEnd int) {
- for y := partStart; y < partEnd; y++ {
- for x := 0; x < width; x++ {
- i := y*src.Stride + x*4
- j := y*dst.Stride + x*4
-
- r := src.Pix[i+0]
- g := src.Pix[i+1]
- b := src.Pix[i+2]
- a := src.Pix[i+3]
-
- c := fn(color.NRGBA{r, g, b, a})
-
- dst.Pix[j+0] = c.R
- dst.Pix[j+1] = c.G
- dst.Pix[j+2] = c.B
- dst.Pix[j+3] = c.A
- }
- }
- })
-
- return dst
-}
-
-// AdjustGamma performs a gamma correction on the image and returns the adjusted image.
-// Gamma parameter must be positive. Gamma = 1.0 gives the original image.
-// Gamma less than 1.0 darkens the image and gamma greater than 1.0 lightens it.
-//
-// Example:
-//
-// dstImage = imaging.AdjustGamma(srcImage, 0.7)
-//
-func AdjustGamma(img image.Image, gamma float64) *image.NRGBA {
- e := 1.0 / math.Max(gamma, 0.0001)
- lut := make([]uint8, 256)
-
- for i := 0; i < 256; i++ {
- lut[i] = clamp(math.Pow(float64(i)/255.0, e) * 255.0)
- }
-
- fn := func(c color.NRGBA) color.NRGBA {
- return color.NRGBA{lut[c.R], lut[c.G], lut[c.B], c.A}
- }
-
- return AdjustFunc(img, fn)
-}
-
-func sigmoid(a, b, x float64) float64 {
- return 1 / (1 + math.Exp(b*(a-x)))
-}
-
-// AdjustSigmoid changes the contrast of the image using a sigmoidal function and returns the adjusted image.
-// It's a non-linear contrast change useful for photo adjustments as it preserves highlight and shadow detail.
-// The midpoint parameter is the midpoint of contrast that must be between 0 and 1, typically 0.5.
-// The factor parameter indicates how much to increase or decrease the contrast, typically in range (-10, 10).
-// If the factor parameter is positive the image contrast is increased otherwise the contrast is decreased.
-//
-// Examples:
-//
-// dstImage = imaging.AdjustSigmoid(srcImage, 0.5, 3.0) // increase the contrast
-// dstImage = imaging.AdjustSigmoid(srcImage, 0.5, -3.0) // decrease the contrast
-//
-func AdjustSigmoid(img image.Image, midpoint, factor float64) *image.NRGBA {
- if factor == 0 {
- return Clone(img)
- }
-
- lut := make([]uint8, 256)
- a := math.Min(math.Max(midpoint, 0.0), 1.0)
- b := math.Abs(factor)
- sig0 := sigmoid(a, b, 0)
- sig1 := sigmoid(a, b, 1)
- e := 1.0e-6
-
- if factor > 0 {
- for i := 0; i < 256; i++ {
- x := float64(i) / 255.0
- sigX := sigmoid(a, b, x)
- f := (sigX - sig0) / (sig1 - sig0)
- lut[i] = clamp(f * 255.0)
- }
- } else {
- for i := 0; i < 256; i++ {
- x := float64(i) / 255.0
- arg := math.Min(math.Max((sig1-sig0)*x+sig0, e), 1.0-e)
- f := a - math.Log(1.0/arg-1.0)/b
- lut[i] = clamp(f * 255.0)
- }
- }
-
- fn := func(c color.NRGBA) color.NRGBA {
- return color.NRGBA{lut[c.R], lut[c.G], lut[c.B], c.A}
- }
-
- return AdjustFunc(img, fn)
-}
-
-// AdjustContrast changes the contrast of the image using the percentage parameter and returns the adjusted image.
-// The percentage must be in range (-100, 100). The percentage = 0 gives the original image.
-// The percentage = -100 gives solid grey image.
-//
-// Examples:
-//
-// dstImage = imaging.AdjustContrast(srcImage, -10) // decrease image contrast by 10%
-// dstImage = imaging.AdjustContrast(srcImage, 20) // increase image contrast by 20%
-//
-func AdjustContrast(img image.Image, percentage float64) *image.NRGBA {
- percentage = math.Min(math.Max(percentage, -100.0), 100.0)
- lut := make([]uint8, 256)
-
- v := (100.0 + percentage) / 100.0
- for i := 0; i < 256; i++ {
- if 0 <= v && v <= 1 {
- lut[i] = clamp((0.5 + (float64(i)/255.0-0.5)*v) * 255.0)
- } else if 1 < v && v < 2 {
- lut[i] = clamp((0.5 + (float64(i)/255.0-0.5)*(1/(2.0-v))) * 255.0)
- } else {
- lut[i] = uint8(float64(i)/255.0+0.5) * 255
- }
- }
-
- fn := func(c color.NRGBA) color.NRGBA {
- return color.NRGBA{lut[c.R], lut[c.G], lut[c.B], c.A}
- }
-
- return AdjustFunc(img, fn)
-}
-
-// AdjustBrightness changes the brightness of the image using the percentage parameter and returns the adjusted image.
-// The percentage must be in range (-100, 100). The percentage = 0 gives the original image.
-// The percentage = -100 gives solid black image. The percentage = 100 gives solid white image.
-//
-// Examples:
-//
-// dstImage = imaging.AdjustBrightness(srcImage, -15) // decrease image brightness by 15%
-// dstImage = imaging.AdjustBrightness(srcImage, 10) // increase image brightness by 10%
-//
-func AdjustBrightness(img image.Image, percentage float64) *image.NRGBA {
- percentage = math.Min(math.Max(percentage, -100.0), 100.0)
- lut := make([]uint8, 256)
-
- shift := 255.0 * percentage / 100.0
- for i := 0; i < 256; i++ {
- lut[i] = clamp(float64(i) + shift)
- }
-
- fn := func(c color.NRGBA) color.NRGBA {
- return color.NRGBA{lut[c.R], lut[c.G], lut[c.B], c.A}
- }
-
- return AdjustFunc(img, fn)
-}
-
-// Grayscale produces grayscale version of the image.
-func Grayscale(img image.Image) *image.NRGBA {
- fn := func(c color.NRGBA) color.NRGBA {
- f := 0.299*float64(c.R) + 0.587*float64(c.G) + 0.114*float64(c.B)
- y := uint8(f + 0.5)
- return color.NRGBA{y, y, y, c.A}
- }
- return AdjustFunc(img, fn)
-}
-
-// Invert produces inverted (negated) version of the image.
-func Invert(img image.Image) *image.NRGBA {
- fn := func(c color.NRGBA) color.NRGBA {
- return color.NRGBA{255 - c.R, 255 - c.G, 255 - c.B, c.A}
- }
- return AdjustFunc(img, fn)
-}
diff --git a/Godeps/_workspace/src/github.com/disintegration/imaging/effects.go b/Godeps/_workspace/src/github.com/disintegration/imaging/effects.go
deleted file mode 100644
index fe92e10a2..000000000
--- a/Godeps/_workspace/src/github.com/disintegration/imaging/effects.go
+++ /dev/null
@@ -1,187 +0,0 @@
-package imaging
-
-import (
- "image"
- "math"
-)
-
-func gaussianBlurKernel(x, sigma float64) float64 {
- return math.Exp(-(x*x)/(2*sigma*sigma)) / (sigma * math.Sqrt(2*math.Pi))
-}
-
-// Blur produces a blurred version of the image using a Gaussian function.
-// Sigma parameter must be positive and indicates how much the image will be blurred.
-//
-// Usage example:
-//
-// dstImage := imaging.Blur(srcImage, 3.5)
-//
-func Blur(img image.Image, sigma float64) *image.NRGBA {
- if sigma <= 0 {
- // sigma parameter must be positive!
- return Clone(img)
- }
-
- src := toNRGBA(img)
- radius := int(math.Ceil(sigma * 3.0))
- kernel := make([]float64, radius+1)
-
- for i := 0; i <= radius; i++ {
- kernel[i] = gaussianBlurKernel(float64(i), sigma)
- }
-
- var dst *image.NRGBA
- dst = blurHorizontal(src, kernel)
- dst = blurVertical(dst, kernel)
-
- return dst
-}
-
-func blurHorizontal(src *image.NRGBA, kernel []float64) *image.NRGBA {
- radius := len(kernel) - 1
- width := src.Bounds().Max.X
- height := src.Bounds().Max.Y
-
- dst := image.NewNRGBA(image.Rect(0, 0, width, height))
-
- parallel(width, func(partStart, partEnd int) {
- for x := partStart; x < partEnd; x++ {
- start := x - radius
- if start < 0 {
- start = 0
- }
-
- end := x + radius
- if end > width-1 {
- end = width - 1
- }
-
- weightSum := 0.0
- for ix := start; ix <= end; ix++ {
- weightSum += kernel[absint(x-ix)]
- }
-
- for y := 0; y < height; y++ {
-
- r, g, b, a := 0.0, 0.0, 0.0, 0.0
- for ix := start; ix <= end; ix++ {
- weight := kernel[absint(x-ix)]
- i := y*src.Stride + ix*4
- r += float64(src.Pix[i+0]) * weight
- g += float64(src.Pix[i+1]) * weight
- b += float64(src.Pix[i+2]) * weight
- a += float64(src.Pix[i+3]) * weight
- }
-
- r = math.Min(math.Max(r/weightSum, 0.0), 255.0)
- g = math.Min(math.Max(g/weightSum, 0.0), 255.0)
- b = math.Min(math.Max(b/weightSum, 0.0), 255.0)
- a = math.Min(math.Max(a/weightSum, 0.0), 255.0)
-
- j := y*dst.Stride + x*4
- dst.Pix[j+0] = uint8(r + 0.5)
- dst.Pix[j+1] = uint8(g + 0.5)
- dst.Pix[j+2] = uint8(b + 0.5)
- dst.Pix[j+3] = uint8(a + 0.5)
-
- }
- }
- })
-
- return dst
-}
-
-func blurVertical(src *image.NRGBA, kernel []float64) *image.NRGBA {
- radius := len(kernel) - 1
- width := src.Bounds().Max.X
- height := src.Bounds().Max.Y
-
- dst := image.NewNRGBA(image.Rect(0, 0, width, height))
-
- parallel(height, func(partStart, partEnd int) {
- for y := partStart; y < partEnd; y++ {
- start := y - radius
- if start < 0 {
- start = 0
- }
-
- end := y + radius
- if end > height-1 {
- end = height - 1
- }
-
- weightSum := 0.0
- for iy := start; iy <= end; iy++ {
- weightSum += kernel[absint(y-iy)]
- }
-
- for x := 0; x < width; x++ {
-
- r, g, b, a := 0.0, 0.0, 0.0, 0.0
- for iy := start; iy <= end; iy++ {
- weight := kernel[absint(y-iy)]
- i := iy*src.Stride + x*4
- r += float64(src.Pix[i+0]) * weight
- g += float64(src.Pix[i+1]) * weight
- b += float64(src.Pix[i+2]) * weight
- a += float64(src.Pix[i+3]) * weight
- }
-
- r = math.Min(math.Max(r/weightSum, 0.0), 255.0)
- g = math.Min(math.Max(g/weightSum, 0.0), 255.0)
- b = math.Min(math.Max(b/weightSum, 0.0), 255.0)
- a = math.Min(math.Max(a/weightSum, 0.0), 255.0)
-
- j := y*dst.Stride + x*4
- dst.Pix[j+0] = uint8(r + 0.5)
- dst.Pix[j+1] = uint8(g + 0.5)
- dst.Pix[j+2] = uint8(b + 0.5)
- dst.Pix[j+3] = uint8(a + 0.5)
-
- }
- }
- })
-
- return dst
-}
-
-// Sharpen produces a sharpened version of the image.
-// Sigma parameter must be positive and indicates how much the image will be sharpened.
-//
-// Usage example:
-//
-// dstImage := imaging.Sharpen(srcImage, 3.5)
-//
-func Sharpen(img image.Image, sigma float64) *image.NRGBA {
- if sigma <= 0 {
- // sigma parameter must be positive!
- return Clone(img)
- }
-
- src := toNRGBA(img)
- blurred := Blur(img, sigma)
-
- width := src.Bounds().Max.X
- height := src.Bounds().Max.Y
- dst := image.NewNRGBA(image.Rect(0, 0, width, height))
-
- parallel(height, func(partStart, partEnd int) {
- for y := partStart; y < partEnd; y++ {
- for x := 0; x < width; x++ {
- i := y*src.Stride + x*4
- for j := 0; j < 4; j++ {
- k := i + j
- val := int(src.Pix[k]) + (int(src.Pix[k]) - int(blurred.Pix[k]))
- if val < 0 {
- val = 0
- } else if val > 255 {
- val = 255
- }
- dst.Pix[k] = uint8(val)
- }
- }
- }
- })
-
- return dst
-}
diff --git a/Godeps/_workspace/src/github.com/disintegration/imaging/helpers.go b/Godeps/_workspace/src/github.com/disintegration/imaging/helpers.go
deleted file mode 100644
index 79967ae44..000000000
--- a/Godeps/_workspace/src/github.com/disintegration/imaging/helpers.go
+++ /dev/null
@@ -1,400 +0,0 @@
-/*
-Package imaging provides basic image manipulation functions (resize, rotate, flip, crop, etc.).
-This package is based on the standard Go image package and works best along with it.
-
-Image manipulation functions provided by the package take any image type
-that implements `image.Image` interface as an input, and return a new image of
-`*image.NRGBA` type (32bit RGBA colors, not premultiplied by alpha).
-*/
-package imaging
-
-import (
- "errors"
- "image"
- "image/color"
- "image/gif"
- "image/jpeg"
- "image/png"
- "io"
- "os"
- "path/filepath"
- "strings"
-
- "golang.org/x/image/bmp"
- "golang.org/x/image/tiff"
-)
-
-type Format int
-
-const (
- JPEG Format = iota
- PNG
- GIF
- TIFF
- BMP
-)
-
-func (f Format) String() string {
- switch f {
- case JPEG:
- return "JPEG"
- case PNG:
- return "PNG"
- case GIF:
- return "GIF"
- case TIFF:
- return "TIFF"
- case BMP:
- return "BMP"
- default:
- return "Unsupported"
- }
-}
-
-var (
- ErrUnsupportedFormat = errors.New("imaging: unsupported image format")
-)
-
-// Decode reads an image from r.
-func Decode(r io.Reader) (image.Image, error) {
- img, _, err := image.Decode(r)
- if err != nil {
- return nil, err
- }
- return toNRGBA(img), nil
-}
-
-// Open loads an image from file
-func Open(filename string) (image.Image, error) {
- file, err := os.Open(filename)
- if err != nil {
- return nil, err
- }
- defer file.Close()
- img, err := Decode(file)
- return img, err
-}
-
-// Encode writes the image img to w in the specified format (JPEG, PNG, GIF, TIFF or BMP).
-func Encode(w io.Writer, img image.Image, format Format) error {
- var err error
- switch format {
- case JPEG:
- var rgba *image.RGBA
- if nrgba, ok := img.(*image.NRGBA); ok {
- if nrgba.Opaque() {
- rgba = &image.RGBA{
- Pix: nrgba.Pix,
- Stride: nrgba.Stride,
- Rect: nrgba.Rect,
- }
- }
- }
- if rgba != nil {
- err = jpeg.Encode(w, rgba, &jpeg.Options{Quality: 95})
- } else {
- err = jpeg.Encode(w, img, &jpeg.Options{Quality: 95})
- }
-
- case PNG:
- err = png.Encode(w, img)
- case GIF:
- err = gif.Encode(w, img, &gif.Options{NumColors: 256})
- case TIFF:
- err = tiff.Encode(w, img, &tiff.Options{Compression: tiff.Deflate, Predictor: true})
- case BMP:
- err = bmp.Encode(w, img)
- default:
- err = ErrUnsupportedFormat
- }
- return err
-}
-
-// Save saves the image to file with the specified filename.
-// The format is determined from the filename extension: "jpg" (or "jpeg"), "png", "gif", "tif" (or "tiff") and "bmp" are supported.
-func Save(img image.Image, filename string) (err error) {
- formats := map[string]Format{
- ".jpg": JPEG,
- ".jpeg": JPEG,
- ".png": PNG,
- ".tif": TIFF,
- ".tiff": TIFF,
- ".bmp": BMP,
- ".gif": GIF,
- }
-
- ext := strings.ToLower(filepath.Ext(filename))
- f, ok := formats[ext]
- if !ok {
- return ErrUnsupportedFormat
- }
-
- file, err := os.Create(filename)
- if err != nil {
- return err
- }
- defer file.Close()
-
- return Encode(file, img, f)
-}
-
-// New creates a new image with the specified width and height, and fills it with the specified color.
-func New(width, height int, fillColor color.Color) *image.NRGBA {
- if width <= 0 || height <= 0 {
- return &image.NRGBA{}
- }
-
- dst := image.NewNRGBA(image.Rect(0, 0, width, height))
- c := color.NRGBAModel.Convert(fillColor).(color.NRGBA)
-
- if c.R == 0 && c.G == 0 && c.B == 0 && c.A == 0 {
- return dst
- }
-
- cs := []uint8{c.R, c.G, c.B, c.A}
-
- // fill the first row
- for x := 0; x < width; x++ {
- copy(dst.Pix[x*4:(x+1)*4], cs)
- }
- // copy the first row to other rows
- for y := 1; y < height; y++ {
- copy(dst.Pix[y*dst.Stride:y*dst.Stride+width*4], dst.Pix[0:width*4])
- }
-
- return dst
-}
-
-// Clone returns a copy of the given image.
-func Clone(img image.Image) *image.NRGBA {
- srcBounds := img.Bounds()
- srcMinX := srcBounds.Min.X
- srcMinY := srcBounds.Min.Y
-
- dstBounds := srcBounds.Sub(srcBounds.Min)
- dstW := dstBounds.Dx()
- dstH := dstBounds.Dy()
- dst := image.NewNRGBA(dstBounds)
-
- switch src := img.(type) {
-
- case *image.NRGBA:
- rowSize := srcBounds.Dx() * 4
- parallel(dstH, func(partStart, partEnd int) {
- for dstY := partStart; dstY < partEnd; dstY++ {
- di := dst.PixOffset(0, dstY)
- si := src.PixOffset(srcMinX, srcMinY+dstY)
- copy(dst.Pix[di:di+rowSize], src.Pix[si:si+rowSize])
- }
- })
-
- case *image.NRGBA64:
- parallel(dstH, func(partStart, partEnd int) {
- for dstY := partStart; dstY < partEnd; dstY++ {
- di := dst.PixOffset(0, dstY)
- si := src.PixOffset(srcMinX, srcMinY+dstY)
- for dstX := 0; dstX < dstW; dstX++ {
-
- dst.Pix[di+0] = src.Pix[si+0]
- dst.Pix[di+1] = src.Pix[si+2]
- dst.Pix[di+2] = src.Pix[si+4]
- dst.Pix[di+3] = src.Pix[si+6]
-
- di += 4
- si += 8
-
- }
- }
- })
-
- case *image.RGBA:
- parallel(dstH, func(partStart, partEnd int) {
- for dstY := partStart; dstY < partEnd; dstY++ {
- di := dst.PixOffset(0, dstY)
- si := src.PixOffset(srcMinX, srcMinY+dstY)
- for dstX := 0; dstX < dstW; dstX++ {
-
- a := src.Pix[si+3]
- dst.Pix[di+3] = a
- switch a {
- case 0:
- dst.Pix[di+0] = 0
- dst.Pix[di+1] = 0
- dst.Pix[di+2] = 0
- case 0xff:
- dst.Pix[di+0] = src.Pix[si+0]
- dst.Pix[di+1] = src.Pix[si+1]
- dst.Pix[di+2] = src.Pix[si+2]
- default:
- var tmp uint16
- tmp = uint16(src.Pix[si+0]) * 0xff / uint16(a)
- dst.Pix[di+0] = uint8(tmp)
- tmp = uint16(src.Pix[si+1]) * 0xff / uint16(a)
- dst.Pix[di+1] = uint8(tmp)
- tmp = uint16(src.Pix[si+2]) * 0xff / uint16(a)
- dst.Pix[di+2] = uint8(tmp)
- }
-
- di += 4
- si += 4
-
- }
- }
- })
-
- case *image.RGBA64:
- parallel(dstH, func(partStart, partEnd int) {
- for dstY := partStart; dstY < partEnd; dstY++ {
- di := dst.PixOffset(0, dstY)
- si := src.PixOffset(srcMinX, srcMinY+dstY)
- for dstX := 0; dstX < dstW; dstX++ {
-
- a := src.Pix[si+6]
- dst.Pix[di+3] = a
- switch a {
- case 0:
- dst.Pix[di+0] = 0
- dst.Pix[di+1] = 0
- dst.Pix[di+2] = 0
- case 0xff:
- dst.Pix[di+0] = src.Pix[si+0]
- dst.Pix[di+1] = src.Pix[si+2]
- dst.Pix[di+2] = src.Pix[si+4]
- default:
- var tmp uint16
- tmp = uint16(src.Pix[si+0]) * 0xff / uint16(a)
- dst.Pix[di+0] = uint8(tmp)
- tmp = uint16(src.Pix[si+2]) * 0xff / uint16(a)
- dst.Pix[di+1] = uint8(tmp)
- tmp = uint16(src.Pix[si+4]) * 0xff / uint16(a)
- dst.Pix[di+2] = uint8(tmp)
- }
-
- di += 4
- si += 8
-
- }
- }
- })
-
- case *image.Gray:
- parallel(dstH, func(partStart, partEnd int) {
- for dstY := partStart; dstY < partEnd; dstY++ {
- di := dst.PixOffset(0, dstY)
- si := src.PixOffset(srcMinX, srcMinY+dstY)
- for dstX := 0; dstX < dstW; dstX++ {
-
- c := src.Pix[si]
- dst.Pix[di+0] = c
- dst.Pix[di+1] = c
- dst.Pix[di+2] = c
- dst.Pix[di+3] = 0xff
-
- di += 4
- si += 1
-
- }
- }
- })
-
- case *image.Gray16:
- parallel(dstH, func(partStart, partEnd int) {
- for dstY := partStart; dstY < partEnd; dstY++ {
- di := dst.PixOffset(0, dstY)
- si := src.PixOffset(srcMinX, srcMinY+dstY)
- for dstX := 0; dstX < dstW; dstX++ {
-
- c := src.Pix[si]
- dst.Pix[di+0] = c
- dst.Pix[di+1] = c
- dst.Pix[di+2] = c
- dst.Pix[di+3] = 0xff
-
- di += 4
- si += 2
-
- }
- }
- })
-
- case *image.YCbCr:
- parallel(dstH, func(partStart, partEnd int) {
- for dstY := partStart; dstY < partEnd; dstY++ {
- di := dst.PixOffset(0, dstY)
- for dstX := 0; dstX < dstW; dstX++ {
-
- srcX := srcMinX + dstX
- srcY := srcMinY + dstY
- siy := src.YOffset(srcX, srcY)
- sic := src.COffset(srcX, srcY)
- r, g, b := color.YCbCrToRGB(src.Y[siy], src.Cb[sic], src.Cr[sic])
- dst.Pix[di+0] = r
- dst.Pix[di+1] = g
- dst.Pix[di+2] = b
- dst.Pix[di+3] = 0xff
-
- di += 4
-
- }
- }
- })
-
- case *image.Paletted:
- plen := len(src.Palette)
- pnew := make([]color.NRGBA, plen)
- for i := 0; i < plen; i++ {
- pnew[i] = color.NRGBAModel.Convert(src.Palette[i]).(color.NRGBA)
- }
-
- parallel(dstH, func(partStart, partEnd int) {
- for dstY := partStart; dstY < partEnd; dstY++ {
- di := dst.PixOffset(0, dstY)
- si := src.PixOffset(srcMinX, srcMinY+dstY)
- for dstX := 0; dstX < dstW; dstX++ {
-
- c := pnew[src.Pix[si]]
- dst.Pix[di+0] = c.R
- dst.Pix[di+1] = c.G
- dst.Pix[di+2] = c.B
- dst.Pix[di+3] = c.A
-
- di += 4
- si += 1
-
- }
- }
- })
-
- default:
- parallel(dstH, func(partStart, partEnd int) {
- for dstY := partStart; dstY < partEnd; dstY++ {
- di := dst.PixOffset(0, dstY)
- for dstX := 0; dstX < dstW; dstX++ {
-
- c := color.NRGBAModel.Convert(img.At(srcMinX+dstX, srcMinY+dstY)).(color.NRGBA)
- dst.Pix[di+0] = c.R
- dst.Pix[di+1] = c.G
- dst.Pix[di+2] = c.B
- dst.Pix[di+3] = c.A
-
- di += 4
-
- }
- }
- })
-
- }
-
- return dst
-}
-
-// This function used internally to convert any image type to NRGBA if needed.
-func toNRGBA(img image.Image) *image.NRGBA {
- srcBounds := img.Bounds()
- if srcBounds.Min.X == 0 && srcBounds.Min.Y == 0 {
- if src0, ok := img.(*image.NRGBA); ok {
- return src0
- }
- }
- return Clone(img)
-}
diff --git a/Godeps/_workspace/src/github.com/disintegration/imaging/resize.go b/Godeps/_workspace/src/github.com/disintegration/imaging/resize.go
deleted file mode 100644
index 3c792e904..000000000
--- a/Godeps/_workspace/src/github.com/disintegration/imaging/resize.go
+++ /dev/null
@@ -1,583 +0,0 @@
-package imaging
-
-import (
- "image"
- "math"
-)
-
-type iwpair struct {
- i int
- w int32
-}
-
-type pweights struct {
- iwpairs []iwpair
- wsum int32
-}
-
-func precomputeWeights(dstSize, srcSize int, filter ResampleFilter) []pweights {
- du := float64(srcSize) / float64(dstSize)
- scale := du
- if scale < 1.0 {
- scale = 1.0
- }
- ru := math.Ceil(scale * filter.Support)
-
- out := make([]pweights, dstSize)
-
- for v := 0; v < dstSize; v++ {
- fu := (float64(v)+0.5)*du - 0.5
-
- startu := int(math.Ceil(fu - ru))
- if startu < 0 {
- startu = 0
- }
- endu := int(math.Floor(fu + ru))
- if endu > srcSize-1 {
- endu = srcSize - 1
- }
-
- wsum := int32(0)
- for u := startu; u <= endu; u++ {
- w := int32(0xff * filter.Kernel((float64(u)-fu)/scale))
- if w != 0 {
- wsum += w
- out[v].iwpairs = append(out[v].iwpairs, iwpair{u, w})
- }
- }
- out[v].wsum = wsum
- }
-
- return out
-}
-
-// Resize resizes the image to the specified width and height using the specified resampling
-// filter and returns the transformed image. If one of width or height is 0, the image aspect
-// ratio is preserved.
-//
-// Supported resample filters: NearestNeighbor, Box, Linear, Hermite, MitchellNetravali,
-// CatmullRom, BSpline, Gaussian, Lanczos, Hann, Hamming, Blackman, Bartlett, Welch, Cosine.
-//
-// Usage example:
-//
-// dstImage := imaging.Resize(srcImage, 800, 600, imaging.Lanczos)
-//
-func Resize(img image.Image, width, height int, filter ResampleFilter) *image.NRGBA {
- dstW, dstH := width, height
-
- if dstW < 0 || dstH < 0 {
- return &image.NRGBA{}
- }
- if dstW == 0 && dstH == 0 {
- return &image.NRGBA{}
- }
-
- src := toNRGBA(img)
-
- srcW := src.Bounds().Max.X
- srcH := src.Bounds().Max.Y
-
- if srcW <= 0 || srcH <= 0 {
- return &image.NRGBA{}
- }
-
- // if new width or height is 0 then preserve aspect ratio, minimum 1px
- if dstW == 0 {
- tmpW := float64(dstH) * float64(srcW) / float64(srcH)
- dstW = int(math.Max(1.0, math.Floor(tmpW+0.5)))
- }
- if dstH == 0 {
- tmpH := float64(dstW) * float64(srcH) / float64(srcW)
- dstH = int(math.Max(1.0, math.Floor(tmpH+0.5)))
- }
-
- var dst *image.NRGBA
-
- if filter.Support <= 0.0 {
- // nearest-neighbor special case
- dst = resizeNearest(src, dstW, dstH)
-
- } else {
- // two-pass resize
- if srcW != dstW {
- dst = resizeHorizontal(src, dstW, filter)
- } else {
- dst = src
- }
-
- if srcH != dstH {
- dst = resizeVertical(dst, dstH, filter)
- }
- }
-
- return dst
-}
-
-func resizeHorizontal(src *image.NRGBA, width int, filter ResampleFilter) *image.NRGBA {
- srcBounds := src.Bounds()
- srcW := srcBounds.Max.X
- srcH := srcBounds.Max.Y
-
- dstW := width
- dstH := srcH
-
- dst := image.NewNRGBA(image.Rect(0, 0, dstW, dstH))
-
- weights := precomputeWeights(dstW, srcW, filter)
-
- parallel(dstH, func(partStart, partEnd int) {
- for dstY := partStart; dstY < partEnd; dstY++ {
- for dstX := 0; dstX < dstW; dstX++ {
- var c [4]int32
- for _, iw := range weights[dstX].iwpairs {
- i := dstY*src.Stride + iw.i*4
- c[0] += int32(src.Pix[i+0]) * iw.w
- c[1] += int32(src.Pix[i+1]) * iw.w
- c[2] += int32(src.Pix[i+2]) * iw.w
- c[3] += int32(src.Pix[i+3]) * iw.w
- }
- j := dstY*dst.Stride + dstX*4
- sum := weights[dstX].wsum
- dst.Pix[j+0] = clampint32(int32(float32(c[0])/float32(sum) + 0.5))
- dst.Pix[j+1] = clampint32(int32(float32(c[1])/float32(sum) + 0.5))
- dst.Pix[j+2] = clampint32(int32(float32(c[2])/float32(sum) + 0.5))
- dst.Pix[j+3] = clampint32(int32(float32(c[3])/float32(sum) + 0.5))
- }
- }
- })
-
- return dst
-}
-
-func resizeVertical(src *image.NRGBA, height int, filter ResampleFilter) *image.NRGBA {
- srcBounds := src.Bounds()
- srcW := srcBounds.Max.X
- srcH := srcBounds.Max.Y
-
- dstW := srcW
- dstH := height
-
- dst := image.NewNRGBA(image.Rect(0, 0, dstW, dstH))
-
- weights := precomputeWeights(dstH, srcH, filter)
-
- parallel(dstW, func(partStart, partEnd int) {
-
- for dstX := partStart; dstX < partEnd; dstX++ {
- for dstY := 0; dstY < dstH; dstY++ {
- var c [4]int32
- for _, iw := range weights[dstY].iwpairs {
- i := iw.i*src.Stride + dstX*4
- c[0] += int32(src.Pix[i+0]) * iw.w
- c[1] += int32(src.Pix[i+1]) * iw.w
- c[2] += int32(src.Pix[i+2]) * iw.w
- c[3] += int32(src.Pix[i+3]) * iw.w
- }
- j := dstY*dst.Stride + dstX*4
- sum := weights[dstY].wsum
- dst.Pix[j+0] = clampint32(int32(float32(c[0])/float32(sum) + 0.5))
- dst.Pix[j+1] = clampint32(int32(float32(c[1])/float32(sum) + 0.5))
- dst.Pix[j+2] = clampint32(int32(float32(c[2])/float32(sum) + 0.5))
- dst.Pix[j+3] = clampint32(int32(float32(c[3])/float32(sum) + 0.5))
- }
- }
-
- })
-
- return dst
-}
-
-// fast nearest-neighbor resize, no filtering
-func resizeNearest(src *image.NRGBA, width, height int) *image.NRGBA {
- dstW, dstH := width, height
-
- srcBounds := src.Bounds()
- srcW := srcBounds.Max.X
- srcH := srcBounds.Max.Y
-
- dst := image.NewNRGBA(image.Rect(0, 0, dstW, dstH))
-
- dx := float64(srcW) / float64(dstW)
- dy := float64(srcH) / float64(dstH)
-
- parallel(dstH, func(partStart, partEnd int) {
-
- for dstY := partStart; dstY < partEnd; dstY++ {
- fy := (float64(dstY)+0.5)*dy - 0.5
-
- for dstX := 0; dstX < dstW; dstX++ {
- fx := (float64(dstX)+0.5)*dx - 0.5
-
- srcX := int(math.Min(math.Max(math.Floor(fx+0.5), 0.0), float64(srcW)))
- srcY := int(math.Min(math.Max(math.Floor(fy+0.5), 0.0), float64(srcH)))
-
- srcOff := srcY*src.Stride + srcX*4
- dstOff := dstY*dst.Stride + dstX*4
-
- copy(dst.Pix[dstOff:dstOff+4], src.Pix[srcOff:srcOff+4])
- }
- }
-
- })
-
- return dst
-}
-
-// Fit scales down the image using the specified resample filter to fit the specified
-// maximum width and height and returns the transformed image.
-//
-// Supported resample filters: NearestNeighbor, Box, Linear, Hermite, MitchellNetravali,
-// CatmullRom, BSpline, Gaussian, Lanczos, Hann, Hamming, Blackman, Bartlett, Welch, Cosine.
-//
-// Usage example:
-//
-// dstImage := imaging.Fit(srcImage, 800, 600, imaging.Lanczos)
-//
-func Fit(img image.Image, width, height int, filter ResampleFilter) *image.NRGBA {
- maxW, maxH := width, height
-
- if maxW <= 0 || maxH <= 0 {
- return &image.NRGBA{}
- }
-
- srcBounds := img.Bounds()
- srcW := srcBounds.Dx()
- srcH := srcBounds.Dy()
-
- if srcW <= 0 || srcH <= 0 {
- return &image.NRGBA{}
- }
-
- if srcW <= maxW && srcH <= maxH {
- return Clone(img)
- }
-
- srcAspectRatio := float64(srcW) / float64(srcH)
- maxAspectRatio := float64(maxW) / float64(maxH)
-
- var newW, newH int
- if srcAspectRatio > maxAspectRatio {
- newW = maxW
- newH = int(float64(newW) / srcAspectRatio)
- } else {
- newH = maxH
- newW = int(float64(newH) * srcAspectRatio)
- }
-
- return Resize(img, newW, newH, filter)
-}
-
-// Fill scales the image to the smallest possible size that will cover the specified dimensions,
-// crops the resized image to the specified dimensions using the given anchor point and returns
-// the transformed image.
-//
-// Supported resample filters: NearestNeighbor, Box, Linear, Hermite, MitchellNetravali,
-// CatmullRom, BSpline, Gaussian, Lanczos, Hann, Hamming, Blackman, Bartlett, Welch, Cosine.
-//
-// Usage example:
-//
-// dstImage := imaging.Fill(srcImage, 800, 600, imaging.Center, imaging.Lanczos)
-//
-func Fill(img image.Image, width, height int, anchor Anchor, filter ResampleFilter) *image.NRGBA {
- minW, minH := width, height
-
- if minW <= 0 || minH <= 0 {
- return &image.NRGBA{}
- }
-
- srcBounds := img.Bounds()
- srcW := srcBounds.Dx()
- srcH := srcBounds.Dy()
-
- if srcW <= 0 || srcH <= 0 {
- return &image.NRGBA{}
- }
-
- if srcW == minW && srcH == minH {
- return Clone(img)
- }
-
- srcAspectRatio := float64(srcW) / float64(srcH)
- minAspectRatio := float64(minW) / float64(minH)
-
- var tmp *image.NRGBA
- if srcAspectRatio < minAspectRatio {
- tmp = Resize(img, minW, 0, filter)
- } else {
- tmp = Resize(img, 0, minH, filter)
- }
-
- return CropAnchor(tmp, minW, minH, anchor)
-}
-
-// Thumbnail scales the image up or down using the specified resample filter, crops it
-// to the specified width and hight and returns the transformed image.
-//
-// Supported resample filters: NearestNeighbor, Box, Linear, Hermite, MitchellNetravali,
-// CatmullRom, BSpline, Gaussian, Lanczos, Hann, Hamming, Blackman, Bartlett, Welch, Cosine.
-//
-// Usage example:
-//
-// dstImage := imaging.Thumbnail(srcImage, 100, 100, imaging.Lanczos)
-//
-func Thumbnail(img image.Image, width, height int, filter ResampleFilter) *image.NRGBA {
- return Fill(img, width, height, Center, filter)
-}
-
-// Resample filter struct. It can be used to make custom filters.
-//
-// Supported resample filters: NearestNeighbor, Box, Linear, Hermite, MitchellNetravali,
-// CatmullRom, BSpline, Gaussian, Lanczos, Hann, Hamming, Blackman, Bartlett, Welch, Cosine.
-//
-// General filter recommendations:
-//
-// - Lanczos
-// Probably the best resampling filter for photographic images yielding sharp results,
-// but it's slower than cubic filters (see below).
-//
-// - CatmullRom
-// A sharp cubic filter. It's a good filter for both upscaling and downscaling if sharp results are needed.
-//
-// - MitchellNetravali
-// A high quality cubic filter that produces smoother results with less ringing than CatmullRom.
-//
-// - BSpline
-// A good filter if a very smooth output is needed.
-//
-// - Linear
-// Bilinear interpolation filter, produces reasonably good, smooth output. It's faster than cubic filters.
-//
-// - Box
-// Simple and fast resampling filter appropriate for downscaling.
-// When upscaling it's similar to NearestNeighbor.
-//
-// - NearestNeighbor
-// Fastest resample filter, no antialiasing at all. Rarely used.
-//
-type ResampleFilter struct {
- Support float64
- Kernel func(float64) float64
-}
-
-// Nearest-neighbor filter, no anti-aliasing.
-var NearestNeighbor ResampleFilter
-
-// Box filter (averaging pixels).
-var Box ResampleFilter
-
-// Linear filter.
-var Linear ResampleFilter
-
-// Hermite cubic spline filter (BC-spline; B=0; C=0).
-var Hermite ResampleFilter
-
-// Mitchell-Netravali cubic filter (BC-spline; B=1/3; C=1/3).
-var MitchellNetravali ResampleFilter
-
-// Catmull-Rom - sharp cubic filter (BC-spline; B=0; C=0.5).
-var CatmullRom ResampleFilter
-
-// Cubic B-spline - smooth cubic filter (BC-spline; B=1; C=0).
-var BSpline ResampleFilter
-
-// Gaussian Blurring Filter.
-var Gaussian ResampleFilter
-
-// Bartlett-windowed sinc filter (3 lobes).
-var Bartlett ResampleFilter
-
-// Lanczos filter (3 lobes).
-var Lanczos ResampleFilter
-
-// Hann-windowed sinc filter (3 lobes).
-var Hann ResampleFilter
-
-// Hamming-windowed sinc filter (3 lobes).
-var Hamming ResampleFilter
-
-// Blackman-windowed sinc filter (3 lobes).
-var Blackman ResampleFilter
-
-// Welch-windowed sinc filter (parabolic window, 3 lobes).
-var Welch ResampleFilter
-
-// Cosine-windowed sinc filter (3 lobes).
-var Cosine ResampleFilter
-
-func bcspline(x, b, c float64) float64 {
- x = math.Abs(x)
- if x < 1.0 {
- return ((12-9*b-6*c)*x*x*x + (-18+12*b+6*c)*x*x + (6 - 2*b)) / 6
- }
- if x < 2.0 {
- return ((-b-6*c)*x*x*x + (6*b+30*c)*x*x + (-12*b-48*c)*x + (8*b + 24*c)) / 6
- }
- return 0
-}
-
-func sinc(x float64) float64 {
- if x == 0 {
- return 1
- }
- return math.Sin(math.Pi*x) / (math.Pi * x)
-}
-
-func init() {
- NearestNeighbor = ResampleFilter{
- Support: 0.0, // special case - not applying the filter
- }
-
- Box = ResampleFilter{
- Support: 0.5,
- Kernel: func(x float64) float64 {
- x = math.Abs(x)
- if x <= 0.5 {
- return 1.0
- }
- return 0
- },
- }
-
- Linear = ResampleFilter{
- Support: 1.0,
- Kernel: func(x float64) float64 {
- x = math.Abs(x)
- if x < 1.0 {
- return 1.0 - x
- }
- return 0
- },
- }
-
- Hermite = ResampleFilter{
- Support: 1.0,
- Kernel: func(x float64) float64 {
- x = math.Abs(x)
- if x < 1.0 {
- return bcspline(x, 0.0, 0.0)
- }
- return 0
- },
- }
-
- MitchellNetravali = ResampleFilter{
- Support: 2.0,
- Kernel: func(x float64) float64 {
- x = math.Abs(x)
- if x < 2.0 {
- return bcspline(x, 1.0/3.0, 1.0/3.0)
- }
- return 0
- },
- }
-
- CatmullRom = ResampleFilter{
- Support: 2.0,
- Kernel: func(x float64) float64 {
- x = math.Abs(x)
- if x < 2.0 {
- return bcspline(x, 0.0, 0.5)
- }
- return 0
- },
- }
-
- BSpline = ResampleFilter{
- Support: 2.0,
- Kernel: func(x float64) float64 {
- x = math.Abs(x)
- if x < 2.0 {
- return bcspline(x, 1.0, 0.0)
- }
- return 0
- },
- }
-
- Gaussian = ResampleFilter{
- Support: 2.0,
- Kernel: func(x float64) float64 {
- x = math.Abs(x)
- if x < 2.0 {
- return math.Exp(-2 * x * x)
- }
- return 0
- },
- }
-
- Bartlett = ResampleFilter{
- Support: 3.0,
- Kernel: func(x float64) float64 {
- x = math.Abs(x)
- if x < 3.0 {
- return sinc(x) * (3.0 - x) / 3.0
- }
- return 0
- },
- }
-
- Lanczos = ResampleFilter{
- Support: 3.0,
- Kernel: func(x float64) float64 {
- x = math.Abs(x)
- if x < 3.0 {
- return sinc(x) * sinc(x/3.0)
- }
- return 0
- },
- }
-
- Hann = ResampleFilter{
- Support: 3.0,
- Kernel: func(x float64) float64 {
- x = math.Abs(x)
- if x < 3.0 {
- return sinc(x) * (0.5 + 0.5*math.Cos(math.Pi*x/3.0))
- }
- return 0
- },
- }
-
- Hamming = ResampleFilter{
- Support: 3.0,
- Kernel: func(x float64) float64 {
- x = math.Abs(x)
- if x < 3.0 {
- return sinc(x) * (0.54 + 0.46*math.Cos(math.Pi*x/3.0))
- }
- return 0
- },
- }
-
- Blackman = ResampleFilter{
- Support: 3.0,
- Kernel: func(x float64) float64 {
- x = math.Abs(x)
- if x < 3.0 {
- return sinc(x) * (0.42 - 0.5*math.Cos(math.Pi*x/3.0+math.Pi) + 0.08*math.Cos(2.0*math.Pi*x/3.0))
- }
- return 0
- },
- }
-
- Welch = ResampleFilter{
- Support: 3.0,
- Kernel: func(x float64) float64 {
- x = math.Abs(x)
- if x < 3.0 {
- return sinc(x) * (1.0 - (x * x / 9.0))
- }
- return 0
- },
- }
-
- Cosine = ResampleFilter{
- Support: 3.0,
- Kernel: func(x float64) float64 {
- x = math.Abs(x)
- if x < 3.0 {
- return sinc(x) * math.Cos((math.Pi/2.0)*(x/3.0))
- }
- return 0
- },
- }
-}
diff --git a/Godeps/_workspace/src/github.com/disintegration/imaging/tools.go b/Godeps/_workspace/src/github.com/disintegration/imaging/tools.go
deleted file mode 100644
index 2c39c900a..000000000
--- a/Godeps/_workspace/src/github.com/disintegration/imaging/tools.go
+++ /dev/null
@@ -1,182 +0,0 @@
-package imaging
-
-import (
- "image"
- "math"
-)
-
-// Anchor is the anchor point for image alignment.
-type Anchor int
-
-const (
- Center Anchor = iota
- TopLeft
- Top
- TopRight
- Left
- Right
- BottomLeft
- Bottom
- BottomRight
-)
-
-func anchorPt(b image.Rectangle, w, h int, anchor Anchor) image.Point {
- var x, y int
- switch anchor {
- case TopLeft:
- x = b.Min.X
- y = b.Min.Y
- case Top:
- x = b.Min.X + (b.Dx()-w)/2
- y = b.Min.Y
- case TopRight:
- x = b.Max.X - w
- y = b.Min.Y
- case Left:
- x = b.Min.X
- y = b.Min.Y + (b.Dy()-h)/2
- case Right:
- x = b.Max.X - w
- y = b.Min.Y + (b.Dy()-h)/2
- case BottomLeft:
- x = b.Min.X
- y = b.Max.Y - h
- case Bottom:
- x = b.Min.X + (b.Dx()-w)/2
- y = b.Max.Y - h
- case BottomRight:
- x = b.Max.X - w
- y = b.Max.Y - h
- default:
- x = b.Min.X + (b.Dx()-w)/2
- y = b.Min.Y + (b.Dy()-h)/2
- }
- return image.Pt(x, y)
-}
-
-// Crop cuts out a rectangular region with the specified bounds
-// from the image and returns the cropped image.
-func Crop(img image.Image, rect image.Rectangle) *image.NRGBA {
- src := toNRGBA(img)
- srcRect := rect.Sub(img.Bounds().Min)
- sub := src.SubImage(srcRect)
- return Clone(sub) // New image Bounds().Min point will be (0, 0)
-}
-
-// CropAnchor cuts out a rectangular region with the specified size
-// from the image using the specified anchor point and returns the cropped image.
-func CropAnchor(img image.Image, width, height int, anchor Anchor) *image.NRGBA {
- srcBounds := img.Bounds()
- pt := anchorPt(srcBounds, width, height, anchor)
- r := image.Rect(0, 0, width, height).Add(pt)
- b := srcBounds.Intersect(r)
- return Crop(img, b)
-}
-
-// CropCenter cuts out a rectangular region with the specified size
-// from the center of the image and returns the cropped image.
-func CropCenter(img image.Image, width, height int) *image.NRGBA {
- return CropAnchor(img, width, height, Center)
-}
-
-// Paste pastes the img image to the background image at the specified position and returns the combined image.
-func Paste(background, img image.Image, pos image.Point) *image.NRGBA {
- src := toNRGBA(img)
- dst := Clone(background) // cloned image bounds start at (0, 0)
- startPt := pos.Sub(background.Bounds().Min) // so we should translate start point
- endPt := startPt.Add(src.Bounds().Size())
- pasteBounds := image.Rectangle{startPt, endPt}
-
- if dst.Bounds().Overlaps(pasteBounds) {
- intersectBounds := dst.Bounds().Intersect(pasteBounds)
-
- rowSize := intersectBounds.Dx() * 4
- numRows := intersectBounds.Dy()
-
- srcStartX := intersectBounds.Min.X - pasteBounds.Min.X
- srcStartY := intersectBounds.Min.Y - pasteBounds.Min.Y
-
- i0 := dst.PixOffset(intersectBounds.Min.X, intersectBounds.Min.Y)
- j0 := src.PixOffset(srcStartX, srcStartY)
-
- di := dst.Stride
- dj := src.Stride
-
- for row := 0; row < numRows; row++ {
- copy(dst.Pix[i0:i0+rowSize], src.Pix[j0:j0+rowSize])
- i0 += di
- j0 += dj
- }
- }
-
- return dst
-}
-
-// PasteCenter pastes the img image to the center of the background image and returns the combined image.
-func PasteCenter(background, img image.Image) *image.NRGBA {
- bgBounds := background.Bounds()
- bgW := bgBounds.Dx()
- bgH := bgBounds.Dy()
- bgMinX := bgBounds.Min.X
- bgMinY := bgBounds.Min.Y
-
- centerX := bgMinX + bgW/2
- centerY := bgMinY + bgH/2
-
- x0 := centerX - img.Bounds().Dx()/2
- y0 := centerY - img.Bounds().Dy()/2
-
- return Paste(background, img, image.Pt(x0, y0))
-}
-
-// Overlay draws the img image over the background image at given position
-// and returns the combined image. Opacity parameter is the opacity of the img
-// image layer, used to compose the images, it must be from 0.0 to 1.0.
-//
-// Usage examples:
-//
-// // draw the sprite over the background at position (50, 50)
-// dstImage := imaging.Overlay(backgroundImage, spriteImage, image.Pt(50, 50), 1.0)
-//
-// // blend two opaque images of the same size
-// dstImage := imaging.Overlay(imageOne, imageTwo, image.Pt(0, 0), 0.5)
-//
-func Overlay(background, img image.Image, pos image.Point, opacity float64) *image.NRGBA {
- opacity = math.Min(math.Max(opacity, 0.0), 1.0) // check: 0.0 <= opacity <= 1.0
-
- src := toNRGBA(img)
- dst := Clone(background) // cloned image bounds start at (0, 0)
- startPt := pos.Sub(background.Bounds().Min) // so we should translate start point
- endPt := startPt.Add(src.Bounds().Size())
- pasteBounds := image.Rectangle{startPt, endPt}
-
- if dst.Bounds().Overlaps(pasteBounds) {
- intersectBounds := dst.Bounds().Intersect(pasteBounds)
-
- for y := intersectBounds.Min.Y; y < intersectBounds.Max.Y; y++ {
- for x := intersectBounds.Min.X; x < intersectBounds.Max.X; x++ {
- i := y*dst.Stride + x*4
-
- srcX := x - pasteBounds.Min.X
- srcY := y - pasteBounds.Min.Y
- j := srcY*src.Stride + srcX*4
-
- a1 := float64(dst.Pix[i+3])
- a2 := float64(src.Pix[j+3])
-
- coef2 := opacity * a2 / 255.0
- coef1 := (1 - coef2) * a1 / 255.0
- coefSum := coef1 + coef2
- coef1 /= coefSum
- coef2 /= coefSum
-
- dst.Pix[i+0] = uint8(float64(dst.Pix[i+0])*coef1 + float64(src.Pix[j+0])*coef2)
- dst.Pix[i+1] = uint8(float64(dst.Pix[i+1])*coef1 + float64(src.Pix[j+1])*coef2)
- dst.Pix[i+2] = uint8(float64(dst.Pix[i+2])*coef1 + float64(src.Pix[j+2])*coef2)
- dst.Pix[i+3] = uint8(math.Min(a1+a2*opacity*(255.0-a1)/255.0, 255.0))
- }
- }
- }
-
- return dst
-}
diff --git a/Godeps/_workspace/src/github.com/disintegration/imaging/transform.go b/Godeps/_workspace/src/github.com/disintegration/imaging/transform.go
deleted file mode 100644
index a11601bba..000000000
--- a/Godeps/_workspace/src/github.com/disintegration/imaging/transform.go
+++ /dev/null
@@ -1,201 +0,0 @@
-package imaging
-
-import (
- "image"
-)
-
-// Rotate90 rotates the image 90 degrees counterclockwise and returns the transformed image.
-func Rotate90(img image.Image) *image.NRGBA {
- src := toNRGBA(img)
- srcW := src.Bounds().Max.X
- srcH := src.Bounds().Max.Y
- dstW := srcH
- dstH := srcW
- dst := image.NewNRGBA(image.Rect(0, 0, dstW, dstH))
-
- parallel(dstH, func(partStart, partEnd int) {
-
- for dstY := partStart; dstY < partEnd; dstY++ {
- for dstX := 0; dstX < dstW; dstX++ {
- srcX := dstH - dstY - 1
- srcY := dstX
-
- srcOff := srcY*src.Stride + srcX*4
- dstOff := dstY*dst.Stride + dstX*4
-
- copy(dst.Pix[dstOff:dstOff+4], src.Pix[srcOff:srcOff+4])
- }
- }
-
- })
-
- return dst
-}
-
-// Rotate180 rotates the image 180 degrees counterclockwise and returns the transformed image.
-func Rotate180(img image.Image) *image.NRGBA {
- src := toNRGBA(img)
- srcW := src.Bounds().Max.X
- srcH := src.Bounds().Max.Y
- dstW := srcW
- dstH := srcH
- dst := image.NewNRGBA(image.Rect(0, 0, dstW, dstH))
-
- parallel(dstH, func(partStart, partEnd int) {
-
- for dstY := partStart; dstY < partEnd; dstY++ {
- for dstX := 0; dstX < dstW; dstX++ {
- srcX := dstW - dstX - 1
- srcY := dstH - dstY - 1
-
- srcOff := srcY*src.Stride + srcX*4
- dstOff := dstY*dst.Stride + dstX*4
-
- copy(dst.Pix[dstOff:dstOff+4], src.Pix[srcOff:srcOff+4])
- }
- }
-
- })
-
- return dst
-}
-
-// Rotate270 rotates the image 270 degrees counterclockwise and returns the transformed image.
-func Rotate270(img image.Image) *image.NRGBA {
- src := toNRGBA(img)
- srcW := src.Bounds().Max.X
- srcH := src.Bounds().Max.Y
- dstW := srcH
- dstH := srcW
- dst := image.NewNRGBA(image.Rect(0, 0, dstW, dstH))
-
- parallel(dstH, func(partStart, partEnd int) {
-
- for dstY := partStart; dstY < partEnd; dstY++ {
- for dstX := 0; dstX < dstW; dstX++ {
- srcX := dstY
- srcY := dstW - dstX - 1
-
- srcOff := srcY*src.Stride + srcX*4
- dstOff := dstY*dst.Stride + dstX*4
-
- copy(dst.Pix[dstOff:dstOff+4], src.Pix[srcOff:srcOff+4])
- }
- }
-
- })
-
- return dst
-}
-
-// FlipH flips the image horizontally (from left to right) and returns the transformed image.
-func FlipH(img image.Image) *image.NRGBA {
- src := toNRGBA(img)
- srcW := src.Bounds().Max.X
- srcH := src.Bounds().Max.Y
- dstW := srcW
- dstH := srcH
- dst := image.NewNRGBA(image.Rect(0, 0, dstW, dstH))
-
- parallel(dstH, func(partStart, partEnd int) {
-
- for dstY := partStart; dstY < partEnd; dstY++ {
- for dstX := 0; dstX < dstW; dstX++ {
- srcX := dstW - dstX - 1
- srcY := dstY
-
- srcOff := srcY*src.Stride + srcX*4
- dstOff := dstY*dst.Stride + dstX*4
-
- copy(dst.Pix[dstOff:dstOff+4], src.Pix[srcOff:srcOff+4])
- }
- }
-
- })
-
- return dst
-}
-
-// FlipV flips the image vertically (from top to bottom) and returns the transformed image.
-func FlipV(img image.Image) *image.NRGBA {
- src := toNRGBA(img)
- srcW := src.Bounds().Max.X
- srcH := src.Bounds().Max.Y
- dstW := srcW
- dstH := srcH
- dst := image.NewNRGBA(image.Rect(0, 0, dstW, dstH))
-
- parallel(dstH, func(partStart, partEnd int) {
-
- for dstY := partStart; dstY < partEnd; dstY++ {
- for dstX := 0; dstX < dstW; dstX++ {
- srcX := dstX
- srcY := dstH - dstY - 1
-
- srcOff := srcY*src.Stride + srcX*4
- dstOff := dstY*dst.Stride + dstX*4
-
- copy(dst.Pix[dstOff:dstOff+4], src.Pix[srcOff:srcOff+4])
- }
- }
-
- })
-
- return dst
-}
-
-// Transpose flips the image horizontally and rotates 90 degrees counter-clockwise.
-func Transpose(img image.Image) *image.NRGBA {
- src := toNRGBA(img)
- srcW := src.Bounds().Max.X
- srcH := src.Bounds().Max.Y
- dstW := srcH
- dstH := srcW
- dst := image.NewNRGBA(image.Rect(0, 0, dstW, dstH))
-
- parallel(dstH, func(partStart, partEnd int) {
-
- for dstY := partStart; dstY < partEnd; dstY++ {
- for dstX := 0; dstX < dstW; dstX++ {
- srcX := dstY
- srcY := dstX
-
- srcOff := srcY*src.Stride + srcX*4
- dstOff := dstY*dst.Stride + dstX*4
-
- copy(dst.Pix[dstOff:dstOff+4], src.Pix[srcOff:srcOff+4])
- }
- }
-
- })
-
- return dst
-}
-
-// Transverse flips the image vertically and rotates 90 degrees counter-clockwise.
-func Transverse(img image.Image) *image.NRGBA {
- src := toNRGBA(img)
- srcW := src.Bounds().Max.X
- srcH := src.Bounds().Max.Y
- dstW := srcH
- dstH := srcW
- dst := image.NewNRGBA(image.Rect(0, 0, dstW, dstH))
-
- parallel(dstH, func(partStart, partEnd int) {
-
- for dstY := partStart; dstY < partEnd; dstY++ {
- for dstX := 0; dstX < dstW; dstX++ {
- srcX := dstH - dstY - 1
- srcY := dstW - dstX - 1
-
- srcOff := srcY*src.Stride + srcX*4
- dstOff := dstY*dst.Stride + dstX*4
-
- copy(dst.Pix[dstOff:dstOff+4], src.Pix[srcOff:srcOff+4])
- }
- }
-
- })
-
- return dst
-}
diff --git a/Godeps/_workspace/src/github.com/disintegration/imaging/utils.go b/Godeps/_workspace/src/github.com/disintegration/imaging/utils.go
deleted file mode 100644
index 8b1ab8adb..000000000
--- a/Godeps/_workspace/src/github.com/disintegration/imaging/utils.go
+++ /dev/null
@@ -1,77 +0,0 @@
-package imaging
-
-import (
- "math"
- "runtime"
- "sync"
- "sync/atomic"
-)
-
-var parallelizationEnabled = true
-
-// if GOMAXPROCS = 1: no goroutines used
-// if GOMAXPROCS > 1: spawn N=GOMAXPROCS workers in separate goroutines
-func parallel(dataSize int, fn func(partStart, partEnd int)) {
- numGoroutines := 1
- partSize := dataSize
-
- if parallelizationEnabled {
- numProcs := runtime.GOMAXPROCS(0)
- if numProcs > 1 {
- numGoroutines = numProcs
- partSize = dataSize / (numGoroutines * 10)
- if partSize < 1 {
- partSize = 1
- }
- }
- }
-
- if numGoroutines == 1 {
- fn(0, dataSize)
- } else {
- var wg sync.WaitGroup
- wg.Add(numGoroutines)
- idx := uint64(0)
-
- for p := 0; p < numGoroutines; p++ {
- go func() {
- defer wg.Done()
- for {
- partStart := int(atomic.AddUint64(&idx, uint64(partSize))) - partSize
- if partStart >= dataSize {
- break
- }
- partEnd := partStart + partSize
- if partEnd > dataSize {
- partEnd = dataSize
- }
- fn(partStart, partEnd)
- }
- }()
- }
-
- wg.Wait()
- }
-}
-
-func absint(i int) int {
- if i < 0 {
- return -i
- }
- return i
-}
-
-// clamp & round float64 to uint8 (0..255)
-func clamp(v float64) uint8 {
- return uint8(math.Min(math.Max(v, 0.0), 255.0) + 0.5)
-}
-
-// clamp int32 to uint8 (0..255)
-func clampint32(v int32) uint8 {
- if v < 0 {
- return 0
- } else if v > 255 {
- return 255
- }
- return uint8(v)
-}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/LICENSE b/Godeps/_workspace/src/github.com/garyburd/redigo/LICENSE
deleted file mode 100644
index 67db85882..000000000
--- a/Godeps/_workspace/src/github.com/garyburd/redigo/LICENSE
+++ /dev/null
@@ -1,175 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/internal/commandinfo.go b/Godeps/_workspace/src/github.com/garyburd/redigo/internal/commandinfo.go
deleted file mode 100644
index dbc60fc8e..000000000
--- a/Godeps/_workspace/src/github.com/garyburd/redigo/internal/commandinfo.go
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2014 Gary Burd
-//
-// Licensed under the Apache License, Version 2.0 (the "License"): you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations
-// under the License.
-
-package internal
-
-import (
- "strings"
-)
-
-const (
- WatchState = 1 << iota
- MultiState
- SubscribeState
- MonitorState
-)
-
-type CommandInfo struct {
- Set, Clear int
-}
-
-var commandInfos = map[string]CommandInfo{
- "WATCH": {Set: WatchState},
- "UNWATCH": {Clear: WatchState},
- "MULTI": {Set: MultiState},
- "EXEC": {Clear: WatchState | MultiState},
- "DISCARD": {Clear: WatchState | MultiState},
- "PSUBSCRIBE": {Set: SubscribeState},
- "SUBSCRIBE": {Set: SubscribeState},
- "MONITOR": {Set: MonitorState},
-}
-
-func init() {
- for n, ci := range commandInfos {
- commandInfos[strings.ToLower(n)] = ci
- }
-}
-
-func LookupCommandInfo(commandName string) CommandInfo {
- if ci, ok := commandInfos[commandName]; ok {
- return ci
- }
- return commandInfos[strings.ToUpper(commandName)]
-}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/internal/redistest/testdb.go b/Godeps/_workspace/src/github.com/garyburd/redigo/internal/redistest/testdb.go
deleted file mode 100644
index b6f205b7f..000000000
--- a/Godeps/_workspace/src/github.com/garyburd/redigo/internal/redistest/testdb.go
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2014 Gary Burd
-//
-// Licensed under the Apache License, Version 2.0 (the "License"): you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations
-// under the License.
-
-// Package redistest contains utilities for writing Redigo tests.
-package redistest
-
-import (
- "errors"
- "time"
-
- "github.com/garyburd/redigo/redis"
-)
-
-type testConn struct {
- redis.Conn
-}
-
-func (t testConn) Close() error {
- _, err := t.Conn.Do("SELECT", "9")
- if err != nil {
- return nil
- }
- _, err = t.Conn.Do("FLUSHDB")
- if err != nil {
- return err
- }
- return t.Conn.Close()
-}
-
-// Dial dials the local Redis server and selects database 9. To prevent
-// stomping on real data, DialTestDB fails if database 9 contains data. The
-// returned connection flushes database 9 on close.
-func Dial() (redis.Conn, error) {
- c, err := redis.DialTimeout("tcp", ":6379", 0, 1*time.Second, 1*time.Second)
- if err != nil {
- return nil, err
- }
-
- _, err = c.Do("SELECT", "9")
- if err != nil {
- c.Close()
- return nil, err
- }
-
- n, err := redis.Int(c.Do("DBSIZE"))
- if err != nil {
- c.Close()
- return nil, err
- }
-
- if n != 0 {
- c.Close()
- return nil, errors.New("database #9 is not empty, test can not continue")
- }
-
- return testConn{c}, nil
-}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/conn.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/conn.go
deleted file mode 100644
index 6a3819f1d..000000000
--- a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/conn.go
+++ /dev/null
@@ -1,567 +0,0 @@
-// Copyright 2012 Gary Burd
-//
-// Licensed under the Apache License, Version 2.0 (the "License"): you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations
-// under the License.
-
-package redis
-
-import (
- "bufio"
- "bytes"
- "errors"
- "fmt"
- "io"
- "net"
- "net/url"
- "regexp"
- "strconv"
- "sync"
- "time"
-)
-
-// conn is the low-level implementation of Conn
-type conn struct {
-
- // Shared
- mu sync.Mutex
- pending int
- err error
- conn net.Conn
-
- // Read
- readTimeout time.Duration
- br *bufio.Reader
-
- // Write
- writeTimeout time.Duration
- bw *bufio.Writer
-
- // Scratch space for formatting argument length.
- // '*' or '$', length, "\r\n"
- lenScratch [32]byte
-
- // Scratch space for formatting integers and floats.
- numScratch [40]byte
-}
-
-// DialTimeout acts like Dial but takes timeouts for establishing the
-// connection to the server, writing a command and reading a reply.
-//
-// Deprecated: Use Dial with options instead.
-func DialTimeout(network, address string, connectTimeout, readTimeout, writeTimeout time.Duration) (Conn, error) {
- return Dial(network, address,
- DialConnectTimeout(connectTimeout),
- DialReadTimeout(readTimeout),
- DialWriteTimeout(writeTimeout))
-}
-
-// DialOption specifies an option for dialing a Redis server.
-type DialOption struct {
- f func(*dialOptions)
-}
-
-type dialOptions struct {
- readTimeout time.Duration
- writeTimeout time.Duration
- dial func(network, addr string) (net.Conn, error)
- db int
- password string
-}
-
-// DialReadTimeout specifies the timeout for reading a single command reply.
-func DialReadTimeout(d time.Duration) DialOption {
- return DialOption{func(do *dialOptions) {
- do.readTimeout = d
- }}
-}
-
-// DialWriteTimeout specifies the timeout for writing a single command.
-func DialWriteTimeout(d time.Duration) DialOption {
- return DialOption{func(do *dialOptions) {
- do.writeTimeout = d
- }}
-}
-
-// DialConnectTimeout specifies the timeout for connecting to the Redis server.
-func DialConnectTimeout(d time.Duration) DialOption {
- return DialOption{func(do *dialOptions) {
- dialer := net.Dialer{Timeout: d}
- do.dial = dialer.Dial
- }}
-}
-
-// DialNetDial specifies a custom dial function for creating TCP
-// connections. If this option is left out, then net.Dial is
-// used. DialNetDial overrides DialConnectTimeout.
-func DialNetDial(dial func(network, addr string) (net.Conn, error)) DialOption {
- return DialOption{func(do *dialOptions) {
- do.dial = dial
- }}
-}
-
-// DialDatabase specifies the database to select when dialing a connection.
-func DialDatabase(db int) DialOption {
- return DialOption{func(do *dialOptions) {
- do.db = db
- }}
-}
-
-// DialPassword specifies the password to use when connecting to
-// the Redis server.
-func DialPassword(password string) DialOption {
- return DialOption{func(do *dialOptions) {
- do.password = password
- }}
-}
-
-// Dial connects to the Redis server at the given network and
-// address using the specified options.
-func Dial(network, address string, options ...DialOption) (Conn, error) {
- do := dialOptions{
- dial: net.Dial,
- }
- for _, option := range options {
- option.f(&do)
- }
-
- netConn, err := do.dial(network, address)
- if err != nil {
- return nil, err
- }
- c := &conn{
- conn: netConn,
- bw: bufio.NewWriter(netConn),
- br: bufio.NewReader(netConn),
- readTimeout: do.readTimeout,
- writeTimeout: do.writeTimeout,
- }
-
- if do.password != "" {
- if _, err := c.Do("AUTH", do.password); err != nil {
- netConn.Close()
- return nil, err
- }
- }
-
- if do.db != 0 {
- if _, err := c.Do("SELECT", do.db); err != nil {
- netConn.Close()
- return nil, err
- }
- }
-
- return c, nil
-}
-
-var pathDBRegexp = regexp.MustCompile(`/(\d+)\z`)
-
-// DialURL connects to a Redis server at the given URL using the Redis
-// URI scheme. URLs should follow the draft IANA specification for the
-// scheme (https://www.iana.org/assignments/uri-schemes/prov/redis).
-func DialURL(rawurl string, options ...DialOption) (Conn, error) {
- u, err := url.Parse(rawurl)
- if err != nil {
- return nil, err
- }
-
- if u.Scheme != "redis" {
- return nil, fmt.Errorf("invalid redis URL scheme: %s", u.Scheme)
- }
-
- // As per the IANA draft spec, the host defaults to localhost and
- // the port defaults to 6379.
- host, port, err := net.SplitHostPort(u.Host)
- if err != nil {
- // assume port is missing
- host = u.Host
- port = "6379"
- }
- if host == "" {
- host = "localhost"
- }
- address := net.JoinHostPort(host, port)
-
- if u.User != nil {
- password, isSet := u.User.Password()
- if isSet {
- options = append(options, DialPassword(password))
- }
- }
-
- match := pathDBRegexp.FindStringSubmatch(u.Path)
- if len(match) == 2 {
- db, err := strconv.Atoi(match[1])
- if err != nil {
- return nil, fmt.Errorf("invalid database: %s", u.Path[1:])
- }
- if db != 0 {
- options = append(options, DialDatabase(db))
- }
- } else if u.Path != "" {
- return nil, fmt.Errorf("invalid database: %s", u.Path[1:])
- }
-
- return Dial("tcp", address, options...)
-}
-
-// NewConn returns a new Redigo connection for the given net connection.
-func NewConn(netConn net.Conn, readTimeout, writeTimeout time.Duration) Conn {
- return &conn{
- conn: netConn,
- bw: bufio.NewWriter(netConn),
- br: bufio.NewReader(netConn),
- readTimeout: readTimeout,
- writeTimeout: writeTimeout,
- }
-}
-
-func (c *conn) Close() error {
- c.mu.Lock()
- err := c.err
- if c.err == nil {
- c.err = errors.New("redigo: closed")
- err = c.conn.Close()
- }
- c.mu.Unlock()
- return err
-}
-
-func (c *conn) fatal(err error) error {
- c.mu.Lock()
- if c.err == nil {
- c.err = err
- // Close connection to force errors on subsequent calls and to unblock
- // other reader or writer.
- c.conn.Close()
- }
- c.mu.Unlock()
- return err
-}
-
-func (c *conn) Err() error {
- c.mu.Lock()
- err := c.err
- c.mu.Unlock()
- return err
-}
-
-func (c *conn) writeLen(prefix byte, n int) error {
- c.lenScratch[len(c.lenScratch)-1] = '\n'
- c.lenScratch[len(c.lenScratch)-2] = '\r'
- i := len(c.lenScratch) - 3
- for {
- c.lenScratch[i] = byte('0' + n%10)
- i -= 1
- n = n / 10
- if n == 0 {
- break
- }
- }
- c.lenScratch[i] = prefix
- _, err := c.bw.Write(c.lenScratch[i:])
- return err
-}
-
-func (c *conn) writeString(s string) error {
- c.writeLen('$', len(s))
- c.bw.WriteString(s)
- _, err := c.bw.WriteString("\r\n")
- return err
-}
-
-func (c *conn) writeBytes(p []byte) error {
- c.writeLen('$', len(p))
- c.bw.Write(p)
- _, err := c.bw.WriteString("\r\n")
- return err
-}
-
-func (c *conn) writeInt64(n int64) error {
- return c.writeBytes(strconv.AppendInt(c.numScratch[:0], n, 10))
-}
-
-func (c *conn) writeFloat64(n float64) error {
- return c.writeBytes(strconv.AppendFloat(c.numScratch[:0], n, 'g', -1, 64))
-}
-
-func (c *conn) writeCommand(cmd string, args []interface{}) (err error) {
- c.writeLen('*', 1+len(args))
- err = c.writeString(cmd)
- for _, arg := range args {
- if err != nil {
- break
- }
- switch arg := arg.(type) {
- case string:
- err = c.writeString(arg)
- case []byte:
- err = c.writeBytes(arg)
- case int:
- err = c.writeInt64(int64(arg))
- case int64:
- err = c.writeInt64(arg)
- case float64:
- err = c.writeFloat64(arg)
- case bool:
- if arg {
- err = c.writeString("1")
- } else {
- err = c.writeString("0")
- }
- case nil:
- err = c.writeString("")
- default:
- var buf bytes.Buffer
- fmt.Fprint(&buf, arg)
- err = c.writeBytes(buf.Bytes())
- }
- }
- return err
-}
-
-type protocolError string
-
-func (pe protocolError) Error() string {
- return fmt.Sprintf("redigo: %s (possible server error or unsupported concurrent read by application)", string(pe))
-}
-
-func (c *conn) readLine() ([]byte, error) {
- p, err := c.br.ReadSlice('\n')
- if err == bufio.ErrBufferFull {
- return nil, protocolError("long response line")
- }
- if err != nil {
- return nil, err
- }
- i := len(p) - 2
- if i < 0 || p[i] != '\r' {
- return nil, protocolError("bad response line terminator")
- }
- return p[:i], nil
-}
-
-// parseLen parses bulk string and array lengths.
-func parseLen(p []byte) (int, error) {
- if len(p) == 0 {
- return -1, protocolError("malformed length")
- }
-
- if p[0] == '-' && len(p) == 2 && p[1] == '1' {
- // handle $-1 and $-1 null replies.
- return -1, nil
- }
-
- var n int
- for _, b := range p {
- n *= 10
- if b < '0' || b > '9' {
- return -1, protocolError("illegal bytes in length")
- }
- n += int(b - '0')
- }
-
- return n, nil
-}
-
-// parseInt parses an integer reply.
-func parseInt(p []byte) (interface{}, error) {
- if len(p) == 0 {
- return 0, protocolError("malformed integer")
- }
-
- var negate bool
- if p[0] == '-' {
- negate = true
- p = p[1:]
- if len(p) == 0 {
- return 0, protocolError("malformed integer")
- }
- }
-
- var n int64
- for _, b := range p {
- n *= 10
- if b < '0' || b > '9' {
- return 0, protocolError("illegal bytes in length")
- }
- n += int64(b - '0')
- }
-
- if negate {
- n = -n
- }
- return n, nil
-}
-
-var (
- okReply interface{} = "OK"
- pongReply interface{} = "PONG"
-)
-
-func (c *conn) readReply() (interface{}, error) {
- line, err := c.readLine()
- if err != nil {
- return nil, err
- }
- if len(line) == 0 {
- return nil, protocolError("short response line")
- }
- switch line[0] {
- case '+':
- switch {
- case len(line) == 3 && line[1] == 'O' && line[2] == 'K':
- // Avoid allocation for frequent "+OK" response.
- return okReply, nil
- case len(line) == 5 && line[1] == 'P' && line[2] == 'O' && line[3] == 'N' && line[4] == 'G':
- // Avoid allocation in PING command benchmarks :)
- return pongReply, nil
- default:
- return string(line[1:]), nil
- }
- case '-':
- return Error(string(line[1:])), nil
- case ':':
- return parseInt(line[1:])
- case '$':
- n, err := parseLen(line[1:])
- if n < 0 || err != nil {
- return nil, err
- }
- p := make([]byte, n)
- _, err = io.ReadFull(c.br, p)
- if err != nil {
- return nil, err
- }
- if line, err := c.readLine(); err != nil {
- return nil, err
- } else if len(line) != 0 {
- return nil, protocolError("bad bulk string format")
- }
- return p, nil
- case '*':
- n, err := parseLen(line[1:])
- if n < 0 || err != nil {
- return nil, err
- }
- r := make([]interface{}, n)
- for i := range r {
- r[i], err = c.readReply()
- if err != nil {
- return nil, err
- }
- }
- return r, nil
- }
- return nil, protocolError("unexpected response line")
-}
-
-func (c *conn) Send(cmd string, args ...interface{}) error {
- c.mu.Lock()
- c.pending += 1
- c.mu.Unlock()
- if c.writeTimeout != 0 {
- c.conn.SetWriteDeadline(time.Now().Add(c.writeTimeout))
- }
- if err := c.writeCommand(cmd, args); err != nil {
- return c.fatal(err)
- }
- return nil
-}
-
-func (c *conn) Flush() error {
- if c.writeTimeout != 0 {
- c.conn.SetWriteDeadline(time.Now().Add(c.writeTimeout))
- }
- if err := c.bw.Flush(); err != nil {
- return c.fatal(err)
- }
- return nil
-}
-
-func (c *conn) Receive() (reply interface{}, err error) {
- if c.readTimeout != 0 {
- c.conn.SetReadDeadline(time.Now().Add(c.readTimeout))
- }
- if reply, err = c.readReply(); err != nil {
- return nil, c.fatal(err)
- }
- // When using pub/sub, the number of receives can be greater than the
- // number of sends. To enable normal use of the connection after
- // unsubscribing from all channels, we do not decrement pending to a
- // negative value.
- //
- // The pending field is decremented after the reply is read to handle the
- // case where Receive is called before Send.
- c.mu.Lock()
- if c.pending > 0 {
- c.pending -= 1
- }
- c.mu.Unlock()
- if err, ok := reply.(Error); ok {
- return nil, err
- }
- return
-}
-
-func (c *conn) Do(cmd string, args ...interface{}) (interface{}, error) {
- c.mu.Lock()
- pending := c.pending
- c.pending = 0
- c.mu.Unlock()
-
- if cmd == "" && pending == 0 {
- return nil, nil
- }
-
- if c.writeTimeout != 0 {
- c.conn.SetWriteDeadline(time.Now().Add(c.writeTimeout))
- }
-
- if cmd != "" {
- if err := c.writeCommand(cmd, args); err != nil {
- return nil, c.fatal(err)
- }
- }
-
- if err := c.bw.Flush(); err != nil {
- return nil, c.fatal(err)
- }
-
- if c.readTimeout != 0 {
- c.conn.SetReadDeadline(time.Now().Add(c.readTimeout))
- }
-
- if cmd == "" {
- reply := make([]interface{}, pending)
- for i := range reply {
- r, e := c.readReply()
- if e != nil {
- return nil, c.fatal(e)
- }
- reply[i] = r
- }
- return reply, nil
- }
-
- var err error
- var reply interface{}
- for i := 0; i <= pending; i++ {
- var e error
- if reply, e = c.readReply(); e != nil {
- return nil, c.fatal(e)
- }
- if e, ok := reply.(Error); ok && err == nil {
- err = e
- }
- }
- return reply, err
-}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/doc.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/doc.go
deleted file mode 100644
index 1ae6f0cc2..000000000
--- a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/doc.go
+++ /dev/null
@@ -1,169 +0,0 @@
-// Copyright 2012 Gary Burd
-//
-// Licensed under the Apache License, Version 2.0 (the "License"): you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations
-// under the License.
-
-// Package redis is a client for the Redis database.
-//
-// The Redigo FAQ (https://github.com/garyburd/redigo/wiki/FAQ) contains more
-// documentation about this package.
-//
-// Connections
-//
-// The Conn interface is the primary interface for working with Redis.
-// Applications create connections by calling the Dial, DialWithTimeout or
-// NewConn functions. In the future, functions will be added for creating
-// sharded and other types of connections.
-//
-// The application must call the connection Close method when the application
-// is done with the connection.
-//
-// Executing Commands
-//
-// The Conn interface has a generic method for executing Redis commands:
-//
-// Do(commandName string, args ...interface{}) (reply interface{}, err error)
-//
-// The Redis command reference (http://redis.io/commands) lists the available
-// commands. An example of using the Redis APPEND command is:
-//
-// n, err := conn.Do("APPEND", "key", "value")
-//
-// The Do method converts command arguments to binary strings for transmission
-// to the server as follows:
-//
-// Go Type Conversion
-// []byte Sent as is
-// string Sent as is
-// int, int64 strconv.FormatInt(v)
-// float64 strconv.FormatFloat(v, 'g', -1, 64)
-// bool true -> "1", false -> "0"
-// nil ""
-// all other types fmt.Print(v)
-//
-// Redis command reply types are represented using the following Go types:
-//
-// Redis type Go type
-// error redis.Error
-// integer int64
-// simple string string
-// bulk string []byte or nil if value not present.
-// array []interface{} or nil if value not present.
-//
-// Use type assertions or the reply helper functions to convert from
-// interface{} to the specific Go type for the command result.
-//
-// Pipelining
-//
-// Connections support pipelining using the Send, Flush and Receive methods.
-//
-// Send(commandName string, args ...interface{}) error
-// Flush() error
-// Receive() (reply interface{}, err error)
-//
-// Send writes the command to the connection's output buffer. Flush flushes the
-// connection's output buffer to the server. Receive reads a single reply from
-// the server. The following example shows a simple pipeline.
-//
-// c.Send("SET", "foo", "bar")
-// c.Send("GET", "foo")
-// c.Flush()
-// c.Receive() // reply from SET
-// v, err = c.Receive() // reply from GET
-//
-// The Do method combines the functionality of the Send, Flush and Receive
-// methods. The Do method starts by writing the command and flushing the output
-// buffer. Next, the Do method receives all pending replies including the reply
-// for the command just sent by Do. If any of the received replies is an error,
-// then Do returns the error. If there are no errors, then Do returns the last
-// reply. If the command argument to the Do method is "", then the Do method
-// will flush the output buffer and receive pending replies without sending a
-// command.
-//
-// Use the Send and Do methods to implement pipelined transactions.
-//
-// c.Send("MULTI")
-// c.Send("INCR", "foo")
-// c.Send("INCR", "bar")
-// r, err := c.Do("EXEC")
-// fmt.Println(r) // prints [1, 1]
-//
-// Concurrency
-//
-// Connections do not support concurrent calls to the write methods (Send,
-// Flush) or concurrent calls to the read method (Receive). Connections do
-// allow a concurrent reader and writer.
-//
-// Because the Do method combines the functionality of Send, Flush and Receive,
-// the Do method cannot be called concurrently with the other methods.
-//
-// For full concurrent access to Redis, use the thread-safe Pool to get and
-// release connections from within a goroutine.
-//
-// Publish and Subscribe
-//
-// Use the Send, Flush and Receive methods to implement Pub/Sub subscribers.
-//
-// c.Send("SUBSCRIBE", "example")
-// c.Flush()
-// for {
-// reply, err := c.Receive()
-// if err != nil {
-// return err
-// }
-// // process pushed message
-// }
-//
-// The PubSubConn type wraps a Conn with convenience methods for implementing
-// subscribers. The Subscribe, PSubscribe, Unsubscribe and PUnsubscribe methods
-// send and flush a subscription management command. The receive method
-// converts a pushed message to convenient types for use in a type switch.
-//
-// psc := redis.PubSubConn{c}
-// psc.Subscribe("example")
-// for {
-// switch v := psc.Receive().(type) {
-// case redis.Message:
-// fmt.Printf("%s: message: %s\n", v.Channel, v.Data)
-// case redis.Subscription:
-// fmt.Printf("%s: %s %d\n", v.Channel, v.Kind, v.Count)
-// case error:
-// return v
-// }
-// }
-//
-// Reply Helpers
-//
-// The Bool, Int, Bytes, String, Strings and Values functions convert a reply
-// to a value of a specific type. To allow convenient wrapping of calls to the
-// connection Do and Receive methods, the functions take a second argument of
-// type error. If the error is non-nil, then the helper function returns the
-// error. If the error is nil, the function converts the reply to the specified
-// type:
-//
-// exists, err := redis.Bool(c.Do("EXISTS", "foo"))
-// if err != nil {
-// // handle error return from c.Do or type conversion error.
-// }
-//
-// The Scan function converts elements of a array reply to Go types:
-//
-// var value1 int
-// var value2 string
-// reply, err := redis.Values(c.Do("MGET", "key1", "key2"))
-// if err != nil {
-// // handle error
-// }
-// if _, err := redis.Scan(reply, &value1, &value2); err != nil {
-// // handle error
-// }
-package redis
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/log.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/log.go
deleted file mode 100644
index 129b86d67..000000000
--- a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/log.go
+++ /dev/null
@@ -1,117 +0,0 @@
-// Copyright 2012 Gary Burd
-//
-// Licensed under the Apache License, Version 2.0 (the "License"): you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations
-// under the License.
-
-package redis
-
-import (
- "bytes"
- "fmt"
- "log"
-)
-
-// NewLoggingConn returns a logging wrapper around a connection.
-func NewLoggingConn(conn Conn, logger *log.Logger, prefix string) Conn {
- if prefix != "" {
- prefix = prefix + "."
- }
- return &loggingConn{conn, logger, prefix}
-}
-
-type loggingConn struct {
- Conn
- logger *log.Logger
- prefix string
-}
-
-func (c *loggingConn) Close() error {
- err := c.Conn.Close()
- var buf bytes.Buffer
- fmt.Fprintf(&buf, "%sClose() -> (%v)", c.prefix, err)
- c.logger.Output(2, buf.String())
- return err
-}
-
-func (c *loggingConn) printValue(buf *bytes.Buffer, v interface{}) {
- const chop = 32
- switch v := v.(type) {
- case []byte:
- if len(v) > chop {
- fmt.Fprintf(buf, "%q...", v[:chop])
- } else {
- fmt.Fprintf(buf, "%q", v)
- }
- case string:
- if len(v) > chop {
- fmt.Fprintf(buf, "%q...", v[:chop])
- } else {
- fmt.Fprintf(buf, "%q", v)
- }
- case []interface{}:
- if len(v) == 0 {
- buf.WriteString("[]")
- } else {
- sep := "["
- fin := "]"
- if len(v) > chop {
- v = v[:chop]
- fin = "...]"
- }
- for _, vv := range v {
- buf.WriteString(sep)
- c.printValue(buf, vv)
- sep = ", "
- }
- buf.WriteString(fin)
- }
- default:
- fmt.Fprint(buf, v)
- }
-}
-
-func (c *loggingConn) print(method, commandName string, args []interface{}, reply interface{}, err error) {
- var buf bytes.Buffer
- fmt.Fprintf(&buf, "%s%s(", c.prefix, method)
- if method != "Receive" {
- buf.WriteString(commandName)
- for _, arg := range args {
- buf.WriteString(", ")
- c.printValue(&buf, arg)
- }
- }
- buf.WriteString(") -> (")
- if method != "Send" {
- c.printValue(&buf, reply)
- buf.WriteString(", ")
- }
- fmt.Fprintf(&buf, "%v)", err)
- c.logger.Output(3, buf.String())
-}
-
-func (c *loggingConn) Do(commandName string, args ...interface{}) (interface{}, error) {
- reply, err := c.Conn.Do(commandName, args...)
- c.print("Do", commandName, args, reply, err)
- return reply, err
-}
-
-func (c *loggingConn) Send(commandName string, args ...interface{}) error {
- err := c.Conn.Send(commandName, args...)
- c.print("Send", commandName, args, nil, err)
- return err
-}
-
-func (c *loggingConn) Receive() (interface{}, error) {
- reply, err := c.Conn.Receive()
- c.print("Receive", "", nil, reply, err)
- return reply, err
-}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/pool.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/pool.go
deleted file mode 100644
index d66ef84b6..000000000
--- a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/pool.go
+++ /dev/null
@@ -1,393 +0,0 @@
-// Copyright 2012 Gary Burd
-//
-// Licensed under the Apache License, Version 2.0 (the "License"): you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations
-// under the License.
-
-package redis
-
-import (
- "bytes"
- "container/list"
- "crypto/rand"
- "crypto/sha1"
- "errors"
- "io"
- "strconv"
- "sync"
- "time"
-
- "github.com/garyburd/redigo/internal"
-)
-
-var nowFunc = time.Now // for testing
-
-// ErrPoolExhausted is returned from a pool connection method (Do, Send,
-// Receive, Flush, Err) when the maximum number of database connections in the
-// pool has been reached.
-var ErrPoolExhausted = errors.New("redigo: connection pool exhausted")
-
-var (
- errPoolClosed = errors.New("redigo: connection pool closed")
- errConnClosed = errors.New("redigo: connection closed")
-)
-
-// Pool maintains a pool of connections. The application calls the Get method
-// to get a connection from the pool and the connection's Close method to
-// return the connection's resources to the pool.
-//
-// The following example shows how to use a pool in a web application. The
-// application creates a pool at application startup and makes it available to
-// request handlers using a global variable.
-//
-// func newPool(server, password string) *redis.Pool {
-// return &redis.Pool{
-// MaxIdle: 3,
-// IdleTimeout: 240 * time.Second,
-// Dial: func () (redis.Conn, error) {
-// c, err := redis.Dial("tcp", server)
-// if err != nil {
-// return nil, err
-// }
-// if _, err := c.Do("AUTH", password); err != nil {
-// c.Close()
-// return nil, err
-// }
-// return c, err
-// },
-// TestOnBorrow: func(c redis.Conn, t time.Time) error {
-// _, err := c.Do("PING")
-// return err
-// },
-// }
-// }
-//
-// var (
-// pool *redis.Pool
-// redisServer = flag.String("redisServer", ":6379", "")
-// redisPassword = flag.String("redisPassword", "", "")
-// )
-//
-// func main() {
-// flag.Parse()
-// pool = newPool(*redisServer, *redisPassword)
-// ...
-// }
-//
-// A request handler gets a connection from the pool and closes the connection
-// when the handler is done:
-//
-// func serveHome(w http.ResponseWriter, r *http.Request) {
-// conn := pool.Get()
-// defer conn.Close()
-// ....
-// }
-//
-type Pool struct {
-
- // Dial is an application supplied function for creating and configuring a
- // connection.
- //
- // The connection returned from Dial must not be in a special state
- // (subscribed to pubsub channel, transaction started, ...).
- Dial func() (Conn, error)
-
- // TestOnBorrow is an optional application supplied function for checking
- // the health of an idle connection before the connection is used again by
- // the application. Argument t is the time that the connection was returned
- // to the pool. If the function returns an error, then the connection is
- // closed.
- TestOnBorrow func(c Conn, t time.Time) error
-
- // Maximum number of idle connections in the pool.
- MaxIdle int
-
- // Maximum number of connections allocated by the pool at a given time.
- // When zero, there is no limit on the number of connections in the pool.
- MaxActive int
-
- // Close connections after remaining idle for this duration. If the value
- // is zero, then idle connections are not closed. Applications should set
- // the timeout to a value less than the server's timeout.
- IdleTimeout time.Duration
-
- // If Wait is true and the pool is at the MaxActive limit, then Get() waits
- // for a connection to be returned to the pool before returning.
- Wait bool
-
- // mu protects fields defined below.
- mu sync.Mutex
- cond *sync.Cond
- closed bool
- active int
-
- // Stack of idleConn with most recently used at the front.
- idle list.List
-}
-
-type idleConn struct {
- c Conn
- t time.Time
-}
-
-// NewPool creates a new pool.
-//
-// Deprecated: Initialize the Pool directory as shown in the example.
-func NewPool(newFn func() (Conn, error), maxIdle int) *Pool {
- return &Pool{Dial: newFn, MaxIdle: maxIdle}
-}
-
-// Get gets a connection. The application must close the returned connection.
-// This method always returns a valid connection so that applications can defer
-// error handling to the first use of the connection. If there is an error
-// getting an underlying connection, then the connection Err, Do, Send, Flush
-// and Receive methods return that error.
-func (p *Pool) Get() Conn {
- c, err := p.get()
- if err != nil {
- return errorConnection{err}
- }
- return &pooledConnection{p: p, c: c}
-}
-
-// ActiveCount returns the number of active connections in the pool.
-func (p *Pool) ActiveCount() int {
- p.mu.Lock()
- active := p.active
- p.mu.Unlock()
- return active
-}
-
-// Close releases the resources used by the pool.
-func (p *Pool) Close() error {
- p.mu.Lock()
- idle := p.idle
- p.idle.Init()
- p.closed = true
- p.active -= idle.Len()
- if p.cond != nil {
- p.cond.Broadcast()
- }
- p.mu.Unlock()
- for e := idle.Front(); e != nil; e = e.Next() {
- e.Value.(idleConn).c.Close()
- }
- return nil
-}
-
-// release decrements the active count and signals waiters. The caller must
-// hold p.mu during the call.
-func (p *Pool) release() {
- p.active -= 1
- if p.cond != nil {
- p.cond.Signal()
- }
-}
-
-// get prunes stale connections and returns a connection from the idle list or
-// creates a new connection.
-func (p *Pool) get() (Conn, error) {
- p.mu.Lock()
-
- // Prune stale connections.
-
- if timeout := p.IdleTimeout; timeout > 0 {
- for i, n := 0, p.idle.Len(); i < n; i++ {
- e := p.idle.Back()
- if e == nil {
- break
- }
- ic := e.Value.(idleConn)
- if ic.t.Add(timeout).After(nowFunc()) {
- break
- }
- p.idle.Remove(e)
- p.release()
- p.mu.Unlock()
- ic.c.Close()
- p.mu.Lock()
- }
- }
-
- for {
-
- // Get idle connection.
-
- for i, n := 0, p.idle.Len(); i < n; i++ {
- e := p.idle.Front()
- if e == nil {
- break
- }
- ic := e.Value.(idleConn)
- p.idle.Remove(e)
- test := p.TestOnBorrow
- p.mu.Unlock()
- if test == nil || test(ic.c, ic.t) == nil {
- return ic.c, nil
- }
- ic.c.Close()
- p.mu.Lock()
- p.release()
- }
-
- // Check for pool closed before dialing a new connection.
-
- if p.closed {
- p.mu.Unlock()
- return nil, errors.New("redigo: get on closed pool")
- }
-
- // Dial new connection if under limit.
-
- if p.MaxActive == 0 || p.active < p.MaxActive {
- dial := p.Dial
- p.active += 1
- p.mu.Unlock()
- c, err := dial()
- if err != nil {
- p.mu.Lock()
- p.release()
- p.mu.Unlock()
- c = nil
- }
- return c, err
- }
-
- if !p.Wait {
- p.mu.Unlock()
- return nil, ErrPoolExhausted
- }
-
- if p.cond == nil {
- p.cond = sync.NewCond(&p.mu)
- }
- p.cond.Wait()
- }
-}
-
-func (p *Pool) put(c Conn, forceClose bool) error {
- err := c.Err()
- p.mu.Lock()
- if !p.closed && err == nil && !forceClose {
- p.idle.PushFront(idleConn{t: nowFunc(), c: c})
- if p.idle.Len() > p.MaxIdle {
- c = p.idle.Remove(p.idle.Back()).(idleConn).c
- } else {
- c = nil
- }
- }
-
- if c == nil {
- if p.cond != nil {
- p.cond.Signal()
- }
- p.mu.Unlock()
- return nil
- }
-
- p.release()
- p.mu.Unlock()
- return c.Close()
-}
-
-type pooledConnection struct {
- p *Pool
- c Conn
- state int
-}
-
-var (
- sentinel []byte
- sentinelOnce sync.Once
-)
-
-func initSentinel() {
- p := make([]byte, 64)
- if _, err := rand.Read(p); err == nil {
- sentinel = p
- } else {
- h := sha1.New()
- io.WriteString(h, "Oops, rand failed. Use time instead.")
- io.WriteString(h, strconv.FormatInt(time.Now().UnixNano(), 10))
- sentinel = h.Sum(nil)
- }
-}
-
-func (pc *pooledConnection) Close() error {
- c := pc.c
- if _, ok := c.(errorConnection); ok {
- return nil
- }
- pc.c = errorConnection{errConnClosed}
-
- if pc.state&internal.MultiState != 0 {
- c.Send("DISCARD")
- pc.state &^= (internal.MultiState | internal.WatchState)
- } else if pc.state&internal.WatchState != 0 {
- c.Send("UNWATCH")
- pc.state &^= internal.WatchState
- }
- if pc.state&internal.SubscribeState != 0 {
- c.Send("UNSUBSCRIBE")
- c.Send("PUNSUBSCRIBE")
- // To detect the end of the message stream, ask the server to echo
- // a sentinel value and read until we see that value.
- sentinelOnce.Do(initSentinel)
- c.Send("ECHO", sentinel)
- c.Flush()
- for {
- p, err := c.Receive()
- if err != nil {
- break
- }
- if p, ok := p.([]byte); ok && bytes.Equal(p, sentinel) {
- pc.state &^= internal.SubscribeState
- break
- }
- }
- }
- c.Do("")
- pc.p.put(c, pc.state != 0)
- return nil
-}
-
-func (pc *pooledConnection) Err() error {
- return pc.c.Err()
-}
-
-func (pc *pooledConnection) Do(commandName string, args ...interface{}) (reply interface{}, err error) {
- ci := internal.LookupCommandInfo(commandName)
- pc.state = (pc.state | ci.Set) &^ ci.Clear
- return pc.c.Do(commandName, args...)
-}
-
-func (pc *pooledConnection) Send(commandName string, args ...interface{}) error {
- ci := internal.LookupCommandInfo(commandName)
- pc.state = (pc.state | ci.Set) &^ ci.Clear
- return pc.c.Send(commandName, args...)
-}
-
-func (pc *pooledConnection) Flush() error {
- return pc.c.Flush()
-}
-
-func (pc *pooledConnection) Receive() (reply interface{}, err error) {
- return pc.c.Receive()
-}
-
-type errorConnection struct{ err error }
-
-func (ec errorConnection) Do(string, ...interface{}) (interface{}, error) { return nil, ec.err }
-func (ec errorConnection) Send(string, ...interface{}) error { return ec.err }
-func (ec errorConnection) Err() error { return ec.err }
-func (ec errorConnection) Close() error { return ec.err }
-func (ec errorConnection) Flush() error { return ec.err }
-func (ec errorConnection) Receive() (interface{}, error) { return nil, ec.err }
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/pubsub.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/pubsub.go
deleted file mode 100644
index c0ecce824..000000000
--- a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/pubsub.go
+++ /dev/null
@@ -1,144 +0,0 @@
-// Copyright 2012 Gary Burd
-//
-// Licensed under the Apache License, Version 2.0 (the "License"): you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations
-// under the License.
-
-package redis
-
-import "errors"
-
-// Subscription represents a subscribe or unsubscribe notification.
-type Subscription struct {
-
- // Kind is "subscribe", "unsubscribe", "psubscribe" or "punsubscribe"
- Kind string
-
- // The channel that was changed.
- Channel string
-
- // The current number of subscriptions for connection.
- Count int
-}
-
-// Message represents a message notification.
-type Message struct {
-
- // The originating channel.
- Channel string
-
- // The message data.
- Data []byte
-}
-
-// PMessage represents a pmessage notification.
-type PMessage struct {
-
- // The matched pattern.
- Pattern string
-
- // The originating channel.
- Channel string
-
- // The message data.
- Data []byte
-}
-
-// Pong represents a pubsub pong notification.
-type Pong struct {
- Data string
-}
-
-// PubSubConn wraps a Conn with convenience methods for subscribers.
-type PubSubConn struct {
- Conn Conn
-}
-
-// Close closes the connection.
-func (c PubSubConn) Close() error {
- return c.Conn.Close()
-}
-
-// Subscribe subscribes the connection to the specified channels.
-func (c PubSubConn) Subscribe(channel ...interface{}) error {
- c.Conn.Send("SUBSCRIBE", channel...)
- return c.Conn.Flush()
-}
-
-// PSubscribe subscribes the connection to the given patterns.
-func (c PubSubConn) PSubscribe(channel ...interface{}) error {
- c.Conn.Send("PSUBSCRIBE", channel...)
- return c.Conn.Flush()
-}
-
-// Unsubscribe unsubscribes the connection from the given channels, or from all
-// of them if none is given.
-func (c PubSubConn) Unsubscribe(channel ...interface{}) error {
- c.Conn.Send("UNSUBSCRIBE", channel...)
- return c.Conn.Flush()
-}
-
-// PUnsubscribe unsubscribes the connection from the given patterns, or from all
-// of them if none is given.
-func (c PubSubConn) PUnsubscribe(channel ...interface{}) error {
- c.Conn.Send("PUNSUBSCRIBE", channel...)
- return c.Conn.Flush()
-}
-
-// Ping sends a PING to the server with the specified data.
-func (c PubSubConn) Ping(data string) error {
- c.Conn.Send("PING", data)
- return c.Conn.Flush()
-}
-
-// Receive returns a pushed message as a Subscription, Message, PMessage, Pong
-// or error. The return value is intended to be used directly in a type switch
-// as illustrated in the PubSubConn example.
-func (c PubSubConn) Receive() interface{} {
- reply, err := Values(c.Conn.Receive())
- if err != nil {
- return err
- }
-
- var kind string
- reply, err = Scan(reply, &kind)
- if err != nil {
- return err
- }
-
- switch kind {
- case "message":
- var m Message
- if _, err := Scan(reply, &m.Channel, &m.Data); err != nil {
- return err
- }
- return m
- case "pmessage":
- var pm PMessage
- if _, err := Scan(reply, &pm.Pattern, &pm.Channel, &pm.Data); err != nil {
- return err
- }
- return pm
- case "subscribe", "psubscribe", "unsubscribe", "punsubscribe":
- s := Subscription{Kind: kind}
- if _, err := Scan(reply, &s.Channel, &s.Count); err != nil {
- return err
- }
- return s
- case "pong":
- var p Pong
- if _, err := Scan(reply, &p.Data); err != nil {
- return err
- }
- return p
- }
- return errors.New("redigo: unknown pubsub notification")
-}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/redis.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/redis.go
deleted file mode 100644
index c90a48ed4..000000000
--- a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/redis.go
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2012 Gary Burd
-//
-// Licensed under the Apache License, Version 2.0 (the "License"): you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations
-// under the License.
-
-package redis
-
-// Error represents an error returned in a command reply.
-type Error string
-
-func (err Error) Error() string { return string(err) }
-
-// Conn represents a connection to a Redis server.
-type Conn interface {
- // Close closes the connection.
- Close() error
-
- // Err returns a non-nil value if the connection is broken. The returned
- // value is either the first non-nil value returned from the underlying
- // network connection or a protocol parsing error. Applications should
- // close broken connections.
- Err() error
-
- // Do sends a command to the server and returns the received reply.
- Do(commandName string, args ...interface{}) (reply interface{}, err error)
-
- // Send writes the command to the client's output buffer.
- Send(commandName string, args ...interface{}) error
-
- // Flush flushes the output buffer to the Redis server.
- Flush() error
-
- // Receive receives a single reply from the Redis server
- Receive() (reply interface{}, err error)
-}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/reply.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/reply.go
deleted file mode 100644
index 57896147f..000000000
--- a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/reply.go
+++ /dev/null
@@ -1,393 +0,0 @@
-// Copyright 2012 Gary Burd
-//
-// Licensed under the Apache License, Version 2.0 (the "License"): you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations
-// under the License.
-
-package redis
-
-import (
- "errors"
- "fmt"
- "strconv"
-)
-
-// ErrNil indicates that a reply value is nil.
-var ErrNil = errors.New("redigo: nil returned")
-
-// Int is a helper that converts a command reply to an integer. If err is not
-// equal to nil, then Int returns 0, err. Otherwise, Int converts the
-// reply to an int as follows:
-//
-// Reply type Result
-// integer int(reply), nil
-// bulk string parsed reply, nil
-// nil 0, ErrNil
-// other 0, error
-func Int(reply interface{}, err error) (int, error) {
- if err != nil {
- return 0, err
- }
- switch reply := reply.(type) {
- case int64:
- x := int(reply)
- if int64(x) != reply {
- return 0, strconv.ErrRange
- }
- return x, nil
- case []byte:
- n, err := strconv.ParseInt(string(reply), 10, 0)
- return int(n), err
- case nil:
- return 0, ErrNil
- case Error:
- return 0, reply
- }
- return 0, fmt.Errorf("redigo: unexpected type for Int, got type %T", reply)
-}
-
-// Int64 is a helper that converts a command reply to 64 bit integer. If err is
-// not equal to nil, then Int returns 0, err. Otherwise, Int64 converts the
-// reply to an int64 as follows:
-//
-// Reply type Result
-// integer reply, nil
-// bulk string parsed reply, nil
-// nil 0, ErrNil
-// other 0, error
-func Int64(reply interface{}, err error) (int64, error) {
- if err != nil {
- return 0, err
- }
- switch reply := reply.(type) {
- case int64:
- return reply, nil
- case []byte:
- n, err := strconv.ParseInt(string(reply), 10, 64)
- return n, err
- case nil:
- return 0, ErrNil
- case Error:
- return 0, reply
- }
- return 0, fmt.Errorf("redigo: unexpected type for Int64, got type %T", reply)
-}
-
-var errNegativeInt = errors.New("redigo: unexpected value for Uint64")
-
-// Uint64 is a helper that converts a command reply to 64 bit integer. If err is
-// not equal to nil, then Int returns 0, err. Otherwise, Int64 converts the
-// reply to an int64 as follows:
-//
-// Reply type Result
-// integer reply, nil
-// bulk string parsed reply, nil
-// nil 0, ErrNil
-// other 0, error
-func Uint64(reply interface{}, err error) (uint64, error) {
- if err != nil {
- return 0, err
- }
- switch reply := reply.(type) {
- case int64:
- if reply < 0 {
- return 0, errNegativeInt
- }
- return uint64(reply), nil
- case []byte:
- n, err := strconv.ParseUint(string(reply), 10, 64)
- return n, err
- case nil:
- return 0, ErrNil
- case Error:
- return 0, reply
- }
- return 0, fmt.Errorf("redigo: unexpected type for Uint64, got type %T", reply)
-}
-
-// Float64 is a helper that converts a command reply to 64 bit float. If err is
-// not equal to nil, then Float64 returns 0, err. Otherwise, Float64 converts
-// the reply to an int as follows:
-//
-// Reply type Result
-// bulk string parsed reply, nil
-// nil 0, ErrNil
-// other 0, error
-func Float64(reply interface{}, err error) (float64, error) {
- if err != nil {
- return 0, err
- }
- switch reply := reply.(type) {
- case []byte:
- n, err := strconv.ParseFloat(string(reply), 64)
- return n, err
- case nil:
- return 0, ErrNil
- case Error:
- return 0, reply
- }
- return 0, fmt.Errorf("redigo: unexpected type for Float64, got type %T", reply)
-}
-
-// String is a helper that converts a command reply to a string. If err is not
-// equal to nil, then String returns "", err. Otherwise String converts the
-// reply to a string as follows:
-//
-// Reply type Result
-// bulk string string(reply), nil
-// simple string reply, nil
-// nil "", ErrNil
-// other "", error
-func String(reply interface{}, err error) (string, error) {
- if err != nil {
- return "", err
- }
- switch reply := reply.(type) {
- case []byte:
- return string(reply), nil
- case string:
- return reply, nil
- case nil:
- return "", ErrNil
- case Error:
- return "", reply
- }
- return "", fmt.Errorf("redigo: unexpected type for String, got type %T", reply)
-}
-
-// Bytes is a helper that converts a command reply to a slice of bytes. If err
-// is not equal to nil, then Bytes returns nil, err. Otherwise Bytes converts
-// the reply to a slice of bytes as follows:
-//
-// Reply type Result
-// bulk string reply, nil
-// simple string []byte(reply), nil
-// nil nil, ErrNil
-// other nil, error
-func Bytes(reply interface{}, err error) ([]byte, error) {
- if err != nil {
- return nil, err
- }
- switch reply := reply.(type) {
- case []byte:
- return reply, nil
- case string:
- return []byte(reply), nil
- case nil:
- return nil, ErrNil
- case Error:
- return nil, reply
- }
- return nil, fmt.Errorf("redigo: unexpected type for Bytes, got type %T", reply)
-}
-
-// Bool is a helper that converts a command reply to a boolean. If err is not
-// equal to nil, then Bool returns false, err. Otherwise Bool converts the
-// reply to boolean as follows:
-//
-// Reply type Result
-// integer value != 0, nil
-// bulk string strconv.ParseBool(reply)
-// nil false, ErrNil
-// other false, error
-func Bool(reply interface{}, err error) (bool, error) {
- if err != nil {
- return false, err
- }
- switch reply := reply.(type) {
- case int64:
- return reply != 0, nil
- case []byte:
- return strconv.ParseBool(string(reply))
- case nil:
- return false, ErrNil
- case Error:
- return false, reply
- }
- return false, fmt.Errorf("redigo: unexpected type for Bool, got type %T", reply)
-}
-
-// MultiBulk is a helper that converts an array command reply to a []interface{}.
-//
-// Deprecated: Use Values instead.
-func MultiBulk(reply interface{}, err error) ([]interface{}, error) { return Values(reply, err) }
-
-// Values is a helper that converts an array command reply to a []interface{}.
-// If err is not equal to nil, then Values returns nil, err. Otherwise, Values
-// converts the reply as follows:
-//
-// Reply type Result
-// array reply, nil
-// nil nil, ErrNil
-// other nil, error
-func Values(reply interface{}, err error) ([]interface{}, error) {
- if err != nil {
- return nil, err
- }
- switch reply := reply.(type) {
- case []interface{}:
- return reply, nil
- case nil:
- return nil, ErrNil
- case Error:
- return nil, reply
- }
- return nil, fmt.Errorf("redigo: unexpected type for Values, got type %T", reply)
-}
-
-// Strings is a helper that converts an array command reply to a []string. If
-// err is not equal to nil, then Strings returns nil, err. Nil array items are
-// converted to "" in the output slice. Strings returns an error if an array
-// item is not a bulk string or nil.
-func Strings(reply interface{}, err error) ([]string, error) {
- if err != nil {
- return nil, err
- }
- switch reply := reply.(type) {
- case []interface{}:
- result := make([]string, len(reply))
- for i := range reply {
- if reply[i] == nil {
- continue
- }
- p, ok := reply[i].([]byte)
- if !ok {
- return nil, fmt.Errorf("redigo: unexpected element type for Strings, got type %T", reply[i])
- }
- result[i] = string(p)
- }
- return result, nil
- case nil:
- return nil, ErrNil
- case Error:
- return nil, reply
- }
- return nil, fmt.Errorf("redigo: unexpected type for Strings, got type %T", reply)
-}
-
-// ByteSlices is a helper that converts an array command reply to a [][]byte.
-// If err is not equal to nil, then ByteSlices returns nil, err. Nil array
-// items are stay nil. ByteSlices returns an error if an array item is not a
-// bulk string or nil.
-func ByteSlices(reply interface{}, err error) ([][]byte, error) {
- if err != nil {
- return nil, err
- }
- switch reply := reply.(type) {
- case []interface{}:
- result := make([][]byte, len(reply))
- for i := range reply {
- if reply[i] == nil {
- continue
- }
- p, ok := reply[i].([]byte)
- if !ok {
- return nil, fmt.Errorf("redigo: unexpected element type for ByteSlices, got type %T", reply[i])
- }
- result[i] = p
- }
- return result, nil
- case nil:
- return nil, ErrNil
- case Error:
- return nil, reply
- }
- return nil, fmt.Errorf("redigo: unexpected type for ByteSlices, got type %T", reply)
-}
-
-// Ints is a helper that converts an array command reply to a []int. If
-// err is not equal to nil, then Ints returns nil, err.
-func Ints(reply interface{}, err error) ([]int, error) {
- var ints []int
- values, err := Values(reply, err)
- if err != nil {
- return ints, err
- }
- if err := ScanSlice(values, &ints); err != nil {
- return ints, err
- }
- return ints, nil
-}
-
-// StringMap is a helper that converts an array of strings (alternating key, value)
-// into a map[string]string. The HGETALL and CONFIG GET commands return replies in this format.
-// Requires an even number of values in result.
-func StringMap(result interface{}, err error) (map[string]string, error) {
- values, err := Values(result, err)
- if err != nil {
- return nil, err
- }
- if len(values)%2 != 0 {
- return nil, errors.New("redigo: StringMap expects even number of values result")
- }
- m := make(map[string]string, len(values)/2)
- for i := 0; i < len(values); i += 2 {
- key, okKey := values[i].([]byte)
- value, okValue := values[i+1].([]byte)
- if !okKey || !okValue {
- return nil, errors.New("redigo: ScanMap key not a bulk string value")
- }
- m[string(key)] = string(value)
- }
- return m, nil
-}
-
-// IntMap is a helper that converts an array of strings (alternating key, value)
-// into a map[string]int. The HGETALL commands return replies in this format.
-// Requires an even number of values in result.
-func IntMap(result interface{}, err error) (map[string]int, error) {
- values, err := Values(result, err)
- if err != nil {
- return nil, err
- }
- if len(values)%2 != 0 {
- return nil, errors.New("redigo: IntMap expects even number of values result")
- }
- m := make(map[string]int, len(values)/2)
- for i := 0; i < len(values); i += 2 {
- key, ok := values[i].([]byte)
- if !ok {
- return nil, errors.New("redigo: ScanMap key not a bulk string value")
- }
- value, err := Int(values[i+1], nil)
- if err != nil {
- return nil, err
- }
- m[string(key)] = value
- }
- return m, nil
-}
-
-// Int64Map is a helper that converts an array of strings (alternating key, value)
-// into a map[string]int64. The HGETALL commands return replies in this format.
-// Requires an even number of values in result.
-func Int64Map(result interface{}, err error) (map[string]int64, error) {
- values, err := Values(result, err)
- if err != nil {
- return nil, err
- }
- if len(values)%2 != 0 {
- return nil, errors.New("redigo: Int64Map expects even number of values result")
- }
- m := make(map[string]int64, len(values)/2)
- for i := 0; i < len(values); i += 2 {
- key, ok := values[i].([]byte)
- if !ok {
- return nil, errors.New("redigo: ScanMap key not a bulk string value")
- }
- value, err := Int64(values[i+1], nil)
- if err != nil {
- return nil, err
- }
- m[string(key)] = value
- }
- return m, nil
-}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/scan.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/scan.go
deleted file mode 100644
index 962e94bcc..000000000
--- a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/scan.go
+++ /dev/null
@@ -1,555 +0,0 @@
-// Copyright 2012 Gary Burd
-//
-// Licensed under the Apache License, Version 2.0 (the "License"): you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations
-// under the License.
-
-package redis
-
-import (
- "errors"
- "fmt"
- "reflect"
- "strconv"
- "strings"
- "sync"
-)
-
-func ensureLen(d reflect.Value, n int) {
- if n > d.Cap() {
- d.Set(reflect.MakeSlice(d.Type(), n, n))
- } else {
- d.SetLen(n)
- }
-}
-
-func cannotConvert(d reflect.Value, s interface{}) error {
- var sname string
- switch s.(type) {
- case string:
- sname = "Redis simple string"
- case Error:
- sname = "Redis error"
- case int64:
- sname = "Redis integer"
- case []byte:
- sname = "Redis bulk string"
- case []interface{}:
- sname = "Redis array"
- default:
- sname = reflect.TypeOf(s).String()
- }
- return fmt.Errorf("cannot convert from %s to %s", sname, d.Type())
-}
-
-func convertAssignBulkString(d reflect.Value, s []byte) (err error) {
- switch d.Type().Kind() {
- case reflect.Float32, reflect.Float64:
- var x float64
- x, err = strconv.ParseFloat(string(s), d.Type().Bits())
- d.SetFloat(x)
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- var x int64
- x, err = strconv.ParseInt(string(s), 10, d.Type().Bits())
- d.SetInt(x)
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
- var x uint64
- x, err = strconv.ParseUint(string(s), 10, d.Type().Bits())
- d.SetUint(x)
- case reflect.Bool:
- var x bool
- x, err = strconv.ParseBool(string(s))
- d.SetBool(x)
- case reflect.String:
- d.SetString(string(s))
- case reflect.Slice:
- if d.Type().Elem().Kind() != reflect.Uint8 {
- err = cannotConvert(d, s)
- } else {
- d.SetBytes(s)
- }
- default:
- err = cannotConvert(d, s)
- }
- return
-}
-
-func convertAssignInt(d reflect.Value, s int64) (err error) {
- switch d.Type().Kind() {
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- d.SetInt(s)
- if d.Int() != s {
- err = strconv.ErrRange
- d.SetInt(0)
- }
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
- if s < 0 {
- err = strconv.ErrRange
- } else {
- x := uint64(s)
- d.SetUint(x)
- if d.Uint() != x {
- err = strconv.ErrRange
- d.SetUint(0)
- }
- }
- case reflect.Bool:
- d.SetBool(s != 0)
- default:
- err = cannotConvert(d, s)
- }
- return
-}
-
-func convertAssignValue(d reflect.Value, s interface{}) (err error) {
- switch s := s.(type) {
- case []byte:
- err = convertAssignBulkString(d, s)
- case int64:
- err = convertAssignInt(d, s)
- default:
- err = cannotConvert(d, s)
- }
- return err
-}
-
-func convertAssignArray(d reflect.Value, s []interface{}) error {
- if d.Type().Kind() != reflect.Slice {
- return cannotConvert(d, s)
- }
- ensureLen(d, len(s))
- for i := 0; i < len(s); i++ {
- if err := convertAssignValue(d.Index(i), s[i]); err != nil {
- return err
- }
- }
- return nil
-}
-
-func convertAssign(d interface{}, s interface{}) (err error) {
- // Handle the most common destination types using type switches and
- // fall back to reflection for all other types.
- switch s := s.(type) {
- case nil:
- // ingore
- case []byte:
- switch d := d.(type) {
- case *string:
- *d = string(s)
- case *int:
- *d, err = strconv.Atoi(string(s))
- case *bool:
- *d, err = strconv.ParseBool(string(s))
- case *[]byte:
- *d = s
- case *interface{}:
- *d = s
- case nil:
- // skip value
- default:
- if d := reflect.ValueOf(d); d.Type().Kind() != reflect.Ptr {
- err = cannotConvert(d, s)
- } else {
- err = convertAssignBulkString(d.Elem(), s)
- }
- }
- case int64:
- switch d := d.(type) {
- case *int:
- x := int(s)
- if int64(x) != s {
- err = strconv.ErrRange
- x = 0
- }
- *d = x
- case *bool:
- *d = s != 0
- case *interface{}:
- *d = s
- case nil:
- // skip value
- default:
- if d := reflect.ValueOf(d); d.Type().Kind() != reflect.Ptr {
- err = cannotConvert(d, s)
- } else {
- err = convertAssignInt(d.Elem(), s)
- }
- }
- case string:
- switch d := d.(type) {
- case *string:
- *d = string(s)
- default:
- err = cannotConvert(reflect.ValueOf(d), s)
- }
- case []interface{}:
- switch d := d.(type) {
- case *[]interface{}:
- *d = s
- case *interface{}:
- *d = s
- case nil:
- // skip value
- default:
- if d := reflect.ValueOf(d); d.Type().Kind() != reflect.Ptr {
- err = cannotConvert(d, s)
- } else {
- err = convertAssignArray(d.Elem(), s)
- }
- }
- case Error:
- err = s
- default:
- err = cannotConvert(reflect.ValueOf(d), s)
- }
- return
-}
-
-// Scan copies from src to the values pointed at by dest.
-//
-// The values pointed at by dest must be an integer, float, boolean, string,
-// []byte, interface{} or slices of these types. Scan uses the standard strconv
-// package to convert bulk strings to numeric and boolean types.
-//
-// If a dest value is nil, then the corresponding src value is skipped.
-//
-// If a src element is nil, then the corresponding dest value is not modified.
-//
-// To enable easy use of Scan in a loop, Scan returns the slice of src
-// following the copied values.
-func Scan(src []interface{}, dest ...interface{}) ([]interface{}, error) {
- if len(src) < len(dest) {
- return nil, errors.New("redigo.Scan: array short")
- }
- var err error
- for i, d := range dest {
- err = convertAssign(d, src[i])
- if err != nil {
- err = fmt.Errorf("redigo.Scan: cannot assign to dest %d: %v", i, err)
- break
- }
- }
- return src[len(dest):], err
-}
-
-type fieldSpec struct {
- name string
- index []int
- omitEmpty bool
-}
-
-type structSpec struct {
- m map[string]*fieldSpec
- l []*fieldSpec
-}
-
-func (ss *structSpec) fieldSpec(name []byte) *fieldSpec {
- return ss.m[string(name)]
-}
-
-func compileStructSpec(t reflect.Type, depth map[string]int, index []int, ss *structSpec) {
- for i := 0; i < t.NumField(); i++ {
- f := t.Field(i)
- switch {
- case f.PkgPath != "" && !f.Anonymous:
- // Ignore unexported fields.
- case f.Anonymous:
- // TODO: Handle pointers. Requires change to decoder and
- // protection against infinite recursion.
- if f.Type.Kind() == reflect.Struct {
- compileStructSpec(f.Type, depth, append(index, i), ss)
- }
- default:
- fs := &fieldSpec{name: f.Name}
- tag := f.Tag.Get("redis")
- p := strings.Split(tag, ",")
- if len(p) > 0 {
- if p[0] == "-" {
- continue
- }
- if len(p[0]) > 0 {
- fs.name = p[0]
- }
- for _, s := range p[1:] {
- switch s {
- case "omitempty":
- fs.omitEmpty = true
- default:
- panic(fmt.Errorf("redigo: unknown field tag %s for type %s", s, t.Name()))
- }
- }
- }
- d, found := depth[fs.name]
- if !found {
- d = 1 << 30
- }
- switch {
- case len(index) == d:
- // At same depth, remove from result.
- delete(ss.m, fs.name)
- j := 0
- for i := 0; i < len(ss.l); i++ {
- if fs.name != ss.l[i].name {
- ss.l[j] = ss.l[i]
- j += 1
- }
- }
- ss.l = ss.l[:j]
- case len(index) < d:
- fs.index = make([]int, len(index)+1)
- copy(fs.index, index)
- fs.index[len(index)] = i
- depth[fs.name] = len(index)
- ss.m[fs.name] = fs
- ss.l = append(ss.l, fs)
- }
- }
- }
-}
-
-var (
- structSpecMutex sync.RWMutex
- structSpecCache = make(map[reflect.Type]*structSpec)
- defaultFieldSpec = &fieldSpec{}
-)
-
-func structSpecForType(t reflect.Type) *structSpec {
-
- structSpecMutex.RLock()
- ss, found := structSpecCache[t]
- structSpecMutex.RUnlock()
- if found {
- return ss
- }
-
- structSpecMutex.Lock()
- defer structSpecMutex.Unlock()
- ss, found = structSpecCache[t]
- if found {
- return ss
- }
-
- ss = &structSpec{m: make(map[string]*fieldSpec)}
- compileStructSpec(t, make(map[string]int), nil, ss)
- structSpecCache[t] = ss
- return ss
-}
-
-var errScanStructValue = errors.New("redigo.ScanStruct: value must be non-nil pointer to a struct")
-
-// ScanStruct scans alternating names and values from src to a struct. The
-// HGETALL and CONFIG GET commands return replies in this format.
-//
-// ScanStruct uses exported field names to match values in the response. Use
-// 'redis' field tag to override the name:
-//
-// Field int `redis:"myName"`
-//
-// Fields with the tag redis:"-" are ignored.
-//
-// Integer, float, boolean, string and []byte fields are supported. Scan uses the
-// standard strconv package to convert bulk string values to numeric and
-// boolean types.
-//
-// If a src element is nil, then the corresponding field is not modified.
-func ScanStruct(src []interface{}, dest interface{}) error {
- d := reflect.ValueOf(dest)
- if d.Kind() != reflect.Ptr || d.IsNil() {
- return errScanStructValue
- }
- d = d.Elem()
- if d.Kind() != reflect.Struct {
- return errScanStructValue
- }
- ss := structSpecForType(d.Type())
-
- if len(src)%2 != 0 {
- return errors.New("redigo.ScanStruct: number of values not a multiple of 2")
- }
-
- for i := 0; i < len(src); i += 2 {
- s := src[i+1]
- if s == nil {
- continue
- }
- name, ok := src[i].([]byte)
- if !ok {
- return fmt.Errorf("redigo.ScanStruct: key %d not a bulk string value", i)
- }
- fs := ss.fieldSpec(name)
- if fs == nil {
- continue
- }
- if err := convertAssignValue(d.FieldByIndex(fs.index), s); err != nil {
- return fmt.Errorf("redigo.ScanStruct: cannot assign field %s: %v", fs.name, err)
- }
- }
- return nil
-}
-
-var (
- errScanSliceValue = errors.New("redigo.ScanSlice: dest must be non-nil pointer to a struct")
-)
-
-// ScanSlice scans src to the slice pointed to by dest. The elements the dest
-// slice must be integer, float, boolean, string, struct or pointer to struct
-// values.
-//
-// Struct fields must be integer, float, boolean or string values. All struct
-// fields are used unless a subset is specified using fieldNames.
-func ScanSlice(src []interface{}, dest interface{}, fieldNames ...string) error {
- d := reflect.ValueOf(dest)
- if d.Kind() != reflect.Ptr || d.IsNil() {
- return errScanSliceValue
- }
- d = d.Elem()
- if d.Kind() != reflect.Slice {
- return errScanSliceValue
- }
-
- isPtr := false
- t := d.Type().Elem()
- if t.Kind() == reflect.Ptr && t.Elem().Kind() == reflect.Struct {
- isPtr = true
- t = t.Elem()
- }
-
- if t.Kind() != reflect.Struct {
- ensureLen(d, len(src))
- for i, s := range src {
- if s == nil {
- continue
- }
- if err := convertAssignValue(d.Index(i), s); err != nil {
- return fmt.Errorf("redigo.ScanSlice: cannot assign element %d: %v", i, err)
- }
- }
- return nil
- }
-
- ss := structSpecForType(t)
- fss := ss.l
- if len(fieldNames) > 0 {
- fss = make([]*fieldSpec, len(fieldNames))
- for i, name := range fieldNames {
- fss[i] = ss.m[name]
- if fss[i] == nil {
- return fmt.Errorf("redigo.ScanSlice: ScanSlice bad field name %s", name)
- }
- }
- }
-
- if len(fss) == 0 {
- return errors.New("redigo.ScanSlice: no struct fields")
- }
-
- n := len(src) / len(fss)
- if n*len(fss) != len(src) {
- return errors.New("redigo.ScanSlice: length not a multiple of struct field count")
- }
-
- ensureLen(d, n)
- for i := 0; i < n; i++ {
- d := d.Index(i)
- if isPtr {
- if d.IsNil() {
- d.Set(reflect.New(t))
- }
- d = d.Elem()
- }
- for j, fs := range fss {
- s := src[i*len(fss)+j]
- if s == nil {
- continue
- }
- if err := convertAssignValue(d.FieldByIndex(fs.index), s); err != nil {
- return fmt.Errorf("redigo.ScanSlice: cannot assign element %d to field %s: %v", i*len(fss)+j, fs.name, err)
- }
- }
- }
- return nil
-}
-
-// Args is a helper for constructing command arguments from structured values.
-type Args []interface{}
-
-// Add returns the result of appending value to args.
-func (args Args) Add(value ...interface{}) Args {
- return append(args, value...)
-}
-
-// AddFlat returns the result of appending the flattened value of v to args.
-//
-// Maps are flattened by appending the alternating keys and map values to args.
-//
-// Slices are flattened by appending the slice elements to args.
-//
-// Structs are flattened by appending the alternating names and values of
-// exported fields to args. If v is a nil struct pointer, then nothing is
-// appended. The 'redis' field tag overrides struct field names. See ScanStruct
-// for more information on the use of the 'redis' field tag.
-//
-// Other types are appended to args as is.
-func (args Args) AddFlat(v interface{}) Args {
- rv := reflect.ValueOf(v)
- switch rv.Kind() {
- case reflect.Struct:
- args = flattenStruct(args, rv)
- case reflect.Slice:
- for i := 0; i < rv.Len(); i++ {
- args = append(args, rv.Index(i).Interface())
- }
- case reflect.Map:
- for _, k := range rv.MapKeys() {
- args = append(args, k.Interface(), rv.MapIndex(k).Interface())
- }
- case reflect.Ptr:
- if rv.Type().Elem().Kind() == reflect.Struct {
- if !rv.IsNil() {
- args = flattenStruct(args, rv.Elem())
- }
- } else {
- args = append(args, v)
- }
- default:
- args = append(args, v)
- }
- return args
-}
-
-func flattenStruct(args Args, v reflect.Value) Args {
- ss := structSpecForType(v.Type())
- for _, fs := range ss.l {
- fv := v.FieldByIndex(fs.index)
- if fs.omitEmpty {
- var empty = false
- switch fv.Kind() {
- case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
- empty = fv.Len() == 0
- case reflect.Bool:
- empty = !fv.Bool()
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- empty = fv.Int() == 0
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- empty = fv.Uint() == 0
- case reflect.Float32, reflect.Float64:
- empty = fv.Float() == 0
- case reflect.Interface, reflect.Ptr:
- empty = fv.IsNil()
- }
- if empty {
- continue
- }
- }
- args = append(args, fs.name, fv.Interface())
- }
- return args
-}
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/script.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/script.go
deleted file mode 100644
index 78605a90a..000000000
--- a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/script.go
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright 2012 Gary Burd
-//
-// Licensed under the Apache License, Version 2.0 (the "License"): you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations
-// under the License.
-
-package redis
-
-import (
- "crypto/sha1"
- "encoding/hex"
- "io"
- "strings"
-)
-
-// Script encapsulates the source, hash and key count for a Lua script. See
-// http://redis.io/commands/eval for information on scripts in Redis.
-type Script struct {
- keyCount int
- src string
- hash string
-}
-
-// NewScript returns a new script object. If keyCount is greater than or equal
-// to zero, then the count is automatically inserted in the EVAL command
-// argument list. If keyCount is less than zero, then the application supplies
-// the count as the first value in the keysAndArgs argument to the Do, Send and
-// SendHash methods.
-func NewScript(keyCount int, src string) *Script {
- h := sha1.New()
- io.WriteString(h, src)
- return &Script{keyCount, src, hex.EncodeToString(h.Sum(nil))}
-}
-
-func (s *Script) args(spec string, keysAndArgs []interface{}) []interface{} {
- var args []interface{}
- if s.keyCount < 0 {
- args = make([]interface{}, 1+len(keysAndArgs))
- args[0] = spec
- copy(args[1:], keysAndArgs)
- } else {
- args = make([]interface{}, 2+len(keysAndArgs))
- args[0] = spec
- args[1] = s.keyCount
- copy(args[2:], keysAndArgs)
- }
- return args
-}
-
-// Do evaluates the script. Under the covers, Do optimistically evaluates the
-// script using the EVALSHA command. If the command fails because the script is
-// not loaded, then Do evaluates the script using the EVAL command (thus
-// causing the script to load).
-func (s *Script) Do(c Conn, keysAndArgs ...interface{}) (interface{}, error) {
- v, err := c.Do("EVALSHA", s.args(s.hash, keysAndArgs)...)
- if e, ok := err.(Error); ok && strings.HasPrefix(string(e), "NOSCRIPT ") {
- v, err = c.Do("EVAL", s.args(s.src, keysAndArgs)...)
- }
- return v, err
-}
-
-// SendHash evaluates the script without waiting for the reply. The script is
-// evaluated with the EVALSHA command. The application must ensure that the
-// script is loaded by a previous call to Send, Do or Load methods.
-func (s *Script) SendHash(c Conn, keysAndArgs ...interface{}) error {
- return c.Send("EVALSHA", s.args(s.hash, keysAndArgs)...)
-}
-
-// Send evaluates the script without waiting for the reply.
-func (s *Script) Send(c Conn, keysAndArgs ...interface{}) error {
- return c.Send("EVAL", s.args(s.src, keysAndArgs)...)
-}
-
-// Load loads the script without evaluating it.
-func (s *Script) Load(c Conn) error {
- _, err := c.Do("SCRIPT", "LOAD", s.src)
- return err
-}
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/.gitignore b/Godeps/_workspace/src/github.com/go-gorp/gorp/.gitignore
deleted file mode 100644
index 8a06adea5..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-_test
-_testmain.go
-_obj
-*~
-*.6
-6.out
-gorptest.bin
-tmp
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/.travis.yml b/Godeps/_workspace/src/github.com/go-gorp/gorp/.travis.yml
deleted file mode 100644
index ce4602884..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/.travis.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-language: go
-go:
-- 1.3
-- 1.4
-- 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
-
-script: ./test_all.sh
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/LICENSE b/Godeps/_workspace/src/github.com/go-gorp/gorp/LICENSE
deleted file mode 100644
index b661111d0..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/LICENSE
+++ /dev/null
@@ -1,22 +0,0 @@
-(The MIT License)
-
-Copyright (c) 2012 James Cooper <james@bitmechanic.com>
-
-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.
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/README.md b/Godeps/_workspace/src/github.com/go-gorp/gorp/README.md
deleted file mode 100644
index 8b9277805..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/README.md
+++ /dev/null
@@ -1,745 +0,0 @@
-# Go Relational Persistence
-
-[![build status](https://img.shields.io/travis/go-gorp/gorp.svg)](http://travis-ci.org/go-gorp/gorp)
-[![code coverage](https://img.shields.io/coveralls/go-gorp/gorp.svg)](https://coveralls.io/r/go-gorp/gorp)
-[![issues](https://img.shields.io/github/issues/go-gorp/gorp.svg)](https://github.com/go-gorp/gorp/issues)
-[![godoc v1](https://img.shields.io/badge/godoc-v1-375EAB.svg)](https://godoc.org/gopkg.in/gorp.v1)
-[![godoc bleeding edge](https://img.shields.io/badge/godoc-bleeding--edge-375EAB.svg)](https://godoc.org/github.com/go-gorp/gorp)
-
-### Update 2015-07-01 Cleanup & feature freeze ([#270](https://github.com/go-gorp/gorp/issues/270))
-
-We are currently cleaning up the backlog of issues and PR's. When this is done the codebase will be split into separate files and there will be breaking changes to the API's. We're also adding better tests and documentation. As a result of these changes the `master` branch will be unstable. Please use `gopkg.in/gorp.v1`. When the cleanup and changes are done, we will release `v2.0`.
-
-At this time we won't accept new feature-related pull-requests because of changes to the codebase. Please create an issue for your feature and wait until `v2.0` has been released.
-
-For more information, please read [#270](https://github.com/go-gorp/gorp/issues/270).
-
-## Introduction
-
-I hesitate to call gorp an ORM. Go doesn't really have objects, at least not in the classic Smalltalk/Java sense. There goes the "O". gorp doesn't know anything about the relationships between your structs (at least not yet). So the "R" is questionable too (but I use it in the name because, well, it seemed more clever).
-
-The "M" is alive and well. Given some Go structs and a database, gorp should remove a fair amount of boilerplate busy-work from your code.
-
-I hope that gorp saves you time, minimizes the drudgery of getting data in and out of your database, and helps your code focus on algorithms, not infrastructure.
-
-* Bind struct fields to table columns via API or tag
-* Support for embedded structs
-* Support for transactions
-* Forward engineer db schema from structs (great for unit tests)
-* Pre/post insert/update/delete hooks
-* Automatically generate insert/update/delete statements for a struct
-* Automatic binding of auto increment PKs back to struct after insert
-* Delete by primary key(s)
-* Select by primary key(s)
-* Optional trace sql logging
-* Bind arbitrary SQL queries to a struct
-* Bind slice to SELECT query results without type assertions
-* Use positional or named bind parameters in custom SELECT queries
-* Optional optimistic locking using a version column (for update/deletes)
-
-## Installation
-
- # install the library:
- go get gopkg.in/gorp.v1
-
- // use in your .go code:
- import (
- "gopkg.in/gorp.v1"
- )
-
-## Versioning
-
-This project provides a stable release (v1.x tags) and a bleeding edge codebase (master).
-
-`gopkg.in/gorp.v1` points to the latest v1.x tag. The API's for v1 are stable and shouldn't change. Development takes place at the master branch. Althought the code in master should always compile and test successfully, it might break API's. We aim to maintain backwards compatibility, but API's and behaviour might be changed to fix a bug. Also note that API's that are new in the master branch can change until released as v2.
-
-If you want to use bleeding edge, use `github.com/go-gorp/gorp` as import path.
-
-## API Documentation
-
-Full godoc output from the latest v1 release is available here:
-
-https://godoc.org/gopkg.in/gorp.v1
-
-For the latest code in master:
-
-https://godoc.org/github.com/go-gorp/gorp
-
-## Supported Go versions
-
-This package is compatible with the last 2 major versions of Go, at this time `1.3` and `1.4`.
-
-Any earlier versions are only supported on a best effort basis and can be dropped any time.
-Go has a great compatibility promise. Upgrading your program to a newer version of Go should never really be a problem.
-
-## Quickstart
-
-```go
-package main
-
-import (
- "database/sql"
- "gopkg.in/gorp.v1"
- _ "github.com/mattn/go-sqlite3"
- "log"
- "time"
-)
-
-func main() {
- // initialize the DbMap
- dbmap := initDb()
- defer dbmap.Db.Close()
-
- // delete any existing rows
- err := dbmap.TruncateTables()
- checkErr(err, "TruncateTables failed")
-
- // create two posts
- p1 := newPost("Go 1.1 released!", "Lorem ipsum lorem ipsum")
- p2 := newPost("Go 1.2 released!", "Lorem ipsum lorem ipsum")
-
- // insert rows - auto increment PKs will be set properly after the insert
- err = dbmap.Insert(&p1, &p2)
- checkErr(err, "Insert failed")
-
- // use convenience SelectInt
- count, err := dbmap.SelectInt("select count(*) from posts")
- checkErr(err, "select count(*) failed")
- log.Println("Rows after inserting:", count)
-
- // update a row
- p2.Title = "Go 1.2 is better than ever"
- count, err = dbmap.Update(&p2)
- checkErr(err, "Update failed")
- log.Println("Rows updated:", count)
-
- // fetch one row - note use of "post_id" instead of "Id" since column is aliased
- //
- // Postgres users should use $1 instead of ? placeholders
- // See 'Known Issues' below
- //
- err = dbmap.SelectOne(&p2, "select * from posts where post_id=?", p2.Id)
- checkErr(err, "SelectOne failed")
- log.Println("p2 row:", p2)
-
- // fetch all rows
- var posts []Post
- _, err = dbmap.Select(&posts, "select * from posts order by post_id")
- checkErr(err, "Select failed")
- log.Println("All rows:")
- for x, p := range posts {
- log.Printf(" %d: %v\n", x, p)
- }
-
- // delete row by PK
- count, err = dbmap.Delete(&p1)
- checkErr(err, "Delete failed")
- log.Println("Rows deleted:", count)
-
- // delete row manually via Exec
- _, err = dbmap.Exec("delete from posts where post_id=?", p2.Id)
- checkErr(err, "Exec failed")
-
- // confirm count is zero
- count, err = dbmap.SelectInt("select count(*) from posts")
- checkErr(err, "select count(*) failed")
- log.Println("Row count - should be zero:", count)
-
- log.Println("Done!")
-}
-
-type Post struct {
- // db tag lets you specify the column name if it differs from the struct field
- Id int64 `db:"post_id"`
- Created int64
- Title string `db:",size:50"` // Column size set to 50
- Body string `db:"article_body,size:1024"` // Set both column name and size
-}
-
-func newPost(title, body string) Post {
- return Post{
- Created: time.Now().UnixNano(),
- Title: title,
- Body: body,
- }
-}
-
-func initDb() *gorp.DbMap {
- // connect to db using standard Go database/sql API
- // use whatever database/sql driver you wish
- db, err := sql.Open("sqlite3", "/tmp/post_db.bin")
- checkErr(err, "sql.Open failed")
-
- // construct a gorp DbMap
- dbmap := &gorp.DbMap{Db: db, Dialect: gorp.SqliteDialect{}}
-
- // add a table, setting the table name to 'posts' and
- // specifying that the Id property is an auto incrementing PK
- dbmap.AddTableWithName(Post{}, "posts").SetKeys(true, "Id")
-
- // create the table. in a production system you'd generally
- // use a migration tool, or create the tables via scripts
- err = dbmap.CreateTablesIfNotExists()
- checkErr(err, "Create tables failed")
-
- return dbmap
-}
-
-func checkErr(err error, msg string) {
- if err != nil {
- log.Fatalln(msg, err)
- }
-}
-```
-
-## Examples
-
-### Mapping structs to tables
-
-First define some types:
-
-```go
-type Invoice struct {
- Id int64
- Created int64
- Updated int64
- Memo string
- PersonId int64
-}
-
-type Person struct {
- Id int64
- Created int64
- Updated int64
- FName string
- LName string
-}
-
-// Example of using tags to alias fields to column names
-// The 'db' value is the column name
-//
-// A hyphen will cause gorp to skip this field, similar to the
-// Go json package.
-//
-// This is equivalent to using the ColMap methods:
-//
-// table := dbmap.AddTableWithName(Product{}, "product")
-// table.ColMap("Id").Rename("product_id")
-// table.ColMap("Price").Rename("unit_price")
-// table.ColMap("IgnoreMe").SetTransient(true)
-//
-// You can optionally declare the field to be a primary key and/or autoincrement
-//
-type Product struct {
- Id int64 `db:"product_id, primarykey, autoincrement"`
- Price int64 `db:"unit_price"`
- IgnoreMe string `db:"-"`
-}
-```
-
-Then create a mapper, typically you'd do this one time at app startup:
-
-```go
-// connect to db using standard Go database/sql API
-// use whatever database/sql driver you wish
-db, err := sql.Open("mymysql", "tcp:localhost:3306*mydb/myuser/mypassword")
-
-// construct a gorp DbMap
-dbmap := &gorp.DbMap{Db: db, Dialect: gorp.MySQLDialect{"InnoDB", "UTF8"}}
-
-// register the structs you wish to use with gorp
-// you can also use the shorter dbmap.AddTable() if you
-// don't want to override the table name
-//
-// SetKeys(true) means we have a auto increment primary key, which
-// will get automatically bound to your struct post-insert
-//
-t1 := dbmap.AddTableWithName(Invoice{}, "invoice_test").SetKeys(true, "Id")
-t2 := dbmap.AddTableWithName(Person{}, "person_test").SetKeys(true, "Id")
-t3 := dbmap.AddTableWithName(Product{}, "product_test").SetKeys(true, "Id")
-```
-
-### Struct Embedding
-
-gorp supports embedding structs. For example:
-
-```go
-type Names struct {
- FirstName string
- LastName string
-}
-
-type WithEmbeddedStruct struct {
- Id int64
- Names
-}
-
-es := &WithEmbeddedStruct{-1, Names{FirstName: "Alice", LastName: "Smith"}}
-err := dbmap.Insert(es)
-```
-
-See the `TestWithEmbeddedStruct` function in `gorp_test.go` for a full example.
-
-### Create/Drop Tables ###
-
-Automatically create / drop registered tables. This is useful for unit tests
-but is entirely optional. You can of course use gorp with tables created manually,
-or with a separate migration tool (like [goose](https://bitbucket.org/liamstask/goose) or [migrate](https://github.com/mattes/migrate)).
-
-```go
-// create all registered tables
-dbmap.CreateTables()
-
-// same as above, but uses "if not exists" clause to skip tables that are
-// already defined
-dbmap.CreateTablesIfNotExists()
-
-// drop
-dbmap.DropTables()
-```
-
-### SQL Logging
-
-Optionally you can pass in a logger to trace all SQL statements.
-I recommend enabling this initially while you're getting the feel for what
-gorp is doing on your behalf.
-
-Gorp defines a `GorpLogger` interface that Go's built in `log.Logger` satisfies.
-However, you can write your own `GorpLogger` implementation, or use a package such
-as `glog` if you want more control over how statements are logged.
-
-```go
-// Will log all SQL statements + args as they are run
-// The first arg is a string prefix to prepend to all log messages
-dbmap.TraceOn("[gorp]", log.New(os.Stdout, "myapp:", log.Lmicroseconds))
-
-// Turn off tracing
-dbmap.TraceOff()
-```
-
-### Insert
-
-```go
-// Must declare as pointers so optional callback hooks
-// can operate on your data, not copies
-inv1 := &Invoice{0, 100, 200, "first order", 0}
-inv2 := &Invoice{0, 100, 200, "second order", 0}
-
-// Insert your rows
-err := dbmap.Insert(inv1, inv2)
-
-// Because we called SetKeys(true) on Invoice, the Id field
-// will be populated after the Insert() automatically
-fmt.Printf("inv1.Id=%d inv2.Id=%d\n", inv1.Id, inv2.Id)
-```
-
-### Update
-
-Continuing the above example, use the `Update` method to modify an Invoice:
-
-```go
-// count is the # of rows updated, which should be 1 in this example
-count, err := dbmap.Update(inv1)
-```
-
-### Delete
-
-If you have primary key(s) defined for a struct, you can use the `Delete`
-method to remove rows:
-
-```go
-count, err := dbmap.Delete(inv1)
-```
-
-### Select by Key
-
-Use the `Get` method to fetch a single row by primary key. It returns
-nil if no row is found.
-
-```go
-// fetch Invoice with Id=99
-obj, err := dbmap.Get(Invoice{}, 99)
-inv := obj.(*Invoice)
-```
-
-### Ad Hoc SQL
-
-#### SELECT
-
-`Select()` and `SelectOne()` provide a simple way to bind arbitrary queries to a slice
-or a single struct.
-
-```go
-// Select a slice - first return value is not needed when a slice pointer is passed to Select()
-var posts []Post
-_, err := dbmap.Select(&posts, "select * from post order by id")
-
-// You can also use primitive types
-var ids []string
-_, err := dbmap.Select(&ids, "select id from post")
-
-// Select a single row.
-// Returns an error if no row found, or if more than one row is found
-var post Post
-err := dbmap.SelectOne(&post, "select * from post where id=?", id)
-```
-
-Want to do joins? Just write the SQL and the struct. gorp will bind them:
-
-```go
-// Define a type for your join
-// It *must* contain all the columns in your SELECT statement
-//
-// The names here should match the aliased column names you specify
-// in your SQL - no additional binding work required. simple.
-//
-type InvoicePersonView struct {
- InvoiceId int64
- PersonId int64
- Memo string
- FName string
-}
-
-// Create some rows
-p1 := &Person{0, 0, 0, "bob", "smith"}
-dbmap.Insert(p1)
-
-// notice how we can wire up p1.Id to the invoice easily
-inv1 := &Invoice{0, 0, 0, "xmas order", p1.Id}
-dbmap.Insert(inv1)
-
-// Run your query
-query := "select i.Id InvoiceId, p.Id PersonId, i.Memo, p.FName " +
- "from invoice_test i, person_test p " +
- "where i.PersonId = p.Id"
-
-// pass a slice to Select()
-var list []InvoicePersonView
-_, err := dbmap.Select(&list, query)
-
-// this should test true
-expected := InvoicePersonView{inv1.Id, p1.Id, inv1.Memo, p1.FName}
-if reflect.DeepEqual(list[0], expected) {
- fmt.Println("Woot! My join worked!")
-}
-```
-
-#### SELECT string or int64
-
-gorp provides a few convenience methods for selecting a single string or int64.
-
-```go
-// select single int64 from db (use $1 instead of ? for postgresql)
-i64, err := dbmap.SelectInt("select count(*) from foo where blah=?", blahVal)
-
-// select single string from db:
-s, err := dbmap.SelectStr("select name from foo where blah=?", blahVal)
-
-```
-
-#### Named bind parameters
-
-You may use a map or struct to bind parameters by name. This is currently
-only supported in SELECT queries.
-
-```go
-_, err := dbm.Select(&dest, "select * from Foo where name = :name and age = :age", map[string]interface{}{
- "name": "Rob",
- "age": 31,
-})
-```
-
-#### UPDATE / DELETE
-
-You can execute raw SQL if you wish. Particularly good for batch operations.
-
-```go
-res, err := dbmap.Exec("delete from invoice_test where PersonId=?", 10)
-```
-
-### Transactions
-
-You can batch operations into a transaction:
-
-```go
-func InsertInv(dbmap *DbMap, inv *Invoice, per *Person) error {
- // Start a new transaction
- trans, err := dbmap.Begin()
- if err != nil {
- return err
- }
-
- trans.Insert(per)
- inv.PersonId = per.Id
- trans.Insert(inv)
-
- // if the commit is successful, a nil error is returned
- return trans.Commit()
-}
-```
-
-### Hooks
-
-Use hooks to update data before/after saving to the db. Good for timestamps:
-
-```go
-// implement the PreInsert and PreUpdate hooks
-func (i *Invoice) PreInsert(s gorp.SqlExecutor) error {
- i.Created = time.Now().UnixNano()
- i.Updated = i.Created
- return nil
-}
-
-func (i *Invoice) PreUpdate(s gorp.SqlExecutor) error {
- i.Updated = time.Now().UnixNano()
- return nil
-}
-
-// You can use the SqlExecutor to cascade additional SQL
-// Take care to avoid cycles. gorp won't prevent them.
-//
-// Here's an example of a cascading delete
-//
-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
- }
- return nil
-}
-```
-
-Full list of hooks that you can implement:
-
- PostGet
- PreInsert
- PostInsert
- PreUpdate
- PostUpdate
- PreDelete
- PostDelete
-
- All have the same signature. for example:
-
- func (p *MyStruct) PostUpdate(s gorp.SqlExecutor) error
-
-### Optimistic Locking
-
-#### Note that this behaviour has changed in v2. See [Migration Guide](#migration-guide).
-
-gorp provides a simple optimistic locking feature, similar to Java's JPA, that
-will raise an error if you try to update/delete a row whose `version` column
-has a value different than the one in memory. This provides a safe way to do
-"select then update" style operations without explicit read and write locks.
-
-```go
-// Version is an auto-incremented number, managed by gorp
-// If this property is present on your struct, update
-// operations will be constrained
-//
-// For example, say we defined Person as:
-
-type Person struct {
- Id int64
- Created int64
- Updated int64
- FName string
- LName string
-
- // automatically used as the Version col
- // use table.SetVersionCol("columnName") to map a different
- // struct field as the version field
- Version int64
-}
-
-p1 := &Person{0, 0, 0, "Bob", "Smith", 0}
-dbmap.Insert(p1) // Version is now 1
-
-obj, err := dbmap.Get(Person{}, p1.Id)
-p2 := obj.(*Person)
-p2.LName = "Edwards"
-dbmap.Update(p2) // Version is now 2
-
-p1.LName = "Howard"
-
-// Raises error because p1.Version == 1, which is out of date
-count, err := dbmap.Update(p1)
-_, ok := err.(gorp.OptimisticLockError)
-if ok {
- // should reach this statement
-
- // in a real app you might reload the row and retry, or
- // you might propegate this to the user, depending on the desired
- // semantics
- fmt.Printf("Tried to update row with stale data: %v\n", err)
-} else {
- // some other db error occurred - log or return up the stack
- fmt.Printf("Unknown db err: %v\n", err)
-}
-```
-### Adding INDEX(es) on column(s) beyond the primary key ###
-
-Indexes are frequently critical for performance. Here is how to add them to your tables.
-
-NB: SqlServer and Oracle need testing and possible adjustment to the
-CreateIndexSuffix() and DropIndexSuffix() methods to make AddIndex()
-work for them.
-
-In the example below we put an index both on the Id field, and on the AcctId field.
-
-```
-type Account struct {
- Id int64
- AcctId string // e.g. this might be a long uuid for portability
-}
-
-// indexType (the 2nd param to AddIndex call) is "Btree" or "Hash" for MySQL.
-// demonstrate adding a second index on AcctId, and constrain that field to have unique values.
-dbm.AddTable(iptab.Account{}).SetKeys(true, "Id").AddIndex("AcctIdIndex", "Btree", []string{"AcctId"}).SetUnique(true)
-
-err = dbm.CreateTablesIfNotExists()
-checkErr(err, "CreateTablesIfNotExists failed")
-
-err = dbm.CreateIndex()
-checkErr(err, "CreateIndex failed")
-
-```
-Check the effect of the CreateIndex() call in mysql:
-```
-$ mysql
-
-MariaDB [test]> show create table Account;
-+---------+--------------------------+
-| Account | CREATE TABLE `Account` (
- `Id` bigint(20) NOT NULL AUTO_INCREMENT,
- `AcctId` varchar(255) DEFAULT NULL,
- PRIMARY KEY (`Id`),
- UNIQUE KEY `AcctIdIndex` (`AcctId`) USING BTREE <<<--- yes! index added.
-) ENGINE=InnoDB DEFAULT CHARSET=utf8
-+---------+--------------------------+
-
-```
-
-
-## Database Drivers
-
-gorp uses the Go 1 `database/sql` package. A full list of compliant drivers is available here:
-
-http://code.google.com/p/go-wiki/wiki/SQLDrivers
-
-Sadly, SQL databases differ on various issues. gorp provides a Dialect interface that should be
-implemented per database vendor. Dialects are provided for:
-
-* MySQL
-* PostgreSQL
-* sqlite3
-
-Each of these three databases pass the test suite. See `gorp_test.go` for example
-DSNs for these three databases.
-
-Support is also provided for:
-
-* Oracle (contributed by @klaidliadon)
-* SQL Server (contributed by @qrawl) - use driver: github.com/denisenkom/go-mssqldb
-
-Note that these databases are not covered by CI and I (@coopernurse) have no good way to
-test them locally. So please try them and send patches as needed, but expect a bit more
-unpredicability.
-
-## Known Issues
-
-### SQL placeholder portability
-
-Different databases use different strings to indicate variable placeholders in
-prepared SQL statements. Unlike some database abstraction layers (such as JDBC),
-Go's `database/sql` does not standardize this.
-
-SQL generated by gorp in the `Insert`, `Update`, `Delete`, and `Get` methods delegates
-to a Dialect implementation for each database, and will generate portable SQL.
-
-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 := 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})
-```
-
-Additionally, when using Postgres as your database, you should utilize `$1` instead
-of `?` placeholders as utilizing `?` placeholders when querying Postgres will result
-in `pq: operator does not exist` errors. Alternatively, use
-`dbMap.Dialect.BindVar(varIdx)` to get the proper variable binding for your dialect.
-
-### time.Time and time zones
-
-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
-
-To avoid any potential issues with timezone/DST, consider using an integer field for time
-data and storing UNIX time.
-
-## 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.
-
-```sh
-# MySQL example:
-export GORP_TEST_DSN=gomysql_test/gomysql_test/abc123
-export GORP_TEST_DIALECT=mysql
-
-# run the tests
-go test
-
-# 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.
-
-## Performance
-
-gorp uses reflection to construct SQL queries and bind parameters. See the BenchmarkNativeCrud vs BenchmarkGorpCrud in gorp_test.go for a simple perf test. On my MacBook Pro gorp is about 2-3% slower than hand written SQL.
-
-## Migration guide
-#### Pre-v2 to v2
-Automatic mapping of the version column used in optimistic locking has been removed as it could cause problems if the type was not int. The version column must now explicitly be set with tablemap.SetVersionCol().
-
-## Help/Support
-
-IRC: #gorp
-Mailing list: gorp-dev@googlegroups.com
-Bugs/Enhancements: Create a github issue
-
-## Pull requests / Contributions
-
-Contributions are very welcome. Please follow these guidelines:
-
-* Fork the `master` branch and issue pull requests targeting the `master` branch
-* If you are adding an enhancement, please open an issue first with your proposed change.
-* Changes that break backwards compatibility in the public API are only accepted after we
- discuss on a GitHub issue for a while.
-
-Thanks!
-
-## Contributors
-
-* matthias-margush - column aliasing via tags
-* Rob Figueiredo - @robfig
-* Quinn Slack - @sqs
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/column.go b/Godeps/_workspace/src/github.com/go-gorp/gorp/column.go
deleted file mode 100644
index 99d4fd555..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/column.go
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright 2012 James Cooper. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// Package gorp provides a simple way to marshal Go structs to and from
-// SQL databases. It uses the database/sql package, and should work with any
-// compliant database/sql driver.
-//
-// Source code and project home:
-// https://github.com/go-gorp/gorp
-
-package gorp
-
-import "reflect"
-
-// ColumnMap represents a mapping between a Go struct field and a single
-// column in a table.
-// Unique and MaxSize only inform the
-// CreateTables() function and are not used by Insert/Update/Delete/Get.
-type ColumnMap struct {
- // Column name in db table
- ColumnName string
-
- // If true, this column is skipped in generated SQL statements
- Transient bool
-
- // If true, " unique" is added to create table statements.
- // Not used elsewhere
- Unique bool
-
- // Query used for getting generated id after insert
- GeneratedIdQuery string
-
- // Passed to Dialect.ToSqlType() to assist in informing the
- // correct column type to map to in CreateTables()
- MaxSize int
-
- DefaultValue string
-
- fieldName string
- gotype reflect.Type
- isPK bool
- isAutoIncr bool
- isNotNull bool
-}
-
-// Rename allows you to specify the column name in the table
-//
-// Example: table.ColMap("Updated").Rename("date_updated")
-//
-func (c *ColumnMap) Rename(colname string) *ColumnMap {
- c.ColumnName = colname
- return c
-}
-
-// SetTransient allows you to mark the column as transient. If true
-// this column will be skipped when SQL statements are generated
-func (c *ColumnMap) SetTransient(b bool) *ColumnMap {
- c.Transient = b
- return c
-}
-
-// SetUnique adds "unique" to the create table statements for this
-// column, if b is true.
-func (c *ColumnMap) SetUnique(b bool) *ColumnMap {
- c.Unique = b
- return c
-}
-
-// SetNotNull adds "not null" to the create table statements for this
-// column, if nn is true.
-func (c *ColumnMap) SetNotNull(nn bool) *ColumnMap {
- c.isNotNull = nn
- return c
-}
-
-// SetMaxSize specifies the max length of values of this column. This is
-// passed to the dialect.ToSqlType() function, which can use the value
-// to alter the generated type for "create table" statements
-func (c *ColumnMap) SetMaxSize(size int) *ColumnMap {
- c.MaxSize = size
- return c
-}
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/db.go b/Godeps/_workspace/src/github.com/go-gorp/gorp/db.go
deleted file mode 100644
index 8bba07cf6..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/db.go
+++ /dev/null
@@ -1,619 +0,0 @@
-// Copyright 2012 James Cooper. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// Package gorp provides a simple way to marshal Go structs to and from
-// SQL databases. It uses the database/sql package, and should work with any
-// compliant database/sql driver.
-//
-// Source code and project home:
-// https://github.com/go-gorp/gorp
-
-package gorp
-
-import (
- "bytes"
- "database/sql"
- "database/sql/driver"
- "errors"
- "fmt"
- "reflect"
- "strconv"
- "strings"
- "time"
-)
-
-// DbMap is the root gorp mapping object. Create one of these for each
-// database schema you wish to map. Each DbMap contains a list of
-// mapped tables.
-//
-// Example:
-//
-// dialect := gorp.MySQLDialect{"InnoDB", "UTF8"}
-// dbmap := &gorp.DbMap{Db: db, Dialect: dialect}
-//
-type DbMap struct {
- // Db handle to use with this map
- Db *sql.DB
-
- // Dialect implementation to use with this map
- Dialect Dialect
-
- TypeConverter TypeConverter
-
- tables []*TableMap
- logger GorpLogger
- logPrefix string
-}
-
-func (m *DbMap) CreateIndex() error {
-
- var err error
- dialect := reflect.TypeOf(m.Dialect)
- for _, table := range m.tables {
- for _, index := range table.indexes {
-
- s := bytes.Buffer{}
- s.WriteString("create")
- if index.Unique {
- s.WriteString(" unique")
- }
- s.WriteString(" index")
- s.WriteString(fmt.Sprintf(" %s on %s", index.IndexName, table.TableName))
- if dname := dialect.Name(); dname == "PostgresDialect" && index.IndexType != "" {
- s.WriteString(fmt.Sprintf(" %s %s", m.Dialect.CreateIndexSuffix(), index.IndexType))
- }
- s.WriteString(" (")
- for x, col := range index.columns {
- if x > 0 {
- s.WriteString(", ")
- }
- s.WriteString(m.Dialect.QuoteField(col))
- }
- s.WriteString(")")
-
- if dname := dialect.Name(); dname == "MySQLDialect" && index.IndexType != "" {
- s.WriteString(fmt.Sprintf(" %s %s", m.Dialect.CreateIndexSuffix(), index.IndexType))
- }
- s.WriteString(";")
- _, err = m.Exec(s.String())
- if err != nil {
- break
- }
- }
- }
- return err
-}
-
-func (t *TableMap) DropIndex(name string) error {
-
- var err error
- dialect := reflect.TypeOf(t.dbmap.Dialect)
- for _, idx := range t.indexes {
- if idx.IndexName == name {
- s := bytes.Buffer{}
- s.WriteString(fmt.Sprintf("DROP INDEX %s", idx.IndexName))
-
- if dname := dialect.Name(); dname == "MySQLDialect" {
- s.WriteString(fmt.Sprintf(" %s %s", t.dbmap.Dialect.DropIndexSuffix(), t.TableName))
- }
- s.WriteString(";")
- _, e := t.dbmap.Exec(s.String())
- if e != nil {
- err = e
- }
- break
- }
- }
- t.ResetSql()
- return err
-}
-
-// AddTable registers the given interface type with gorp. The table name
-// will be given the name of the TypeOf(i). You must call this function,
-// or AddTableWithName, for any struct type you wish to persist with
-// the given DbMap.
-//
-// This operation is idempotent. If i's type is already mapped, the
-// existing *TableMap is returned
-func (m *DbMap) AddTable(i interface{}) *TableMap {
- return m.AddTableWithName(i, "")
-}
-
-// AddTableWithName has the same behavior as AddTable, but sets
-// table.TableName to name.
-func (m *DbMap) AddTableWithName(i interface{}, name string) *TableMap {
- return m.AddTableWithNameAndSchema(i, "", name)
-}
-
-// AddTableWithNameAndSchema has the same behavior as AddTable, but sets
-// table.TableName to name.
-func (m *DbMap) AddTableWithNameAndSchema(i interface{}, schema string, name string) *TableMap {
- t := reflect.TypeOf(i)
- if name == "" {
- name = t.Name()
- }
-
- // check if we have a table for this type already
- // if so, update the name and return the existing pointer
- for i := range m.tables {
- table := m.tables[i]
- if table.gotype == t {
- table.TableName = name
- return table
- }
- }
-
- tmap := &TableMap{gotype: t, TableName: name, SchemaName: schema, dbmap: m}
- var primaryKey []*ColumnMap
- tmap.Columns, primaryKey = m.readStructColumns(t)
- m.tables = append(m.tables, tmap)
- if len(primaryKey) > 0 {
- tmap.keys = append(tmap.keys, primaryKey...)
- }
-
- return tmap
-}
-
-func (m *DbMap) readStructColumns(t reflect.Type) (cols []*ColumnMap, primaryKey []*ColumnMap) {
- primaryKey = make([]*ColumnMap, 0)
- n := t.NumField()
- for i := 0; i < n; i++ {
- f := t.Field(i)
- if f.Anonymous && f.Type.Kind() == reflect.Struct {
- // Recursively add nested fields in embedded structs.
- subcols, subpk := m.readStructColumns(f.Type)
- // Don't append nested fields that have the same field
- // name as an already-mapped field.
- for _, subcol := range subcols {
- shouldAppend := true
- for _, col := range cols {
- if !subcol.Transient && subcol.fieldName == col.fieldName {
- shouldAppend = false
- break
- }
- }
- if shouldAppend {
- cols = append(cols, subcol)
- }
- }
- if subpk != nil {
- primaryKey = append(primaryKey, subpk...)
- }
- } else {
- // Tag = Name { ',' Option }
- // Option = OptionKey [ ':' OptionValue ]
- cArguments := strings.Split(f.Tag.Get("db"), ",")
- columnName := cArguments[0]
- var maxSize int
- var defaultValue string
- var isAuto bool
- var isPK bool
- for _, argString := range cArguments[1:] {
- argString = strings.TrimSpace(argString)
- arg := strings.SplitN(argString, ":", 2)
-
- // check mandatory/unexpected option values
- switch arg[0] {
- case "size", "default":
- // options requiring value
- if len(arg) == 1 {
- panic(fmt.Sprintf("missing option value for option %v on field %v", arg[0], f.Name))
- }
- default:
- // options where value is invalid (currently all other options)
- if len(arg) == 2 {
- panic(fmt.Sprintf("unexpected option value for option %v on field %v", arg[0], f.Name))
- }
- }
-
- switch arg[0] {
- case "size":
- maxSize, _ = strconv.Atoi(arg[1])
- case "default":
- defaultValue = arg[1]
- case "primarykey":
- isPK = true
- case "autoincrement":
- isAuto = true
- default:
- panic(fmt.Sprintf("Unrecognized tag option for field %v: %v", f.Name, arg))
- }
- }
- if columnName == "" {
- columnName = f.Name
- }
-
- gotype := f.Type
- value := reflect.New(gotype).Interface()
- if m.TypeConverter != nil {
- // Make a new pointer to a value of type gotype and
- // pass it to the TypeConverter's FromDb method to see
- // if a different type should be used for the column
- // type during table creation.
- scanner, useHolder := m.TypeConverter.FromDb(value)
- if useHolder {
- value = scanner.Holder
- gotype = reflect.TypeOf(value)
- }
- }
- if typer, ok := value.(SqlTyper); ok {
- gotype = reflect.TypeOf(typer.SqlType())
- } else if valuer, ok := value.(driver.Valuer); ok {
- // Only check for driver.Valuer if SqlTyper wasn't
- // found.
- v, err := valuer.Value()
- if err == nil && v != nil {
- gotype = reflect.TypeOf(v)
- }
- }
- cm := &ColumnMap{
- ColumnName: columnName,
- DefaultValue: defaultValue,
- Transient: columnName == "-",
- fieldName: f.Name,
- gotype: gotype,
- isPK: isPK,
- isAutoIncr: isAuto,
- MaxSize: maxSize,
- }
- if isPK {
- primaryKey = append(primaryKey, cm)
- }
- // Check for nested fields of the same field name and
- // override them.
- shouldAppend := true
- for index, col := range cols {
- if !col.Transient && col.fieldName == cm.fieldName {
- cols[index] = cm
- shouldAppend = false
- break
- }
- }
- if shouldAppend {
- cols = append(cols, cm)
- }
- }
-
- }
- return
-}
-
-// CreateTables iterates through TableMaps registered to this DbMap and
-// executes "create table" statements against the database for each.
-//
-// This is particularly useful in unit tests where you want to create
-// and destroy the schema automatically.
-func (m *DbMap) CreateTables() error {
- return m.createTables(false)
-}
-
-// CreateTablesIfNotExists is similar to CreateTables, but starts
-// each statement with "create table if not exists" so that existing
-// tables do not raise errors
-func (m *DbMap) CreateTablesIfNotExists() error {
- return m.createTables(true)
-}
-
-func (m *DbMap) createTables(ifNotExists bool) error {
- var err error
- for i := range m.tables {
- table := m.tables[i]
- sql := table.SqlForCreate(ifNotExists)
- _, err = m.Exec(sql)
- if err != nil {
- break
- }
- }
- return err
-}
-
-// DropTable drops an individual table.
-// Returns an error when the table does not exist.
-func (m *DbMap) DropTable(table interface{}) error {
- t := reflect.TypeOf(table)
- return m.dropTable(t, false)
-}
-
-// DropTableIfExists drops an individual table when the table exists.
-func (m *DbMap) DropTableIfExists(table interface{}) error {
- t := reflect.TypeOf(table)
- return m.dropTable(t, true)
-}
-
-// DropTables iterates through TableMaps registered to this DbMap and
-// executes "drop table" statements against the database for each.
-func (m *DbMap) DropTables() error {
- return m.dropTables(false)
-}
-
-// DropTablesIfExists is the same as DropTables, but uses the "if exists" clause to
-// avoid errors for tables that do not exist.
-func (m *DbMap) DropTablesIfExists() error {
- return m.dropTables(true)
-}
-
-// Goes through all the registered tables, dropping them one by one.
-// If an error is encountered, then it is returned and the rest of
-// the tables are not dropped.
-func (m *DbMap) dropTables(addIfExists bool) (err error) {
- for _, table := range m.tables {
- err = m.dropTableImpl(table, addIfExists)
- if err != nil {
- return err
- }
- }
- return err
-}
-
-// Implementation of dropping a single table.
-func (m *DbMap) dropTable(t reflect.Type, addIfExists bool) error {
- table := tableOrNil(m, t)
- if table == nil {
- return fmt.Errorf("table %s was not registered", table.TableName)
- }
-
- return m.dropTableImpl(table, addIfExists)
-}
-
-func (m *DbMap) dropTableImpl(table *TableMap, ifExists bool) (err error) {
- tableDrop := "drop table"
- if ifExists {
- tableDrop = m.Dialect.IfTableExists(tableDrop, table.SchemaName, table.TableName)
- }
- _, err = m.Exec(fmt.Sprintf("%s %s;", tableDrop, m.Dialect.QuotedTableForQuery(table.SchemaName, table.TableName)))
- return err
-}
-
-// TruncateTables iterates through TableMaps registered to this DbMap and
-// executes "truncate table" statements against the database for each, or in the case of
-// sqlite, a "delete from" with no "where" clause, which uses the truncate optimization
-// (http://www.sqlite.org/lang_delete.html)
-func (m *DbMap) TruncateTables() error {
- var err error
- for i := range m.tables {
- table := m.tables[i]
- _, e := m.Exec(fmt.Sprintf("%s %s;", m.Dialect.TruncateClause(), m.Dialect.QuotedTableForQuery(table.SchemaName, table.TableName)))
- if e != nil {
- err = e
- }
- }
- return err
-}
-
-// Insert runs a SQL INSERT statement for each element in list. List
-// items must be pointers.
-//
-// Any interface whose TableMap has an auto-increment primary key will
-// have its last insert id bound to the PK field on the struct.
-//
-// The hook functions PreInsert() and/or PostInsert() will be executed
-// before/after the INSERT statement if the interface defines them.
-//
-// Panics if any interface in the list has not been registered with AddTable
-func (m *DbMap) Insert(list ...interface{}) error {
- return insert(m, m, list...)
-}
-
-// Update runs a SQL UPDATE statement for each element in list. List
-// items must be pointers.
-//
-// The hook functions PreUpdate() and/or PostUpdate() will be executed
-// before/after the UPDATE statement if the interface defines them.
-//
-// Returns the number of rows updated.
-//
-// Returns an error if SetKeys has not been called on the TableMap
-// Panics if any interface in the list has not been registered with AddTable
-func (m *DbMap) Update(list ...interface{}) (int64, error) {
- return update(m, m, nil, list...)
-}
-
-// UpdateColumns runs a SQL UPDATE statement for each element in list. List
-// items must be pointers.
-//
-// Only the columns accepted by filter are included in the UPDATE.
-//
-// The hook functions PreUpdate() and/or PostUpdate() will be executed
-// before/after the UPDATE statement if the interface defines them.
-//
-// Returns the number of rows updated.
-//
-// Returns an error if SetKeys has not been called on the TableMap
-// Panics if any interface in the list has not been registered with AddTable
-func (m *DbMap) UpdateColumns(filter ColumnFilter, list ...interface{}) (int64, error) {
- return update(m, m, filter, list...)
-}
-
-// Delete runs a SQL DELETE statement for each element in list. List
-// items must be pointers.
-//
-// The hook functions PreDelete() and/or PostDelete() will be executed
-// before/after the DELETE statement if the interface defines them.
-//
-// Returns the number of rows deleted.
-//
-// Returns an error if SetKeys has not been called on the TableMap
-// Panics if any interface in the list has not been registered with AddTable
-func (m *DbMap) Delete(list ...interface{}) (int64, error) {
- return delete(m, m, list...)
-}
-
-// Get runs a SQL SELECT to fetch a single row from the table based on the
-// primary key(s)
-//
-// i should be an empty value for the struct to load. keys should be
-// the primary key value(s) for the row to load. If multiple keys
-// exist on the table, the order should match the column order
-// specified in SetKeys() when the table mapping was defined.
-//
-// The hook function PostGet() will be executed after the SELECT
-// statement if the interface defines them.
-//
-// Returns a pointer to a struct that matches or nil if no row is found.
-//
-// Returns an error if SetKeys has not been called on the TableMap
-// Panics if any interface in the list has not been registered with AddTable
-func (m *DbMap) Get(i interface{}, keys ...interface{}) (interface{}, error) {
- return get(m, m, i, keys...)
-}
-
-// Select runs an arbitrary SQL query, binding the columns in the result
-// to fields on the struct specified by i. args represent the bind
-// parameters for the SQL statement.
-//
-// Column names on the SELECT statement should be aliased to the field names
-// on the struct i. Returns an error if one or more columns in the result
-// do not match. It is OK if fields on i are not part of the SQL
-// statement.
-//
-// The hook function PostGet() will be executed after the SELECT
-// statement if the interface defines them.
-//
-// Values are returned in one of two ways:
-// 1. If i is a struct or a pointer to a struct, returns a slice of pointers to
-// matching rows of type i.
-// 2. If i is a pointer to a slice, the results will be appended to that slice
-// and nil returned.
-//
-// i does NOT need to be registered with AddTable()
-func (m *DbMap) Select(i interface{}, query string, args ...interface{}) ([]interface{}, error) {
- return hookedselect(m, m, i, query, args...)
-}
-
-// Exec runs an arbitrary SQL statement. args represent the bind parameters.
-// This is equivalent to running: Exec() using database/sql
-func (m *DbMap) Exec(query string, args ...interface{}) (sql.Result, error) {
- if m.logger != nil {
- now := time.Now()
- defer m.trace(now, query, args...)
- }
- return exec(m, query, args...)
-}
-
-// SelectInt is a convenience wrapper around the gorp.SelectInt function
-func (m *DbMap) SelectInt(query string, args ...interface{}) (int64, error) {
- return SelectInt(m, query, args...)
-}
-
-// SelectNullInt is a convenience wrapper around the gorp.SelectNullInt function
-func (m *DbMap) SelectNullInt(query string, args ...interface{}) (sql.NullInt64, error) {
- return SelectNullInt(m, query, args...)
-}
-
-// SelectFloat is a convenience wrapper around the gorp.SelectFloat function
-func (m *DbMap) SelectFloat(query string, args ...interface{}) (float64, error) {
- return SelectFloat(m, query, args...)
-}
-
-// SelectNullFloat is a convenience wrapper around the gorp.SelectNullFloat function
-func (m *DbMap) SelectNullFloat(query string, args ...interface{}) (sql.NullFloat64, error) {
- return SelectNullFloat(m, query, args...)
-}
-
-// SelectStr is a convenience wrapper around the gorp.SelectStr function
-func (m *DbMap) SelectStr(query string, args ...interface{}) (string, error) {
- return SelectStr(m, query, args...)
-}
-
-// SelectNullStr is a convenience wrapper around the gorp.SelectNullStr function
-func (m *DbMap) SelectNullStr(query string, args ...interface{}) (sql.NullString, error) {
- return SelectNullStr(m, query, args...)
-}
-
-// SelectOne is a convenience wrapper around the gorp.SelectOne function
-func (m *DbMap) SelectOne(holder interface{}, query string, args ...interface{}) error {
- return SelectOne(m, m, holder, query, args...)
-}
-
-// Begin starts a gorp Transaction
-func (m *DbMap) Begin() (*Transaction, error) {
- if m.logger != nil {
- now := time.Now()
- defer m.trace(now, "begin;")
- }
- tx, err := m.Db.Begin()
- if err != nil {
- return nil, err
- }
- return &Transaction{m, tx, false}, nil
-}
-
-// TableFor returns the *TableMap corresponding to the given Go Type
-// If no table is mapped to that type an error is returned.
-// If checkPK is true and the mapped table has no registered PKs, an error is returned.
-func (m *DbMap) TableFor(t reflect.Type, checkPK bool) (*TableMap, error) {
- table := tableOrNil(m, t)
- if table == nil {
- return nil, fmt.Errorf("no table found for type: %v", t.Name())
- }
-
- if checkPK && len(table.keys) < 1 {
- e := fmt.Sprintf("gorp: no keys defined for table: %s",
- table.TableName)
- return nil, errors.New(e)
- }
-
- return table, nil
-}
-
-// Prepare creates a prepared statement for later queries or executions.
-// Multiple queries or executions may be run concurrently from the returned statement.
-// This is equivalent to running: Prepare() using database/sql
-func (m *DbMap) Prepare(query string) (*sql.Stmt, error) {
- if m.logger != nil {
- now := time.Now()
- defer m.trace(now, query, nil)
- }
- return m.Db.Prepare(query)
-}
-
-func tableOrNil(m *DbMap, t reflect.Type) *TableMap {
- for i := range m.tables {
- table := m.tables[i]
- if table.gotype == t {
- return table
- }
- }
- return nil
-}
-
-func (m *DbMap) tableForPointer(ptr interface{}, checkPK bool) (*TableMap, reflect.Value, error) {
- ptrv := reflect.ValueOf(ptr)
- if ptrv.Kind() != reflect.Ptr {
- e := fmt.Sprintf("gorp: passed non-pointer: %v (kind=%v)", ptr,
- ptrv.Kind())
- return nil, reflect.Value{}, errors.New(e)
- }
- elem := ptrv.Elem()
- etype := reflect.TypeOf(elem.Interface())
- t, err := m.TableFor(etype, checkPK)
- if err != nil {
- return nil, reflect.Value{}, err
- }
-
- return t, elem, nil
-}
-
-func (m *DbMap) queryRow(query string, args ...interface{}) *sql.Row {
- if m.logger != nil {
- now := time.Now()
- defer m.trace(now, query, args...)
- }
- return m.Db.QueryRow(query, args...)
-}
-
-func (m *DbMap) query(query string, args ...interface{}) (*sql.Rows, error) {
- if m.logger != nil {
- now := time.Now()
- defer m.trace(now, query, args...)
- }
- return m.Db.Query(query, args...)
-}
-
-func (m *DbMap) trace(started time.Time, query string, args ...interface{}) {
- if m.logger != nil {
- var margs = argsString(args...)
- m.logger.Printf("%s%s [%s] (%v)", m.logPrefix, query, margs, (time.Now().Sub(started)))
- }
-}
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/dialect.go b/Godeps/_workspace/src/github.com/go-gorp/gorp/dialect.go
deleted file mode 100644
index 203bc62b5..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/dialect.go
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright 2012 James Cooper. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// Package gorp provides a simple way to marshal Go structs to and from
-// SQL databases. It uses the database/sql package, and should work with any
-// compliant database/sql driver.
-//
-// Source code and project home:
-// https://github.com/go-gorp/gorp
-
-package gorp
-
-import "reflect"
-
-// The Dialect interface encapsulates behaviors that differ across
-// SQL databases. At present the Dialect is only used by CreateTables()
-// but this could change in the future
-type Dialect interface {
-
- // adds a suffix to any query, usually ";"
- QuerySuffix() string
-
- // ToSqlType returns the SQL column type to use when creating a
- // table of the given Go Type. maxsize can be used to switch based on
- // size. For example, in MySQL []byte could map to BLOB, MEDIUMBLOB,
- // or LONGBLOB depending on the maxsize
- ToSqlType(val reflect.Type, maxsize int, isAutoIncr bool) string
-
- // string to append to primary key column definitions
- AutoIncrStr() string
-
- // string to bind autoincrement columns to. Empty string will
- // remove reference to those columns in the INSERT statement.
- AutoIncrBindValue() string
-
- AutoIncrInsertSuffix(col *ColumnMap) string
-
- // string to append to "create table" statement for vendor specific
- // table attributes
- CreateTableSuffix() string
-
- // string to append to "create index" statement
- CreateIndexSuffix() string
-
- // string to append to "drop index" statement
- DropIndexSuffix() string
-
- // string to truncate tables
- TruncateClause() string
-
- // bind variable string to use when forming SQL statements
- // in many dbs it is "?", but Postgres appears to use $1
- //
- // i is a zero based index of the bind variable in this statement
- //
- BindVar(i int) string
-
- // Handles quoting of a field name to ensure that it doesn't raise any
- // SQL parsing exceptions by using a reserved word as a field name.
- QuoteField(field string) string
-
- // Handles building up of a schema.database string that is compatible with
- // the given dialect
- //
- // schema - The schema that <table> lives in
- // table - The table name
- QuotedTableForQuery(schema string, table string) string
-
- // Existance clause for table creation / deletion
- IfSchemaNotExists(command, schema string) string
- IfTableExists(command, schema, table string) string
- IfTableNotExists(command, schema, table string) string
-}
-
-// IntegerAutoIncrInserter is implemented by dialects that can perform
-// inserts with automatically incremented integer primary keys. If
-// the dialect can handle automatic assignment of more than just
-// integers, see TargetedAutoIncrInserter.
-type IntegerAutoIncrInserter interface {
- InsertAutoIncr(exec SqlExecutor, insertSql string, params ...interface{}) (int64, error)
-}
-
-// TargetedAutoIncrInserter is implemented by dialects that can
-// perform automatic assignment of any primary key type (i.e. strings
-// for uuids, integers for serials, etc).
-type TargetedAutoIncrInserter interface {
- // InsertAutoIncrToTarget runs an insert operation and assigns the
- // automatically generated primary key directly to the passed in
- // target. The target should be a pointer to the primary key
- // field of the value being inserted.
- InsertAutoIncrToTarget(exec SqlExecutor, insertSql string, target interface{}, params ...interface{}) error
-}
-
-// TargetQueryInserter is implemented by dialects that can perform
-// assignment of integer primary key type by executing a query
-// like "select sequence.currval from dual".
-type TargetQueryInserter interface {
- // TargetQueryInserter runs an insert operation and assigns the
- // automatically generated primary key retrived by the query
- // extracted from the GeneratedIdQuery field of the id column.
- InsertQueryToTarget(exec SqlExecutor, insertSql, idSql string, target interface{}, params ...interface{}) error
-}
-
-func standardInsertAutoIncr(exec SqlExecutor, insertSql string, params ...interface{}) (int64, error) {
- res, err := exec.Exec(insertSql, params...)
- if err != nil {
- return 0, err
- }
- return res.LastInsertId()
-}
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/dialect_mysql.go b/Godeps/_workspace/src/github.com/go-gorp/gorp/dialect_mysql.go
deleted file mode 100644
index 3d7d34027..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/dialect_mysql.go
+++ /dev/null
@@ -1,171 +0,0 @@
-// Copyright 2012 James Cooper. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// Package gorp provides a simple way to marshal Go structs to and from
-// SQL databases. It uses the database/sql package, and should work with any
-// compliant database/sql driver.
-//
-// Source code and project home:
-// https://github.com/go-gorp/gorp
-
-package gorp
-
-import (
- "fmt"
- "reflect"
- "strings"
-)
-
-// Implementation of Dialect for MySQL databases.
-type MySQLDialect struct {
-
- // Engine is the storage engine to use "InnoDB" vs "MyISAM" for example
- Engine string
-
- // Encoding is the character encoding to use for created tables
- Encoding string
-}
-
-func (d MySQLDialect) QuerySuffix() string { return ";" }
-
-func (d MySQLDialect) ToSqlType(val reflect.Type, maxsize int, isAutoIncr bool) string {
- switch val.Kind() {
- case reflect.Ptr:
- return d.ToSqlType(val.Elem(), maxsize, isAutoIncr)
- case reflect.Bool:
- return "boolean"
- case reflect.Int8:
- return "tinyint"
- case reflect.Uint8:
- return "tinyint unsigned"
- case reflect.Int16:
- return "smallint"
- case reflect.Uint16:
- return "smallint unsigned"
- case reflect.Int, reflect.Int32:
- return "int"
- case reflect.Uint, reflect.Uint32:
- return "int unsigned"
- case reflect.Int64:
- return "bigint"
- case reflect.Uint64:
- return "bigint unsigned"
- case reflect.Float64, reflect.Float32:
- return "double"
- case reflect.Slice:
- if val.Elem().Kind() == reflect.Uint8 {
- return "mediumblob"
- }
- }
-
- switch val.Name() {
- case "NullInt64":
- return "bigint"
- case "NullFloat64":
- return "double"
- case "NullBool":
- return "tinyint"
- case "Time":
- 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.
- */
- if maxsize < 256 {
- return fmt.Sprintf("varchar(%d)", maxsize)
- } else {
- return "text"
- }
-}
-
-// Returns auto_increment
-func (d MySQLDialect) AutoIncrStr() string {
- return "auto_increment"
-}
-
-func (d MySQLDialect) AutoIncrBindValue() string {
- return "null"
-}
-
-func (d MySQLDialect) AutoIncrInsertSuffix(col *ColumnMap) string {
- return ""
-}
-
-// Returns engine=%s charset=%s based on values stored on struct
-func (d MySQLDialect) CreateTableSuffix() string {
- if d.Engine == "" || d.Encoding == "" {
- msg := "gorp - undefined"
-
- if d.Engine == "" {
- msg += " MySQLDialect.Engine"
- }
- if d.Engine == "" && d.Encoding == "" {
- msg += ","
- }
- if d.Encoding == "" {
- msg += " MySQLDialect.Encoding"
- }
- msg += ". Check that your MySQLDialect was correctly initialized when declared."
- panic(msg)
- }
-
- return fmt.Sprintf(" engine=%s charset=%s", d.Engine, d.Encoding)
-}
-
-func (m MySQLDialect) CreateIndexSuffix() string {
- return "using"
-}
-
-func (m MySQLDialect) DropIndexSuffix() string {
- return "on"
-}
-
-func (m MySQLDialect) TruncateClause() string {
- return "truncate"
-}
-
-// Returns "?"
-func (d MySQLDialect) BindVar(i int) string {
- return "?"
-}
-
-func (d MySQLDialect) InsertAutoIncr(exec SqlExecutor, insertSql string, params ...interface{}) (int64, error) {
- return standardInsertAutoIncr(exec, insertSql, params...)
-}
-
-func (d MySQLDialect) QuoteField(f string) string {
- return "`" + f + "`"
-}
-
-func (d MySQLDialect) QuotedTableForQuery(schema string, table string) string {
- if strings.TrimSpace(schema) == "" {
- return d.QuoteField(table)
- }
-
- return schema + "." + d.QuoteField(table)
-}
-
-func (d MySQLDialect) IfSchemaNotExists(command, schema string) string {
- return fmt.Sprintf("%s if not exists", command)
-}
-
-func (d MySQLDialect) IfTableExists(command, schema, table string) string {
- return fmt.Sprintf("%s if exists", command)
-}
-
-func (d MySQLDialect) IfTableNotExists(command, schema, table string) string {
- return fmt.Sprintf("%s if not exists", command)
-}
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/dialect_oracle.go b/Godeps/_workspace/src/github.com/go-gorp/gorp/dialect_oracle.go
deleted file mode 100644
index c381380f9..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/dialect_oracle.go
+++ /dev/null
@@ -1,146 +0,0 @@
-// Copyright 2012 James Cooper. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// Package gorp provides a simple way to marshal Go structs to and from
-// SQL databases. It uses the database/sql package, and should work with any
-// compliant database/sql driver.
-//
-// Source code and project home:
-// https://github.com/go-gorp/gorp
-
-package gorp
-
-import (
- "fmt"
- "reflect"
- "strings"
-)
-
-// Implementation of Dialect for Oracle databases.
-type OracleDialect struct{}
-
-func (d OracleDialect) QuerySuffix() string { return "" }
-
-func (d OracleDialect) CreateIndexSuffix() string { return "" }
-
-func (d OracleDialect) DropIndexSuffix() string { return "" }
-
-func (d OracleDialect) ToSqlType(val reflect.Type, maxsize int, isAutoIncr bool) string {
- switch val.Kind() {
- case reflect.Ptr:
- return d.ToSqlType(val.Elem(), maxsize, isAutoIncr)
- case reflect.Bool:
- return "boolean"
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32:
- if isAutoIncr {
- return "serial"
- }
- return "integer"
- case reflect.Int64, reflect.Uint64:
- if isAutoIncr {
- return "bigserial"
- }
- return "bigint"
- case reflect.Float64:
- return "double precision"
- case reflect.Float32:
- return "real"
- case reflect.Slice:
- if val.Elem().Kind() == reflect.Uint8 {
- return "bytea"
- }
- }
-
- switch val.Name() {
- case "NullInt64":
- return "bigint"
- case "NullFloat64":
- return "double precision"
- case "NullBool":
- return "boolean"
- case "NullTime", "Time":
- return "timestamp with time zone"
- }
-
- if maxsize > 0 {
- return fmt.Sprintf("varchar(%d)", maxsize)
- } else {
- return "text"
- }
-
-}
-
-// Returns empty string
-func (d OracleDialect) AutoIncrStr() string {
- return ""
-}
-
-func (d OracleDialect) AutoIncrBindValue() string {
- return "NULL"
-}
-
-func (d OracleDialect) AutoIncrInsertSuffix(col *ColumnMap) string {
- return ""
-}
-
-// Returns suffix
-func (d OracleDialect) CreateTableSuffix() string {
- return ""
-}
-
-func (d OracleDialect) TruncateClause() string {
- return "truncate"
-}
-
-// Returns "$(i+1)"
-func (d OracleDialect) BindVar(i int) string {
- return fmt.Sprintf(":%d", i+1)
-}
-
-// After executing the insert uses the ColMap IdQuery to get the generated id
-func (d OracleDialect) InsertQueryToTarget(exec SqlExecutor, insertSql, idSql string, target interface{}, params ...interface{}) error {
- _, err := exec.Exec(insertSql, params...)
- if err != nil {
- return err
- }
- id, err := exec.SelectInt(idSql)
- if err != nil {
- return err
- }
- switch target.(type) {
- case *int64:
- *(target.(*int64)) = id
- case *int32:
- *(target.(*int32)) = int32(id)
- case int:
- *(target.(*int)) = int(id)
- default:
- return fmt.Errorf("Id field can be int, int32 or int64")
- }
- return nil
-}
-
-func (d OracleDialect) QuoteField(f string) string {
- return `"` + strings.ToUpper(f) + `"`
-}
-
-func (d OracleDialect) QuotedTableForQuery(schema string, table string) string {
- if strings.TrimSpace(schema) == "" {
- return d.QuoteField(table)
- }
-
- return schema + "." + d.QuoteField(table)
-}
-
-func (d OracleDialect) IfSchemaNotExists(command, schema string) string {
- return fmt.Sprintf("%s if not exists", command)
-}
-
-func (d OracleDialect) IfTableExists(command, schema, table string) string {
- return fmt.Sprintf("%s if exists", command)
-}
-
-func (d OracleDialect) IfTableNotExists(command, schema, table string) string {
- return fmt.Sprintf("%s if not exists", command)
-}
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/dialect_postgres.go b/Godeps/_workspace/src/github.com/go-gorp/gorp/dialect_postgres.go
deleted file mode 100644
index a086381a8..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/dialect_postgres.go
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright 2012 James Cooper. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// Package gorp provides a simple way to marshal Go structs to and from
-// SQL databases. It uses the database/sql package, and should work with any
-// compliant database/sql driver.
-//
-// Source code and project home:
-// https://github.com/go-gorp/gorp
-
-package gorp
-
-import (
- "fmt"
- "reflect"
- "strings"
-)
-
-type PostgresDialect struct {
- suffix string
-}
-
-func (d PostgresDialect) QuerySuffix() string { return ";" }
-
-func (d PostgresDialect) ToSqlType(val reflect.Type, maxsize int, isAutoIncr bool) string {
- switch val.Kind() {
- case reflect.Ptr:
- return d.ToSqlType(val.Elem(), maxsize, isAutoIncr)
- case reflect.Bool:
- return "boolean"
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32:
- if isAutoIncr {
- return "serial"
- }
- return "integer"
- case reflect.Int64, reflect.Uint64:
- if isAutoIncr {
- return "bigserial"
- }
- return "bigint"
- case reflect.Float64:
- return "double precision"
- case reflect.Float32:
- return "real"
- case reflect.Slice:
- if val.Elem().Kind() == reflect.Uint8 {
- return "bytea"
- }
- }
-
- switch val.Name() {
- case "NullInt64":
- return "bigint"
- case "NullFloat64":
- return "double precision"
- case "NullBool":
- return "boolean"
- case "Time", "NullTime":
- return "timestamp with time zone"
- }
-
- if maxsize > 0 {
- return fmt.Sprintf("varchar(%d)", maxsize)
- } else {
- return "text"
- }
-
-}
-
-// Returns empty string
-func (d PostgresDialect) AutoIncrStr() string {
- return ""
-}
-
-func (d PostgresDialect) AutoIncrBindValue() string {
- return "default"
-}
-
-func (d PostgresDialect) AutoIncrInsertSuffix(col *ColumnMap) string {
- return " returning " + col.ColumnName
-}
-
-// Returns suffix
-func (d PostgresDialect) CreateTableSuffix() string {
- return d.suffix
-}
-
-func (d PostgresDialect) CreateIndexSuffix() string {
- return "using"
-}
-
-func (d PostgresDialect) DropIndexSuffix() string {
- return ""
-}
-
-func (d PostgresDialect) TruncateClause() string {
- return "truncate"
-}
-
-// Returns "$(i+1)"
-func (d PostgresDialect) BindVar(i int) string {
- return fmt.Sprintf("$%d", i+1)
-}
-
-func (d PostgresDialect) InsertAutoIncrToTarget(exec SqlExecutor, insertSql string, target interface{}, params ...interface{}) error {
- rows, err := exec.query(insertSql, params...)
- if err != nil {
- return err
- }
- defer rows.Close()
-
- if !rows.Next() {
- return fmt.Errorf("No serial value returned for insert: %s Encountered error: %s", insertSql, rows.Err())
- }
- if err := rows.Scan(target); err != nil {
- return err
- }
- if rows.Next() {
- return fmt.Errorf("more than two serial value returned for insert: %s", insertSql)
- }
- return rows.Err()
-}
-
-func (d PostgresDialect) QuoteField(f string) string {
- return `"` + strings.ToLower(f) + `"`
-}
-
-func (d PostgresDialect) QuotedTableForQuery(schema string, table string) string {
- if strings.TrimSpace(schema) == "" {
- return d.QuoteField(table)
- }
-
- return schema + "." + d.QuoteField(table)
-}
-
-func (d PostgresDialect) IfSchemaNotExists(command, schema string) string {
- return fmt.Sprintf("%s if not exists", command)
-}
-
-func (d PostgresDialect) IfTableExists(command, schema, table string) string {
- return fmt.Sprintf("%s if exists", command)
-}
-
-func (d PostgresDialect) IfTableNotExists(command, schema, table string) string {
- return fmt.Sprintf("%s if not exists", command)
-}
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/dialect_sqlite.go b/Godeps/_workspace/src/github.com/go-gorp/gorp/dialect_sqlite.go
deleted file mode 100644
index 7d9b29757..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/dialect_sqlite.go
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright 2012 James Cooper. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// Package gorp provides a simple way to marshal Go structs to and from
-// SQL databases. It uses the database/sql package, and should work with any
-// compliant database/sql driver.
-//
-// Source code and project home:
-// https://github.com/go-gorp/gorp
-
-package gorp
-
-import (
- "fmt"
- "reflect"
-)
-
-type SqliteDialect struct {
- suffix string
-}
-
-func (d SqliteDialect) QuerySuffix() string { return ";" }
-
-func (d SqliteDialect) ToSqlType(val reflect.Type, maxsize int, isAutoIncr bool) string {
- switch val.Kind() {
- case reflect.Ptr:
- return d.ToSqlType(val.Elem(), maxsize, isAutoIncr)
- case reflect.Bool:
- return "integer"
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
- return "integer"
- case reflect.Float64, reflect.Float32:
- return "real"
- case reflect.Slice:
- if val.Elem().Kind() == reflect.Uint8 {
- return "blob"
- }
- }
-
- switch val.Name() {
- case "NullInt64":
- return "integer"
- case "NullFloat64":
- return "real"
- case "NullBool":
- return "integer"
- case "Time":
- return "datetime"
- }
-
- if maxsize < 1 {
- maxsize = 255
- }
- return fmt.Sprintf("varchar(%d)", maxsize)
-}
-
-// Returns autoincrement
-func (d SqliteDialect) AutoIncrStr() string {
- return "autoincrement"
-}
-
-func (d SqliteDialect) AutoIncrBindValue() string {
- return "null"
-}
-
-func (d SqliteDialect) AutoIncrInsertSuffix(col *ColumnMap) string {
- return ""
-}
-
-// Returns suffix
-func (d SqliteDialect) CreateTableSuffix() string {
- return d.suffix
-}
-
-func (d SqliteDialect) CreateIndexSuffix() string {
- return ""
-}
-
-func (d SqliteDialect) DropIndexSuffix() string {
- return ""
-}
-
-// With sqlite, there technically isn't a TRUNCATE statement,
-// but a DELETE FROM uses a truncate optimization:
-// http://www.sqlite.org/lang_delete.html
-func (d SqliteDialect) TruncateClause() string {
- return "delete from"
-}
-
-// Returns "?"
-func (d SqliteDialect) BindVar(i int) string {
- return "?"
-}
-
-func (d SqliteDialect) InsertAutoIncr(exec SqlExecutor, insertSql string, params ...interface{}) (int64, error) {
- return standardInsertAutoIncr(exec, insertSql, params...)
-}
-
-func (d SqliteDialect) QuoteField(f string) string {
- return `"` + f + `"`
-}
-
-// sqlite does not have schemas like PostgreSQL does, so just escape it like normal
-func (d SqliteDialect) QuotedTableForQuery(schema string, table string) string {
- return d.QuoteField(table)
-}
-
-func (d SqliteDialect) IfSchemaNotExists(command, schema string) string {
- return fmt.Sprintf("%s if not exists", command)
-}
-
-func (d SqliteDialect) IfTableExists(command, schema, table string) string {
- return fmt.Sprintf("%s if exists", command)
-}
-
-func (d SqliteDialect) IfTableNotExists(command, schema, table string) string {
- return fmt.Sprintf("%s if not exists", command)
-}
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/dialect_sqlserver.go b/Godeps/_workspace/src/github.com/go-gorp/gorp/dialect_sqlserver.go
deleted file mode 100644
index 8808af598..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/dialect_sqlserver.go
+++ /dev/null
@@ -1,152 +0,0 @@
-// Copyright 2012 James Cooper. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// Package gorp provides a simple way to marshal Go structs to and from
-// SQL databases. It uses the database/sql package, and should work with any
-// compliant database/sql driver.
-//
-// Source code and project home:
-// https://github.com/go-gorp/gorp
-
-package gorp
-
-import (
- "fmt"
- "reflect"
- "strings"
-)
-
-// Implementation of Dialect for Microsoft SQL Server databases.
-// Use gorp.SqlServerDialect{"2005"} for legacy datatypes.
-// Tested with driver: github.com/denisenkom/go-mssqldb
-
-type SqlServerDialect struct {
-
- // If set to "2005" legacy datatypes will be used
- Version string
-}
-
-func (d SqlServerDialect) ToSqlType(val reflect.Type, maxsize int, isAutoIncr bool) string {
- switch val.Kind() {
- case reflect.Ptr:
- return d.ToSqlType(val.Elem(), maxsize, isAutoIncr)
- case reflect.Bool:
- return "bit"
- case reflect.Int8:
- return "tinyint"
- case reflect.Uint8:
- return "smallint"
- case reflect.Int16:
- return "smallint"
- case reflect.Uint16:
- return "int"
- case reflect.Int, reflect.Int32:
- return "int"
- case reflect.Uint, reflect.Uint32:
- return "bigint"
- case reflect.Int64:
- return "bigint"
- case reflect.Uint64:
- return "numeric(20,0)"
- case reflect.Float32:
- return "float(24)"
- case reflect.Float64:
- return "float(53)"
- case reflect.Slice:
- if val.Elem().Kind() == reflect.Uint8 {
- return "varbinary"
- }
- }
-
- switch val.Name() {
- case "NullInt64":
- return "bigint"
- case "NullFloat64":
- return "float(53)"
- case "NullBool":
- return "bit"
- case "NullTime", "Time":
- if d.Version == "2005" {
- return "datetime"
- }
- return "datetime2"
- }
-
- if maxsize < 1 {
- if d.Version == "2005" {
- maxsize = 255
- } else {
- return fmt.Sprintf("nvarchar(max)")
- }
- }
- return fmt.Sprintf("nvarchar(%d)", maxsize)
-}
-
-// Returns auto_increment
-func (d SqlServerDialect) AutoIncrStr() string {
- return "identity(0,1)"
-}
-
-// Empty string removes autoincrement columns from the INSERT statements.
-func (d SqlServerDialect) AutoIncrBindValue() string {
- return ""
-}
-
-func (d SqlServerDialect) AutoIncrInsertSuffix(col *ColumnMap) string {
- return ""
-}
-
-func (d SqlServerDialect) CreateTableSuffix() string { return ";" }
-
-func (d SqlServerDialect) TruncateClause() string {
- return "truncate table"
-}
-
-// Returns "?"
-func (d SqlServerDialect) BindVar(i int) string {
- return "?"
-}
-
-func (d SqlServerDialect) InsertAutoIncr(exec SqlExecutor, insertSql string, params ...interface{}) (int64, error) {
- return standardInsertAutoIncr(exec, insertSql, params...)
-}
-
-func (d SqlServerDialect) QuoteField(f string) string {
- return "[" + strings.Replace(f, "]", "]]", -1) + "]"
-}
-
-func (d SqlServerDialect) QuotedTableForQuery(schema string, table string) string {
- if strings.TrimSpace(schema) == "" {
- return d.QuoteField(table)
- }
- return d.QuoteField(schema) + "." + d.QuoteField(table)
-}
-
-func (d SqlServerDialect) QuerySuffix() string { return ";" }
-
-func (d SqlServerDialect) IfSchemaNotExists(command, schema string) string {
- s := fmt.Sprintf("if schema_id(N'%s') is null %s", schema, command)
- return s
-}
-
-func (d SqlServerDialect) IfTableExists(command, schema, table string) string {
- var schema_clause string
- if strings.TrimSpace(schema) != "" {
- schema_clause = fmt.Sprintf("%s.", d.QuoteField(schema))
- }
- s := fmt.Sprintf("if object_id('%s%s') is not null %s", schema_clause, d.QuoteField(table), command)
- return s
-}
-
-func (d SqlServerDialect) IfTableNotExists(command, schema, table string) string {
- var schema_clause string
- if strings.TrimSpace(schema) != "" {
- schema_clause = fmt.Sprintf("%s.", schema)
- }
- s := fmt.Sprintf("if object_id('%s%s') is null %s", schema_clause, table, command)
- return s
-}
-
-func (d SqlServerDialect) CreateIndexSuffix() string { return "" }
-func (d SqlServerDialect) DropIndexSuffix() string { return "" }
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/errors.go b/Godeps/_workspace/src/github.com/go-gorp/gorp/errors.go
deleted file mode 100644
index d13f03fc3..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/errors.go
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2012 James Cooper. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// Package gorp provides a simple way to marshal Go structs to and from
-// SQL databases. It uses the database/sql package, and should work with any
-// compliant database/sql driver.
-//
-// Source code and project home:
-// https://github.com/go-gorp/gorp
-
-package gorp
-
-import (
- "fmt"
-)
-
-// A non-fatal error, when a select query returns columns that do not exist
-// as fields in the struct it is being mapped to
-// TODO: discuss wether this needs an error. encoding/json silently ignores missing fields
-type NoFieldInTypeError struct {
- TypeName string
- MissingColNames []string
-}
-
-func (err *NoFieldInTypeError) Error() string {
- return fmt.Sprintf("gorp: no fields %+v in type %s", err.MissingColNames, err.TypeName)
-}
-
-// returns true if the error is non-fatal (ie, we shouldn't immediately return)
-func NonFatalError(err error) bool {
- switch err.(type) {
- case *NoFieldInTypeError:
- return true
- default:
- return false
- }
-}
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/gorp.go b/Godeps/_workspace/src/github.com/go-gorp/gorp/gorp.go
deleted file mode 100644
index 1f32283f5..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/gorp.go
+++ /dev/null
@@ -1,558 +0,0 @@
-// Copyright 2012 James Cooper. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// Package gorp provides a simple way to marshal Go structs to and from
-// SQL databases. It uses the database/sql package, and should work with any
-// compliant database/sql driver.
-//
-// Source code and project home:
-// https://github.com/go-gorp/gorp
-//
-package gorp
-
-import (
- "database/sql"
- "database/sql/driver"
- "fmt"
- "reflect"
- "regexp"
- "strings"
- "time"
-)
-
-// OracleString (empty string is null)
-// TODO: move to dialect/oracle?, rename to String?
-type OracleString struct {
- sql.NullString
-}
-
-// Scan implements the Scanner interface.
-func (os *OracleString) Scan(value interface{}) error {
- if value == nil {
- os.String, os.Valid = "", false
- return nil
- }
- os.Valid = true
- return os.NullString.Scan(value)
-}
-
-// Value implements the driver Valuer interface.
-func (os OracleString) Value() (driver.Value, error) {
- if !os.Valid || os.String == "" {
- return nil, nil
- }
- return os.String, nil
-}
-
-// SqlTyper is a type that returns its database type. Most of the
-// time, the type can just use "database/sql/driver".Valuer; but when
-// it returns nil for its empty value, it needs to implement SqlTyper
-// to have its column type detected properly during table creation.
-type SqlTyper interface {
- SqlType() driver.Valuer
-}
-
-// for fields that exists in DB table, but not exists in struct
-type dummyField struct{}
-
-// Scan implements the Scanner interface.
-func (nt *dummyField) Scan(value interface{}) error {
- return nil
-}
-
-var zeroVal reflect.Value
-var versFieldConst = "[gorp_ver_field]"
-
-// The TypeConverter interface provides a way to map a value of one
-// type to another type when persisting to, or loading from, a database.
-//
-// Example use cases: Implement type converter to convert bool types to "y"/"n" strings,
-// or serialize a struct member as a JSON blob.
-type TypeConverter interface {
- // ToDb converts val to another type. Called before INSERT/UPDATE operations
- ToDb(val interface{}) (interface{}, error)
-
- // FromDb returns a CustomScanner appropriate for this type. This will be used
- // to hold values returned from SELECT queries.
- //
- // In particular the CustomScanner returned should implement a Binder
- // function appropriate for the Go type you wish to convert the db value to
- //
- // If bool==false, then no custom scanner will be used for this field.
- FromDb(target interface{}) (CustomScanner, bool)
-}
-
-// Executor exposes the sql.DB and sql.Tx Exec function so that it can be used
-// on internal functions that convert named parameters for the Exec function.
-type executor interface {
- Exec(query string, args ...interface{}) (sql.Result, error)
-}
-
-// SqlExecutor exposes gorp operations that can be run from Pre/Post
-// hooks. This hides whether the current operation that triggered the
-// hook is in a transaction.
-//
-// See the DbMap function docs for each of the functions below for more
-// information.
-type SqlExecutor interface {
- Get(i interface{}, keys ...interface{}) (interface{}, error)
- Insert(list ...interface{}) error
- Update(list ...interface{}) (int64, error)
- Delete(list ...interface{}) (int64, error)
- Exec(query string, args ...interface{}) (sql.Result, error)
- Select(i interface{}, query string,
- args ...interface{}) ([]interface{}, error)
- SelectInt(query string, args ...interface{}) (int64, error)
- SelectNullInt(query string, args ...interface{}) (sql.NullInt64, error)
- SelectFloat(query string, args ...interface{}) (float64, error)
- SelectNullFloat(query string, args ...interface{}) (sql.NullFloat64, error)
- SelectStr(query string, args ...interface{}) (string, error)
- SelectNullStr(query string, args ...interface{}) (sql.NullString, error)
- SelectOne(holder interface{}, query string, args ...interface{}) error
- query(query string, args ...interface{}) (*sql.Rows, error)
- queryRow(query string, args ...interface{}) *sql.Row
-}
-
-// Compile-time check that DbMap and Transaction implement the SqlExecutor
-// interface.
-var _, _ SqlExecutor = &DbMap{}, &Transaction{}
-
-func argsString(args ...interface{}) string {
- var margs string
- for i, a := range args {
- var v interface{} = a
- if x, ok := v.(driver.Valuer); ok {
- y, err := x.Value()
- if err == nil {
- v = y
- }
- }
- switch v.(type) {
- case string:
- v = fmt.Sprintf("%q", v)
- default:
- v = fmt.Sprintf("%v", v)
- }
- margs += fmt.Sprintf("%d:%s", i+1, v)
- if i+1 < len(args) {
- margs += " "
- }
- }
- return margs
-}
-
-// Calls the Exec function on the executor, but attempts to expand any eligible named
-// query arguments first.
-func exec(e SqlExecutor, query string, args ...interface{}) (sql.Result, error) {
- var dbMap *DbMap
- var executor executor
- switch m := e.(type) {
- case *DbMap:
- executor = m.Db
- dbMap = m
- case *Transaction:
- executor = m.tx
- dbMap = m.dbmap
- }
-
- if len(args) == 1 {
- query, args = maybeExpandNamedQuery(dbMap, query, args)
- }
-
- return executor.Exec(query, args...)
-}
-
-// maybeExpandNamedQuery checks the given arg to see if it's eligible to be used
-// as input to a named query. If so, it rewrites the query to use
-// dialect-dependent bindvars and instantiates the corresponding slice of
-// parameters by extracting data from the map / struct.
-// If not, returns the input values unchanged.
-func maybeExpandNamedQuery(m *DbMap, query string, args []interface{}) (string, []interface{}) {
- var (
- arg = args[0]
- argval = reflect.ValueOf(arg)
- )
- if argval.Kind() == reflect.Ptr {
- argval = argval.Elem()
- }
-
- if argval.Kind() == reflect.Map && argval.Type().Key().Kind() == reflect.String {
- return expandNamedQuery(m, query, func(key string) reflect.Value {
- return argval.MapIndex(reflect.ValueOf(key))
- })
- }
- if argval.Kind() != reflect.Struct {
- return query, args
- }
- if _, ok := arg.(time.Time); ok {
- // time.Time is driver.Value
- return query, args
- }
- if _, ok := arg.(driver.Valuer); ok {
- // driver.Valuer will be converted to driver.Value.
- return query, args
- }
-
- return expandNamedQuery(m, query, argval.FieldByName)
-}
-
-var keyRegexp = regexp.MustCompile(`:[[:word:]]+`)
-
-// expandNamedQuery accepts a query with placeholders of the form ":key", and a
-// single arg of Kind Struct or Map[string]. It returns the query with the
-// dialect's placeholders, and a slice of args ready for positional insertion
-// into the query.
-func expandNamedQuery(m *DbMap, query string, keyGetter func(key string) reflect.Value) (string, []interface{}) {
- var (
- n int
- args []interface{}
- )
- return keyRegexp.ReplaceAllStringFunc(query, func(key string) string {
- val := keyGetter(key[1:])
- if !val.IsValid() {
- return key
- }
- args = append(args, val.Interface())
- newVar := m.Dialect.BindVar(n)
- n++
- return newVar
- }), args
-}
-
-func columnToFieldIndex(m *DbMap, t reflect.Type, cols []string) ([][]int, error) {
- colToFieldIndex := make([][]int, len(cols))
-
- // check if type t is a mapped table - if so we'll
- // check the table for column aliasing below
- tableMapped := false
- table := tableOrNil(m, t)
- if table != nil {
- tableMapped = true
- }
-
- // Loop over column names and find field in i to bind to
- // based on column name. all returned columns must match
- // a field in the i struct
- missingColNames := []string{}
- for x := range cols {
- colName := strings.ToLower(cols[x])
- field, found := t.FieldByNameFunc(func(fieldName string) bool {
- field, _ := t.FieldByName(fieldName)
- cArguments := strings.Split(field.Tag.Get("db"), ",")
- fieldName = cArguments[0]
-
- if fieldName == "-" {
- return false
- } else if fieldName == "" {
- fieldName = field.Name
- }
- if tableMapped {
- colMap := colMapOrNil(table, fieldName)
- if colMap != nil {
- fieldName = colMap.ColumnName
- }
- }
- return colName == strings.ToLower(fieldName)
- })
- if found {
- colToFieldIndex[x] = field.Index
- }
- if colToFieldIndex[x] == nil {
- missingColNames = append(missingColNames, colName)
- }
- }
- if len(missingColNames) > 0 {
- return colToFieldIndex, &NoFieldInTypeError{
- TypeName: t.Name(),
- MissingColNames: missingColNames,
- }
- }
- return colToFieldIndex, nil
-}
-
-func fieldByName(val reflect.Value, fieldName string) *reflect.Value {
- // try to find field by exact match
- f := val.FieldByName(fieldName)
-
- if f != zeroVal {
- return &f
- }
-
- // try to find by case insensitive match - only the Postgres driver
- // seems to require this - in the case where columns are aliased in the sql
- fieldNameL := strings.ToLower(fieldName)
- fieldCount := val.NumField()
- t := val.Type()
- for i := 0; i < fieldCount; i++ {
- sf := t.Field(i)
- if strings.ToLower(sf.Name) == fieldNameL {
- f := val.Field(i)
- return &f
- }
- }
-
- return nil
-}
-
-// toSliceType returns the element type of the given object, if the object is a
-// "*[]*Element" or "*[]Element". If not, returns nil.
-// err is returned if the user was trying to pass a pointer-to-slice but failed.
-func toSliceType(i interface{}) (reflect.Type, error) {
- t := reflect.TypeOf(i)
- if t.Kind() != reflect.Ptr {
- // If it's a slice, return a more helpful error message
- if t.Kind() == reflect.Slice {
- return nil, fmt.Errorf("gorp: cannot SELECT into a non-pointer slice: %v", t)
- }
- return nil, nil
- }
- if t = t.Elem(); t.Kind() != reflect.Slice {
- return nil, nil
- }
- return t.Elem(), nil
-}
-
-func toType(i interface{}) (reflect.Type, error) {
- t := reflect.TypeOf(i)
-
- // If a Pointer to a type, follow
- for t.Kind() == reflect.Ptr {
- t = t.Elem()
- }
-
- if t.Kind() != reflect.Struct {
- return nil, fmt.Errorf("gorp: cannot SELECT into this type: %v", reflect.TypeOf(i))
- }
- return t, nil
-}
-
-func get(m *DbMap, exec SqlExecutor, i interface{},
- keys ...interface{}) (interface{}, error) {
-
- t, err := toType(i)
- if err != nil {
- return nil, err
- }
-
- table, err := m.TableFor(t, true)
- if err != nil {
- return nil, err
- }
-
- plan := table.bindGet()
-
- v := reflect.New(t)
- dest := make([]interface{}, len(plan.argFields))
-
- conv := m.TypeConverter
- custScan := make([]CustomScanner, 0)
-
- for x, fieldName := range plan.argFields {
- f := v.Elem().FieldByName(fieldName)
- target := f.Addr().Interface()
- if conv != nil {
- scanner, ok := conv.FromDb(target)
- if ok {
- target = scanner.Holder
- custScan = append(custScan, scanner)
- }
- }
- dest[x] = target
- }
-
- row := exec.queryRow(plan.query, keys...)
- err = row.Scan(dest...)
- if err != nil {
- if err == sql.ErrNoRows {
- err = nil
- }
- return nil, err
- }
-
- for _, c := range custScan {
- err = c.Bind()
- if err != nil {
- return nil, err
- }
- }
-
- if v, ok := v.Interface().(HasPostGet); ok {
- err := v.PostGet(exec)
- if err != nil {
- return nil, err
- }
- }
-
- return v.Interface(), nil
-}
-
-func delete(m *DbMap, exec SqlExecutor, list ...interface{}) (int64, error) {
- count := int64(0)
- for _, ptr := range list {
- table, elem, err := m.tableForPointer(ptr, true)
- if err != nil {
- return -1, err
- }
-
- eval := elem.Addr().Interface()
- if v, ok := eval.(HasPreDelete); ok {
- err = v.PreDelete(exec)
- if err != nil {
- return -1, err
- }
- }
-
- bi, err := table.bindDelete(elem)
- if err != nil {
- return -1, err
- }
-
- res, err := exec.Exec(bi.query, bi.args...)
- if err != nil {
- return -1, err
- }
- rows, err := res.RowsAffected()
- if err != nil {
- return -1, err
- }
-
- if rows == 0 && bi.existingVersion > 0 {
- return lockError(m, exec, table.TableName,
- bi.existingVersion, elem, bi.keys...)
- }
-
- count += rows
-
- if v, ok := eval.(HasPostDelete); ok {
- err := v.PostDelete(exec)
- if err != nil {
- return -1, err
- }
- }
- }
-
- return count, nil
-}
-
-func update(m *DbMap, exec SqlExecutor, colFilter ColumnFilter, list ...interface{}) (int64, error) {
- count := int64(0)
- for _, ptr := range list {
- table, elem, err := m.tableForPointer(ptr, true)
- if err != nil {
- return -1, err
- }
-
- eval := elem.Addr().Interface()
- if v, ok := eval.(HasPreUpdate); ok {
- err = v.PreUpdate(exec)
- if err != nil {
- return -1, err
- }
- }
-
- bi, err := table.bindUpdate(elem, colFilter)
- if err != nil {
- return -1, err
- }
-
- res, err := exec.Exec(bi.query, bi.args...)
- if err != nil {
- return -1, err
- }
-
- rows, err := res.RowsAffected()
- if err != nil {
- return -1, err
- }
-
- if rows == 0 && bi.existingVersion > 0 {
- return lockError(m, exec, table.TableName,
- bi.existingVersion, elem, bi.keys...)
- }
-
- if bi.versField != "" {
- elem.FieldByName(bi.versField).SetInt(bi.existingVersion + 1)
- }
-
- count += rows
-
- if v, ok := eval.(HasPostUpdate); ok {
- err = v.PostUpdate(exec)
- if err != nil {
- return -1, err
- }
- }
- }
- return count, nil
-}
-
-func insert(m *DbMap, exec SqlExecutor, list ...interface{}) error {
- for _, ptr := range list {
- table, elem, err := m.tableForPointer(ptr, false)
- if err != nil {
- return err
- }
-
- eval := elem.Addr().Interface()
- if v, ok := eval.(HasPreInsert); ok {
- err := v.PreInsert(exec)
- if err != nil {
- return err
- }
- }
-
- bi, err := table.bindInsert(elem)
- if err != nil {
- return err
- }
-
- if bi.autoIncrIdx > -1 {
- f := elem.FieldByName(bi.autoIncrFieldName)
- switch inserter := m.Dialect.(type) {
- case IntegerAutoIncrInserter:
- id, err := inserter.InsertAutoIncr(exec, bi.query, bi.args...)
- if err != nil {
- return err
- }
- k := f.Kind()
- if (k == reflect.Int) || (k == reflect.Int16) || (k == reflect.Int32) || (k == reflect.Int64) {
- f.SetInt(id)
- } else if (k == reflect.Uint) || (k == reflect.Uint16) || (k == reflect.Uint32) || (k == reflect.Uint64) {
- f.SetUint(uint64(id))
- } else {
- return fmt.Errorf("gorp: cannot set autoincrement value on non-Int field. SQL=%s autoIncrIdx=%d autoIncrFieldName=%s", bi.query, bi.autoIncrIdx, bi.autoIncrFieldName)
- }
- case TargetedAutoIncrInserter:
- err := inserter.InsertAutoIncrToTarget(exec, bi.query, f.Addr().Interface(), bi.args...)
- if err != nil {
- return err
- }
- case TargetQueryInserter:
- var idQuery = table.ColMap(bi.autoIncrFieldName).GeneratedIdQuery
- if idQuery == "" {
- return fmt.Errorf("gorp: cannot set %s value if its ColumnMap.GeneratedIdQuery is empty", bi.autoIncrFieldName)
- }
- err := inserter.InsertQueryToTarget(exec, bi.query, idQuery, f.Addr().Interface(), bi.args...)
- if err != nil {
- return err
- }
- default:
- return fmt.Errorf("gorp: cannot use autoincrement fields on dialects that do not implement an autoincrementing interface")
- }
- } else {
- _, err := exec.Exec(bi.query, bi.args...)
- if err != nil {
- return err
- }
- }
-
- if v, ok := eval.(HasPostInsert); ok {
- err := v.PostInsert(exec)
- if err != nil {
- return err
- }
- }
- }
- return nil
-}
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/hooks.go b/Godeps/_workspace/src/github.com/go-gorp/gorp/hooks.go
deleted file mode 100644
index 192b51f00..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/hooks.go
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2012 James Cooper. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// Package gorp provides a simple way to marshal Go structs to and from
-// SQL databases. It uses the database/sql package, and should work with any
-// compliant database/sql driver.
-//
-// Source code and project home:
-// https://github.com/go-gorp/gorp
-
-package gorp
-
-//++ TODO v2-phase3: HasPostGet => PostGetter, HasPostDelete => PostDeleter, etc.
-
-// PostUpdate() will be executed after the GET statement.
-type HasPostGet interface {
- PostGet(SqlExecutor) error
-}
-
-// PostUpdate() will be executed after the DELETE statement
-type HasPostDelete interface {
- PostDelete(SqlExecutor) error
-}
-
-// PostUpdate() will be executed after the UPDATE statement
-type HasPostUpdate interface {
- PostUpdate(SqlExecutor) error
-}
-
-// PostInsert() will be executed after the INSERT statement
-type HasPostInsert interface {
- PostInsert(SqlExecutor) error
-}
-
-// PreDelete() will be executed before the DELETE statement.
-type HasPreDelete interface {
- PreDelete(SqlExecutor) error
-}
-
-// PreUpdate() will be executed before UPDATE statement.
-type HasPreUpdate interface {
- PreUpdate(SqlExecutor) error
-}
-
-// PreInsert() will be executed before INSERT statement.
-type HasPreInsert interface {
- PreInsert(SqlExecutor) error
-}
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/index.go b/Godeps/_workspace/src/github.com/go-gorp/gorp/index.go
deleted file mode 100644
index 01ecd9eca..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/index.go
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2012 James Cooper. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// Package gorp provides a simple way to marshal Go structs to and from
-// SQL databases. It uses the database/sql package, and should work with any
-// compliant database/sql driver.
-//
-// Source code and project home:
-// https://github.com/go-gorp/gorp
-
-package gorp
-
-// IndexMap represents a mapping between a Go struct field and a single
-// index in a table.
-// Unique and MaxSize only inform the
-// CreateTables() function and are not used by Insert/Update/Delete/Get.
-type IndexMap struct {
- // Index name in db table
- IndexName string
-
- // If true, " unique" is added to create index statements.
- // Not used elsewhere
- Unique bool
-
- // Index type supported by Dialect
- // Postgres: B-tree, Hash, GiST and GIN.
- // Mysql: Btree, Hash.
- // Sqlite: nil.
- IndexType string
-
- // Columns name for single and multiple indexes
- columns []string
-}
-
-// Rename allows you to specify the index name in the table
-//
-// Example: table.IndMap("customer_test_idx").Rename("customer_idx")
-//
-func (idx *IndexMap) Rename(indname string) *IndexMap {
- idx.IndexName = indname
- return idx
-}
-
-// SetUnique adds "unique" to the create index statements for this
-// index, if b is true.
-func (idx *IndexMap) SetUnique(b bool) *IndexMap {
- idx.Unique = b
- return idx
-}
-
-// SetIndexType specifies the index type supported by chousen SQL Dialect
-func (idx *IndexMap) SetIndexType(indtype string) *IndexMap {
- idx.IndexType = indtype
- return idx
-}
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/lockerror.go b/Godeps/_workspace/src/github.com/go-gorp/gorp/lockerror.go
deleted file mode 100644
index 07b3047ae..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/lockerror.go
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2012 James Cooper. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// Package gorp provides a simple way to marshal Go structs to and from
-// SQL databases. It uses the database/sql package, and should work with any
-// compliant database/sql driver.
-//
-// Source code and project home:
-// https://github.com/go-gorp/gorp
-
-package gorp
-
-import (
- "fmt"
- "reflect"
-)
-
-// OptimisticLockError is returned by Update() or Delete() if the
-// struct being modified has a Version field and the value is not equal to
-// the current value in the database
-type OptimisticLockError struct {
- // Table name where the lock error occurred
- TableName string
-
- // Primary key values of the row being updated/deleted
- Keys []interface{}
-
- // true if a row was found with those keys, indicating the
- // LocalVersion is stale. false if no value was found with those
- // keys, suggesting the row has been deleted since loaded, or
- // was never inserted to begin with
- RowExists bool
-
- // Version value on the struct passed to Update/Delete. This value is
- // out of sync with the database.
- LocalVersion int64
-}
-
-// Error returns a description of the cause of the lock error
-func (e OptimisticLockError) Error() string {
- if e.RowExists {
- return fmt.Sprintf("gorp: OptimisticLockError table=%s keys=%v out of date version=%d", e.TableName, e.Keys, e.LocalVersion)
- }
-
- return fmt.Sprintf("gorp: OptimisticLockError no row found for table=%s keys=%v", e.TableName, e.Keys)
-}
-
-func lockError(m *DbMap, exec SqlExecutor, tableName string,
- existingVer int64, elem reflect.Value,
- keys ...interface{}) (int64, error) {
-
- existing, err := get(m, exec, elem.Interface(), keys...)
- if err != nil {
- return -1, err
- }
-
- ole := OptimisticLockError{tableName, keys, true, existingVer}
- if existing == nil {
- ole.RowExists = false
- }
- return -1, ole
-}
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/logging.go b/Godeps/_workspace/src/github.com/go-gorp/gorp/logging.go
deleted file mode 100644
index 89d6c0e79..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/logging.go
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2012 James Cooper. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// Package gorp provides a simple way to marshal Go structs to and from
-// SQL databases. It uses the database/sql package, and should work with any
-// compliant database/sql driver.
-//
-// Source code and project home:
-// https://github.com/go-gorp/gorp
-
-package gorp
-
-import "fmt"
-
-type GorpLogger interface {
- Printf(format string, v ...interface{})
-}
-
-// TraceOn turns on SQL statement logging for this DbMap. After this is
-// called, all SQL statements will be sent to the logger. If prefix is
-// a non-empty string, it will be written to the front of all logged
-// strings, which can aid in filtering log lines.
-//
-// Use TraceOn if you want to spy on the SQL statements that gorp
-// generates.
-//
-// Note that the base log.Logger type satisfies GorpLogger, but adapters can
-// easily be written for other logging packages (e.g., the golang-sanctioned
-// glog framework).
-func (m *DbMap) TraceOn(prefix string, logger GorpLogger) {
- m.logger = logger
- if prefix == "" {
- m.logPrefix = prefix
- } else {
- m.logPrefix = fmt.Sprintf("%s ", prefix)
- }
-}
-
-// TraceOff turns off tracing. It is idempotent.
-func (m *DbMap) TraceOff() {
- m.logger = nil
- m.logPrefix = ""
-}
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/nulltypes.go b/Godeps/_workspace/src/github.com/go-gorp/gorp/nulltypes.go
deleted file mode 100644
index 870770372..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/nulltypes.go
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 2012 James Cooper. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// Package gorp provides a simple way to marshal Go structs to and from
-// SQL databases. It uses the database/sql package, and should work with any
-// compliant database/sql driver.
-//
-// Source code and project home:
-// https://github.com/go-gorp/gorp
-
-package gorp
-
-import (
- "database/sql/driver"
- "time"
-)
-
-// A nullable Time value
-type NullTime struct {
- Time time.Time
- Valid bool // Valid is true if Time is not NULL
-}
-
-// Scan implements the Scanner interface.
-func (nt *NullTime) Scan(value interface{}) error {
- switch t := value.(type) {
- 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
- }
- }
- }
- return nil
-}
-
-// Value implements the driver Valuer interface.
-func (nt NullTime) Value() (driver.Value, error) {
- if !nt.Valid {
- return nil, nil
- }
- return nt.Time, nil
-}
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/select.go b/Godeps/_workspace/src/github.com/go-gorp/gorp/select.go
deleted file mode 100644
index d6ff92ee3..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/select.go
+++ /dev/null
@@ -1,351 +0,0 @@
-// Copyright 2012 James Cooper. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// Package gorp provides a simple way to marshal Go structs to and from
-// SQL databases. It uses the database/sql package, and should work with any
-// compliant database/sql driver.
-//
-// Source code and project home:
-// https://github.com/go-gorp/gorp
-
-package gorp
-
-import (
- "database/sql"
- "fmt"
- "reflect"
-)
-
-// SelectInt executes the given query, which should be a SELECT statement for a single
-// integer column, and returns the value of the first row returned. If no rows are
-// found, zero is returned.
-func SelectInt(e SqlExecutor, query string, args ...interface{}) (int64, error) {
- var h int64
- err := selectVal(e, &h, query, args...)
- if err != nil && err != sql.ErrNoRows {
- return 0, err
- }
- return h, nil
-}
-
-// SelectNullInt executes the given query, which should be a SELECT statement for a single
-// integer column, and returns the value of the first row returned. If no rows are
-// found, the empty sql.NullInt64 value is returned.
-func SelectNullInt(e SqlExecutor, query string, args ...interface{}) (sql.NullInt64, error) {
- var h sql.NullInt64
- err := selectVal(e, &h, query, args...)
- if err != nil && err != sql.ErrNoRows {
- return h, err
- }
- return h, nil
-}
-
-// SelectFloat executes the given query, which should be a SELECT statement for a single
-// float column, and returns the value of the first row returned. If no rows are
-// found, zero is returned.
-func SelectFloat(e SqlExecutor, query string, args ...interface{}) (float64, error) {
- var h float64
- err := selectVal(e, &h, query, args...)
- if err != nil && err != sql.ErrNoRows {
- return 0, err
- }
- return h, nil
-}
-
-// SelectNullFloat executes the given query, which should be a SELECT statement for a single
-// float column, and returns the value of the first row returned. If no rows are
-// found, the empty sql.NullInt64 value is returned.
-func SelectNullFloat(e SqlExecutor, query string, args ...interface{}) (sql.NullFloat64, error) {
- var h sql.NullFloat64
- err := selectVal(e, &h, query, args...)
- if err != nil && err != sql.ErrNoRows {
- return h, err
- }
- return h, nil
-}
-
-// SelectStr executes the given query, which should be a SELECT statement for a single
-// char/varchar column, and returns the value of the first row returned. If no rows are
-// found, an empty string is returned.
-func SelectStr(e SqlExecutor, query string, args ...interface{}) (string, error) {
- var h string
- err := selectVal(e, &h, query, args...)
- if err != nil && err != sql.ErrNoRows {
- return "", err
- }
- return h, nil
-}
-
-// SelectNullStr executes the given query, which should be a SELECT
-// statement for a single char/varchar column, and returns the value
-// of the first row returned. If no rows are found, the empty
-// sql.NullString is returned.
-func SelectNullStr(e SqlExecutor, query string, args ...interface{}) (sql.NullString, error) {
- var h sql.NullString
- err := selectVal(e, &h, query, args...)
- if err != nil && err != sql.ErrNoRows {
- return h, err
- }
- return h, nil
-}
-
-// SelectOne executes the given query (which should be a SELECT statement)
-// and binds the result to holder, which must be a pointer.
-//
-// If no row is found, an error (sql.ErrNoRows specifically) will be returned
-//
-// If more than one row is found, an error will be returned.
-//
-func SelectOne(m *DbMap, e SqlExecutor, holder interface{}, query string, args ...interface{}) error {
- t := reflect.TypeOf(holder)
- if t.Kind() == reflect.Ptr {
- t = t.Elem()
- } else {
- return fmt.Errorf("gorp: SelectOne holder must be a pointer, but got: %t", holder)
- }
-
- // Handle pointer to pointer
- isptr := false
- if t.Kind() == reflect.Ptr {
- isptr = true
- t = t.Elem()
- }
-
- if t.Kind() == reflect.Struct {
- var nonFatalErr error
-
- list, err := hookedselect(m, e, holder, query, args...)
- if err != nil {
- if !NonFatalError(err) { // FIXME: double negative, rename NonFatalError to FatalError
- return err
- }
- nonFatalErr = err
- }
-
- dest := reflect.ValueOf(holder)
- if isptr {
- dest = dest.Elem()
- }
-
- if list != nil && len(list) > 0 { // FIXME: invert if/else
- // check for multiple rows
- if len(list) > 1 {
- return fmt.Errorf("gorp: multiple rows returned for: %s - %v", query, args)
- }
-
- // Initialize if nil
- if dest.IsNil() {
- dest.Set(reflect.New(t))
- }
-
- // only one row found
- src := reflect.ValueOf(list[0])
- dest.Elem().Set(src.Elem())
- } else {
- // No rows found, return a proper error.
- return sql.ErrNoRows
- }
-
- return nonFatalErr
- }
-
- return selectVal(e, holder, query, args...)
-}
-
-func selectVal(e SqlExecutor, holder interface{}, query string, args ...interface{}) error {
- if len(args) == 1 {
- switch m := e.(type) {
- case *DbMap:
- query, args = maybeExpandNamedQuery(m, query, args)
- case *Transaction:
- query, args = maybeExpandNamedQuery(m.dbmap, query, args)
- }
- }
- rows, err := e.query(query, args...)
- if err != nil {
- return err
- }
- defer rows.Close()
-
- if !rows.Next() {
- return sql.ErrNoRows
- }
-
- return rows.Scan(holder)
-}
-
-func hookedselect(m *DbMap, exec SqlExecutor, i interface{}, query string,
- args ...interface{}) ([]interface{}, error) {
-
- var nonFatalErr error
-
- list, err := rawselect(m, exec, i, query, args...)
- if err != nil {
- if !NonFatalError(err) {
- return nil, err
- }
- nonFatalErr = err
- }
-
- // Determine where the results are: written to i, or returned in list
- if t, _ := toSliceType(i); t == nil {
- for _, v := range list {
- if v, ok := v.(HasPostGet); ok {
- err := v.PostGet(exec)
- if err != nil {
- return nil, err
- }
- }
- }
- } else {
- resultsValue := reflect.Indirect(reflect.ValueOf(i))
- for i := 0; i < resultsValue.Len(); i++ {
- if v, ok := resultsValue.Index(i).Interface().(HasPostGet); ok {
- err := v.PostGet(exec)
- if err != nil {
- return nil, err
- }
- }
- }
- }
- return list, nonFatalErr
-}
-
-func rawselect(m *DbMap, exec SqlExecutor, i interface{}, query string,
- args ...interface{}) ([]interface{}, error) {
- var (
- appendToSlice = false // Write results to i directly?
- intoStruct = true // Selecting into a struct?
- pointerElements = true // Are the slice elements pointers (vs values)?
- )
-
- var nonFatalErr error
-
- // get type for i, verifying it's a supported destination
- t, err := toType(i)
- if err != nil {
- var err2 error
- if t, err2 = toSliceType(i); t == nil {
- if err2 != nil {
- return nil, err2
- }
- return nil, err
- }
- pointerElements = t.Kind() == reflect.Ptr
- if pointerElements {
- t = t.Elem()
- }
- appendToSlice = true
- intoStruct = t.Kind() == reflect.Struct
- }
-
- // If the caller supplied a single struct/map argument, assume a "named
- // parameter" query. Extract the named arguments from the struct/map, create
- // the flat arg slice, and rewrite the query to use the dialect's placeholder.
- if len(args) == 1 {
- query, args = maybeExpandNamedQuery(m, query, args)
- }
-
- // Run the query
- rows, err := exec.query(query, args...)
- if err != nil {
- return nil, err
- }
- defer rows.Close()
-
- // Fetch the column names as returned from db
- cols, err := rows.Columns()
- if err != nil {
- return nil, err
- }
-
- if !intoStruct && len(cols) > 1 {
- return nil, fmt.Errorf("gorp: select into non-struct slice requires 1 column, got %d", len(cols))
- }
-
- var colToFieldIndex [][]int
- if intoStruct {
- colToFieldIndex, err = columnToFieldIndex(m, t, cols)
- if err != nil {
- if !NonFatalError(err) {
- return nil, err
- }
- nonFatalErr = err
- }
- }
-
- conv := m.TypeConverter
-
- // Add results to one of these two slices.
- var (
- list = make([]interface{}, 0)
- sliceValue = reflect.Indirect(reflect.ValueOf(i))
- )
-
- for {
- if !rows.Next() {
- // if error occured return rawselect
- if rows.Err() != nil {
- return nil, rows.Err()
- }
- // time to exit from outer "for" loop
- break
- }
- v := reflect.New(t)
- dest := make([]interface{}, len(cols))
-
- custScan := make([]CustomScanner, 0)
-
- for x := range cols {
- f := v.Elem()
- if intoStruct {
- index := colToFieldIndex[x]
- if index == nil {
- // this field is not present in the struct, so create a dummy
- // value for rows.Scan to scan into
- var dummy dummyField
- dest[x] = &dummy
- continue
- }
- f = f.FieldByIndex(index)
- }
- target := f.Addr().Interface()
- if conv != nil {
- scanner, ok := conv.FromDb(target)
- if ok {
- target = scanner.Holder
- custScan = append(custScan, scanner)
- }
- }
- dest[x] = target
- }
-
- err = rows.Scan(dest...)
- if err != nil {
- return nil, err
- }
-
- for _, c := range custScan {
- err = c.Bind()
- if err != nil {
- return nil, err
- }
- }
-
- if appendToSlice {
- if !pointerElements {
- v = v.Elem()
- }
- sliceValue.Set(reflect.Append(sliceValue, v))
- } else {
- list = append(list, v.Interface())
- }
- }
-
- if appendToSlice && sliceValue.IsNil() {
- sliceValue.Set(reflect.MakeSlice(sliceValue.Type(), 0, 0))
- }
-
- return list, nonFatalErr
-}
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/table.go b/Godeps/_workspace/src/github.com/go-gorp/gorp/table.go
deleted file mode 100644
index 5c513909a..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/table.go
+++ /dev/null
@@ -1,247 +0,0 @@
-// Copyright 2012 James Cooper. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// Package gorp provides a simple way to marshal Go structs to and from
-// SQL databases. It uses the database/sql package, and should work with any
-// compliant database/sql driver.
-//
-// Source code and project home:
-// https://github.com/go-gorp/gorp
-
-package gorp
-
-import (
- "bytes"
- "fmt"
- "reflect"
- "strings"
-)
-
-// TableMap represents a mapping between a Go struct and a database table
-// Use dbmap.AddTable() or dbmap.AddTableWithName() to create these
-type TableMap struct {
- // Name of database table.
- TableName string
- SchemaName string
- gotype reflect.Type
- Columns []*ColumnMap
- keys []*ColumnMap
- indexes []*IndexMap
- uniqueTogether [][]string
- version *ColumnMap
- insertPlan bindPlan
- updatePlan bindPlan
- deletePlan bindPlan
- getPlan bindPlan
- dbmap *DbMap
-}
-
-// ResetSql removes cached insert/update/select/delete SQL strings
-// associated with this TableMap. Call this if you've modified
-// any column names or the table name itself.
-func (t *TableMap) ResetSql() {
- t.insertPlan = bindPlan{}
- t.updatePlan = bindPlan{}
- t.deletePlan = bindPlan{}
- t.getPlan = bindPlan{}
-}
-
-// SetKeys lets you specify the fields on a struct that map to primary
-// key columns on the table. If isAutoIncr is set, result.LastInsertId()
-// will be used after INSERT to bind the generated id to the Go struct.
-//
-// Automatically calls ResetSql() to ensure SQL statements are regenerated.
-//
-// Panics if isAutoIncr is true, and fieldNames length != 1
-//
-func (t *TableMap) SetKeys(isAutoIncr bool, fieldNames ...string) *TableMap {
- if isAutoIncr && len(fieldNames) != 1 {
- panic(fmt.Sprintf(
- "gorp: SetKeys: fieldNames length must be 1 if key is auto-increment. (Saw %v fieldNames)",
- len(fieldNames)))
- }
- t.keys = make([]*ColumnMap, 0)
- for _, name := range fieldNames {
- colmap := t.ColMap(name)
- colmap.isPK = true
- colmap.isAutoIncr = isAutoIncr
- t.keys = append(t.keys, colmap)
- }
- t.ResetSql()
-
- return t
-}
-
-// SetUniqueTogether lets you specify uniqueness constraints across multiple
-// columns on the table. Each call adds an additional constraint for the
-// specified columns.
-//
-// Automatically calls ResetSql() to ensure SQL statements are regenerated.
-//
-// Panics if fieldNames length < 2.
-//
-func (t *TableMap) SetUniqueTogether(fieldNames ...string) *TableMap {
- if len(fieldNames) < 2 {
- panic(fmt.Sprintf(
- "gorp: SetUniqueTogether: must provide at least two fieldNames to set uniqueness constraint."))
- }
-
- columns := make([]string, 0)
- for _, name := range fieldNames {
- columns = append(columns, name)
- }
- t.uniqueTogether = append(t.uniqueTogether, columns)
- t.ResetSql()
-
- return t
-}
-
-// ColMap returns the ColumnMap pointer matching the given struct field
-// name. It panics if the struct does not contain a field matching this
-// name.
-func (t *TableMap) ColMap(field string) *ColumnMap {
- col := colMapOrNil(t, field)
- if col == nil {
- e := fmt.Sprintf("No ColumnMap in table %s type %s with field %s",
- t.TableName, t.gotype.Name(), field)
-
- panic(e)
- }
- return col
-}
-
-func colMapOrNil(t *TableMap, field string) *ColumnMap {
- for _, col := range t.Columns {
- if col.fieldName == field || col.ColumnName == field {
- return col
- }
- }
- return nil
-}
-
-// IdxMap returns the IndexMap pointer matching the given index name.
-func (t *TableMap) IdxMap(field string) *IndexMap {
- for _, idx := range t.indexes {
- if idx.IndexName == field {
- return idx
- }
- }
- return nil
-}
-
-// AddIndex registers the index with gorp for specified table with given parameters.
-// This operation is idempotent. If index is already mapped, the
-// existing *IndexMap is returned
-// Function will panic if one of the given for index columns does not exists
-//
-// Automatically calls ResetSql() to ensure SQL statements are regenerated.
-//
-func (t *TableMap) AddIndex(name string, idxtype string, columns []string) *IndexMap {
- // check if we have a index with this name already
- for _, idx := range t.indexes {
- if idx.IndexName == name {
- return idx
- }
- }
- for _, icol := range columns {
- if res := t.ColMap(icol); res == nil {
- e := fmt.Sprintf("No ColumnName in table %s to create index on", t.TableName)
- panic(e)
- }
- }
-
- idx := &IndexMap{IndexName: name, Unique: false, IndexType: idxtype, columns: columns}
- t.indexes = append(t.indexes, idx)
- t.ResetSql()
- return idx
-}
-
-// SetVersionCol sets the column to use as the Version field. By default
-// the "Version" field is used. Returns the column found, or panics
-// if the struct does not contain a field matching this name.
-//
-// Automatically calls ResetSql() to ensure SQL statements are regenerated.
-func (t *TableMap) SetVersionCol(field string) *ColumnMap {
- c := t.ColMap(field)
- t.version = c
- t.ResetSql()
- return c
-}
-
-// 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{}
- dialect := t.dbmap.Dialect
-
- if strings.TrimSpace(t.SchemaName) != "" {
- schemaCreate := "create schema"
- if ifNotExists {
- s.WriteString(dialect.IfSchemaNotExists(schemaCreate, t.SchemaName))
- } else {
- s.WriteString(schemaCreate)
- }
- s.WriteString(fmt.Sprintf(" %s;", t.SchemaName))
- }
-
- tableCreate := "create table"
- if ifNotExists {
- s.WriteString(dialect.IfTableNotExists(tableCreate, t.SchemaName, t.TableName))
- } else {
- s.WriteString(tableCreate)
- }
- s.WriteString(fmt.Sprintf(" %s (", dialect.QuotedTableForQuery(t.SchemaName, t.TableName)))
-
- x := 0
- for _, col := range t.Columns {
- if !col.Transient {
- if x > 0 {
- s.WriteString(", ")
- }
- stype := dialect.ToSqlType(col.gotype, col.MaxSize, col.isAutoIncr)
- s.WriteString(fmt.Sprintf("%s %s", dialect.QuoteField(col.ColumnName), stype))
-
- if col.isPK || col.isNotNull {
- s.WriteString(" not null")
- }
- if col.isPK && len(t.keys) == 1 {
- s.WriteString(" primary key")
- }
- if col.Unique {
- s.WriteString(" unique")
- }
- if col.isAutoIncr {
- s.WriteString(fmt.Sprintf(" %s", dialect.AutoIncrStr()))
- }
-
- x++
- }
- }
- if len(t.keys) > 1 {
- s.WriteString(", primary key (")
- for x := range t.keys {
- if x > 0 {
- s.WriteString(", ")
- }
- s.WriteString(dialect.QuoteField(t.keys[x].ColumnName))
- }
- s.WriteString(")")
- }
- if len(t.uniqueTogether) > 0 {
- for _, columns := range t.uniqueTogether {
- s.WriteString(", unique (")
- for i, column := range columns {
- if i > 0 {
- s.WriteString(", ")
- }
- s.WriteString(dialect.QuoteField(column))
- }
- s.WriteString(")")
- }
- }
- s.WriteString(") ")
- s.WriteString(dialect.CreateTableSuffix())
- s.WriteString(dialect.QuerySuffix())
- return s.String()
-}
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/table_bindings.go b/Godeps/_workspace/src/github.com/go-gorp/gorp/table_bindings.go
deleted file mode 100644
index 1727d0d09..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/table_bindings.go
+++ /dev/null
@@ -1,317 +0,0 @@
-// Copyright 2012 James Cooper. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// Package gorp provides a simple way to marshal Go structs to and from
-// SQL databases. It uses the database/sql package, and should work with any
-// compliant database/sql driver.
-//
-// Source code and project home:
-// https://github.com/go-gorp/gorp
-
-package gorp
-
-import (
- "bytes"
- "fmt"
- "reflect"
-)
-
-// CustomScanner binds a database column value to a Go type
-type CustomScanner struct {
- // After a row is scanned, Holder will contain the value from the database column.
- // Initialize the CustomScanner with the concrete Go type you wish the database
- // driver to scan the raw column into.
- Holder interface{}
- // Target typically holds a pointer to the target struct field to bind the Holder
- // value to.
- Target interface{}
- // Binder is a custom function that converts the holder value to the target type
- // and sets target accordingly. This function should return error if a problem
- // occurs converting the holder to the target.
- Binder func(holder interface{}, target interface{}) error
-}
-
-// Used to filter columns when selectively updating
-type ColumnFilter func(*ColumnMap) bool
-
-func acceptAllFilter(col *ColumnMap) bool {
- return true
-}
-
-// Bind is called automatically by gorp after Scan()
-func (me CustomScanner) Bind() error {
- return me.Binder(me.Holder, me.Target)
-}
-
-type bindPlan struct {
- query string
- argFields []string
- keyFields []string
- versField string
- autoIncrIdx int
- autoIncrFieldName string
-}
-
-func (plan bindPlan) createBindInstance(elem reflect.Value, conv TypeConverter) (bindInstance, error) {
- bi := bindInstance{query: plan.query, autoIncrIdx: plan.autoIncrIdx, autoIncrFieldName: plan.autoIncrFieldName, versField: plan.versField}
- if plan.versField != "" {
- bi.existingVersion = elem.FieldByName(plan.versField).Int()
- }
-
- var err error
-
- for i := 0; i < len(plan.argFields); i++ {
- k := plan.argFields[i]
- if k == versFieldConst {
- newVer := bi.existingVersion + 1
- bi.args = append(bi.args, newVer)
- if bi.existingVersion == 0 {
- elem.FieldByName(plan.versField).SetInt(int64(newVer))
- }
- } else {
- val := elem.FieldByName(k).Interface()
- if conv != nil {
- val, err = conv.ToDb(val)
- if err != nil {
- return bindInstance{}, err
- }
- }
- bi.args = append(bi.args, val)
- }
- }
-
- for i := 0; i < len(plan.keyFields); i++ {
- k := plan.keyFields[i]
- val := elem.FieldByName(k).Interface()
- if conv != nil {
- val, err = conv.ToDb(val)
- if err != nil {
- return bindInstance{}, err
- }
- }
- bi.keys = append(bi.keys, val)
- }
-
- return bi, nil
-}
-
-type bindInstance struct {
- query string
- args []interface{}
- keys []interface{}
- existingVersion int64
- versField string
- autoIncrIdx int
- autoIncrFieldName string
-}
-
-func (t *TableMap) bindInsert(elem reflect.Value) (bindInstance, error) {
- plan := t.insertPlan
- if plan.query == "" {
- plan.autoIncrIdx = -1
-
- s := bytes.Buffer{}
- s2 := bytes.Buffer{}
- s.WriteString(fmt.Sprintf("insert into %s (", t.dbmap.Dialect.QuotedTableForQuery(t.SchemaName, t.TableName)))
-
- x := 0
- first := true
- for y := range t.Columns {
- col := t.Columns[y]
- if !(col.isAutoIncr && t.dbmap.Dialect.AutoIncrBindValue() == "") {
- if !col.Transient {
- if !first {
- s.WriteString(",")
- s2.WriteString(",")
- }
- s.WriteString(t.dbmap.Dialect.QuoteField(col.ColumnName))
-
- if col.isAutoIncr {
- s2.WriteString(t.dbmap.Dialect.AutoIncrBindValue())
- plan.autoIncrIdx = y
- plan.autoIncrFieldName = col.fieldName
- } else {
- if col.DefaultValue == "" {
- s2.WriteString(t.dbmap.Dialect.BindVar(x))
- if col == t.version {
- plan.versField = col.fieldName
- plan.argFields = append(plan.argFields, versFieldConst)
- } else {
- plan.argFields = append(plan.argFields, col.fieldName)
- }
- x++
- } else {
- s2.WriteString(col.DefaultValue)
- }
- }
- first = false
- }
- } else {
- plan.autoIncrIdx = y
- plan.autoIncrFieldName = col.fieldName
- }
- }
- s.WriteString(") values (")
- s.WriteString(s2.String())
- s.WriteString(")")
- if plan.autoIncrIdx > -1 {
- s.WriteString(t.dbmap.Dialect.AutoIncrInsertSuffix(t.Columns[plan.autoIncrIdx]))
- }
- s.WriteString(t.dbmap.Dialect.QuerySuffix())
-
- plan.query = s.String()
- t.insertPlan = plan
- }
-
- return plan.createBindInstance(elem, t.dbmap.TypeConverter)
-}
-
-func (t *TableMap) bindUpdate(elem reflect.Value, colFilter ColumnFilter) (bindInstance, error) {
- if colFilter == nil {
- colFilter = acceptAllFilter
- }
-
- plan := t.updatePlan
- if plan.query == "" {
-
- s := bytes.Buffer{}
- s.WriteString(fmt.Sprintf("update %s set ", t.dbmap.Dialect.QuotedTableForQuery(t.SchemaName, t.TableName)))
- x := 0
-
- for y := range t.Columns {
- col := t.Columns[y]
- if !col.isAutoIncr && !col.Transient && colFilter(col) {
- if x > 0 {
- s.WriteString(", ")
- }
- s.WriteString(t.dbmap.Dialect.QuoteField(col.ColumnName))
- s.WriteString("=")
- s.WriteString(t.dbmap.Dialect.BindVar(x))
-
- if col == t.version {
- plan.versField = col.fieldName
- plan.argFields = append(plan.argFields, versFieldConst)
- } else {
- plan.argFields = append(plan.argFields, col.fieldName)
- }
- x++
- }
- }
-
- s.WriteString(" where ")
- for y := range t.keys {
- col := t.keys[y]
- if y > 0 {
- s.WriteString(" and ")
- }
- s.WriteString(t.dbmap.Dialect.QuoteField(col.ColumnName))
- s.WriteString("=")
- s.WriteString(t.dbmap.Dialect.BindVar(x))
-
- plan.argFields = append(plan.argFields, col.fieldName)
- plan.keyFields = append(plan.keyFields, col.fieldName)
- x++
- }
- if plan.versField != "" {
- s.WriteString(" and ")
- s.WriteString(t.dbmap.Dialect.QuoteField(t.version.ColumnName))
- s.WriteString("=")
- s.WriteString(t.dbmap.Dialect.BindVar(x))
- plan.argFields = append(plan.argFields, plan.versField)
- }
- s.WriteString(t.dbmap.Dialect.QuerySuffix())
-
- plan.query = s.String()
- t.updatePlan = plan
- }
-
- return plan.createBindInstance(elem, t.dbmap.TypeConverter)
-}
-
-func (t *TableMap) bindDelete(elem reflect.Value) (bindInstance, error) {
- plan := t.deletePlan
- if plan.query == "" {
-
- s := bytes.Buffer{}
- s.WriteString(fmt.Sprintf("delete from %s", t.dbmap.Dialect.QuotedTableForQuery(t.SchemaName, t.TableName)))
-
- for y := range t.Columns {
- col := t.Columns[y]
- if !col.Transient {
- if col == t.version {
- plan.versField = col.fieldName
- }
- }
- }
-
- s.WriteString(" where ")
- for x := range t.keys {
- k := t.keys[x]
- if x > 0 {
- s.WriteString(" and ")
- }
- s.WriteString(t.dbmap.Dialect.QuoteField(k.ColumnName))
- s.WriteString("=")
- s.WriteString(t.dbmap.Dialect.BindVar(x))
-
- plan.keyFields = append(plan.keyFields, k.fieldName)
- plan.argFields = append(plan.argFields, k.fieldName)
- }
- if plan.versField != "" {
- s.WriteString(" and ")
- s.WriteString(t.dbmap.Dialect.QuoteField(t.version.ColumnName))
- s.WriteString("=")
- s.WriteString(t.dbmap.Dialect.BindVar(len(plan.argFields)))
-
- plan.argFields = append(plan.argFields, plan.versField)
- }
- s.WriteString(t.dbmap.Dialect.QuerySuffix())
-
- plan.query = s.String()
- t.deletePlan = plan
- }
-
- return plan.createBindInstance(elem, t.dbmap.TypeConverter)
-}
-
-func (t *TableMap) bindGet() bindPlan {
- plan := t.getPlan
- if plan.query == "" {
-
- s := bytes.Buffer{}
- s.WriteString("select ")
-
- x := 0
- for _, col := range t.Columns {
- if !col.Transient {
- if x > 0 {
- s.WriteString(",")
- }
- s.WriteString(t.dbmap.Dialect.QuoteField(col.ColumnName))
- plan.argFields = append(plan.argFields, col.fieldName)
- x++
- }
- }
- s.WriteString(" from ")
- s.WriteString(t.dbmap.Dialect.QuotedTableForQuery(t.SchemaName, t.TableName))
- s.WriteString(" where ")
- for x := range t.keys {
- col := t.keys[x]
- if x > 0 {
- s.WriteString(" and ")
- }
- s.WriteString(t.dbmap.Dialect.QuoteField(col.ColumnName))
- s.WriteString("=")
- s.WriteString(t.dbmap.Dialect.BindVar(x))
-
- plan.keyFields = append(plan.keyFields, col.fieldName)
- }
- s.WriteString(t.dbmap.Dialect.QuerySuffix())
-
- plan.query = s.String()
- t.getPlan = plan
- }
-
- return plan
-}
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/test_all.sh b/Godeps/_workspace/src/github.com/go-gorp/gorp/test_all.sh
deleted file mode 100644
index f2d16961a..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/test_all.sh
+++ /dev/null
@@ -1,38 +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 "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/Godeps/_workspace/src/github.com/go-gorp/gorp/transaction.go b/Godeps/_workspace/src/github.com/go-gorp/gorp/transaction.go
deleted file mode 100644
index 6430f24f1..000000000
--- a/Godeps/_workspace/src/github.com/go-gorp/gorp/transaction.go
+++ /dev/null
@@ -1,193 +0,0 @@
-// Copyright 2012 James Cooper. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// Package gorp provides a simple way to marshal Go structs to and from
-// SQL databases. It uses the database/sql package, and should work with any
-// compliant database/sql driver.
-//
-// Source code and project home:
-// https://github.com/go-gorp/gorp
-
-package gorp
-
-import (
- "database/sql"
- "time"
-)
-
-// Transaction represents a database transaction.
-// Insert/Update/Delete/Get/Exec operations will be run in the context
-// of that transaction. Transactions should be terminated with
-// a call to Commit() or Rollback()
-type Transaction struct {
- dbmap *DbMap
- tx *sql.Tx
- closed bool
-}
-
-// Insert has the same behavior as DbMap.Insert(), but runs in a transaction.
-func (t *Transaction) Insert(list ...interface{}) error {
- return insert(t.dbmap, t, list...)
-}
-
-// Update had the same behavior as DbMap.Update(), but runs in a transaction.
-func (t *Transaction) Update(list ...interface{}) (int64, error) {
- return update(t.dbmap, t, nil, list...)
-}
-
-// UpdateColumns had the same behavior as DbMap.UpdateColumns(), but runs in a transaction.
-func (t *Transaction) UpdateColumns(filter ColumnFilter, list ...interface{}) (int64, error) {
- return update(t.dbmap, t, filter, list...)
-}
-
-// Delete has the same behavior as DbMap.Delete(), but runs in a transaction.
-func (t *Transaction) Delete(list ...interface{}) (int64, error) {
- return delete(t.dbmap, t, list...)
-}
-
-// Get has the same behavior as DbMap.Get(), but runs in a transaction.
-func (t *Transaction) Get(i interface{}, keys ...interface{}) (interface{}, error) {
- return get(t.dbmap, t, i, keys...)
-}
-
-// Select has the same behavior as DbMap.Select(), but runs in a transaction.
-func (t *Transaction) Select(i interface{}, query string, args ...interface{}) ([]interface{}, error) {
- return hookedselect(t.dbmap, t, i, query, args...)
-}
-
-// Exec has the same behavior as DbMap.Exec(), but runs in a transaction.
-func (t *Transaction) Exec(query string, args ...interface{}) (sql.Result, error) {
- if t.dbmap.logger != nil {
- now := time.Now()
- defer t.dbmap.trace(now, query, args...)
- }
- return exec(t, query, args...)
-}
-
-// SelectInt is a convenience wrapper around the gorp.SelectInt function.
-func (t *Transaction) SelectInt(query string, args ...interface{}) (int64, error) {
- return SelectInt(t, query, args...)
-}
-
-// SelectNullInt is a convenience wrapper around the gorp.SelectNullInt function.
-func (t *Transaction) SelectNullInt(query string, args ...interface{}) (sql.NullInt64, error) {
- return SelectNullInt(t, query, args...)
-}
-
-// SelectFloat is a convenience wrapper around the gorp.SelectFloat function.
-func (t *Transaction) SelectFloat(query string, args ...interface{}) (float64, error) {
- return SelectFloat(t, query, args...)
-}
-
-// SelectNullFloat is a convenience wrapper around the gorp.SelectNullFloat function.
-func (t *Transaction) SelectNullFloat(query string, args ...interface{}) (sql.NullFloat64, error) {
- return SelectNullFloat(t, query, args...)
-}
-
-// SelectStr is a convenience wrapper around the gorp.SelectStr function.
-func (t *Transaction) SelectStr(query string, args ...interface{}) (string, error) {
- return SelectStr(t, query, args...)
-}
-
-// SelectNullStr is a convenience wrapper around the gorp.SelectNullStr function.
-func (t *Transaction) SelectNullStr(query string, args ...interface{}) (sql.NullString, error) {
- return SelectNullStr(t, query, args...)
-}
-
-// SelectOne is a convenience wrapper around the gorp.SelectOne function.
-func (t *Transaction) SelectOne(holder interface{}, query string, args ...interface{}) error {
- return SelectOne(t.dbmap, t, holder, query, args...)
-}
-
-// Commit commits the underlying database transaction.
-func (t *Transaction) Commit() error {
- if !t.closed {
- t.closed = true
- if t.dbmap.logger != nil {
- now := time.Now()
- defer t.dbmap.trace(now, "commit;")
- }
- return t.tx.Commit()
- }
-
- return sql.ErrTxDone
-}
-
-// Rollback rolls back the underlying database transaction.
-func (t *Transaction) Rollback() error {
- if !t.closed {
- t.closed = true
- if t.dbmap.logger != nil {
- now := time.Now()
- defer t.dbmap.trace(now, "rollback;")
- }
- return t.tx.Rollback()
- }
-
- return sql.ErrTxDone
-}
-
-// Savepoint creates a savepoint with the given name. The name is interpolated
-// directly into the SQL SAVEPOINT statement, so you must sanitize it if it is
-// derived from user input.
-func (t *Transaction) Savepoint(name string) error {
- query := "savepoint " + t.dbmap.Dialect.QuoteField(name)
- if t.dbmap.logger != nil {
- now := time.Now()
- defer t.dbmap.trace(now, query, nil)
- }
- _, err := t.tx.Exec(query)
- return err
-}
-
-// RollbackToSavepoint rolls back to the savepoint with the given name. The
-// name is interpolated directly into the SQL SAVEPOINT statement, so you must
-// sanitize it if it is derived from user input.
-func (t *Transaction) RollbackToSavepoint(savepoint string) error {
- query := "rollback to savepoint " + t.dbmap.Dialect.QuoteField(savepoint)
- if t.dbmap.logger != nil {
- now := time.Now()
- defer t.dbmap.trace(now, query, nil)
- }
- _, err := t.tx.Exec(query)
- return err
-}
-
-// ReleaseSavepint releases the savepoint with the given name. The name is
-// interpolated directly into the SQL SAVEPOINT statement, so you must sanitize
-// it if it is derived from user input.
-func (t *Transaction) ReleaseSavepoint(savepoint string) error {
- query := "release savepoint " + t.dbmap.Dialect.QuoteField(savepoint)
- if t.dbmap.logger != nil {
- now := time.Now()
- defer t.dbmap.trace(now, query, nil)
- }
- _, err := t.tx.Exec(query)
- return err
-}
-
-// Prepare has the same behavior as DbMap.Prepare(), but runs in a transaction.
-func (t *Transaction) Prepare(query string) (*sql.Stmt, error) {
- if t.dbmap.logger != nil {
- now := time.Now()
- defer t.dbmap.trace(now, query, nil)
- }
- return t.tx.Prepare(query)
-}
-
-func (t *Transaction) queryRow(query string, args ...interface{}) *sql.Row {
- if t.dbmap.logger != nil {
- now := time.Now()
- defer t.dbmap.trace(now, query, args...)
- }
- return t.tx.QueryRow(query, args...)
-}
-
-func (t *Transaction) query(query string, args ...interface{}) (*sql.Rows, error) {
- if t.dbmap.logger != nil {
- now := time.Now()
- defer t.dbmap.trace(now, query, args...)
- }
- return t.tx.Query(query, args...)
-}
diff --git a/Godeps/_workspace/src/github.com/go-ldap/ldap/.gitignore b/Godeps/_workspace/src/github.com/go-ldap/ldap/.gitignore
deleted file mode 100644
index e69de29bb..000000000
--- a/Godeps/_workspace/src/github.com/go-ldap/ldap/.gitignore
+++ /dev/null
diff --git a/Godeps/_workspace/src/github.com/go-ldap/ldap/.travis.yml b/Godeps/_workspace/src/github.com/go-ldap/ldap/.travis.yml
deleted file mode 100644
index a7a38951b..000000000
--- a/Godeps/_workspace/src/github.com/go-ldap/ldap/.travis.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-language: go
-go:
- - 1.2
- - 1.3
- - 1.4
- - 1.5
- - tip
-go_import_path: gopkg.in/ldap.v2
-install:
- - go get gopkg.in/asn1-ber.v1
- - go get gopkg.in/ldap.v2
- - go get code.google.com/p/go.tools/cmd/cover || go get golang.org/x/tools/cmd/cover
- - go build -v ./...
-script:
- - go test -v -cover ./...
diff --git a/Godeps/_workspace/src/github.com/go-ldap/ldap/LICENSE b/Godeps/_workspace/src/github.com/go-ldap/ldap/LICENSE
deleted file mode 100644
index 744875676..000000000
--- a/Godeps/_workspace/src/github.com/go-ldap/ldap/LICENSE
+++ /dev/null
@@ -1,27 +0,0 @@
-Copyright (c) 2012 The Go Authors. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the following disclaimer
-in the documentation and/or other materials provided with the
-distribution.
- * Neither the name of Google Inc. nor the names of its
-contributors may be used to endorse or promote products derived from
-this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Godeps/_workspace/src/github.com/go-ldap/ldap/README.md b/Godeps/_workspace/src/github.com/go-ldap/ldap/README.md
deleted file mode 100644
index 68121c3e2..000000000
--- a/Godeps/_workspace/src/github.com/go-ldap/ldap/README.md
+++ /dev/null
@@ -1,55 +0,0 @@
-[![GoDoc](https://godoc.org/gopkg.in/ldap.v1?status.svg)](https://godoc.org/gopkg.in/ldap.v1)
-[![Build Status](https://travis-ci.org/go-ldap/ldap.svg)](https://travis-ci.org/go-ldap/ldap)
-
-# Basic LDAP v3 functionality for the GO programming language.
-
-## Install
-
-For the latest version use:
-
- go get gopkg.in/ldap.v2
-
-Import the latest version with:
-
- import "gopkg.in/ldap.v2"
-
-
-## Required Libraries:
-
- - gopkg.in/asn1-ber.v1
-
-## Working:
-
- - Connecting to LDAP server
- - Binding to LDAP server
- - Searching for entries
- - Compiling string filters to LDAP filters
- - Paging Search Results
- - Modify Requests / Responses
- - Add Requests / Responses
- - Delete Requests / Responses
- - Better Unicode support
-
-## Examples:
-
- - search
- - modify
-
-## Tests Implemented:
-
- - Filter Compile / Decompile
-
-## TODO:
-
- - [x] Add Requests / Responses
- - [x] Delete Requests / Responses
- - [x] Modify DN Requests / Responses
- - [ ] Compare Requests / Responses
- - [ ] Implement Tests / Benchmarks
-
-
-
----
-The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/)
-The design is licensed under the Creative Commons 3.0 Attributions license.
-Read this article for more details: http://blog.golang.org/gopher
diff --git a/Godeps/_workspace/src/github.com/go-ldap/ldap/add.go b/Godeps/_workspace/src/github.com/go-ldap/ldap/add.go
deleted file mode 100644
index 643ce5ffe..000000000
--- a/Godeps/_workspace/src/github.com/go-ldap/ldap/add.go
+++ /dev/null
@@ -1,104 +0,0 @@
-//
-// https://tools.ietf.org/html/rfc4511
-//
-// AddRequest ::= [APPLICATION 8] SEQUENCE {
-// entry LDAPDN,
-// attributes AttributeList }
-//
-// AttributeList ::= SEQUENCE OF attribute Attribute
-
-package ldap
-
-import (
- "errors"
- "log"
-
- "gopkg.in/asn1-ber.v1"
-)
-
-type Attribute struct {
- attrType string
- attrVals []string
-}
-
-func (a *Attribute) encode() *ber.Packet {
- seq := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Attribute")
- seq.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, a.attrType, "Type"))
- set := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSet, nil, "AttributeValue")
- for _, value := range a.attrVals {
- set.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, value, "Vals"))
- }
- seq.AppendChild(set)
- return seq
-}
-
-type AddRequest struct {
- dn string
- attributes []Attribute
-}
-
-func (a AddRequest) encode() *ber.Packet {
- request := ber.Encode(ber.ClassApplication, ber.TypeConstructed, ApplicationAddRequest, nil, "Add Request")
- request.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, a.dn, "DN"))
- attributes := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Attributes")
- for _, attribute := range a.attributes {
- attributes.AppendChild(attribute.encode())
- }
- request.AppendChild(attributes)
- return request
-}
-
-func (a *AddRequest) Attribute(attrType string, attrVals []string) {
- a.attributes = append(a.attributes, Attribute{attrType: attrType, attrVals: attrVals})
-}
-
-func NewAddRequest(dn string) *AddRequest {
- return &AddRequest{
- dn: dn,
- }
-
-}
-
-func (l *Conn) Add(addRequest *AddRequest) error {
- messageID := l.nextMessageID()
- packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "LDAP Request")
- packet.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, messageID, "MessageID"))
- packet.AppendChild(addRequest.encode())
-
- l.Debug.PrintPacket(packet)
-
- channel, err := l.sendMessage(packet)
- if err != nil {
- return err
- }
- if channel == nil {
- return NewError(ErrorNetwork, errors.New("ldap: could not send message"))
- }
- defer l.finishMessage(messageID)
-
- l.Debug.Printf("%d: waiting for response", messageID)
- packet = <-channel
- l.Debug.Printf("%d: got response %p", messageID, packet)
- if packet == nil {
- return NewError(ErrorNetwork, errors.New("ldap: could not retrieve message"))
- }
-
- if l.Debug {
- if err := addLDAPDescriptions(packet); err != nil {
- return err
- }
- ber.PrintPacket(packet)
- }
-
- if packet.Children[1].Tag == ApplicationAddResponse {
- resultCode, resultDescription := getLDAPResultCode(packet)
- if resultCode != 0 {
- return NewError(resultCode, errors.New(resultDescription))
- }
- } else {
- log.Printf("Unexpected Response: %d", packet.Children[1].Tag)
- }
-
- l.Debug.Printf("%d: returning", messageID)
- return nil
-}
diff --git a/Godeps/_workspace/src/github.com/go-ldap/ldap/bind.go b/Godeps/_workspace/src/github.com/go-ldap/ldap/bind.go
deleted file mode 100644
index 4ad4b896c..000000000
--- a/Godeps/_workspace/src/github.com/go-ldap/ldap/bind.go
+++ /dev/null
@@ -1,135 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package ldap
-
-import (
- "errors"
-
- "gopkg.in/asn1-ber.v1"
-)
-
-type SimpleBindRequest struct {
- Username string
- Password string
- Controls []Control
-}
-
-type SimpleBindResult struct {
- Controls []Control
-}
-
-func NewSimpleBindRequest(username string, password string, controls []Control) *SimpleBindRequest {
- return &SimpleBindRequest{
- Username: username,
- Password: password,
- Controls: controls,
- }
-}
-
-func (bindRequest *SimpleBindRequest) encode() *ber.Packet {
- request := ber.Encode(ber.ClassApplication, ber.TypeConstructed, ApplicationBindRequest, nil, "Bind Request")
- request.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, 3, "Version"))
- request.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, bindRequest.Username, "User Name"))
- request.AppendChild(ber.NewString(ber.ClassContext, ber.TypePrimitive, 0, bindRequest.Password, "Password"))
-
- request.AppendChild(encodeControls(bindRequest.Controls))
-
- return request
-}
-
-func (l *Conn) SimpleBind(simpleBindRequest *SimpleBindRequest) (*SimpleBindResult, error) {
- messageID := l.nextMessageID()
-
- packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "LDAP Request")
- packet.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, messageID, "MessageID"))
- encodedBindRequest := simpleBindRequest.encode()
- packet.AppendChild(encodedBindRequest)
-
- if l.Debug {
- ber.PrintPacket(packet)
- }
-
- channel, err := l.sendMessage(packet)
- if err != nil {
- return nil, err
- }
- if channel == nil {
- return nil, NewError(ErrorNetwork, errors.New("ldap: could not send message"))
- }
- defer l.finishMessage(messageID)
-
- packet = <-channel
- if packet == nil {
- return nil, NewError(ErrorNetwork, errors.New("ldap: could not retrieve response"))
- }
-
- if l.Debug {
- if err := addLDAPDescriptions(packet); err != nil {
- return nil, err
- }
- ber.PrintPacket(packet)
- }
-
- result := &SimpleBindResult{
- Controls: make([]Control, 0),
- }
-
- if len(packet.Children) == 3 {
- for _, child := range packet.Children[2].Children {
- result.Controls = append(result.Controls, DecodeControl(child))
- }
- }
-
- resultCode, resultDescription := getLDAPResultCode(packet)
- if resultCode != 0 {
- return result, NewError(resultCode, errors.New(resultDescription))
- }
-
- return result, nil
-}
-
-func (l *Conn) Bind(username, password string) error {
- messageID := l.nextMessageID()
-
- packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "LDAP Request")
- packet.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, messageID, "MessageID"))
- bindRequest := ber.Encode(ber.ClassApplication, ber.TypeConstructed, ApplicationBindRequest, nil, "Bind Request")
- bindRequest.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, 3, "Version"))
- bindRequest.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, username, "User Name"))
- bindRequest.AppendChild(ber.NewString(ber.ClassContext, ber.TypePrimitive, 0, password, "Password"))
- packet.AppendChild(bindRequest)
-
- if l.Debug {
- ber.PrintPacket(packet)
- }
-
- channel, err := l.sendMessage(packet)
- if err != nil {
- return err
- }
- if channel == nil {
- return NewError(ErrorNetwork, errors.New("ldap: could not send message"))
- }
- defer l.finishMessage(messageID)
-
- packet = <-channel
- if packet == nil {
- return NewError(ErrorNetwork, errors.New("ldap: could not retrieve response"))
- }
-
- if l.Debug {
- if err := addLDAPDescriptions(packet); err != nil {
- return err
- }
- ber.PrintPacket(packet)
- }
-
- resultCode, resultDescription := getLDAPResultCode(packet)
- if resultCode != 0 {
- return NewError(resultCode, errors.New(resultDescription))
- }
-
- return nil
-}
diff --git a/Godeps/_workspace/src/github.com/go-ldap/ldap/client.go b/Godeps/_workspace/src/github.com/go-ldap/ldap/client.go
deleted file mode 100644
index d3401f9e6..000000000
--- a/Godeps/_workspace/src/github.com/go-ldap/ldap/client.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package ldap
-
-import "crypto/tls"
-
-// Client knows how to interact with an LDAP server
-type Client interface {
- Start()
- StartTLS(config *tls.Config) error
- Close()
-
- Bind(username, password string) error
- SimpleBind(simpleBindRequest *SimpleBindRequest) (*SimpleBindResult, error)
-
- Add(addRequest *AddRequest) error
- Del(delRequest *DelRequest) error
- Modify(modifyRequest *ModifyRequest) error
-
- Compare(dn, attribute, value string) (bool, error)
- PasswordModify(passwordModifyRequest *PasswordModifyRequest) (*PasswordModifyResult, error)
-
- Search(searchRequest *SearchRequest) (*SearchResult, error)
- SearchWithPaging(searchRequest *SearchRequest, pagingSize uint32) (*SearchResult, error)
-}
diff --git a/Godeps/_workspace/src/github.com/go-ldap/ldap/compare.go b/Godeps/_workspace/src/github.com/go-ldap/ldap/compare.go
deleted file mode 100644
index 802e9cc93..000000000
--- a/Godeps/_workspace/src/github.com/go-ldap/ldap/compare.go
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-//
-// File contains Compare functionality
-//
-// https://tools.ietf.org/html/rfc4511
-//
-// CompareRequest ::= [APPLICATION 14] SEQUENCE {
-// entry LDAPDN,
-// ava AttributeValueAssertion }
-//
-// AttributeValueAssertion ::= SEQUENCE {
-// attributeDesc AttributeDescription,
-// assertionValue AssertionValue }
-//
-// AttributeDescription ::= LDAPString
-// -- Constrained to <attributedescription>
-// -- [RFC4512]
-//
-// AttributeValue ::= OCTET STRING
-//
-
-package ldap
-
-import (
- "errors"
- "fmt"
-
- "gopkg.in/asn1-ber.v1"
-)
-
-// Compare checks to see if the attribute of the dn matches value. Returns true if it does otherwise
-// false with any error that occurs if any.
-func (l *Conn) Compare(dn, attribute, value string) (bool, error) {
- messageID := l.nextMessageID()
- packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "LDAP Request")
- packet.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, messageID, "MessageID"))
-
- request := ber.Encode(ber.ClassApplication, ber.TypeConstructed, ApplicationCompareRequest, nil, "Compare Request")
- request.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, dn, "DN"))
-
- ava := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "AttributeValueAssertion")
- ava.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, attribute, "AttributeDesc"))
- ava.AppendChild(ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagOctetString, value, "AssertionValue"))
- request.AppendChild(ava)
- packet.AppendChild(request)
-
- l.Debug.PrintPacket(packet)
-
- channel, err := l.sendMessage(packet)
- if err != nil {
- return false, err
- }
- if channel == nil {
- return false, NewError(ErrorNetwork, errors.New("ldap: could not send message"))
- }
- defer l.finishMessage(messageID)
-
- l.Debug.Printf("%d: waiting for response", messageID)
- packet = <-channel
- l.Debug.Printf("%d: got response %p", messageID, packet)
- if packet == nil {
- return false, NewError(ErrorNetwork, errors.New("ldap: could not retrieve message"))
- }
-
- if l.Debug {
- if err := addLDAPDescriptions(packet); err != nil {
- return false, err
- }
- ber.PrintPacket(packet)
- }
-
- if packet.Children[1].Tag == ApplicationCompareResponse {
- resultCode, resultDescription := getLDAPResultCode(packet)
- if resultCode == LDAPResultCompareTrue {
- return true, nil
- } else if resultCode == LDAPResultCompareFalse {
- return false, nil
- } else {
- return false, NewError(resultCode, errors.New(resultDescription))
- }
- }
- return false, fmt.Errorf("Unexpected Response: %d", packet.Children[1].Tag)
-}
diff --git a/Godeps/_workspace/src/github.com/go-ldap/ldap/conn.go b/Godeps/_workspace/src/github.com/go-ldap/ldap/conn.go
deleted file mode 100644
index 2f16443f6..000000000
--- a/Godeps/_workspace/src/github.com/go-ldap/ldap/conn.go
+++ /dev/null
@@ -1,369 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package ldap
-
-import (
- "crypto/tls"
- "errors"
- "fmt"
- "log"
- "net"
- "sync"
- "time"
-
- "gopkg.in/asn1-ber.v1"
-)
-
-const (
- MessageQuit = 0
- MessageRequest = 1
- MessageResponse = 2
- MessageFinish = 3
-)
-
-type messagePacket struct {
- Op int
- MessageID int64
- Packet *ber.Packet
- Channel chan *ber.Packet
-}
-
-type sendMessageFlags uint
-
-const (
- startTLS sendMessageFlags = 1 << iota
-)
-
-// Conn represents an LDAP Connection
-type Conn struct {
- conn net.Conn
- isTLS bool
- isClosing bool
- isStartingTLS bool
- Debug debugging
- chanConfirm chan bool
- chanResults map[int64]chan *ber.Packet
- chanMessage chan *messagePacket
- chanMessageID chan int64
- wgSender sync.WaitGroup
- wgClose sync.WaitGroup
- once sync.Once
- outstandingRequests uint
- messageMutex sync.Mutex
-}
-
-var _ Client = &Conn{}
-
-// DefaultTimeout is a package-level variable that sets the timeout value
-// used for the Dial and DialTLS methods.
-//
-// WARNING: since this is a package-level variable, setting this value from
-// multiple places will probably result in undesired behaviour.
-var DefaultTimeout = 60 * time.Second
-
-// Dial connects to the given address on the given network using net.Dial
-// and then returns a new Conn for the connection.
-func Dial(network, addr string) (*Conn, error) {
- c, err := net.DialTimeout(network, addr, DefaultTimeout)
- if err != nil {
- return nil, NewError(ErrorNetwork, err)
- }
- conn := NewConn(c, false)
- conn.Start()
- return conn, nil
-}
-
-// DialTLS connects to the given address on the given network using tls.Dial
-// and then returns a new Conn for the connection.
-func DialTLS(network, addr string, config *tls.Config) (*Conn, error) {
- dc, err := net.DialTimeout(network, addr, DefaultTimeout)
- if err != nil {
- return nil, NewError(ErrorNetwork, err)
- }
- c := tls.Client(dc, config)
- err = c.Handshake()
- if err != nil {
- // Handshake error, close the established connection before we return an error
- dc.Close()
- return nil, NewError(ErrorNetwork, err)
- }
- conn := NewConn(c, true)
- conn.Start()
- return conn, nil
-}
-
-// NewConn returns a new Conn using conn for network I/O.
-func NewConn(conn net.Conn, isTLS bool) *Conn {
- return &Conn{
- conn: conn,
- chanConfirm: make(chan bool),
- chanMessageID: make(chan int64),
- chanMessage: make(chan *messagePacket, 10),
- chanResults: map[int64]chan *ber.Packet{},
- isTLS: isTLS,
- }
-}
-
-func (l *Conn) Start() {
- go l.reader()
- go l.processMessages()
- l.wgClose.Add(1)
-}
-
-// Close closes the connection.
-func (l *Conn) Close() {
- l.once.Do(func() {
- l.isClosing = true
- l.wgSender.Wait()
-
- l.Debug.Printf("Sending quit message and waiting for confirmation")
- l.chanMessage <- &messagePacket{Op: MessageQuit}
- <-l.chanConfirm
- close(l.chanMessage)
-
- l.Debug.Printf("Closing network connection")
- if err := l.conn.Close(); err != nil {
- log.Print(err)
- }
-
- l.wgClose.Done()
- })
- l.wgClose.Wait()
-}
-
-// Returns the next available messageID
-func (l *Conn) nextMessageID() int64 {
- if l.chanMessageID != nil {
- if messageID, ok := <-l.chanMessageID; ok {
- return messageID
- }
- }
- return 0
-}
-
-// StartTLS sends the command to start a TLS session and then creates a new TLS Client
-func (l *Conn) StartTLS(config *tls.Config) error {
- messageID := l.nextMessageID()
-
- if l.isTLS {
- return NewError(ErrorNetwork, errors.New("ldap: already encrypted"))
- }
-
- packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "LDAP Request")
- packet.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, messageID, "MessageID"))
- request := ber.Encode(ber.ClassApplication, ber.TypeConstructed, ApplicationExtendedRequest, nil, "Start TLS")
- request.AppendChild(ber.NewString(ber.ClassContext, ber.TypePrimitive, 0, "1.3.6.1.4.1.1466.20037", "TLS Extended Command"))
- packet.AppendChild(request)
- l.Debug.PrintPacket(packet)
-
- channel, err := l.sendMessageWithFlags(packet, startTLS)
- if err != nil {
- return err
- }
- if channel == nil {
- return NewError(ErrorNetwork, errors.New("ldap: could not send message"))
- }
-
- l.Debug.Printf("%d: waiting for response", messageID)
- packet = <-channel
- l.Debug.Printf("%d: got response %p", messageID, packet)
- l.finishMessage(messageID)
-
- if l.Debug {
- if err := addLDAPDescriptions(packet); err != nil {
- l.Close()
- return err
- }
- ber.PrintPacket(packet)
- }
-
- if resultCode, message := getLDAPResultCode(packet); resultCode == LDAPResultSuccess {
- conn := tls.Client(l.conn, config)
-
- if err := conn.Handshake(); err != nil {
- l.Close()
- return NewError(ErrorNetwork, fmt.Errorf("TLS handshake failed (%v)", err))
- }
-
- l.isTLS = true
- l.conn = conn
- } else {
- return NewError(resultCode, fmt.Errorf("ldap: cannot StartTLS (%s)", message))
- }
- go l.reader()
-
- return nil
-}
-
-func (l *Conn) sendMessage(packet *ber.Packet) (chan *ber.Packet, error) {
- return l.sendMessageWithFlags(packet, 0)
-}
-
-func (l *Conn) sendMessageWithFlags(packet *ber.Packet, flags sendMessageFlags) (chan *ber.Packet, error) {
- if l.isClosing {
- return nil, NewError(ErrorNetwork, errors.New("ldap: connection closed"))
- }
- l.messageMutex.Lock()
- l.Debug.Printf("flags&startTLS = %d", flags&startTLS)
- if l.isStartingTLS {
- l.messageMutex.Unlock()
- return nil, NewError(ErrorNetwork, errors.New("ldap: connection is in startls phase."))
- }
- if flags&startTLS != 0 {
- if l.outstandingRequests != 0 {
- l.messageMutex.Unlock()
- return nil, NewError(ErrorNetwork, errors.New("ldap: cannot StartTLS with outstanding requests"))
- } else {
- l.isStartingTLS = true
- }
- }
- l.outstandingRequests++
-
- l.messageMutex.Unlock()
-
- out := make(chan *ber.Packet)
- message := &messagePacket{
- Op: MessageRequest,
- MessageID: packet.Children[0].Value.(int64),
- Packet: packet,
- Channel: out,
- }
- l.sendProcessMessage(message)
- return out, nil
-}
-
-func (l *Conn) finishMessage(messageID int64) {
- if l.isClosing {
- return
- }
-
- l.messageMutex.Lock()
- l.outstandingRequests--
- if l.isStartingTLS {
- l.isStartingTLS = false
- }
- l.messageMutex.Unlock()
-
- message := &messagePacket{
- Op: MessageFinish,
- MessageID: messageID,
- }
- l.sendProcessMessage(message)
-}
-
-func (l *Conn) sendProcessMessage(message *messagePacket) bool {
- if l.isClosing {
- return false
- }
- l.wgSender.Add(1)
- l.chanMessage <- message
- l.wgSender.Done()
- return true
-}
-
-func (l *Conn) processMessages() {
- defer func() {
- if err := recover(); err != nil {
- log.Printf("ldap: recovered panic in processMessages: %v", err)
- }
- for messageID, channel := range l.chanResults {
- l.Debug.Printf("Closing channel for MessageID %d", messageID)
- close(channel)
- delete(l.chanResults, messageID)
- }
- close(l.chanMessageID)
- l.chanConfirm <- true
- close(l.chanConfirm)
- }()
-
- var messageID int64 = 1
- for {
- select {
- case l.chanMessageID <- messageID:
- messageID++
- case messagePacket, ok := <-l.chanMessage:
- if !ok {
- l.Debug.Printf("Shutting down - message channel is closed")
- return
- }
- switch messagePacket.Op {
- case MessageQuit:
- l.Debug.Printf("Shutting down - quit message received")
- return
- case MessageRequest:
- // Add to message list and write to network
- l.Debug.Printf("Sending message %d", messagePacket.MessageID)
- l.chanResults[messagePacket.MessageID] = messagePacket.Channel
- // go routine
- buf := messagePacket.Packet.Bytes()
-
- _, err := l.conn.Write(buf)
- if err != nil {
- l.Debug.Printf("Error Sending Message: %s", err.Error())
- break
- }
- case MessageResponse:
- l.Debug.Printf("Receiving message %d", messagePacket.MessageID)
- if chanResult, ok := l.chanResults[messagePacket.MessageID]; ok {
- chanResult <- messagePacket.Packet
- } else {
- log.Printf("Received unexpected message %d", messagePacket.MessageID)
- ber.PrintPacket(messagePacket.Packet)
- }
- case MessageFinish:
- // Remove from message list
- l.Debug.Printf("Finished message %d", messagePacket.MessageID)
- close(l.chanResults[messagePacket.MessageID])
- delete(l.chanResults, messagePacket.MessageID)
- }
- }
- }
-}
-
-func (l *Conn) reader() {
- cleanstop := false
- defer func() {
- if err := recover(); err != nil {
- log.Printf("ldap: recovered panic in reader: %v", err)
- }
- if !cleanstop {
- l.Close()
- }
- }()
-
- for {
- if cleanstop {
- l.Debug.Printf("reader clean stopping (without closing the connection)")
- return
- }
- packet, err := ber.ReadPacket(l.conn)
- if err != nil {
- // A read error is expected here if we are closing the connection...
- if !l.isClosing {
- l.Debug.Printf("reader error: %s", err.Error())
- }
- return
- }
- addLDAPDescriptions(packet)
- if len(packet.Children) == 0 {
- l.Debug.Printf("Received bad ldap packet")
- continue
- }
- l.messageMutex.Lock()
- if l.isStartingTLS {
- cleanstop = true
- }
- l.messageMutex.Unlock()
- message := &messagePacket{
- Op: MessageResponse,
- MessageID: packet.Children[0].Value.(int64),
- Packet: packet,
- }
- if !l.sendProcessMessage(message) {
- return
- }
-
- }
-}
diff --git a/Godeps/_workspace/src/github.com/go-ldap/ldap/control.go b/Godeps/_workspace/src/github.com/go-ldap/ldap/control.go
deleted file mode 100644
index 4d8298093..000000000
--- a/Godeps/_workspace/src/github.com/go-ldap/ldap/control.go
+++ /dev/null
@@ -1,332 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package ldap
-
-import (
- "fmt"
- "strconv"
-
- "gopkg.in/asn1-ber.v1"
-)
-
-const (
- ControlTypePaging = "1.2.840.113556.1.4.319"
- ControlTypeBeheraPasswordPolicy = "1.3.6.1.4.1.42.2.27.8.5.1"
- ControlTypeVChuPasswordMustChange = "2.16.840.1.113730.3.4.4"
- ControlTypeVChuPasswordWarning = "2.16.840.1.113730.3.4.5"
- ControlTypeManageDsaIT = "2.16.840.1.113730.3.4.2"
-)
-
-var ControlTypeMap = map[string]string{
- ControlTypePaging: "Paging",
- ControlTypeBeheraPasswordPolicy: "Password Policy - Behera Draft",
- ControlTypeManageDsaIT: "Manage DSA IT",
-}
-
-type Control interface {
- GetControlType() string
- Encode() *ber.Packet
- String() string
-}
-
-type ControlString struct {
- ControlType string
- Criticality bool
- ControlValue string
-}
-
-func (c *ControlString) GetControlType() string {
- return c.ControlType
-}
-
-func (c *ControlString) Encode() *ber.Packet {
- packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Control")
- packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, c.ControlType, "Control Type ("+ControlTypeMap[c.ControlType]+")"))
- if c.Criticality {
- packet.AppendChild(ber.NewBoolean(ber.ClassUniversal, ber.TypePrimitive, ber.TagBoolean, c.Criticality, "Criticality"))
- }
- packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, string(c.ControlValue), "Control Value"))
- return packet
-}
-
-func (c *ControlString) String() string {
- return fmt.Sprintf("Control Type: %s (%q) Criticality: %t Control Value: %s", ControlTypeMap[c.ControlType], c.ControlType, c.Criticality, c.ControlValue)
-}
-
-type ControlPaging struct {
- PagingSize uint32
- Cookie []byte
-}
-
-func (c *ControlPaging) GetControlType() string {
- return ControlTypePaging
-}
-
-func (c *ControlPaging) Encode() *ber.Packet {
- packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Control")
- packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, ControlTypePaging, "Control Type ("+ControlTypeMap[ControlTypePaging]+")"))
-
- p2 := ber.Encode(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, nil, "Control Value (Paging)")
- seq := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Search Control Value")
- seq.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, uint64(c.PagingSize), "Paging Size"))
- cookie := ber.Encode(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, nil, "Cookie")
- cookie.Value = c.Cookie
- cookie.Data.Write(c.Cookie)
- seq.AppendChild(cookie)
- p2.AppendChild(seq)
-
- packet.AppendChild(p2)
- return packet
-}
-
-func (c *ControlPaging) String() string {
- return fmt.Sprintf(
- "Control Type: %s (%q) Criticality: %t PagingSize: %d Cookie: %q",
- ControlTypeMap[ControlTypePaging],
- ControlTypePaging,
- false,
- c.PagingSize,
- c.Cookie)
-}
-
-func (c *ControlPaging) SetCookie(cookie []byte) {
- c.Cookie = cookie
-}
-
-type ControlBeheraPasswordPolicy struct {
- Expire int64
- Grace int64
- Error int8
- ErrorString string
-}
-
-func (c *ControlBeheraPasswordPolicy) GetControlType() string {
- return ControlTypeBeheraPasswordPolicy
-}
-
-func (c *ControlBeheraPasswordPolicy) Encode() *ber.Packet {
- packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Control")
- packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, ControlTypeBeheraPasswordPolicy, "Control Type ("+ControlTypeMap[ControlTypeBeheraPasswordPolicy]+")"))
-
- return packet
-}
-
-func (c *ControlBeheraPasswordPolicy) String() string {
- return fmt.Sprintf(
- "Control Type: %s (%q) Criticality: %t Expire: %d Grace: %d Error: %d, ErrorString: %s",
- ControlTypeMap[ControlTypeBeheraPasswordPolicy],
- ControlTypeBeheraPasswordPolicy,
- false,
- c.Expire,
- c.Grace,
- c.Error,
- c.ErrorString)
-}
-
-type ControlVChuPasswordMustChange struct {
- MustChange bool
-}
-
-func (c *ControlVChuPasswordMustChange) GetControlType() string {
- return ControlTypeVChuPasswordMustChange
-}
-
-func (c *ControlVChuPasswordMustChange) Encode() *ber.Packet {
- return nil
-}
-
-func (c *ControlVChuPasswordMustChange) String() string {
- return fmt.Sprintf(
- "Control Type: %s (%q) Criticality: %t MustChange: %b",
- ControlTypeMap[ControlTypeVChuPasswordMustChange],
- ControlTypeVChuPasswordMustChange,
- false,
- c.MustChange)
-}
-
-type ControlVChuPasswordWarning struct {
- Expire int64
-}
-
-func (c *ControlVChuPasswordWarning) GetControlType() string {
- return ControlTypeVChuPasswordWarning
-}
-
-func (c *ControlVChuPasswordWarning) Encode() *ber.Packet {
- return nil
-}
-
-func (c *ControlVChuPasswordWarning) String() string {
- return fmt.Sprintf(
- "Control Type: %s (%q) Criticality: %t Expire: %b",
- ControlTypeMap[ControlTypeVChuPasswordWarning],
- ControlTypeVChuPasswordWarning,
- false,
- c.Expire)
-}
-
-type ControlManageDsaIT struct {
- Criticality bool
-}
-
-func (c *ControlManageDsaIT) GetControlType() string {
- return ControlTypeManageDsaIT
-}
-
-func (c *ControlManageDsaIT) Encode() *ber.Packet {
- //FIXME
- packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Control")
- packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, ControlTypeManageDsaIT, "Control Type ("+ControlTypeMap[ControlTypeManageDsaIT]+")"))
- if c.Criticality {
- packet.AppendChild(ber.NewBoolean(ber.ClassUniversal, ber.TypePrimitive, ber.TagBoolean, c.Criticality, "Criticality"))
- }
- return packet
-}
-
-func (c *ControlManageDsaIT) String() string {
- return fmt.Sprintf(
- "Control Type: %s (%q) Criticality: %t",
- ControlTypeMap[ControlTypeManageDsaIT],
- ControlTypeManageDsaIT,
- c.Criticality)
-}
-
-func NewControlManageDsaIT(Criticality bool) *ControlManageDsaIT {
- return &ControlManageDsaIT{Criticality: Criticality}
-}
-
-func FindControl(controls []Control, controlType string) Control {
- for _, c := range controls {
- if c.GetControlType() == controlType {
- return c
- }
- }
- return nil
-}
-
-func DecodeControl(packet *ber.Packet) Control {
- ControlType := packet.Children[0].Value.(string)
- Criticality := false
-
- packet.Children[0].Description = "Control Type (" + ControlTypeMap[ControlType] + ")"
- value := packet.Children[1]
- if len(packet.Children) == 3 {
- value = packet.Children[2]
- packet.Children[1].Description = "Criticality"
- Criticality = packet.Children[1].Value.(bool)
- }
-
- value.Description = "Control Value"
- switch ControlType {
- case ControlTypePaging:
- value.Description += " (Paging)"
- c := new(ControlPaging)
- if value.Value != nil {
- valueChildren := ber.DecodePacket(value.Data.Bytes())
- value.Data.Truncate(0)
- value.Value = nil
- value.AppendChild(valueChildren)
- }
- value = value.Children[0]
- value.Description = "Search Control Value"
- value.Children[0].Description = "Paging Size"
- value.Children[1].Description = "Cookie"
- c.PagingSize = uint32(value.Children[0].Value.(int64))
- c.Cookie = value.Children[1].Data.Bytes()
- value.Children[1].Value = c.Cookie
- return c
- case ControlTypeBeheraPasswordPolicy:
- value.Description += " (Password Policy - Behera)"
- c := NewControlBeheraPasswordPolicy()
- if value.Value != nil {
- valueChildren := ber.DecodePacket(value.Data.Bytes())
- value.Data.Truncate(0)
- value.Value = nil
- value.AppendChild(valueChildren)
- }
-
- sequence := value.Children[0]
-
- for _, child := range sequence.Children {
- if child.Tag == 0 {
- //Warning
- child := child.Children[0]
- packet := ber.DecodePacket(child.Data.Bytes())
- val, ok := packet.Value.(int64)
- if ok {
- if child.Tag == 0 {
- //timeBeforeExpiration
- c.Expire = val
- child.Value = c.Expire
- } else if child.Tag == 1 {
- //graceAuthNsRemaining
- c.Grace = val
- child.Value = c.Grace
- }
- }
- } else if child.Tag == 1 {
- // Error
- packet := ber.DecodePacket(child.Data.Bytes())
- val, ok := packet.Value.(int8)
- if !ok {
- // what to do?
- val = -1
- }
- c.Error = val
- child.Value = c.Error
- c.ErrorString = BeheraPasswordPolicyErrorMap[c.Error]
- }
- }
- return c
- case ControlTypeVChuPasswordMustChange:
- c := &ControlVChuPasswordMustChange{MustChange: true}
- return c
- case ControlTypeVChuPasswordWarning:
- c := &ControlVChuPasswordWarning{Expire: -1}
- expireStr := ber.DecodeString(value.Data.Bytes())
-
- expire, err := strconv.ParseInt(expireStr, 10, 64)
- if err != nil {
- return nil
- }
- c.Expire = expire
- value.Value = c.Expire
-
- return c
- }
- c := new(ControlString)
- c.ControlType = ControlType
- c.Criticality = Criticality
- c.ControlValue = value.Value.(string)
- return c
-}
-
-func NewControlString(controlType string, criticality bool, controlValue string) *ControlString {
- return &ControlString{
- ControlType: controlType,
- Criticality: criticality,
- ControlValue: controlValue,
- }
-}
-
-func NewControlPaging(pagingSize uint32) *ControlPaging {
- return &ControlPaging{PagingSize: pagingSize}
-}
-
-func NewControlBeheraPasswordPolicy() *ControlBeheraPasswordPolicy {
- return &ControlBeheraPasswordPolicy{
- Expire: -1,
- Grace: -1,
- Error: -1,
- }
-}
-
-func encodeControls(controls []Control) *ber.Packet {
- packet := ber.Encode(ber.ClassContext, ber.TypeConstructed, 0, nil, "Controls")
- for _, control := range controls {
- packet.AppendChild(control.Encode())
- }
- return packet
-}
diff --git a/Godeps/_workspace/src/github.com/go-ldap/ldap/debug.go b/Godeps/_workspace/src/github.com/go-ldap/ldap/debug.go
deleted file mode 100644
index b8a7ecbff..000000000
--- a/Godeps/_workspace/src/github.com/go-ldap/ldap/debug.go
+++ /dev/null
@@ -1,24 +0,0 @@
-package ldap
-
-import (
- "log"
-
- "gopkg.in/asn1-ber.v1"
-)
-
-// debbuging type
-// - has a Printf method to write the debug output
-type debugging bool
-
-// write debug output
-func (debug debugging) Printf(format string, args ...interface{}) {
- if debug {
- log.Printf(format, args...)
- }
-}
-
-func (debug debugging) PrintPacket(packet *ber.Packet) {
- if debug {
- ber.PrintPacket(packet)
- }
-}
diff --git a/Godeps/_workspace/src/github.com/go-ldap/ldap/del.go b/Godeps/_workspace/src/github.com/go-ldap/ldap/del.go
deleted file mode 100644
index 2f0eae1cd..000000000
--- a/Godeps/_workspace/src/github.com/go-ldap/ldap/del.go
+++ /dev/null
@@ -1,79 +0,0 @@
-//
-// https://tools.ietf.org/html/rfc4511
-//
-// DelRequest ::= [APPLICATION 10] LDAPDN
-
-package ldap
-
-import (
- "errors"
- "log"
-
- "gopkg.in/asn1-ber.v1"
-)
-
-type DelRequest struct {
- DN string
- Controls []Control
-}
-
-func (d DelRequest) encode() *ber.Packet {
- request := ber.Encode(ber.ClassApplication, ber.TypePrimitive, ApplicationDelRequest, d.DN, "Del Request")
- request.Data.Write([]byte(d.DN))
- return request
-}
-
-func NewDelRequest(DN string,
- Controls []Control) *DelRequest {
- return &DelRequest{
- DN: DN,
- Controls: Controls,
- }
-}
-
-func (l *Conn) Del(delRequest *DelRequest) error {
- messageID := l.nextMessageID()
- packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "LDAP Request")
- packet.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, messageID, "MessageID"))
- packet.AppendChild(delRequest.encode())
- if delRequest.Controls != nil {
- packet.AppendChild(encodeControls(delRequest.Controls))
- }
-
- l.Debug.PrintPacket(packet)
-
- channel, err := l.sendMessage(packet)
- if err != nil {
- return err
- }
- if channel == nil {
- return NewError(ErrorNetwork, errors.New("ldap: could not send message"))
- }
- defer l.finishMessage(messageID)
-
- l.Debug.Printf("%d: waiting for response", messageID)
- packet = <-channel
- l.Debug.Printf("%d: got response %p", messageID, packet)
- if packet == nil {
- return NewError(ErrorNetwork, errors.New("ldap: could not retrieve message"))
- }
-
- if l.Debug {
- if err := addLDAPDescriptions(packet); err != nil {
- return err
- }
- ber.PrintPacket(packet)
- }
-
- if packet.Children[1].Tag == ApplicationDelResponse {
- resultCode, resultDescription := getLDAPResultCode(packet)
- if resultCode != 0 {
- return NewError(resultCode, errors.New(resultDescription))
- }
- } else {
- log.Printf("Unexpected Response: %d", packet.Children[1].Tag)
- }
-
- l.Debug.Printf("%d: returning", messageID)
- return nil
-}
diff --git a/Godeps/_workspace/src/github.com/go-ldap/ldap/dn.go b/Godeps/_workspace/src/github.com/go-ldap/ldap/dn.go
deleted file mode 100644
index 5d83c5e9a..000000000
--- a/Godeps/_workspace/src/github.com/go-ldap/ldap/dn.go
+++ /dev/null
@@ -1,155 +0,0 @@
-// Copyright 2015 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-//
-// File contains DN parsing functionallity
-//
-// https://tools.ietf.org/html/rfc4514
-//
-// distinguishedName = [ relativeDistinguishedName
-// *( COMMA relativeDistinguishedName ) ]
-// relativeDistinguishedName = attributeTypeAndValue
-// *( PLUS attributeTypeAndValue )
-// attributeTypeAndValue = attributeType EQUALS attributeValue
-// attributeType = descr / numericoid
-// attributeValue = string / hexstring
-//
-// ; The following characters are to be escaped when they appear
-// ; in the value to be encoded: ESC, one of <escaped>, leading
-// ; SHARP or SPACE, trailing SPACE, and NULL.
-// string = [ ( leadchar / pair ) [ *( stringchar / pair )
-// ( trailchar / pair ) ] ]
-//
-// leadchar = LUTF1 / UTFMB
-// LUTF1 = %x01-1F / %x21 / %x24-2A / %x2D-3A /
-// %x3D / %x3F-5B / %x5D-7F
-//
-// trailchar = TUTF1 / UTFMB
-// TUTF1 = %x01-1F / %x21 / %x23-2A / %x2D-3A /
-// %x3D / %x3F-5B / %x5D-7F
-//
-// stringchar = SUTF1 / UTFMB
-// SUTF1 = %x01-21 / %x23-2A / %x2D-3A /
-// %x3D / %x3F-5B / %x5D-7F
-//
-// pair = ESC ( ESC / special / hexpair )
-// special = escaped / SPACE / SHARP / EQUALS
-// escaped = DQUOTE / PLUS / COMMA / SEMI / LANGLE / RANGLE
-// hexstring = SHARP 1*hexpair
-// hexpair = HEX HEX
-//
-// where the productions <descr>, <numericoid>, <COMMA>, <DQUOTE>,
-// <EQUALS>, <ESC>, <HEX>, <LANGLE>, <NULL>, <PLUS>, <RANGLE>, <SEMI>,
-// <SPACE>, <SHARP>, and <UTFMB> are defined in [RFC4512].
-//
-
-package ldap
-
-import (
- "bytes"
- enchex "encoding/hex"
- "errors"
- "fmt"
- "strings"
-
- ber "gopkg.in/asn1-ber.v1"
-)
-
-type AttributeTypeAndValue struct {
- Type string
- Value string
-}
-
-type RelativeDN struct {
- Attributes []*AttributeTypeAndValue
-}
-
-type DN struct {
- RDNs []*RelativeDN
-}
-
-func ParseDN(str string) (*DN, error) {
- dn := new(DN)
- dn.RDNs = make([]*RelativeDN, 0)
- rdn := new(RelativeDN)
- rdn.Attributes = make([]*AttributeTypeAndValue, 0)
- buffer := bytes.Buffer{}
- attribute := new(AttributeTypeAndValue)
- escaping := false
-
- for i := 0; i < len(str); i++ {
- char := str[i]
- if escaping {
- escaping = false
- switch char {
- case ' ', '"', '#', '+', ',', ';', '<', '=', '>', '\\':
- buffer.WriteByte(char)
- continue
- }
- // Not a special character, assume hex encoded octet
- if len(str) == i+1 {
- return nil, errors.New("Got corrupted escaped character")
- }
-
- dst := []byte{0}
- n, err := enchex.Decode([]byte(dst), []byte(str[i:i+2]))
- if err != nil {
- return nil, errors.New(
- fmt.Sprintf("Failed to decode escaped character: %s", err))
- } else if n != 1 {
- return nil, errors.New(
- fmt.Sprintf("Expected 1 byte when un-escaping, got %d", n))
- }
- buffer.WriteByte(dst[0])
- i++
- } else if char == '\\' {
- escaping = true
- } else if char == '=' {
- attribute.Type = buffer.String()
- buffer.Reset()
- // Special case: If the first character in the value is # the
- // following data is BER encoded so we can just fast forward
- // and decode.
- if len(str) > i+1 && str[i+1] == '#' {
- i += 2
- index := strings.IndexAny(str[i:], ",+")
- data := str
- if index > 0 {
- data = str[i : i+index]
- } else {
- data = str[i:]
- }
- raw_ber, err := enchex.DecodeString(data)
- if err != nil {
- return nil, errors.New(
- fmt.Sprintf("Failed to decode BER encoding: %s", err))
- }
- packet := ber.DecodePacket(raw_ber)
- buffer.WriteString(packet.Data.String())
- i += len(data) - 1
- }
- } else if char == ',' || char == '+' {
- // We're done with this RDN or value, push it
- attribute.Value = buffer.String()
- rdn.Attributes = append(rdn.Attributes, attribute)
- attribute = new(AttributeTypeAndValue)
- if char == ',' {
- dn.RDNs = append(dn.RDNs, rdn)
- rdn = new(RelativeDN)
- rdn.Attributes = make([]*AttributeTypeAndValue, 0)
- }
- buffer.Reset()
- } else {
- buffer.WriteByte(char)
- }
- }
- if buffer.Len() > 0 {
- if len(attribute.Type) == 0 {
- return nil, errors.New("DN ended with incomplete type, value pair")
- }
- attribute.Value = buffer.String()
- rdn.Attributes = append(rdn.Attributes, attribute)
- dn.RDNs = append(dn.RDNs, rdn)
- }
- return dn, nil
-}
diff --git a/Godeps/_workspace/src/github.com/go-ldap/ldap/doc.go b/Godeps/_workspace/src/github.com/go-ldap/ldap/doc.go
deleted file mode 100644
index f20d39bc9..000000000
--- a/Godeps/_workspace/src/github.com/go-ldap/ldap/doc.go
+++ /dev/null
@@ -1,4 +0,0 @@
-/*
-Package ldap provides basic LDAP v3 functionality.
-*/
-package ldap
diff --git a/Godeps/_workspace/src/github.com/go-ldap/ldap/error.go b/Godeps/_workspace/src/github.com/go-ldap/ldap/error.go
deleted file mode 100644
index 2dbc30ac0..000000000
--- a/Godeps/_workspace/src/github.com/go-ldap/ldap/error.go
+++ /dev/null
@@ -1,137 +0,0 @@
-package ldap
-
-import (
- "fmt"
-
- "gopkg.in/asn1-ber.v1"
-)
-
-// LDAP Result Codes
-const (
- LDAPResultSuccess = 0
- LDAPResultOperationsError = 1
- LDAPResultProtocolError = 2
- LDAPResultTimeLimitExceeded = 3
- LDAPResultSizeLimitExceeded = 4
- LDAPResultCompareFalse = 5
- LDAPResultCompareTrue = 6
- LDAPResultAuthMethodNotSupported = 7
- LDAPResultStrongAuthRequired = 8
- LDAPResultReferral = 10
- LDAPResultAdminLimitExceeded = 11
- LDAPResultUnavailableCriticalExtension = 12
- LDAPResultConfidentialityRequired = 13
- LDAPResultSaslBindInProgress = 14
- LDAPResultNoSuchAttribute = 16
- LDAPResultUndefinedAttributeType = 17
- LDAPResultInappropriateMatching = 18
- LDAPResultConstraintViolation = 19
- LDAPResultAttributeOrValueExists = 20
- LDAPResultInvalidAttributeSyntax = 21
- LDAPResultNoSuchObject = 32
- LDAPResultAliasProblem = 33
- LDAPResultInvalidDNSyntax = 34
- LDAPResultAliasDereferencingProblem = 36
- LDAPResultInappropriateAuthentication = 48
- LDAPResultInvalidCredentials = 49
- LDAPResultInsufficientAccessRights = 50
- LDAPResultBusy = 51
- LDAPResultUnavailable = 52
- LDAPResultUnwillingToPerform = 53
- LDAPResultLoopDetect = 54
- LDAPResultNamingViolation = 64
- LDAPResultObjectClassViolation = 65
- LDAPResultNotAllowedOnNonLeaf = 66
- LDAPResultNotAllowedOnRDN = 67
- LDAPResultEntryAlreadyExists = 68
- LDAPResultObjectClassModsProhibited = 69
- LDAPResultAffectsMultipleDSAs = 71
- LDAPResultOther = 80
-
- ErrorNetwork = 200
- ErrorFilterCompile = 201
- ErrorFilterDecompile = 202
- ErrorDebugging = 203
- ErrorUnexpectedMessage = 204
- ErrorUnexpectedResponse = 205
-)
-
-var LDAPResultCodeMap = map[uint8]string{
- LDAPResultSuccess: "Success",
- LDAPResultOperationsError: "Operations Error",
- LDAPResultProtocolError: "Protocol Error",
- LDAPResultTimeLimitExceeded: "Time Limit Exceeded",
- LDAPResultSizeLimitExceeded: "Size Limit Exceeded",
- LDAPResultCompareFalse: "Compare False",
- LDAPResultCompareTrue: "Compare True",
- LDAPResultAuthMethodNotSupported: "Auth Method Not Supported",
- LDAPResultStrongAuthRequired: "Strong Auth Required",
- LDAPResultReferral: "Referral",
- LDAPResultAdminLimitExceeded: "Admin Limit Exceeded",
- LDAPResultUnavailableCriticalExtension: "Unavailable Critical Extension",
- LDAPResultConfidentialityRequired: "Confidentiality Required",
- LDAPResultSaslBindInProgress: "Sasl Bind In Progress",
- LDAPResultNoSuchAttribute: "No Such Attribute",
- LDAPResultUndefinedAttributeType: "Undefined Attribute Type",
- LDAPResultInappropriateMatching: "Inappropriate Matching",
- LDAPResultConstraintViolation: "Constraint Violation",
- LDAPResultAttributeOrValueExists: "Attribute Or Value Exists",
- LDAPResultInvalidAttributeSyntax: "Invalid Attribute Syntax",
- LDAPResultNoSuchObject: "No Such Object",
- LDAPResultAliasProblem: "Alias Problem",
- LDAPResultInvalidDNSyntax: "Invalid DN Syntax",
- LDAPResultAliasDereferencingProblem: "Alias Dereferencing Problem",
- LDAPResultInappropriateAuthentication: "Inappropriate Authentication",
- LDAPResultInvalidCredentials: "Invalid Credentials",
- LDAPResultInsufficientAccessRights: "Insufficient Access Rights",
- LDAPResultBusy: "Busy",
- LDAPResultUnavailable: "Unavailable",
- LDAPResultUnwillingToPerform: "Unwilling To Perform",
- LDAPResultLoopDetect: "Loop Detect",
- LDAPResultNamingViolation: "Naming Violation",
- LDAPResultObjectClassViolation: "Object Class Violation",
- LDAPResultNotAllowedOnNonLeaf: "Not Allowed On Non Leaf",
- LDAPResultNotAllowedOnRDN: "Not Allowed On RDN",
- LDAPResultEntryAlreadyExists: "Entry Already Exists",
- LDAPResultObjectClassModsProhibited: "Object Class Mods Prohibited",
- LDAPResultAffectsMultipleDSAs: "Affects Multiple DSAs",
- LDAPResultOther: "Other",
-}
-
-func getLDAPResultCode(packet *ber.Packet) (code uint8, description string) {
- if len(packet.Children) >= 2 {
- response := packet.Children[1]
- if response.ClassType == ber.ClassApplication && response.TagType == ber.TypeConstructed && len(response.Children) >= 3 {
- // Children[1].Children[2] is the diagnosticMessage which is guaranteed to exist as seen here: https://tools.ietf.org/html/rfc4511#section-4.1.9
- return uint8(response.Children[0].Value.(int64)), response.Children[2].Value.(string)
- }
- }
-
- return ErrorNetwork, "Invalid packet format"
-}
-
-type Error struct {
- Err error
- ResultCode uint8
-}
-
-func (e *Error) Error() string {
- return fmt.Sprintf("LDAP Result Code %d %q: %s", e.ResultCode, LDAPResultCodeMap[e.ResultCode], e.Err.Error())
-}
-
-func NewError(resultCode uint8, err error) error {
- return &Error{ResultCode: resultCode, Err: err}
-}
-
-func IsErrorWithCode(err error, desiredResultCode uint8) bool {
- if err == nil {
- return false
- }
-
- serverError, ok := err.(*Error)
- if !ok {
- return false
- }
-
- return serverError.ResultCode == desiredResultCode
-}
diff --git a/Godeps/_workspace/src/github.com/go-ldap/ldap/filter.go b/Godeps/_workspace/src/github.com/go-ldap/ldap/filter.go
deleted file mode 100644
index 63bcec1e3..000000000
--- a/Godeps/_workspace/src/github.com/go-ldap/ldap/filter.go
+++ /dev/null
@@ -1,456 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package ldap
-
-import (
- "bytes"
- hexpac "encoding/hex"
- "errors"
- "fmt"
- "strings"
- "unicode/utf8"
-
- "gopkg.in/asn1-ber.v1"
-)
-
-const (
- FilterAnd = 0
- FilterOr = 1
- FilterNot = 2
- FilterEqualityMatch = 3
- FilterSubstrings = 4
- FilterGreaterOrEqual = 5
- FilterLessOrEqual = 6
- FilterPresent = 7
- FilterApproxMatch = 8
- FilterExtensibleMatch = 9
-)
-
-var FilterMap = map[uint64]string{
- FilterAnd: "And",
- FilterOr: "Or",
- FilterNot: "Not",
- FilterEqualityMatch: "Equality Match",
- FilterSubstrings: "Substrings",
- FilterGreaterOrEqual: "Greater Or Equal",
- FilterLessOrEqual: "Less Or Equal",
- FilterPresent: "Present",
- FilterApproxMatch: "Approx Match",
- FilterExtensibleMatch: "Extensible Match",
-}
-
-const (
- FilterSubstringsInitial = 0
- FilterSubstringsAny = 1
- FilterSubstringsFinal = 2
-)
-
-var FilterSubstringsMap = map[uint64]string{
- FilterSubstringsInitial: "Substrings Initial",
- FilterSubstringsAny: "Substrings Any",
- FilterSubstringsFinal: "Substrings Final",
-}
-
-const (
- MatchingRuleAssertionMatchingRule = 1
- MatchingRuleAssertionType = 2
- MatchingRuleAssertionMatchValue = 3
- MatchingRuleAssertionDNAttributes = 4
-)
-
-var MatchingRuleAssertionMap = map[uint64]string{
- MatchingRuleAssertionMatchingRule: "Matching Rule Assertion Matching Rule",
- MatchingRuleAssertionType: "Matching Rule Assertion Type",
- MatchingRuleAssertionMatchValue: "Matching Rule Assertion Match Value",
- MatchingRuleAssertionDNAttributes: "Matching Rule Assertion DN Attributes",
-}
-
-func CompileFilter(filter string) (*ber.Packet, error) {
- if len(filter) == 0 || filter[0] != '(' {
- return nil, NewError(ErrorFilterCompile, errors.New("ldap: filter does not start with an '('"))
- }
- packet, pos, err := compileFilter(filter, 1)
- if err != nil {
- return nil, err
- }
- if pos != len(filter) {
- return nil, NewError(ErrorFilterCompile, errors.New("ldap: finished compiling filter with extra at end: "+fmt.Sprint(filter[pos:])))
- }
- return packet, nil
-}
-
-func DecompileFilter(packet *ber.Packet) (ret string, err error) {
- defer func() {
- if r := recover(); r != nil {
- err = NewError(ErrorFilterDecompile, errors.New("ldap: error decompiling filter"))
- }
- }()
- ret = "("
- err = nil
- childStr := ""
-
- switch packet.Tag {
- case FilterAnd:
- ret += "&"
- for _, child := range packet.Children {
- childStr, err = DecompileFilter(child)
- if err != nil {
- return
- }
- ret += childStr
- }
- case FilterOr:
- ret += "|"
- for _, child := range packet.Children {
- childStr, err = DecompileFilter(child)
- if err != nil {
- return
- }
- ret += childStr
- }
- case FilterNot:
- ret += "!"
- childStr, err = DecompileFilter(packet.Children[0])
- if err != nil {
- return
- }
- ret += childStr
-
- case FilterSubstrings:
- ret += ber.DecodeString(packet.Children[0].Data.Bytes())
- ret += "="
- for i, child := range packet.Children[1].Children {
- if i == 0 && child.Tag != FilterSubstringsInitial {
- ret += "*"
- }
- ret += EscapeFilter(ber.DecodeString(child.Data.Bytes()))
- if child.Tag != FilterSubstringsFinal {
- ret += "*"
- }
- }
- case FilterEqualityMatch:
- ret += ber.DecodeString(packet.Children[0].Data.Bytes())
- ret += "="
- ret += EscapeFilter(ber.DecodeString(packet.Children[1].Data.Bytes()))
- case FilterGreaterOrEqual:
- ret += ber.DecodeString(packet.Children[0].Data.Bytes())
- ret += ">="
- ret += EscapeFilter(ber.DecodeString(packet.Children[1].Data.Bytes()))
- case FilterLessOrEqual:
- ret += ber.DecodeString(packet.Children[0].Data.Bytes())
- ret += "<="
- ret += EscapeFilter(ber.DecodeString(packet.Children[1].Data.Bytes()))
- case FilterPresent:
- ret += ber.DecodeString(packet.Data.Bytes())
- ret += "=*"
- case FilterApproxMatch:
- ret += ber.DecodeString(packet.Children[0].Data.Bytes())
- ret += "~="
- ret += EscapeFilter(ber.DecodeString(packet.Children[1].Data.Bytes()))
- case FilterExtensibleMatch:
- attr := ""
- dnAttributes := false
- matchingRule := ""
- value := ""
-
- for _, child := range packet.Children {
- switch child.Tag {
- case MatchingRuleAssertionMatchingRule:
- matchingRule = ber.DecodeString(child.Data.Bytes())
- case MatchingRuleAssertionType:
- attr = ber.DecodeString(child.Data.Bytes())
- case MatchingRuleAssertionMatchValue:
- value = ber.DecodeString(child.Data.Bytes())
- case MatchingRuleAssertionDNAttributes:
- dnAttributes = child.Value.(bool)
- }
- }
-
- if len(attr) > 0 {
- ret += attr
- }
- if dnAttributes {
- ret += ":dn"
- }
- if len(matchingRule) > 0 {
- ret += ":"
- ret += matchingRule
- }
- ret += ":="
- ret += EscapeFilter(value)
- }
-
- ret += ")"
- return
-}
-
-func compileFilterSet(filter string, pos int, parent *ber.Packet) (int, error) {
- for pos < len(filter) && filter[pos] == '(' {
- child, newPos, err := compileFilter(filter, pos+1)
- if err != nil {
- return pos, err
- }
- pos = newPos
- parent.AppendChild(child)
- }
- if pos == len(filter) {
- return pos, NewError(ErrorFilterCompile, errors.New("ldap: unexpected end of filter"))
- }
-
- return pos + 1, nil
-}
-
-func compileFilter(filter string, pos int) (*ber.Packet, int, error) {
- var (
- packet *ber.Packet
- err error
- )
-
- defer func() {
- if r := recover(); r != nil {
- err = NewError(ErrorFilterCompile, errors.New("ldap: error compiling filter"))
- }
- }()
- newPos := pos
-
- currentRune, currentWidth := utf8.DecodeRuneInString(filter[newPos:])
-
- switch currentRune {
- case utf8.RuneError:
- return nil, 0, NewError(ErrorFilterCompile, fmt.Errorf("ldap: error reading rune at position %d", newPos))
- case '(':
- packet, newPos, err = compileFilter(filter, pos+currentWidth)
- newPos++
- return packet, newPos, err
- case '&':
- packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterAnd, nil, FilterMap[FilterAnd])
- newPos, err = compileFilterSet(filter, pos+currentWidth, packet)
- return packet, newPos, err
- case '|':
- packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterOr, nil, FilterMap[FilterOr])
- newPos, err = compileFilterSet(filter, pos+currentWidth, packet)
- return packet, newPos, err
- case '!':
- packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterNot, nil, FilterMap[FilterNot])
- var child *ber.Packet
- child, newPos, err = compileFilter(filter, pos+currentWidth)
- packet.AppendChild(child)
- return packet, newPos, err
- default:
- READING_ATTR := 0
- READING_EXTENSIBLE_MATCHING_RULE := 1
- READING_CONDITION := 2
-
- state := READING_ATTR
-
- attribute := ""
- extensibleDNAttributes := false
- extensibleMatchingRule := ""
- condition := ""
-
- for newPos < len(filter) {
- remainingFilter := filter[newPos:]
- currentRune, currentWidth = utf8.DecodeRuneInString(remainingFilter)
- if currentRune == ')' {
- break
- }
- if currentRune == utf8.RuneError {
- return packet, newPos, NewError(ErrorFilterCompile, fmt.Errorf("ldap: error reading rune at position %d", newPos))
- }
-
- switch state {
- case READING_ATTR:
- switch {
- // Extensible rule, with only DN-matching
- case currentRune == ':' && strings.HasPrefix(remainingFilter, ":dn:="):
- packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterExtensibleMatch, nil, FilterMap[FilterExtensibleMatch])
- extensibleDNAttributes = true
- state = READING_CONDITION
- newPos += 5
-
- // Extensible rule, with DN-matching and a matching OID
- case currentRune == ':' && strings.HasPrefix(remainingFilter, ":dn:"):
- packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterExtensibleMatch, nil, FilterMap[FilterExtensibleMatch])
- extensibleDNAttributes = true
- state = READING_EXTENSIBLE_MATCHING_RULE
- newPos += 4
-
- // Extensible rule, with attr only
- case currentRune == ':' && strings.HasPrefix(remainingFilter, ":="):
- packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterExtensibleMatch, nil, FilterMap[FilterExtensibleMatch])
- state = READING_CONDITION
- newPos += 2
-
- // Extensible rule, with no DN attribute matching
- case currentRune == ':':
- packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterExtensibleMatch, nil, FilterMap[FilterExtensibleMatch])
- state = READING_EXTENSIBLE_MATCHING_RULE
- newPos += 1
-
- // Equality condition
- case currentRune == '=':
- packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterEqualityMatch, nil, FilterMap[FilterEqualityMatch])
- state = READING_CONDITION
- newPos += 1
-
- // Greater-than or equal
- case currentRune == '>' && strings.HasPrefix(remainingFilter, ">="):
- packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterGreaterOrEqual, nil, FilterMap[FilterGreaterOrEqual])
- state = READING_CONDITION
- newPos += 2
-
- // Less-than or equal
- case currentRune == '<' && strings.HasPrefix(remainingFilter, "<="):
- packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterLessOrEqual, nil, FilterMap[FilterLessOrEqual])
- state = READING_CONDITION
- newPos += 2
-
- // Approx
- case currentRune == '~' && strings.HasPrefix(remainingFilter, "~="):
- packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterApproxMatch, nil, FilterMap[FilterApproxMatch])
- state = READING_CONDITION
- newPos += 2
-
- // Still reading the attribute name
- default:
- attribute += fmt.Sprintf("%c", currentRune)
- newPos += currentWidth
- }
-
- case READING_EXTENSIBLE_MATCHING_RULE:
- switch {
-
- // Matching rule OID is done
- case currentRune == ':' && strings.HasPrefix(remainingFilter, ":="):
- state = READING_CONDITION
- newPos += 2
-
- // Still reading the matching rule oid
- default:
- extensibleMatchingRule += fmt.Sprintf("%c", currentRune)
- newPos += currentWidth
- }
-
- case READING_CONDITION:
- // append to the condition
- condition += fmt.Sprintf("%c", currentRune)
- newPos += currentWidth
- }
- }
-
- if newPos == len(filter) {
- err = NewError(ErrorFilterCompile, errors.New("ldap: unexpected end of filter"))
- return packet, newPos, err
- }
- if packet == nil {
- err = NewError(ErrorFilterCompile, errors.New("ldap: error parsing filter"))
- return packet, newPos, err
- }
-
- switch {
- case packet.Tag == FilterExtensibleMatch:
- // MatchingRuleAssertion ::= SEQUENCE {
- // matchingRule [1] MatchingRuleID OPTIONAL,
- // type [2] AttributeDescription OPTIONAL,
- // matchValue [3] AssertionValue,
- // dnAttributes [4] BOOLEAN DEFAULT FALSE
- // }
-
- // Include the matching rule oid, if specified
- if len(extensibleMatchingRule) > 0 {
- packet.AppendChild(ber.NewString(ber.ClassContext, ber.TypePrimitive, MatchingRuleAssertionMatchingRule, extensibleMatchingRule, MatchingRuleAssertionMap[MatchingRuleAssertionMatchingRule]))
- }
-
- // Include the attribute, if specified
- if len(attribute) > 0 {
- packet.AppendChild(ber.NewString(ber.ClassContext, ber.TypePrimitive, MatchingRuleAssertionType, attribute, MatchingRuleAssertionMap[MatchingRuleAssertionType]))
- }
-
- // Add the value (only required child)
- encodedString, err := escapedStringToEncodedBytes(condition)
- if err != nil {
- return packet, newPos, err
- }
- packet.AppendChild(ber.NewString(ber.ClassContext, ber.TypePrimitive, MatchingRuleAssertionMatchValue, encodedString, MatchingRuleAssertionMap[MatchingRuleAssertionMatchValue]))
-
- // Defaults to false, so only include in the sequence if true
- if extensibleDNAttributes {
- packet.AppendChild(ber.NewBoolean(ber.ClassContext, ber.TypePrimitive, MatchingRuleAssertionDNAttributes, extensibleDNAttributes, MatchingRuleAssertionMap[MatchingRuleAssertionDNAttributes]))
- }
-
- case packet.Tag == FilterEqualityMatch && condition == "*":
- packet = ber.NewString(ber.ClassContext, ber.TypePrimitive, FilterPresent, attribute, FilterMap[FilterPresent])
- case packet.Tag == FilterEqualityMatch && strings.Contains(condition, "*"):
- packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, attribute, "Attribute"))
- packet.Tag = FilterSubstrings
- packet.Description = FilterMap[uint64(packet.Tag)]
- seq := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Substrings")
- parts := strings.Split(condition, "*")
- for i, part := range parts {
- if part == "" {
- continue
- }
- var tag ber.Tag
- switch i {
- case 0:
- tag = FilterSubstringsInitial
- case len(parts) - 1:
- tag = FilterSubstringsFinal
- default:
- tag = FilterSubstringsAny
- }
- encodedString, err := escapedStringToEncodedBytes(part)
- if err != nil {
- return packet, newPos, err
- }
- seq.AppendChild(ber.NewString(ber.ClassContext, ber.TypePrimitive, tag, encodedString, FilterSubstringsMap[uint64(tag)]))
- }
- packet.AppendChild(seq)
- default:
- encodedString, err := escapedStringToEncodedBytes(condition)
- if err != nil {
- return packet, newPos, err
- }
- packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, attribute, "Attribute"))
- packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, encodedString, "Condition"))
- }
-
- newPos += currentWidth
- return packet, newPos, err
- }
-}
-
-// Convert from "ABC\xx\xx\xx" form to literal bytes for transport
-func escapedStringToEncodedBytes(escapedString string) (string, error) {
- var buffer bytes.Buffer
- i := 0
- for i < len(escapedString) {
- currentRune, currentWidth := utf8.DecodeRuneInString(escapedString[i:])
- if currentRune == utf8.RuneError {
- return "", NewError(ErrorFilterCompile, fmt.Errorf("ldap: error reading rune at position %d", i))
- }
-
- // Check for escaped hex characters and convert them to their literal value for transport.
- if currentRune == '\\' {
- // http://tools.ietf.org/search/rfc4515
- // \ (%x5C) is not a valid character unless it is followed by two HEX characters due to not
- // being a member of UTF1SUBSET.
- if i+2 > len(escapedString) {
- return "", NewError(ErrorFilterCompile, errors.New("ldap: missing characters for escape in filter"))
- }
- if escByte, decodeErr := hexpac.DecodeString(escapedString[i+1 : i+3]); decodeErr != nil {
- return "", NewError(ErrorFilterCompile, errors.New("ldap: invalid characters for escape in filter"))
- } else {
- buffer.WriteByte(escByte[0])
- i += 2 // +1 from end of loop, so 3 total for \xx.
- }
- } else {
- buffer.WriteRune(currentRune)
- }
-
- i += currentWidth
- }
- return buffer.String(), nil
-}
diff --git a/Godeps/_workspace/src/github.com/go-ldap/ldap/ldap.go b/Godeps/_workspace/src/github.com/go-ldap/ldap/ldap.go
deleted file mode 100644
index 1620aaea6..000000000
--- a/Godeps/_workspace/src/github.com/go-ldap/ldap/ldap.go
+++ /dev/null
@@ -1,286 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package ldap
-
-import (
- "errors"
- "io/ioutil"
- "os"
-
- ber "gopkg.in/asn1-ber.v1"
-)
-
-// LDAP Application Codes
-const (
- ApplicationBindRequest = 0
- ApplicationBindResponse = 1
- ApplicationUnbindRequest = 2
- ApplicationSearchRequest = 3
- ApplicationSearchResultEntry = 4
- ApplicationSearchResultDone = 5
- ApplicationModifyRequest = 6
- ApplicationModifyResponse = 7
- ApplicationAddRequest = 8
- ApplicationAddResponse = 9
- ApplicationDelRequest = 10
- ApplicationDelResponse = 11
- ApplicationModifyDNRequest = 12
- ApplicationModifyDNResponse = 13
- ApplicationCompareRequest = 14
- ApplicationCompareResponse = 15
- ApplicationAbandonRequest = 16
- ApplicationSearchResultReference = 19
- ApplicationExtendedRequest = 23
- ApplicationExtendedResponse = 24
-)
-
-var ApplicationMap = map[uint8]string{
- ApplicationBindRequest: "Bind Request",
- ApplicationBindResponse: "Bind Response",
- ApplicationUnbindRequest: "Unbind Request",
- ApplicationSearchRequest: "Search Request",
- ApplicationSearchResultEntry: "Search Result Entry",
- ApplicationSearchResultDone: "Search Result Done",
- ApplicationModifyRequest: "Modify Request",
- ApplicationModifyResponse: "Modify Response",
- ApplicationAddRequest: "Add Request",
- ApplicationAddResponse: "Add Response",
- ApplicationDelRequest: "Del Request",
- ApplicationDelResponse: "Del Response",
- ApplicationModifyDNRequest: "Modify DN Request",
- ApplicationModifyDNResponse: "Modify DN Response",
- ApplicationCompareRequest: "Compare Request",
- ApplicationCompareResponse: "Compare Response",
- ApplicationAbandonRequest: "Abandon Request",
- ApplicationSearchResultReference: "Search Result Reference",
- ApplicationExtendedRequest: "Extended Request",
- ApplicationExtendedResponse: "Extended Response",
-}
-
-// Ldap Behera Password Policy Draft 10 (https://tools.ietf.org/html/draft-behera-ldap-password-policy-10)
-const (
- BeheraPasswordExpired = 0
- BeheraAccountLocked = 1
- BeheraChangeAfterReset = 2
- BeheraPasswordModNotAllowed = 3
- BeheraMustSupplyOldPassword = 4
- BeheraInsufficientPasswordQuality = 5
- BeheraPasswordTooShort = 6
- BeheraPasswordTooYoung = 7
- BeheraPasswordInHistory = 8
-)
-
-var BeheraPasswordPolicyErrorMap = map[int8]string{
- BeheraPasswordExpired: "Password expired",
- BeheraAccountLocked: "Account locked",
- BeheraChangeAfterReset: "Password must be changed",
- BeheraPasswordModNotAllowed: "Policy prevents password modification",
- BeheraMustSupplyOldPassword: "Policy requires old password in order to change password",
- BeheraInsufficientPasswordQuality: "Password fails quality checks",
- BeheraPasswordTooShort: "Password is too short for policy",
- BeheraPasswordTooYoung: "Password has been changed too recently",
- BeheraPasswordInHistory: "New password is in list of old passwords",
-}
-
-// Adds descriptions to an LDAP Response packet for debugging
-func addLDAPDescriptions(packet *ber.Packet) (err error) {
- defer func() {
- if r := recover(); r != nil {
- err = NewError(ErrorDebugging, errors.New("ldap: cannot process packet to add descriptions"))
- }
- }()
- packet.Description = "LDAP Response"
- packet.Children[0].Description = "Message ID"
-
- application := uint8(packet.Children[1].Tag)
- packet.Children[1].Description = ApplicationMap[application]
-
- switch application {
- case ApplicationBindRequest:
- addRequestDescriptions(packet)
- case ApplicationBindResponse:
- addDefaultLDAPResponseDescriptions(packet)
- case ApplicationUnbindRequest:
- addRequestDescriptions(packet)
- case ApplicationSearchRequest:
- addRequestDescriptions(packet)
- case ApplicationSearchResultEntry:
- packet.Children[1].Children[0].Description = "Object Name"
- packet.Children[1].Children[1].Description = "Attributes"
- for _, child := range packet.Children[1].Children[1].Children {
- child.Description = "Attribute"
- child.Children[0].Description = "Attribute Name"
- child.Children[1].Description = "Attribute Values"
- for _, grandchild := range child.Children[1].Children {
- grandchild.Description = "Attribute Value"
- }
- }
- if len(packet.Children) == 3 {
- addControlDescriptions(packet.Children[2])
- }
- case ApplicationSearchResultDone:
- addDefaultLDAPResponseDescriptions(packet)
- case ApplicationModifyRequest:
- addRequestDescriptions(packet)
- case ApplicationModifyResponse:
- case ApplicationAddRequest:
- addRequestDescriptions(packet)
- case ApplicationAddResponse:
- case ApplicationDelRequest:
- addRequestDescriptions(packet)
- case ApplicationDelResponse:
- case ApplicationModifyDNRequest:
- addRequestDescriptions(packet)
- case ApplicationModifyDNResponse:
- case ApplicationCompareRequest:
- addRequestDescriptions(packet)
- case ApplicationCompareResponse:
- case ApplicationAbandonRequest:
- addRequestDescriptions(packet)
- case ApplicationSearchResultReference:
- case ApplicationExtendedRequest:
- addRequestDescriptions(packet)
- case ApplicationExtendedResponse:
- }
-
- return nil
-}
-
-func addControlDescriptions(packet *ber.Packet) {
- packet.Description = "Controls"
- for _, child := range packet.Children {
- child.Description = "Control"
- child.Children[0].Description = "Control Type (" + ControlTypeMap[child.Children[0].Value.(string)] + ")"
- value := child.Children[1]
- if len(child.Children) == 3 {
- child.Children[1].Description = "Criticality"
- value = child.Children[2]
- }
- value.Description = "Control Value"
-
- switch child.Children[0].Value.(string) {
- case ControlTypePaging:
- value.Description += " (Paging)"
- if value.Value != nil {
- valueChildren := ber.DecodePacket(value.Data.Bytes())
- value.Data.Truncate(0)
- value.Value = nil
- valueChildren.Children[1].Value = valueChildren.Children[1].Data.Bytes()
- value.AppendChild(valueChildren)
- }
- value.Children[0].Description = "Real Search Control Value"
- value.Children[0].Children[0].Description = "Paging Size"
- value.Children[0].Children[1].Description = "Cookie"
-
- case ControlTypeBeheraPasswordPolicy:
- value.Description += " (Password Policy - Behera Draft)"
- if value.Value != nil {
- valueChildren := ber.DecodePacket(value.Data.Bytes())
- value.Data.Truncate(0)
- value.Value = nil
- value.AppendChild(valueChildren)
- }
- sequence := value.Children[0]
- for _, child := range sequence.Children {
- if child.Tag == 0 {
- //Warning
- child := child.Children[0]
- packet := ber.DecodePacket(child.Data.Bytes())
- val, ok := packet.Value.(int64)
- if ok {
- if child.Tag == 0 {
- //timeBeforeExpiration
- value.Description += " (TimeBeforeExpiration)"
- child.Value = val
- } else if child.Tag == 1 {
- //graceAuthNsRemaining
- value.Description += " (GraceAuthNsRemaining)"
- child.Value = val
- }
- }
- } else if child.Tag == 1 {
- // Error
- packet := ber.DecodePacket(child.Data.Bytes())
- val, ok := packet.Value.(int8)
- if !ok {
- val = -1
- }
- child.Description = "Error"
- child.Value = val
- }
- }
- }
- }
-}
-
-func addRequestDescriptions(packet *ber.Packet) {
- packet.Description = "LDAP Request"
- packet.Children[0].Description = "Message ID"
- packet.Children[1].Description = ApplicationMap[uint8(packet.Children[1].Tag)]
- if len(packet.Children) == 3 {
- addControlDescriptions(packet.Children[2])
- }
-}
-
-func addDefaultLDAPResponseDescriptions(packet *ber.Packet) {
- resultCode, _ := getLDAPResultCode(packet)
- packet.Children[1].Children[0].Description = "Result Code (" + LDAPResultCodeMap[resultCode] + ")"
- packet.Children[1].Children[1].Description = "Matched DN"
- packet.Children[1].Children[2].Description = "Error Message"
- if len(packet.Children[1].Children) > 3 {
- packet.Children[1].Children[3].Description = "Referral"
- }
- if len(packet.Children) == 3 {
- addControlDescriptions(packet.Children[2])
- }
-}
-
-func DebugBinaryFile(fileName string) error {
- file, err := ioutil.ReadFile(fileName)
- if err != nil {
- return NewError(ErrorDebugging, err)
- }
- ber.PrintBytes(os.Stdout, file, "")
- packet := ber.DecodePacket(file)
- addLDAPDescriptions(packet)
- ber.PrintPacket(packet)
-
- return nil
-}
-
-var hex = "0123456789abcdef"
-
-func mustEscape(c byte) bool {
- return c > 0x7f || c == '(' || c == ')' || c == '\\' || c == '*' || c == 0
-}
-
-// EscapeFilter escapes from the provided LDAP filter string the special
-// characters in the set `()*\` and those out of the range 0 < c < 0x80,
-// as defined in RFC4515.
-func EscapeFilter(filter string) string {
- escape := 0
- for i := 0; i < len(filter); i++ {
- if mustEscape(filter[i]) {
- escape++
- }
- }
- if escape == 0 {
- return filter
- }
- buf := make([]byte, len(filter)+escape*2)
- for i, j := 0, 0; i < len(filter); i++ {
- c := filter[i]
- if mustEscape(c) {
- buf[j+0] = '\\'
- buf[j+1] = hex[c>>4]
- buf[j+2] = hex[c&0xf]
- j += 3
- } else {
- buf[j] = c
- j++
- }
- }
- return string(buf)
-}
diff --git a/Godeps/_workspace/src/github.com/go-ldap/ldap/modify.go b/Godeps/_workspace/src/github.com/go-ldap/ldap/modify.go
deleted file mode 100644
index 4372a19dc..000000000
--- a/Godeps/_workspace/src/github.com/go-ldap/ldap/modify.go
+++ /dev/null
@@ -1,156 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-//
-// File contains Modify functionality
-//
-// https://tools.ietf.org/html/rfc4511
-//
-// ModifyRequest ::= [APPLICATION 6] SEQUENCE {
-// object LDAPDN,
-// changes SEQUENCE OF change SEQUENCE {
-// operation ENUMERATED {
-// add (0),
-// delete (1),
-// replace (2),
-// ... },
-// modification PartialAttribute } }
-//
-// PartialAttribute ::= SEQUENCE {
-// type AttributeDescription,
-// vals SET OF value AttributeValue }
-//
-// AttributeDescription ::= LDAPString
-// -- Constrained to <attributedescription>
-// -- [RFC4512]
-//
-// AttributeValue ::= OCTET STRING
-//
-
-package ldap
-
-import (
- "errors"
- "log"
-
- "gopkg.in/asn1-ber.v1"
-)
-
-const (
- AddAttribute = 0
- DeleteAttribute = 1
- ReplaceAttribute = 2
-)
-
-type PartialAttribute struct {
- attrType string
- attrVals []string
-}
-
-func (p *PartialAttribute) encode() *ber.Packet {
- seq := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "PartialAttribute")
- seq.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, p.attrType, "Type"))
- set := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSet, nil, "AttributeValue")
- for _, value := range p.attrVals {
- set.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, value, "Vals"))
- }
- seq.AppendChild(set)
- return seq
-}
-
-type ModifyRequest struct {
- dn string
- addAttributes []PartialAttribute
- deleteAttributes []PartialAttribute
- replaceAttributes []PartialAttribute
-}
-
-func (m *ModifyRequest) Add(attrType string, attrVals []string) {
- m.addAttributes = append(m.addAttributes, PartialAttribute{attrType: attrType, attrVals: attrVals})
-}
-
-func (m *ModifyRequest) Delete(attrType string, attrVals []string) {
- m.deleteAttributes = append(m.deleteAttributes, PartialAttribute{attrType: attrType, attrVals: attrVals})
-}
-
-func (m *ModifyRequest) Replace(attrType string, attrVals []string) {
- m.replaceAttributes = append(m.replaceAttributes, PartialAttribute{attrType: attrType, attrVals: attrVals})
-}
-
-func (m ModifyRequest) encode() *ber.Packet {
- request := ber.Encode(ber.ClassApplication, ber.TypeConstructed, ApplicationModifyRequest, nil, "Modify Request")
- request.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, m.dn, "DN"))
- changes := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Changes")
- for _, attribute := range m.addAttributes {
- change := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Change")
- change.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagEnumerated, uint64(AddAttribute), "Operation"))
- change.AppendChild(attribute.encode())
- changes.AppendChild(change)
- }
- for _, attribute := range m.deleteAttributes {
- change := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Change")
- change.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagEnumerated, uint64(DeleteAttribute), "Operation"))
- change.AppendChild(attribute.encode())
- changes.AppendChild(change)
- }
- for _, attribute := range m.replaceAttributes {
- change := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Change")
- change.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagEnumerated, uint64(ReplaceAttribute), "Operation"))
- change.AppendChild(attribute.encode())
- changes.AppendChild(change)
- }
- request.AppendChild(changes)
- return request
-}
-
-func NewModifyRequest(
- dn string,
-) *ModifyRequest {
- return &ModifyRequest{
- dn: dn,
- }
-}
-
-func (l *Conn) Modify(modifyRequest *ModifyRequest) error {
- messageID := l.nextMessageID()
- packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "LDAP Request")
- packet.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, messageID, "MessageID"))
- packet.AppendChild(modifyRequest.encode())
-
- l.Debug.PrintPacket(packet)
-
- channel, err := l.sendMessage(packet)
- if err != nil {
- return err
- }
- if channel == nil {
- return NewError(ErrorNetwork, errors.New("ldap: could not send message"))
- }
- defer l.finishMessage(messageID)
-
- l.Debug.Printf("%d: waiting for response", messageID)
- packet = <-channel
- l.Debug.Printf("%d: got response %p", messageID, packet)
- if packet == nil {
- return NewError(ErrorNetwork, errors.New("ldap: could not retrieve message"))
- }
-
- if l.Debug {
- if err := addLDAPDescriptions(packet); err != nil {
- return err
- }
- ber.PrintPacket(packet)
- }
-
- if packet.Children[1].Tag == ApplicationModifyResponse {
- resultCode, resultDescription := getLDAPResultCode(packet)
- if resultCode != 0 {
- return NewError(resultCode, errors.New(resultDescription))
- }
- } else {
- log.Printf("Unexpected Response: %d", packet.Children[1].Tag)
- }
-
- l.Debug.Printf("%d: returning", messageID)
- return nil
-}
diff --git a/Godeps/_workspace/src/github.com/go-ldap/ldap/passwdmodify.go b/Godeps/_workspace/src/github.com/go-ldap/ldap/passwdmodify.go
deleted file mode 100644
index 508b11ed7..000000000
--- a/Godeps/_workspace/src/github.com/go-ldap/ldap/passwdmodify.go
+++ /dev/null
@@ -1,137 +0,0 @@
-// This file contains the password modify extended operation as specified in rfc 3062
-//
-// https://tools.ietf.org/html/rfc3062
-//
-
-package ldap
-
-import (
- "errors"
- "fmt"
-
- "gopkg.in/asn1-ber.v1"
-)
-
-const (
- passwordModifyOID = "1.3.6.1.4.1.4203.1.11.1"
-)
-
-type PasswordModifyRequest struct {
- UserIdentity string
- OldPassword string
- NewPassword string
-}
-
-type PasswordModifyResult struct {
- GeneratedPassword string
-}
-
-func (r *PasswordModifyRequest) encode() (*ber.Packet, error) {
- request := ber.Encode(ber.ClassApplication, ber.TypeConstructed, ApplicationExtendedRequest, nil, "Password Modify Extended Operation")
- request.AppendChild(ber.NewString(ber.ClassContext, ber.TypePrimitive, 0, passwordModifyOID, "Extended Request Name: Password Modify OID"))
- extendedRequestValue := ber.Encode(ber.ClassContext, ber.TypePrimitive, 1, nil, "Extended Request Value: Password Modify Request")
- passwordModifyRequestValue := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Password Modify Request")
- if r.UserIdentity != "" {
- passwordModifyRequestValue.AppendChild(ber.NewString(ber.ClassContext, ber.TypePrimitive, 0, r.UserIdentity, "User Identity"))
- }
- if r.OldPassword != "" {
- passwordModifyRequestValue.AppendChild(ber.NewString(ber.ClassContext, ber.TypePrimitive, 1, r.OldPassword, "Old Password"))
- }
- if r.NewPassword != "" {
- passwordModifyRequestValue.AppendChild(ber.NewString(ber.ClassContext, ber.TypePrimitive, 2, r.NewPassword, "New Password"))
- }
-
- extendedRequestValue.AppendChild(passwordModifyRequestValue)
- request.AppendChild(extendedRequestValue)
-
- return request, nil
-}
-
-// Create a new PasswordModifyRequest
-//
-// According to the RFC 3602:
-// userIdentity is a string representing the user associated with the request.
-// This string may or may not be an LDAPDN (RFC 2253).
-// If userIdentity is empty then the operation will act on the user associated
-// with the session.
-//
-// oldPassword is the current user's password, it can be empty or it can be
-// needed depending on the session user access rights (usually an administrator
-// can change a user's password without knowing the current one) and the
-// password policy (see pwdSafeModify password policy's attribute)
-//
-// newPassword is the desired user's password. If empty the server can return
-// an error or generate a new password that will be available in the
-// PasswordModifyResult.GeneratedPassword
-//
-func NewPasswordModifyRequest(userIdentity string, oldPassword string, newPassword string) *PasswordModifyRequest {
- return &PasswordModifyRequest{
- UserIdentity: userIdentity,
- OldPassword: oldPassword,
- NewPassword: newPassword,
- }
-}
-
-func (l *Conn) PasswordModify(passwordModifyRequest *PasswordModifyRequest) (*PasswordModifyResult, error) {
- messageID := l.nextMessageID()
-
- packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "LDAP Request")
- packet.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, messageID, "MessageID"))
-
- encodedPasswordModifyRequest, err := passwordModifyRequest.encode()
- if err != nil {
- return nil, err
- }
- packet.AppendChild(encodedPasswordModifyRequest)
-
- l.Debug.PrintPacket(packet)
-
- channel, err := l.sendMessage(packet)
- if err != nil {
- return nil, err
- }
- if channel == nil {
- return nil, NewError(ErrorNetwork, errors.New("ldap: could not send message"))
- }
- defer l.finishMessage(messageID)
-
- result := &PasswordModifyResult{}
-
- l.Debug.Printf("%d: waiting for response", messageID)
- packet = <-channel
- l.Debug.Printf("%d: got response %p", messageID, packet)
-
- if packet == nil {
- return nil, NewError(ErrorNetwork, errors.New("ldap: could not retrieve message"))
- }
-
- if l.Debug {
- if err := addLDAPDescriptions(packet); err != nil {
- return nil, err
- }
- ber.PrintPacket(packet)
- }
-
- if packet.Children[1].Tag == ApplicationExtendedResponse {
- resultCode, resultDescription := getLDAPResultCode(packet)
- if resultCode != 0 {
- return nil, NewError(resultCode, errors.New(resultDescription))
- }
- } else {
- return nil, NewError(ErrorUnexpectedResponse, fmt.Errorf("Unexpected Response: %d", packet.Children[1].Tag))
- }
-
- extendedResponse := packet.Children[1]
- for _, child := range extendedResponse.Children {
- if child.Tag == 11 {
- passwordModifyReponseValue := ber.DecodePacket(child.Data.Bytes())
- if len(passwordModifyReponseValue.Children) == 1 {
- if passwordModifyReponseValue.Children[0].Tag == 0 {
- result.GeneratedPassword = ber.DecodeString(passwordModifyReponseValue.Children[0].Data.Bytes())
- }
- }
- }
- }
-
- return result, nil
-}
diff --git a/Godeps/_workspace/src/github.com/go-ldap/ldap/search.go b/Godeps/_workspace/src/github.com/go-ldap/ldap/search.go
deleted file mode 100644
index f63c9fb02..000000000
--- a/Godeps/_workspace/src/github.com/go-ldap/ldap/search.go
+++ /dev/null
@@ -1,403 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-//
-// File contains Search functionality
-//
-// https://tools.ietf.org/html/rfc4511
-//
-// SearchRequest ::= [APPLICATION 3] SEQUENCE {
-// baseObject LDAPDN,
-// scope ENUMERATED {
-// baseObject (0),
-// singleLevel (1),
-// wholeSubtree (2),
-// ... },
-// derefAliases ENUMERATED {
-// neverDerefAliases (0),
-// derefInSearching (1),
-// derefFindingBaseObj (2),
-// derefAlways (3) },
-// sizeLimit INTEGER (0 .. maxInt),
-// timeLimit INTEGER (0 .. maxInt),
-// typesOnly BOOLEAN,
-// filter Filter,
-// attributes AttributeSelection }
-//
-// AttributeSelection ::= SEQUENCE OF selector LDAPString
-// -- The LDAPString is constrained to
-// -- <attributeSelector> in Section 4.5.1.8
-//
-// Filter ::= CHOICE {
-// and [0] SET SIZE (1..MAX) OF filter Filter,
-// or [1] SET SIZE (1..MAX) OF filter Filter,
-// not [2] Filter,
-// equalityMatch [3] AttributeValueAssertion,
-// substrings [4] SubstringFilter,
-// greaterOrEqual [5] AttributeValueAssertion,
-// lessOrEqual [6] AttributeValueAssertion,
-// present [7] AttributeDescription,
-// approxMatch [8] AttributeValueAssertion,
-// extensibleMatch [9] MatchingRuleAssertion,
-// ... }
-//
-// SubstringFilter ::= SEQUENCE {
-// type AttributeDescription,
-// substrings SEQUENCE SIZE (1..MAX) OF substring CHOICE {
-// initial [0] AssertionValue, -- can occur at most once
-// any [1] AssertionValue,
-// final [2] AssertionValue } -- can occur at most once
-// }
-//
-// MatchingRuleAssertion ::= SEQUENCE {
-// matchingRule [1] MatchingRuleId OPTIONAL,
-// type [2] AttributeDescription OPTIONAL,
-// matchValue [3] AssertionValue,
-// dnAttributes [4] BOOLEAN DEFAULT FALSE }
-//
-//
-
-package ldap
-
-import (
- "errors"
- "fmt"
- "sort"
- "strings"
-
- "gopkg.in/asn1-ber.v1"
-)
-
-const (
- ScopeBaseObject = 0
- ScopeSingleLevel = 1
- ScopeWholeSubtree = 2
-)
-
-var ScopeMap = map[int]string{
- ScopeBaseObject: "Base Object",
- ScopeSingleLevel: "Single Level",
- ScopeWholeSubtree: "Whole Subtree",
-}
-
-const (
- NeverDerefAliases = 0
- DerefInSearching = 1
- DerefFindingBaseObj = 2
- DerefAlways = 3
-)
-
-var DerefMap = map[int]string{
- NeverDerefAliases: "NeverDerefAliases",
- DerefInSearching: "DerefInSearching",
- DerefFindingBaseObj: "DerefFindingBaseObj",
- DerefAlways: "DerefAlways",
-}
-
-// NewEntry returns an Entry object with the specified distinguished name and attribute key-value pairs.
-// The map of attributes is accessed in alphabetical order of the keys in order to ensure that, for the
-// same input map of attributes, the output entry will contain the same order of attributes
-func NewEntry(dn string, attributes map[string][]string) *Entry {
- var attributeNames []string
- for attributeName := range attributes {
- attributeNames = append(attributeNames, attributeName)
- }
- sort.Strings(attributeNames)
-
- var encodedAttributes []*EntryAttribute
- for _, attributeName := range attributeNames {
- encodedAttributes = append(encodedAttributes, NewEntryAttribute(attributeName, attributes[attributeName]))
- }
- return &Entry{
- DN: dn,
- Attributes: encodedAttributes,
- }
-}
-
-type Entry struct {
- DN string
- Attributes []*EntryAttribute
-}
-
-func (e *Entry) GetAttributeValues(attribute string) []string {
- for _, attr := range e.Attributes {
- if attr.Name == attribute {
- return attr.Values
- }
- }
- return []string{}
-}
-
-func (e *Entry) GetRawAttributeValues(attribute string) [][]byte {
- for _, attr := range e.Attributes {
- if attr.Name == attribute {
- return attr.ByteValues
- }
- }
- return [][]byte{}
-}
-
-func (e *Entry) GetAttributeValue(attribute string) string {
- values := e.GetAttributeValues(attribute)
- if len(values) == 0 {
- return ""
- }
- return values[0]
-}
-
-func (e *Entry) GetRawAttributeValue(attribute string) []byte {
- values := e.GetRawAttributeValues(attribute)
- if len(values) == 0 {
- return []byte{}
- }
- return values[0]
-}
-
-func (e *Entry) Print() {
- fmt.Printf("DN: %s\n", e.DN)
- for _, attr := range e.Attributes {
- attr.Print()
- }
-}
-
-func (e *Entry) PrettyPrint(indent int) {
- fmt.Printf("%sDN: %s\n", strings.Repeat(" ", indent), e.DN)
- for _, attr := range e.Attributes {
- attr.PrettyPrint(indent + 2)
- }
-}
-
-// NewEntryAttribute returns a new EntryAttribute with the desired key-value pair
-func NewEntryAttribute(name string, values []string) *EntryAttribute {
- var bytes [][]byte
- for _, value := range values {
- bytes = append(bytes, []byte(value))
- }
- return &EntryAttribute{
- Name: name,
- Values: values,
- ByteValues: bytes,
- }
-}
-
-type EntryAttribute struct {
- Name string
- Values []string
- ByteValues [][]byte
-}
-
-func (e *EntryAttribute) Print() {
- fmt.Printf("%s: %s\n", e.Name, e.Values)
-}
-
-func (e *EntryAttribute) PrettyPrint(indent int) {
- fmt.Printf("%s%s: %s\n", strings.Repeat(" ", indent), e.Name, e.Values)
-}
-
-type SearchResult struct {
- Entries []*Entry
- Referrals []string
- Controls []Control
-}
-
-func (s *SearchResult) Print() {
- for _, entry := range s.Entries {
- entry.Print()
- }
-}
-
-func (s *SearchResult) PrettyPrint(indent int) {
- for _, entry := range s.Entries {
- entry.PrettyPrint(indent)
- }
-}
-
-type SearchRequest struct {
- BaseDN string
- Scope int
- DerefAliases int
- SizeLimit int
- TimeLimit int
- TypesOnly bool
- Filter string
- Attributes []string
- Controls []Control
-}
-
-func (s *SearchRequest) encode() (*ber.Packet, error) {
- request := ber.Encode(ber.ClassApplication, ber.TypeConstructed, ApplicationSearchRequest, nil, "Search Request")
- request.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, s.BaseDN, "Base DN"))
- request.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagEnumerated, uint64(s.Scope), "Scope"))
- request.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagEnumerated, uint64(s.DerefAliases), "Deref Aliases"))
- request.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, uint64(s.SizeLimit), "Size Limit"))
- request.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, uint64(s.TimeLimit), "Time Limit"))
- request.AppendChild(ber.NewBoolean(ber.ClassUniversal, ber.TypePrimitive, ber.TagBoolean, s.TypesOnly, "Types Only"))
- // compile and encode filter
- filterPacket, err := CompileFilter(s.Filter)
- if err != nil {
- return nil, err
- }
- request.AppendChild(filterPacket)
- // encode attributes
- attributesPacket := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Attributes")
- for _, attribute := range s.Attributes {
- attributesPacket.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, attribute, "Attribute"))
- }
- request.AppendChild(attributesPacket)
- return request, nil
-}
-
-func NewSearchRequest(
- BaseDN string,
- Scope, DerefAliases, SizeLimit, TimeLimit int,
- TypesOnly bool,
- Filter string,
- Attributes []string,
- Controls []Control,
-) *SearchRequest {
- return &SearchRequest{
- BaseDN: BaseDN,
- Scope: Scope,
- DerefAliases: DerefAliases,
- SizeLimit: SizeLimit,
- TimeLimit: TimeLimit,
- TypesOnly: TypesOnly,
- Filter: Filter,
- Attributes: Attributes,
- Controls: Controls,
- }
-}
-
-func (l *Conn) SearchWithPaging(searchRequest *SearchRequest, pagingSize uint32) (*SearchResult, error) {
- if searchRequest.Controls == nil {
- searchRequest.Controls = make([]Control, 0)
- }
-
- pagingControl := NewControlPaging(pagingSize)
- searchRequest.Controls = append(searchRequest.Controls, pagingControl)
- searchResult := new(SearchResult)
- for {
- result, err := l.Search(searchRequest)
- l.Debug.Printf("Looking for Paging Control...")
- if err != nil {
- return searchResult, err
- }
- if result == nil {
- return searchResult, NewError(ErrorNetwork, errors.New("ldap: packet not received"))
- }
-
- for _, entry := range result.Entries {
- searchResult.Entries = append(searchResult.Entries, entry)
- }
- for _, referral := range result.Referrals {
- searchResult.Referrals = append(searchResult.Referrals, referral)
- }
- for _, control := range result.Controls {
- searchResult.Controls = append(searchResult.Controls, control)
- }
-
- l.Debug.Printf("Looking for Paging Control...")
- pagingResult := FindControl(result.Controls, ControlTypePaging)
- if pagingResult == nil {
- pagingControl = nil
- l.Debug.Printf("Could not find paging control. Breaking...")
- break
- }
-
- cookie := pagingResult.(*ControlPaging).Cookie
- if len(cookie) == 0 {
- pagingControl = nil
- l.Debug.Printf("Could not find cookie. Breaking...")
- break
- }
- pagingControl.SetCookie(cookie)
- }
-
- if pagingControl != nil {
- l.Debug.Printf("Abandoning Paging...")
- pagingControl.PagingSize = 0
- l.Search(searchRequest)
- }
-
- return searchResult, nil
-}
-
-func (l *Conn) Search(searchRequest *SearchRequest) (*SearchResult, error) {
- messageID := l.nextMessageID()
- packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "LDAP Request")
- packet.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, messageID, "MessageID"))
- // encode search request
- encodedSearchRequest, err := searchRequest.encode()
- if err != nil {
- return nil, err
- }
- packet.AppendChild(encodedSearchRequest)
- // encode search controls
- if searchRequest.Controls != nil {
- packet.AppendChild(encodeControls(searchRequest.Controls))
- }
-
- l.Debug.PrintPacket(packet)
-
- channel, err := l.sendMessage(packet)
- if err != nil {
- return nil, err
- }
- if channel == nil {
- return nil, NewError(ErrorNetwork, errors.New("ldap: could not send message"))
- }
- defer l.finishMessage(messageID)
-
- result := &SearchResult{
- Entries: make([]*Entry, 0),
- Referrals: make([]string, 0),
- Controls: make([]Control, 0)}
-
- foundSearchResultDone := false
- for !foundSearchResultDone {
- l.Debug.Printf("%d: waiting for response", messageID)
- packet = <-channel
- l.Debug.Printf("%d: got response %p", messageID, packet)
- if packet == nil {
- return nil, NewError(ErrorNetwork, errors.New("ldap: could not retrieve message"))
- }
-
- if l.Debug {
- if err := addLDAPDescriptions(packet); err != nil {
- return nil, err
- }
- ber.PrintPacket(packet)
- }
-
- switch packet.Children[1].Tag {
- case 4:
- entry := new(Entry)
- entry.DN = packet.Children[1].Children[0].Value.(string)
- for _, child := range packet.Children[1].Children[1].Children {
- attr := new(EntryAttribute)
- attr.Name = child.Children[0].Value.(string)
- for _, value := range child.Children[1].Children {
- attr.Values = append(attr.Values, value.Value.(string))
- attr.ByteValues = append(attr.ByteValues, value.ByteValue)
- }
- entry.Attributes = append(entry.Attributes, attr)
- }
- result.Entries = append(result.Entries, entry)
- case 5:
- resultCode, resultDescription := getLDAPResultCode(packet)
- if resultCode != 0 {
- return result, NewError(resultCode, errors.New(resultDescription))
- }
- if len(packet.Children) == 3 {
- for _, child := range packet.Children[2].Children {
- result.Controls = append(result.Controls, DecodeControl(child))
- }
- }
- foundSearchResultDone = true
- case 19:
- result.Referrals = append(result.Referrals, packet.Children[1].Children[0].Value.(string))
- }
- }
- l.Debug.Printf("%d: returning", messageID)
- return result, nil
-}
diff --git a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/.gitignore b/Godeps/_workspace/src/github.com/go-sql-driver/mysql/.gitignore
deleted file mode 100644
index ba8e0cb3a..000000000
--- a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-.DS_Store
-.DS_Store?
-._*
-.Spotlight-V100
-.Trashes
-Icon?
-ehthumbs.db
-Thumbs.db
diff --git a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/.travis.yml b/Godeps/_workspace/src/github.com/go-sql-driver/mysql/.travis.yml
deleted file mode 100644
index 2f4e3c2f0..000000000
--- a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/.travis.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-sudo: false
-language: go
-go:
- - 1.2
- - 1.3
- - 1.4
- - tip
-
-before_script:
- - mysql -e 'create database gotest;'
diff --git a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/AUTHORS b/Godeps/_workspace/src/github.com/go-sql-driver/mysql/AUTHORS
deleted file mode 100644
index 6dd0167f3..000000000
--- a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/AUTHORS
+++ /dev/null
@@ -1,46 +0,0 @@
-# This is the official list of Go-MySQL-Driver authors for copyright purposes.
-
-# If you are submitting a patch, please add your name or the name of the
-# organization which holds the copyright to this list in alphabetical order.
-
-# Names should be added to this file as
-# Name <email address>
-# The email address is not required for organizations.
-# Please keep the list sorted.
-
-
-# Individual Persons
-
-Aaron Hopkins <go-sql-driver at die.net>
-Arne Hormann <arnehormann at gmail.com>
-Carlos Nieto <jose.carlos at menteslibres.net>
-Chris Moos <chris at tech9computers.com>
-DisposaBoy <disposaboy at dby.me>
-Frederick Mayle <frederickmayle at gmail.com>
-Gustavo Kristic <gkristic at gmail.com>
-Hanno Braun <mail at hannobraun.com>
-Henri Yandell <flamefew at gmail.com>
-Hirotaka Yamamoto <ymmt2005 at gmail.com>
-INADA Naoki <songofacandy at gmail.com>
-James Harr <james.harr at gmail.com>
-Jian Zhen <zhenjl at gmail.com>
-Joshua Prunier <joshua.prunier at gmail.com>
-Julien Schmidt <go-sql-driver at julienschmidt.com>
-Kamil Dziedzic <kamil at klecza.pl>
-Leonardo YongUk Kim <dalinaum at gmail.com>
-Lucas Liu <extrafliu at gmail.com>
-Luke Scott <luke at webconnex.com>
-Michael Woolnough <michael.woolnough at gmail.com>
-Nicola Peduzzi <thenikso at gmail.com>
-Runrioter Wung <runrioter at gmail.com>
-Soroush Pour <me at soroushjp.com>
-Stan Putrya <root.vagner at gmail.com>
-Xiaobing Jiang <s7v7nislands at gmail.com>
-Xiuming Chen <cc at cxm.cc>
-Julien Lefevre <julien.lefevr at gmail.com>
-
-# Organizations
-
-Barracuda Networks, Inc.
-Google Inc.
-Stripe Inc.
diff --git a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/CHANGELOG.md b/Godeps/_workspace/src/github.com/go-sql-driver/mysql/CHANGELOG.md
deleted file mode 100644
index 161ad0fcc..000000000
--- a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/CHANGELOG.md
+++ /dev/null
@@ -1,92 +0,0 @@
-## HEAD
-
-Changes:
-
- - Go 1.1 is no longer supported
- - Use decimals field from MySQL to format time types (#249)
- - Buffer optimizations (#269)
- - TLS ServerName defaults to the host (#283)
-
-Bugfixes:
-
- - Enable microsecond resolution on TIME, DATETIME and TIMESTAMP (#249)
- - Fixed handling of queries without columns and rows (#255)
- - Fixed a panic when SetKeepAlive() failed (#298)
-
-New Features:
- - Support for returning table alias on Columns() (#289)
- - Placeholder interpolation, can be actived with the DSN parameter `interpolateParams=true` (#309, #318)
-
-
-## Version 1.2 (2014-06-03)
-
-Changes:
-
- - We switched back to a "rolling release". `go get` installs the current master branch again
- - Version v1 of the driver will not be maintained anymore. Go 1.0 is no longer supported by this driver
- - Exported errors to allow easy checking from application code
- - Enabled TCP Keepalives on TCP connections
- - Optimized INFILE handling (better buffer size calculation, lazy init, ...)
- - The DSN parser also checks for a missing separating slash
- - Faster binary date / datetime to string formatting
- - Also exported the MySQLWarning type
- - mysqlConn.Close returns the first error encountered instead of ignoring all errors
- - writePacket() automatically writes the packet size to the header
- - readPacket() uses an iterative approach instead of the recursive approach to merge splitted packets
-
-New Features:
-
- - `RegisterDial` allows the usage of a custom dial function to establish the network connection
- - Setting the connection collation is possible with the `collation` DSN parameter. This parameter should be preferred over the `charset` parameter
- - Logging of critical errors is configurable with `SetLogger`
- - Google CloudSQL support
-
-Bugfixes:
-
- - Allow more than 32 parameters in prepared statements
- - Various old_password fixes
- - Fixed TestConcurrent test to pass Go's race detection
- - Fixed appendLengthEncodedInteger for large numbers
- - Renamed readLengthEnodedString to readLengthEncodedString and skipLengthEnodedString to skipLengthEncodedString (fixed typo)
-
-
-## Version 1.1 (2013-11-02)
-
-Changes:
-
- - Go-MySQL-Driver now requires Go 1.1
- - Connections now use the collation `utf8_general_ci` by default. Adding `&charset=UTF8` to the DSN should not be necessary anymore
- - Made closing rows and connections error tolerant. This allows for example deferring rows.Close() without checking for errors
- - `[]byte(nil)` is now treated as a NULL value. Before, it was treated like an empty string / `[]byte("")`
- - DSN parameter values must now be url.QueryEscape'ed. This allows text values to contain special characters, such as '&'.
- - Use the IO buffer also for writing. This results in zero allocations (by the driver) for most queries
- - Optimized the buffer for reading
- - stmt.Query now caches column metadata
- - New Logo
- - Changed the copyright header to include all contributors
- - Improved the LOAD INFILE documentation
- - The driver struct is now exported to make the driver directly accessible
- - Refactored the driver tests
- - Added more benchmarks and moved all to a separate file
- - Other small refactoring
-
-New Features:
-
- - Added *old_passwords* support: Required in some cases, but must be enabled by adding `allowOldPasswords=true` to the DSN since it is insecure
- - Added a `clientFoundRows` parameter: Return the number of matching rows instead of the number of rows changed on UPDATEs
- - Added TLS/SSL support: Use a TLS/SSL encrypted connection to the server. Custom TLS configs can be registered and used
-
-Bugfixes:
-
- - Fixed MySQL 4.1 support: MySQL 4.1 sends packets with lengths which differ from the specification
- - Convert to DB timezone when inserting `time.Time`
- - Splitted packets (more than 16MB) are now merged correctly
- - Fixed false positive `io.EOF` errors when the data was fully read
- - Avoid panics on reuse of closed connections
- - Fixed empty string producing false nil values
- - Fixed sign byte for positive TIME fields
-
-
-## Version 1.0 (2013-05-14)
-
-Initial Release
diff --git a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/CONTRIBUTING.md b/Godeps/_workspace/src/github.com/go-sql-driver/mysql/CONTRIBUTING.md
deleted file mode 100644
index f87c19824..000000000
--- a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/CONTRIBUTING.md
+++ /dev/null
@@ -1,40 +0,0 @@
-# Contributing Guidelines
-
-## Reporting Issues
-
-Before creating a new Issue, please check first if a similar Issue [already exists](https://github.com/go-sql-driver/mysql/issues?state=open) or was [recently closed](https://github.com/go-sql-driver/mysql/issues?direction=desc&page=1&sort=updated&state=closed).
-
-Please provide the following minimum information:
-* Your Go-MySQL-Driver version (or git SHA)
-* Your Go version (run `go version` in your console)
-* A detailed issue description
-* Error Log if present
-* If possible, a short example
-
-
-## Contributing Code
-
-By contributing to this project, you share your code under the Mozilla Public License 2, as specified in the LICENSE file.
-Don't forget to add yourself to the AUTHORS file.
-
-### Pull Requests Checklist
-
-Please check the following points before submitting your pull request:
-- [x] Code compiles correctly
-- [x] Created tests, if possible
-- [x] All tests pass
-- [x] Extended the README / documentation, if necessary
-- [x] Added yourself to the AUTHORS file
-
-### Code Review
-
-Everyone is invited to review and comment on pull requests.
-If it looks fine to you, comment with "LGTM" (Looks good to me).
-
-If changes are required, notice the reviewers with "PTAL" (Please take another look) after committing the fixes.
-
-Before merging the Pull Request, at least one [team member](https://github.com/go-sql-driver?tab=members) must have commented with "LGTM".
-
-## Development Ideas
-
-If you are looking for ideas for code contributions, please check our [Development Ideas](https://github.com/go-sql-driver/mysql/wiki/Development-Ideas) Wiki page.
diff --git a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/LICENSE b/Godeps/_workspace/src/github.com/go-sql-driver/mysql/LICENSE
deleted file mode 100644
index 14e2f777f..000000000
--- a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/LICENSE
+++ /dev/null
@@ -1,373 +0,0 @@
-Mozilla Public License Version 2.0
-==================================
-
-1. Definitions
---------------
-
-1.1. "Contributor"
- means each individual or legal entity that creates, contributes to
- the creation of, or owns Covered Software.
-
-1.2. "Contributor Version"
- means the combination of the Contributions of others (if any) used
- by a Contributor and that particular Contributor's Contribution.
-
-1.3. "Contribution"
- means Covered Software of a particular Contributor.
-
-1.4. "Covered Software"
- means Source Code Form to which the initial Contributor has attached
- the notice in Exhibit A, the Executable Form of such Source Code
- Form, and Modifications of such Source Code Form, in each case
- including portions thereof.
-
-1.5. "Incompatible With Secondary Licenses"
- means
-
- (a) that the initial Contributor has attached the notice described
- in Exhibit B to the Covered Software; or
-
- (b) that the Covered Software was made available under the terms of
- version 1.1 or earlier of the License, but not also under the
- terms of a Secondary License.
-
-1.6. "Executable Form"
- means any form of the work other than Source Code Form.
-
-1.7. "Larger Work"
- means a work that combines Covered Software with other material, in
- a separate file or files, that is not Covered Software.
-
-1.8. "License"
- means this document.
-
-1.9. "Licensable"
- means having the right to grant, to the maximum extent possible,
- whether at the time of the initial grant or subsequently, any and
- all of the rights conveyed by this License.
-
-1.10. "Modifications"
- means any of the following:
-
- (a) any file in Source Code Form that results from an addition to,
- deletion from, or modification of the contents of Covered
- Software; or
-
- (b) any new file in Source Code Form that contains any Covered
- Software.
-
-1.11. "Patent Claims" of a Contributor
- means any patent claim(s), including without limitation, method,
- process, and apparatus claims, in any patent Licensable by such
- Contributor that would be infringed, but for the grant of the
- License, by the making, using, selling, offering for sale, having
- made, import, or transfer of either its Contributions or its
- Contributor Version.
-
-1.12. "Secondary License"
- means either the GNU General Public License, Version 2.0, the GNU
- Lesser General Public License, Version 2.1, the GNU Affero General
- Public License, Version 3.0, or any later versions of those
- licenses.
-
-1.13. "Source Code Form"
- means the form of the work preferred for making modifications.
-
-1.14. "You" (or "Your")
- means an individual or a legal entity exercising rights under this
- License. For legal entities, "You" includes any entity that
- controls, is controlled by, or is under common control with You. For
- purposes of this definition, "control" means (a) the power, direct
- or indirect, to cause the direction or management of such entity,
- whether by contract or otherwise, or (b) ownership of more than
- fifty percent (50%) of the outstanding shares or beneficial
- ownership of such entity.
-
-2. License Grants and Conditions
---------------------------------
-
-2.1. Grants
-
-Each Contributor hereby grants You a world-wide, royalty-free,
-non-exclusive license:
-
-(a) under intellectual property rights (other than patent or trademark)
- Licensable by such Contributor to use, reproduce, make available,
- modify, display, perform, distribute, and otherwise exploit its
- Contributions, either on an unmodified basis, with Modifications, or
- as part of a Larger Work; and
-
-(b) under Patent Claims of such Contributor to make, use, sell, offer
- for sale, have made, import, and otherwise transfer either its
- Contributions or its Contributor Version.
-
-2.2. Effective Date
-
-The licenses granted in Section 2.1 with respect to any Contribution
-become effective for each Contribution on the date the Contributor first
-distributes such Contribution.
-
-2.3. Limitations on Grant Scope
-
-The licenses granted in this Section 2 are the only rights granted under
-this License. No additional rights or licenses will be implied from the
-distribution or licensing of Covered Software under this License.
-Notwithstanding Section 2.1(b) above, no patent license is granted by a
-Contributor:
-
-(a) for any code that a Contributor has removed from Covered Software;
- or
-
-(b) for infringements caused by: (i) Your and any other third party's
- modifications of Covered Software, or (ii) the combination of its
- Contributions with other software (except as part of its Contributor
- Version); or
-
-(c) under Patent Claims infringed by Covered Software in the absence of
- its Contributions.
-
-This License does not grant any rights in the trademarks, service marks,
-or logos of any Contributor (except as may be necessary to comply with
-the notice requirements in Section 3.4).
-
-2.4. Subsequent Licenses
-
-No Contributor makes additional grants as a result of Your choice to
-distribute the Covered Software under a subsequent version of this
-License (see Section 10.2) or under the terms of a Secondary License (if
-permitted under the terms of Section 3.3).
-
-2.5. Representation
-
-Each Contributor represents that the Contributor believes its
-Contributions are its original creation(s) or it has sufficient rights
-to grant the rights to its Contributions conveyed by this License.
-
-2.6. Fair Use
-
-This License is not intended to limit any rights You have under
-applicable copyright doctrines of fair use, fair dealing, or other
-equivalents.
-
-2.7. Conditions
-
-Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
-in Section 2.1.
-
-3. Responsibilities
--------------------
-
-3.1. Distribution of Source Form
-
-All distribution of Covered Software in Source Code Form, including any
-Modifications that You create or to which You contribute, must be under
-the terms of this License. You must inform recipients that the Source
-Code Form of the Covered Software is governed by the terms of this
-License, and how they can obtain a copy of this License. You may not
-attempt to alter or restrict the recipients' rights in the Source Code
-Form.
-
-3.2. Distribution of Executable Form
-
-If You distribute Covered Software in Executable Form then:
-
-(a) such Covered Software must also be made available in Source Code
- Form, as described in Section 3.1, and You must inform recipients of
- the Executable Form how they can obtain a copy of such Source Code
- Form by reasonable means in a timely manner, at a charge no more
- than the cost of distribution to the recipient; and
-
-(b) You may distribute such Executable Form under the terms of this
- License, or sublicense it under different terms, provided that the
- license for the Executable Form does not attempt to limit or alter
- the recipients' rights in the Source Code Form under this License.
-
-3.3. Distribution of a Larger Work
-
-You may create and distribute a Larger Work under terms of Your choice,
-provided that You also comply with the requirements of this License for
-the Covered Software. If the Larger Work is a combination of Covered
-Software with a work governed by one or more Secondary Licenses, and the
-Covered Software is not Incompatible With Secondary Licenses, this
-License permits You to additionally distribute such Covered Software
-under the terms of such Secondary License(s), so that the recipient of
-the Larger Work may, at their option, further distribute the Covered
-Software under the terms of either this License or such Secondary
-License(s).
-
-3.4. Notices
-
-You may not remove or alter the substance of any license notices
-(including copyright notices, patent notices, disclaimers of warranty,
-or limitations of liability) contained within the Source Code Form of
-the Covered Software, except that You may alter any license notices to
-the extent required to remedy known factual inaccuracies.
-
-3.5. Application of Additional Terms
-
-You may choose to offer, and to charge a fee for, warranty, support,
-indemnity or liability obligations to one or more recipients of Covered
-Software. However, You may do so only on Your own behalf, and not on
-behalf of any Contributor. You must make it absolutely clear that any
-such warranty, support, indemnity, or liability obligation is offered by
-You alone, and You hereby agree to indemnify every Contributor for any
-liability incurred by such Contributor as a result of warranty, support,
-indemnity or liability terms You offer. You may include additional
-disclaimers of warranty and limitations of liability specific to any
-jurisdiction.
-
-4. Inability to Comply Due to Statute or Regulation
----------------------------------------------------
-
-If it is impossible for You to comply with any of the terms of this
-License with respect to some or all of the Covered Software due to
-statute, judicial order, or regulation then You must: (a) comply with
-the terms of this License to the maximum extent possible; and (b)
-describe the limitations and the code they affect. Such description must
-be placed in a text file included with all distributions of the Covered
-Software under this License. Except to the extent prohibited by statute
-or regulation, such description must be sufficiently detailed for a
-recipient of ordinary skill to be able to understand it.
-
-5. Termination
---------------
-
-5.1. The rights granted under this License will terminate automatically
-if You fail to comply with any of its terms. However, if You become
-compliant, then the rights granted under this License from a particular
-Contributor are reinstated (a) provisionally, unless and until such
-Contributor explicitly and finally terminates Your grants, and (b) on an
-ongoing basis, if such Contributor fails to notify You of the
-non-compliance by some reasonable means prior to 60 days after You have
-come back into compliance. Moreover, Your grants from a particular
-Contributor are reinstated on an ongoing basis if such Contributor
-notifies You of the non-compliance by some reasonable means, this is the
-first time You have received notice of non-compliance with this License
-from such Contributor, and You become compliant prior to 30 days after
-Your receipt of the notice.
-
-5.2. If You initiate litigation against any entity by asserting a patent
-infringement claim (excluding declaratory judgment actions,
-counter-claims, and cross-claims) alleging that a Contributor Version
-directly or indirectly infringes any patent, then the rights granted to
-You by any and all Contributors for the Covered Software under Section
-2.1 of this License shall terminate.
-
-5.3. In the event of termination under Sections 5.1 or 5.2 above, all
-end user license agreements (excluding distributors and resellers) which
-have been validly granted by You or Your distributors under this License
-prior to termination shall survive termination.
-
-************************************************************************
-* *
-* 6. Disclaimer of Warranty *
-* ------------------------- *
-* *
-* Covered Software is provided under this License on an "as is" *
-* basis, without warranty of any kind, either expressed, implied, or *
-* statutory, including, without limitation, warranties that the *
-* Covered Software is free of defects, merchantable, fit for a *
-* particular purpose or non-infringing. The entire risk as to the *
-* quality and performance of the Covered Software is with You. *
-* Should any Covered Software prove defective in any respect, You *
-* (not any Contributor) assume the cost of any necessary servicing, *
-* repair, or correction. This disclaimer of warranty constitutes an *
-* essential part of this License. No use of any Covered Software is *
-* authorized under this License except under this disclaimer. *
-* *
-************************************************************************
-
-************************************************************************
-* *
-* 7. Limitation of Liability *
-* -------------------------- *
-* *
-* Under no circumstances and under no legal theory, whether tort *
-* (including negligence), contract, or otherwise, shall any *
-* Contributor, or anyone who distributes Covered Software as *
-* permitted above, be liable to You for any direct, indirect, *
-* special, incidental, or consequential damages of any character *
-* including, without limitation, damages for lost profits, loss of *
-* goodwill, work stoppage, computer failure or malfunction, or any *
-* and all other commercial damages or losses, even if such party *
-* shall have been informed of the possibility of such damages. This *
-* limitation of liability shall not apply to liability for death or *
-* personal injury resulting from such party's negligence to the *
-* extent applicable law prohibits such limitation. Some *
-* jurisdictions do not allow the exclusion or limitation of *
-* incidental or consequential damages, so this exclusion and *
-* limitation may not apply to You. *
-* *
-************************************************************************
-
-8. Litigation
--------------
-
-Any litigation relating to this License may be brought only in the
-courts of a jurisdiction where the defendant maintains its principal
-place of business and such litigation shall be governed by laws of that
-jurisdiction, without reference to its conflict-of-law provisions.
-Nothing in this Section shall prevent a party's ability to bring
-cross-claims or counter-claims.
-
-9. Miscellaneous
-----------------
-
-This License represents the complete agreement concerning the subject
-matter hereof. If any provision of this License is held to be
-unenforceable, such provision shall be reformed only to the extent
-necessary to make it enforceable. Any law or regulation which provides
-that the language of a contract shall be construed against the drafter
-shall not be used to construe this License against a Contributor.
-
-10. Versions of the License
----------------------------
-
-10.1. New Versions
-
-Mozilla Foundation is the license steward. Except as provided in Section
-10.3, no one other than the license steward has the right to modify or
-publish new versions of this License. Each version will be given a
-distinguishing version number.
-
-10.2. Effect of New Versions
-
-You may distribute the Covered Software under the terms of the version
-of the License under which You originally received the Covered Software,
-or under the terms of any subsequent version published by the license
-steward.
-
-10.3. Modified Versions
-
-If you create software not governed by this License, and you want to
-create a new license for such software, you may create and use a
-modified version of this License if you rename the license and remove
-any references to the name of the license steward (except to note that
-such modified license differs from this License).
-
-10.4. Distributing Source Code Form that is Incompatible With Secondary
-Licenses
-
-If You choose to distribute Source Code Form that is Incompatible With
-Secondary Licenses under the terms of this version of the License, the
-notice described in Exhibit B of this License must be attached.
-
-Exhibit A - Source Code Form License Notice
--------------------------------------------
-
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-If it is not possible or desirable to put the notice in a particular
-file, then You may include the notice in a location (such as a LICENSE
-file in a relevant directory) where a recipient would be likely to look
-for such a notice.
-
-You may add additional accurate notices of copyright ownership.
-
-Exhibit B - "Incompatible With Secondary Licenses" Notice
----------------------------------------------------------
-
- This Source Code Form is "Incompatible With Secondary Licenses", as
- defined by the Mozilla Public License, v. 2.0.
diff --git a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/README.md b/Godeps/_workspace/src/github.com/go-sql-driver/mysql/README.md
deleted file mode 100644
index 706b7ef2e..000000000
--- a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/README.md
+++ /dev/null
@@ -1,386 +0,0 @@
-# Go-MySQL-Driver
-
-A MySQL-Driver for Go's [database/sql](http://golang.org/pkg/database/sql) package
-
-![Go-MySQL-Driver logo](https://raw.github.com/wiki/go-sql-driver/mysql/gomysql_m.png "Golang Gopher holding the MySQL Dolphin")
-
-**Latest stable Release:** [Version 1.2 (June 03, 2014)](https://github.com/go-sql-driver/mysql/releases)
-
-[![Build Status](https://travis-ci.org/go-sql-driver/mysql.png?branch=master)](https://travis-ci.org/go-sql-driver/mysql)
-
----------------------------------------
- * [Features](#features)
- * [Requirements](#requirements)
- * [Installation](#installation)
- * [Usage](#usage)
- * [DSN (Data Source Name)](#dsn-data-source-name)
- * [Password](#password)
- * [Protocol](#protocol)
- * [Address](#address)
- * [Parameters](#parameters)
- * [Examples](#examples)
- * [LOAD DATA LOCAL INFILE support](#load-data-local-infile-support)
- * [time.Time support](#timetime-support)
- * [Unicode support](#unicode-support)
- * [Testing / Development](#testing--development)
- * [License](#license)
-
----------------------------------------
-
-## Features
- * Lightweight and [fast](https://github.com/go-sql-driver/sql-benchmark "golang MySQL-Driver performance")
- * Native Go implementation. No C-bindings, just pure Go
- * Connections over TCP/IPv4, TCP/IPv6, Unix domain sockets or [custom protocols](http://godoc.org/github.com/go-sql-driver/mysql#DialFunc)
- * Automatic handling of broken connections
- * Automatic Connection Pooling *(by database/sql package)*
- * Supports queries larger than 16MB
- * Full [`sql.RawBytes`](http://golang.org/pkg/database/sql/#RawBytes) support.
- * Intelligent `LONG DATA` handling in prepared statements
- * Secure `LOAD DATA LOCAL INFILE` support with file Whitelisting and `io.Reader` support
- * Optional `time.Time` parsing
- * Optional placeholder interpolation
-
-## Requirements
- * Go 1.2 or higher
- * MySQL (4.1+), MariaDB, Percona Server, Google CloudSQL or Sphinx (2.2.3+)
-
----------------------------------------
-
-## Installation
-Simple install the package to your [$GOPATH](http://code.google.com/p/go-wiki/wiki/GOPATH "GOPATH") with the [go tool](http://golang.org/cmd/go/ "go command") from shell:
-```bash
-$ go get github.com/go-sql-driver/mysql
-```
-Make sure [Git is installed](http://git-scm.com/downloads) on your machine and in your system's `PATH`.
-
-## Usage
-_Go MySQL Driver_ is an implementation of Go's `database/sql/driver` interface. You only need to import the driver and can use the full [`database/sql`](http://golang.org/pkg/database/sql) API then.
-
-Use `mysql` as `driverName` and a valid [DSN](#dsn-data-source-name) as `dataSourceName`:
-```go
-import "database/sql"
-import _ "github.com/go-sql-driver/mysql"
-
-db, err := sql.Open("mysql", "user:password@/dbname")
-```
-
-[Examples are available in our Wiki](https://github.com/go-sql-driver/mysql/wiki/Examples "Go-MySQL-Driver Examples").
-
-
-### DSN (Data Source Name)
-
-The Data Source Name has a common format, like e.g. [PEAR DB](http://pear.php.net/manual/en/package.database.db.intro-dsn.php) uses it, but without type-prefix (optional parts marked by squared brackets):
-```
-[username[:password]@][protocol[(address)]]/dbname[?param1=value1&...&paramN=valueN]
-```
-
-A DSN in its fullest form:
-```
-username:password@protocol(address)/dbname?param=value
-```
-
-Except for the databasename, all values are optional. So the minimal DSN is:
-```
-/dbname
-```
-
-If you do not want to preselect a database, leave `dbname` empty:
-```
-/
-```
-This has the same effect as an empty DSN string:
-```
-
-```
-
-#### Password
-Passwords can consist of any character. Escaping is **not** necessary.
-
-#### Protocol
-See [net.Dial](http://golang.org/pkg/net/#Dial) for more information which networks are available.
-In general you should use an Unix domain socket if available and TCP otherwise for best performance.
-
-#### Address
-For TCP and UDP networks, addresses have the form `host:port`.
-If `host` is a literal IPv6 address, it must be enclosed in square brackets.
-The functions [net.JoinHostPort](http://golang.org/pkg/net/#JoinHostPort) and [net.SplitHostPort](http://golang.org/pkg/net/#SplitHostPort) manipulate addresses in this form.
-
-For Unix domain sockets the address is the absolute path to the MySQL-Server-socket, e.g. `/var/run/mysqld/mysqld.sock` or `/tmp/mysql.sock`.
-
-#### Parameters
-*Parameters are case-sensitive!*
-
-Notice that any of `true`, `TRUE`, `True` or `1` is accepted to stand for a true boolean value. Not surprisingly, false can be specified as any of: `false`, `FALSE`, `False` or `0`.
-
-##### `allowAllFiles`
-
-```
-Type: bool
-Valid Values: true, false
-Default: false
-```
-
-`allowAllFiles=true` disables the file Whitelist for `LOAD DATA LOCAL INFILE` and allows *all* files.
-[*Might be insecure!*](http://dev.mysql.com/doc/refman/5.7/en/load-data-local.html)
-
-##### `allowCleartextPasswords`
-
-```
-Type: bool
-Valid Values: true, false
-Default: false
-```
-
-`allowCleartextPasswords=true` allows using the [cleartext client side plugin](http://dev.mysql.com/doc/en/cleartext-authentication-plugin.html) if required by an account, such as one defined with the [PAM authentication plugin](http://dev.mysql.com/doc/en/pam-authentication-plugin.html). Sending passwords in clear text may be a security problem in some configurations. To avoid problems if there is any possibility that the password would be intercepted, clients should connect to MySQL Server using a method that protects the password. Possibilities include [TLS / SSL](#tls), IPsec, or a private network.
-
-##### `allowOldPasswords`
-
-```
-Type: bool
-Valid Values: true, false
-Default: false
-```
-`allowOldPasswords=true` allows the usage of the insecure old password method. This should be avoided, but is necessary in some cases. See also [the old_passwords wiki page](https://github.com/go-sql-driver/mysql/wiki/old_passwords).
-
-##### `charset`
-
-```
-Type: string
-Valid Values: <name>
-Default: none
-```
-
-Sets the charset used for client-server interaction (`"SET NAMES <value>"`). If multiple charsets are set (separated by a comma), the following charset is used if setting the charset failes. This enables for example support for `utf8mb4` ([introduced in MySQL 5.5.3](http://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html)) with fallback to `utf8` for older servers (`charset=utf8mb4,utf8`).
-
-Usage of the `charset` parameter is discouraged because it issues additional queries to the server.
-Unless you need the fallback behavior, please use `collation` instead.
-
-##### `collation`
-
-```
-Type: string
-Valid Values: <name>
-Default: utf8_general_ci
-```
-
-Sets the collation used for client-server interaction on connection. In contrast to `charset`, `collation` does not issue additional queries. If the specified collation is unavailable on the target server, the connection will fail.
-
-A list of valid charsets for a server is retrievable with `SHOW COLLATION`.
-
-##### `clientFoundRows`
-
-```
-Type: bool
-Valid Values: true, false
-Default: false
-```
-
-`clientFoundRows=true` causes an UPDATE to return the number of matching rows instead of the number of rows changed.
-
-##### `columnsWithAlias`
-
-```
-Type: bool
-Valid Values: true, false
-Default: false
-```
-
-When `columnsWithAlias` is true, calls to `sql.Rows.Columns()` will return the table alias and the column name separated by a dot. For example:
-
-```
-SELECT u.id FROM users as u
-```
-
-will return `u.id` instead of just `id` if `columnsWithAlias=true`.
-
-##### `interpolateParams`
-
-```
-Type: bool
-Valid Values: true, false
-Default: false
-```
-
-If `interpolateParams` is true, placeholders (`?`) in calls to `db.Query()` and `db.Exec()` are interpolated into a single query string with given parameters. This reduces the number of roundtrips, since the driver has to prepare a statement, execute it with given parameters and close the statement again with `interpolateParams=false`.
-
-*This can not be used together with the multibyte encodings BIG5, CP932, GB2312, GBK or SJIS. These are blacklisted as they may [introduce a SQL injection vulnerability](http://stackoverflow.com/a/12118602/3430118)!*
-
-##### `loc`
-
-```
-Type: string
-Valid Values: <escaped name>
-Default: UTC
-```
-
-Sets the location for time.Time values (when using `parseTime=true`). *"Local"* sets the system's location. See [time.LoadLocation](http://golang.org/pkg/time/#LoadLocation) for details.
-
-Note that this sets the location for time.Time values but does not change MySQL's [time_zone setting](https://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html). For that see the [time_zone system variable](#system-variables), which can also be set as a DSN parameter.
-
-Please keep in mind, that param values must be [url.QueryEscape](http://golang.org/pkg/net/url/#QueryEscape)'ed. Alternatively you can manually replace the `/` with `%2F`. For example `US/Pacific` would be `loc=US%2FPacific`.
-
-
-##### `parseTime`
-
-```
-Type: bool
-Valid Values: true, false
-Default: false
-```
-
-`parseTime=true` changes the output type of `DATE` and `DATETIME` values to `time.Time` instead of `[]byte` / `string`
-
-
-##### `strict`
-
-```
-Type: bool
-Valid Values: true, false
-Default: false
-```
-
-`strict=true` enables the strict mode in which MySQL warnings are treated as errors.
-
-By default MySQL also treats notes as warnings. Use [`sql_notes=false`](http://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_sql_notes) to ignore notes. See the [examples](#examples) for an DSN example.
-
-
-##### `timeout`
-
-```
-Type: decimal number
-Default: OS default
-```
-
-*Driver* side connection timeout. The value must be a string of decimal numbers, each with optional fraction and a unit suffix ( *"ms"*, *"s"*, *"m"*, *"h"* ), such as *"30s"*, *"0.5m"* or *"1m30s"*. To set a server side timeout, use the parameter [`wait_timeout`](http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_wait_timeout).
-
-
-##### `tls`
-
-```
-Type: bool / string
-Valid Values: true, false, skip-verify, <name>
-Default: false
-```
-
-`tls=true` enables TLS / SSL encrypted connection to the server. Use `skip-verify` if you want to use a self-signed or invalid certificate (server side). Use a custom value registered with [`mysql.RegisterTLSConfig`](http://godoc.org/github.com/go-sql-driver/mysql#RegisterTLSConfig).
-
-
-##### System Variables
-
-All other parameters are interpreted as system variables:
- * `autocommit`: `"SET autocommit=<value>"`
- * [`time_zone`](https://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html): `"SET time_zone=<value>"`
- * [`tx_isolation`](https://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_tx_isolation): `"SET tx_isolation=<value>"`
- * `param`: `"SET <param>=<value>"`
-
-*The values must be [url.QueryEscape](http://golang.org/pkg/net/url/#QueryEscape)'ed!*
-
-#### Examples
-```
-user@unix(/path/to/socket)/dbname
-```
-
-```
-root:pw@unix(/tmp/mysql.sock)/myDatabase?loc=Local
-```
-
-```
-user:password@tcp(localhost:5555)/dbname?tls=skip-verify&autocommit=true
-```
-
-Use the [strict mode](#strict) but ignore notes:
-```
-user:password@/dbname?strict=true&sql_notes=false
-```
-
-TCP via IPv6:
-```
-user:password@tcp([de:ad:be:ef::ca:fe]:80)/dbname?timeout=90s&collation=utf8mb4_unicode_ci
-```
-
-TCP on a remote host, e.g. Amazon RDS:
-```
-id:password@tcp(your-amazonaws-uri.com:3306)/dbname
-```
-
-Google Cloud SQL on App Engine:
-```
-user@cloudsql(project-id:instance-name)/dbname
-```
-
-TCP using default port (3306) on localhost:
-```
-user:password@tcp/dbname?charset=utf8mb4,utf8&sys_var=esc%40ped
-```
-
-Use the default protocol (tcp) and host (localhost:3306):
-```
-user:password@/dbname
-```
-
-No Database preselected:
-```
-user:password@/
-```
-
-### `LOAD DATA LOCAL INFILE` support
-For this feature you need direct access to the package. Therefore you must change the import path (no `_`):
-```go
-import "github.com/go-sql-driver/mysql"
-```
-
-Files must be whitelisted by registering them with `mysql.RegisterLocalFile(filepath)` (recommended) or the Whitelist check must be deactivated by using the DSN parameter `allowAllFiles=true` ([*Might be insecure!*](http://dev.mysql.com/doc/refman/5.7/en/load-data-local.html)).
-
-To use a `io.Reader` a handler function must be registered with `mysql.RegisterReaderHandler(name, handler)` which returns a `io.Reader` or `io.ReadCloser`. The Reader is available with the filepath `Reader::<name>` then. Choose different names for different handlers and `DeregisterReaderHandler` when you don't need it anymore.
-
-See the [godoc of Go-MySQL-Driver](http://godoc.org/github.com/go-sql-driver/mysql "golang mysql driver documentation") for details.
-
-
-### `time.Time` support
-The default internal output type of MySQL `DATE` and `DATETIME` values is `[]byte` which allows you to scan the value into a `[]byte`, `string` or `sql.RawBytes` variable in your programm.
-
-However, many want to scan MySQL `DATE` and `DATETIME` values into `time.Time` variables, which is the logical opposite in Go to `DATE` and `DATETIME` in MySQL. You can do that by changing the internal output type from `[]byte` to `time.Time` with the DSN parameter `parseTime=true`. You can set the default [`time.Time` location](http://golang.org/pkg/time/#Location) with the `loc` DSN parameter.
-
-**Caution:** As of Go 1.1, this makes `time.Time` the only variable type you can scan `DATE` and `DATETIME` values into. This breaks for example [`sql.RawBytes` support](https://github.com/go-sql-driver/mysql/wiki/Examples#rawbytes).
-
-Alternatively you can use the [`NullTime`](http://godoc.org/github.com/go-sql-driver/mysql#NullTime) type as the scan destination, which works with both `time.Time` and `string` / `[]byte`.
-
-
-### Unicode support
-Since version 1.1 Go-MySQL-Driver automatically uses the collation `utf8_general_ci` by default.
-
-Other collations / charsets can be set using the [`collation`](#collation) DSN parameter.
-
-Version 1.0 of the driver recommended adding `&charset=utf8` (alias for `SET NAMES utf8`) to the DSN to enable proper UTF-8 support. This is not necessary anymore. The [`collation`](#collation) parameter should be preferred to set another collation / charset than the default.
-
-See http://dev.mysql.com/doc/refman/5.7/en/charset-unicode.html for more details on MySQL's Unicode support.
-
-
-## Testing / Development
-To run the driver tests you may need to adjust the configuration. See the [Testing Wiki-Page](https://github.com/go-sql-driver/mysql/wiki/Testing "Testing") for details.
-
-Go-MySQL-Driver is not feature-complete yet. Your help is very appreciated.
-If you want to contribute, you can work on an [open issue](https://github.com/go-sql-driver/mysql/issues?state=open) or review a [pull request](https://github.com/go-sql-driver/mysql/pulls).
-
-See the [Contribution Guidelines](https://github.com/go-sql-driver/mysql/blob/master/CONTRIBUTING.md) for details.
-
----------------------------------------
-
-## License
-Go-MySQL-Driver is licensed under the [Mozilla Public License Version 2.0](https://raw.github.com/go-sql-driver/mysql/master/LICENSE)
-
-Mozilla summarizes the license scope as follows:
-> MPL: The copyleft applies to any files containing MPLed code.
-
-
-That means:
- * You can **use** the **unchanged** source code both in private and commercially
- * When distributing, you **must publish** the source code of any **changed files** licensed under the MPL 2.0 under a) the MPL 2.0 itself or b) a compatible license (e.g. GPL 3.0 or Apache License 2.0)
- * You **needn't publish** the source code of your library as long as the files licensed under the MPL 2.0 are **unchanged**
-
-Please read the [MPL 2.0 FAQ](http://www.mozilla.org/MPL/2.0/FAQ.html) if you have further questions regarding the license.
-
-You can read the full terms here: [LICENSE](https://raw.github.com/go-sql-driver/mysql/master/LICENSE)
-
-![Go Gopher and MySQL Dolphin](https://raw.github.com/wiki/go-sql-driver/mysql/go-mysql-driver_m.jpg "Golang Gopher transporting the MySQL Dolphin in a wheelbarrow")
-
diff --git a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/appengine.go b/Godeps/_workspace/src/github.com/go-sql-driver/mysql/appengine.go
deleted file mode 100644
index 565614eef..000000000
--- a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/appengine.go
+++ /dev/null
@@ -1,19 +0,0 @@
-// Go MySQL Driver - A MySQL-Driver for Go's database/sql package
-//
-// Copyright 2013 The Go-MySQL-Driver Authors. All rights reserved.
-//
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this file,
-// You can obtain one at http://mozilla.org/MPL/2.0/.
-
-// +build appengine
-
-package mysql
-
-import (
- "appengine/cloudsql"
-)
-
-func init() {
- RegisterDial("cloudsql", cloudsql.Dial)
-}
diff --git a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/buffer.go b/Godeps/_workspace/src/github.com/go-sql-driver/mysql/buffer.go
deleted file mode 100644
index 509ce89e4..000000000
--- a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/buffer.go
+++ /dev/null
@@ -1,136 +0,0 @@
-// Go MySQL Driver - A MySQL-Driver for Go's database/sql package
-//
-// Copyright 2013 The Go-MySQL-Driver Authors. All rights reserved.
-//
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this file,
-// You can obtain one at http://mozilla.org/MPL/2.0/.
-
-package mysql
-
-import "io"
-
-const defaultBufSize = 4096
-
-// A buffer which is used for both reading and writing.
-// This is possible since communication on each connection is synchronous.
-// In other words, we can't write and read simultaneously on the same connection.
-// The buffer is similar to bufio.Reader / Writer but zero-copy-ish
-// Also highly optimized for this particular use case.
-type buffer struct {
- buf []byte
- rd io.Reader
- idx int
- length int
-}
-
-func newBuffer(rd io.Reader) buffer {
- var b [defaultBufSize]byte
- return buffer{
- buf: b[:],
- rd: rd,
- }
-}
-
-// fill reads into the buffer until at least _need_ bytes are in it
-func (b *buffer) fill(need int) error {
- n := b.length
-
- // move existing data to the beginning
- if n > 0 && b.idx > 0 {
- copy(b.buf[0:n], b.buf[b.idx:])
- }
-
- // grow buffer if necessary
- // TODO: let the buffer shrink again at some point
- // Maybe keep the org buf slice and swap back?
- if need > len(b.buf) {
- // Round up to the next multiple of the default size
- newBuf := make([]byte, ((need/defaultBufSize)+1)*defaultBufSize)
- copy(newBuf, b.buf)
- b.buf = newBuf
- }
-
- b.idx = 0
-
- for {
- nn, err := b.rd.Read(b.buf[n:])
- n += nn
-
- switch err {
- case nil:
- if n < need {
- continue
- }
- b.length = n
- return nil
-
- case io.EOF:
- if n >= need {
- b.length = n
- return nil
- }
- return io.ErrUnexpectedEOF
-
- default:
- return err
- }
- }
-}
-
-// returns next N bytes from buffer.
-// The returned slice is only guaranteed to be valid until the next read
-func (b *buffer) readNext(need int) ([]byte, error) {
- if b.length < need {
- // refill
- if err := b.fill(need); err != nil {
- return nil, err
- }
- }
-
- offset := b.idx
- b.idx += need
- b.length -= need
- return b.buf[offset:b.idx], nil
-}
-
-// returns a buffer with the requested size.
-// If possible, a slice from the existing buffer is returned.
-// Otherwise a bigger buffer is made.
-// Only one buffer (total) can be used at a time.
-func (b *buffer) takeBuffer(length int) []byte {
- if b.length > 0 {
- return nil
- }
-
- // test (cheap) general case first
- if length <= defaultBufSize || length <= cap(b.buf) {
- return b.buf[:length]
- }
-
- if length < maxPacketSize {
- b.buf = make([]byte, length)
- return b.buf
- }
- return make([]byte, length)
-}
-
-// shortcut which can be used if the requested buffer is guaranteed to be
-// smaller than defaultBufSize
-// Only one buffer (total) can be used at a time.
-func (b *buffer) takeSmallBuffer(length int) []byte {
- if b.length == 0 {
- return b.buf[:length]
- }
- return nil
-}
-
-// takeCompleteBuffer returns the complete existing buffer.
-// This can be used if the necessary buffer size is unknown.
-// Only one buffer (total) can be used at a time.
-func (b *buffer) takeCompleteBuffer() []byte {
- if b.length == 0 {
- return b.buf
- }
- return nil
-}
diff --git a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/collations.go b/Godeps/_workspace/src/github.com/go-sql-driver/mysql/collations.go
deleted file mode 100644
index 6c1d613d5..000000000
--- a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/collations.go
+++ /dev/null
@@ -1,250 +0,0 @@
-// Go MySQL Driver - A MySQL-Driver for Go's database/sql package
-//
-// Copyright 2014 The Go-MySQL-Driver Authors. All rights reserved.
-//
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this file,
-// You can obtain one at http://mozilla.org/MPL/2.0/.
-
-package mysql
-
-const defaultCollation byte = 33 // utf8_general_ci
-
-// A list of available collations mapped to the internal ID.
-// To update this map use the following MySQL query:
-// SELECT COLLATION_NAME, ID FROM information_schema.COLLATIONS
-var collations = map[string]byte{
- "big5_chinese_ci": 1,
- "latin2_czech_cs": 2,
- "dec8_swedish_ci": 3,
- "cp850_general_ci": 4,
- "latin1_german1_ci": 5,
- "hp8_english_ci": 6,
- "koi8r_general_ci": 7,
- "latin1_swedish_ci": 8,
- "latin2_general_ci": 9,
- "swe7_swedish_ci": 10,
- "ascii_general_ci": 11,
- "ujis_japanese_ci": 12,
- "sjis_japanese_ci": 13,
- "cp1251_bulgarian_ci": 14,
- "latin1_danish_ci": 15,
- "hebrew_general_ci": 16,
- "tis620_thai_ci": 18,
- "euckr_korean_ci": 19,
- "latin7_estonian_cs": 20,
- "latin2_hungarian_ci": 21,
- "koi8u_general_ci": 22,
- "cp1251_ukrainian_ci": 23,
- "gb2312_chinese_ci": 24,
- "greek_general_ci": 25,
- "cp1250_general_ci": 26,
- "latin2_croatian_ci": 27,
- "gbk_chinese_ci": 28,
- "cp1257_lithuanian_ci": 29,
- "latin5_turkish_ci": 30,
- "latin1_german2_ci": 31,
- "armscii8_general_ci": 32,
- "utf8_general_ci": 33,
- "cp1250_czech_cs": 34,
- "ucs2_general_ci": 35,
- "cp866_general_ci": 36,
- "keybcs2_general_ci": 37,
- "macce_general_ci": 38,
- "macroman_general_ci": 39,
- "cp852_general_ci": 40,
- "latin7_general_ci": 41,
- "latin7_general_cs": 42,
- "macce_bin": 43,
- "cp1250_croatian_ci": 44,
- "utf8mb4_general_ci": 45,
- "utf8mb4_bin": 46,
- "latin1_bin": 47,
- "latin1_general_ci": 48,
- "latin1_general_cs": 49,
- "cp1251_bin": 50,
- "cp1251_general_ci": 51,
- "cp1251_general_cs": 52,
- "macroman_bin": 53,
- "utf16_general_ci": 54,
- "utf16_bin": 55,
- "utf16le_general_ci": 56,
- "cp1256_general_ci": 57,
- "cp1257_bin": 58,
- "cp1257_general_ci": 59,
- "utf32_general_ci": 60,
- "utf32_bin": 61,
- "utf16le_bin": 62,
- "binary": 63,
- "armscii8_bin": 64,
- "ascii_bin": 65,
- "cp1250_bin": 66,
- "cp1256_bin": 67,
- "cp866_bin": 68,
- "dec8_bin": 69,
- "greek_bin": 70,
- "hebrew_bin": 71,
- "hp8_bin": 72,
- "keybcs2_bin": 73,
- "koi8r_bin": 74,
- "koi8u_bin": 75,
- "latin2_bin": 77,
- "latin5_bin": 78,
- "latin7_bin": 79,
- "cp850_bin": 80,
- "cp852_bin": 81,
- "swe7_bin": 82,
- "utf8_bin": 83,
- "big5_bin": 84,
- "euckr_bin": 85,
- "gb2312_bin": 86,
- "gbk_bin": 87,
- "sjis_bin": 88,
- "tis620_bin": 89,
- "ucs2_bin": 90,
- "ujis_bin": 91,
- "geostd8_general_ci": 92,
- "geostd8_bin": 93,
- "latin1_spanish_ci": 94,
- "cp932_japanese_ci": 95,
- "cp932_bin": 96,
- "eucjpms_japanese_ci": 97,
- "eucjpms_bin": 98,
- "cp1250_polish_ci": 99,
- "utf16_unicode_ci": 101,
- "utf16_icelandic_ci": 102,
- "utf16_latvian_ci": 103,
- "utf16_romanian_ci": 104,
- "utf16_slovenian_ci": 105,
- "utf16_polish_ci": 106,
- "utf16_estonian_ci": 107,
- "utf16_spanish_ci": 108,
- "utf16_swedish_ci": 109,
- "utf16_turkish_ci": 110,
- "utf16_czech_ci": 111,
- "utf16_danish_ci": 112,
- "utf16_lithuanian_ci": 113,
- "utf16_slovak_ci": 114,
- "utf16_spanish2_ci": 115,
- "utf16_roman_ci": 116,
- "utf16_persian_ci": 117,
- "utf16_esperanto_ci": 118,
- "utf16_hungarian_ci": 119,
- "utf16_sinhala_ci": 120,
- "utf16_german2_ci": 121,
- "utf16_croatian_ci": 122,
- "utf16_unicode_520_ci": 123,
- "utf16_vietnamese_ci": 124,
- "ucs2_unicode_ci": 128,
- "ucs2_icelandic_ci": 129,
- "ucs2_latvian_ci": 130,
- "ucs2_romanian_ci": 131,
- "ucs2_slovenian_ci": 132,
- "ucs2_polish_ci": 133,
- "ucs2_estonian_ci": 134,
- "ucs2_spanish_ci": 135,
- "ucs2_swedish_ci": 136,
- "ucs2_turkish_ci": 137,
- "ucs2_czech_ci": 138,
- "ucs2_danish_ci": 139,
- "ucs2_lithuanian_ci": 140,
- "ucs2_slovak_ci": 141,
- "ucs2_spanish2_ci": 142,
- "ucs2_roman_ci": 143,
- "ucs2_persian_ci": 144,
- "ucs2_esperanto_ci": 145,
- "ucs2_hungarian_ci": 146,
- "ucs2_sinhala_ci": 147,
- "ucs2_german2_ci": 148,
- "ucs2_croatian_ci": 149,
- "ucs2_unicode_520_ci": 150,
- "ucs2_vietnamese_ci": 151,
- "ucs2_general_mysql500_ci": 159,
- "utf32_unicode_ci": 160,
- "utf32_icelandic_ci": 161,
- "utf32_latvian_ci": 162,
- "utf32_romanian_ci": 163,
- "utf32_slovenian_ci": 164,
- "utf32_polish_ci": 165,
- "utf32_estonian_ci": 166,
- "utf32_spanish_ci": 167,
- "utf32_swedish_ci": 168,
- "utf32_turkish_ci": 169,
- "utf32_czech_ci": 170,
- "utf32_danish_ci": 171,
- "utf32_lithuanian_ci": 172,
- "utf32_slovak_ci": 173,
- "utf32_spanish2_ci": 174,
- "utf32_roman_ci": 175,
- "utf32_persian_ci": 176,
- "utf32_esperanto_ci": 177,
- "utf32_hungarian_ci": 178,
- "utf32_sinhala_ci": 179,
- "utf32_german2_ci": 180,
- "utf32_croatian_ci": 181,
- "utf32_unicode_520_ci": 182,
- "utf32_vietnamese_ci": 183,
- "utf8_unicode_ci": 192,
- "utf8_icelandic_ci": 193,
- "utf8_latvian_ci": 194,
- "utf8_romanian_ci": 195,
- "utf8_slovenian_ci": 196,
- "utf8_polish_ci": 197,
- "utf8_estonian_ci": 198,
- "utf8_spanish_ci": 199,
- "utf8_swedish_ci": 200,
- "utf8_turkish_ci": 201,
- "utf8_czech_ci": 202,
- "utf8_danish_ci": 203,
- "utf8_lithuanian_ci": 204,
- "utf8_slovak_ci": 205,
- "utf8_spanish2_ci": 206,
- "utf8_roman_ci": 207,
- "utf8_persian_ci": 208,
- "utf8_esperanto_ci": 209,
- "utf8_hungarian_ci": 210,
- "utf8_sinhala_ci": 211,
- "utf8_german2_ci": 212,
- "utf8_croatian_ci": 213,
- "utf8_unicode_520_ci": 214,
- "utf8_vietnamese_ci": 215,
- "utf8_general_mysql500_ci": 223,
- "utf8mb4_unicode_ci": 224,
- "utf8mb4_icelandic_ci": 225,
- "utf8mb4_latvian_ci": 226,
- "utf8mb4_romanian_ci": 227,
- "utf8mb4_slovenian_ci": 228,
- "utf8mb4_polish_ci": 229,
- "utf8mb4_estonian_ci": 230,
- "utf8mb4_spanish_ci": 231,
- "utf8mb4_swedish_ci": 232,
- "utf8mb4_turkish_ci": 233,
- "utf8mb4_czech_ci": 234,
- "utf8mb4_danish_ci": 235,
- "utf8mb4_lithuanian_ci": 236,
- "utf8mb4_slovak_ci": 237,
- "utf8mb4_spanish2_ci": 238,
- "utf8mb4_roman_ci": 239,
- "utf8mb4_persian_ci": 240,
- "utf8mb4_esperanto_ci": 241,
- "utf8mb4_hungarian_ci": 242,
- "utf8mb4_sinhala_ci": 243,
- "utf8mb4_german2_ci": 244,
- "utf8mb4_croatian_ci": 245,
- "utf8mb4_unicode_520_ci": 246,
- "utf8mb4_vietnamese_ci": 247,
-}
-
-// A blacklist of collations which is unsafe to interpolate parameters.
-// These multibyte encodings may contains 0x5c (`\`) in their trailing bytes.
-var unsafeCollations = map[byte]bool{
- 1: true, // big5_chinese_ci
- 13: true, // sjis_japanese_ci
- 28: true, // gbk_chinese_ci
- 84: true, // big5_bin
- 86: true, // gb2312_bin
- 87: true, // gbk_bin
- 88: true, // sjis_bin
- 95: true, // cp932_japanese_ci
- 96: true, // cp932_bin
-}
diff --git a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/connection.go b/Godeps/_workspace/src/github.com/go-sql-driver/mysql/connection.go
deleted file mode 100644
index 72ed09d69..000000000
--- a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/connection.go
+++ /dev/null
@@ -1,403 +0,0 @@
-// Go MySQL Driver - A MySQL-Driver for Go's database/sql package
-//
-// Copyright 2012 The Go-MySQL-Driver Authors. All rights reserved.
-//
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this file,
-// You can obtain one at http://mozilla.org/MPL/2.0/.
-
-package mysql
-
-import (
- "crypto/tls"
- "database/sql/driver"
- "errors"
- "net"
- "strconv"
- "strings"
- "time"
-)
-
-type mysqlConn struct {
- buf buffer
- netConn net.Conn
- affectedRows uint64
- insertId uint64
- cfg *config
- maxPacketAllowed int
- maxWriteSize int
- flags clientFlag
- status statusFlag
- sequence uint8
- parseTime bool
- strict bool
-}
-
-type config struct {
- user string
- passwd string
- net string
- addr string
- dbname string
- params map[string]string
- loc *time.Location
- tls *tls.Config
- timeout time.Duration
- collation uint8
- allowAllFiles bool
- allowOldPasswords bool
- allowCleartextPasswords bool
- clientFoundRows bool
- columnsWithAlias bool
- interpolateParams bool
-}
-
-// Handles parameters set in DSN after the connection is established
-func (mc *mysqlConn) handleParams() (err error) {
- for param, val := range mc.cfg.params {
- switch param {
- // Charset
- case "charset":
- charsets := strings.Split(val, ",")
- for i := range charsets {
- // ignore errors here - a charset may not exist
- err = mc.exec("SET NAMES " + charsets[i])
- if err == nil {
- break
- }
- }
- if err != nil {
- return
- }
-
- // time.Time parsing
- case "parseTime":
- var isBool bool
- mc.parseTime, isBool = readBool(val)
- if !isBool {
- return errors.New("Invalid Bool value: " + val)
- }
-
- // Strict mode
- case "strict":
- var isBool bool
- mc.strict, isBool = readBool(val)
- if !isBool {
- return errors.New("Invalid Bool value: " + val)
- }
-
- // Compression
- case "compress":
- err = errors.New("Compression not implemented yet")
- return
-
- // System Vars
- default:
- err = mc.exec("SET " + param + "=" + val + "")
- if err != nil {
- return
- }
- }
- }
-
- return
-}
-
-func (mc *mysqlConn) Begin() (driver.Tx, error) {
- if mc.netConn == nil {
- errLog.Print(ErrInvalidConn)
- return nil, driver.ErrBadConn
- }
- err := mc.exec("START TRANSACTION")
- if err == nil {
- return &mysqlTx{mc}, err
- }
-
- return nil, err
-}
-
-func (mc *mysqlConn) Close() (err error) {
- // Makes Close idempotent
- if mc.netConn != nil {
- err = mc.writeCommandPacket(comQuit)
- if err == nil {
- err = mc.netConn.Close()
- } else {
- mc.netConn.Close()
- }
- mc.netConn = nil
- }
-
- mc.cfg = nil
- mc.buf.rd = nil
-
- return
-}
-
-func (mc *mysqlConn) Prepare(query string) (driver.Stmt, error) {
- if mc.netConn == nil {
- errLog.Print(ErrInvalidConn)
- return nil, driver.ErrBadConn
- }
- // Send command
- err := mc.writeCommandPacketStr(comStmtPrepare, query)
- if err != nil {
- return nil, err
- }
-
- stmt := &mysqlStmt{
- mc: mc,
- }
-
- // Read Result
- columnCount, err := stmt.readPrepareResultPacket()
- if err == nil {
- if stmt.paramCount > 0 {
- if err = mc.readUntilEOF(); err != nil {
- return nil, err
- }
- }
-
- if columnCount > 0 {
- err = mc.readUntilEOF()
- }
- }
-
- return stmt, err
-}
-
-func (mc *mysqlConn) interpolateParams(query string, args []driver.Value) (string, error) {
- buf := mc.buf.takeCompleteBuffer()
- if buf == nil {
- // can not take the buffer. Something must be wrong with the connection
- errLog.Print(ErrBusyBuffer)
- return "", driver.ErrBadConn
- }
- buf = buf[:0]
- argPos := 0
-
- for i := 0; i < len(query); i++ {
- q := strings.IndexByte(query[i:], '?')
- if q == -1 {
- buf = append(buf, query[i:]...)
- break
- }
- buf = append(buf, query[i:i+q]...)
- i += q
-
- arg := args[argPos]
- argPos++
-
- if arg == nil {
- buf = append(buf, "NULL"...)
- continue
- }
-
- switch v := arg.(type) {
- case int64:
- buf = strconv.AppendInt(buf, v, 10)
- case float64:
- buf = strconv.AppendFloat(buf, v, 'g', -1, 64)
- case bool:
- if v {
- buf = append(buf, '1')
- } else {
- buf = append(buf, '0')
- }
- case time.Time:
- if v.IsZero() {
- buf = append(buf, "'0000-00-00'"...)
- } else {
- v := v.In(mc.cfg.loc)
- v = v.Add(time.Nanosecond * 500) // To round under microsecond
- year := v.Year()
- year100 := year / 100
- year1 := year % 100
- month := v.Month()
- day := v.Day()
- hour := v.Hour()
- minute := v.Minute()
- second := v.Second()
- micro := v.Nanosecond() / 1000
-
- buf = append(buf, []byte{
- '\'',
- digits10[year100], digits01[year100],
- digits10[year1], digits01[year1],
- '-',
- digits10[month], digits01[month],
- '-',
- digits10[day], digits01[day],
- ' ',
- digits10[hour], digits01[hour],
- ':',
- digits10[minute], digits01[minute],
- ':',
- digits10[second], digits01[second],
- }...)
-
- if micro != 0 {
- micro10000 := micro / 10000
- micro100 := micro / 100 % 100
- micro1 := micro % 100
- buf = append(buf, []byte{
- '.',
- digits10[micro10000], digits01[micro10000],
- digits10[micro100], digits01[micro100],
- digits10[micro1], digits01[micro1],
- }...)
- }
- buf = append(buf, '\'')
- }
- case []byte:
- if v == nil {
- buf = append(buf, "NULL"...)
- } else {
- buf = append(buf, "_binary'"...)
- if mc.status&statusNoBackslashEscapes == 0 {
- buf = escapeBytesBackslash(buf, v)
- } else {
- buf = escapeBytesQuotes(buf, v)
- }
- buf = append(buf, '\'')
- }
- case string:
- buf = append(buf, '\'')
- if mc.status&statusNoBackslashEscapes == 0 {
- buf = escapeStringBackslash(buf, v)
- } else {
- buf = escapeStringQuotes(buf, v)
- }
- buf = append(buf, '\'')
- default:
- return "", driver.ErrSkip
- }
-
- if len(buf)+4 > mc.maxPacketAllowed {
- return "", driver.ErrSkip
- }
- }
- if argPos != len(args) {
- return "", driver.ErrSkip
- }
- return string(buf), nil
-}
-
-func (mc *mysqlConn) Exec(query string, args []driver.Value) (driver.Result, error) {
- if mc.netConn == nil {
- errLog.Print(ErrInvalidConn)
- return nil, driver.ErrBadConn
- }
- if len(args) != 0 {
- if !mc.cfg.interpolateParams {
- return nil, driver.ErrSkip
- }
- // try to interpolate the parameters to save extra roundtrips for preparing and closing a statement
- prepared, err := mc.interpolateParams(query, args)
- if err != nil {
- return nil, err
- }
- query = prepared
- args = nil
- }
- mc.affectedRows = 0
- mc.insertId = 0
-
- err := mc.exec(query)
- if err == nil {
- return &mysqlResult{
- affectedRows: int64(mc.affectedRows),
- insertId: int64(mc.insertId),
- }, err
- }
- return nil, err
-}
-
-// Internal function to execute commands
-func (mc *mysqlConn) exec(query string) error {
- // Send command
- err := mc.writeCommandPacketStr(comQuery, query)
- if err != nil {
- return err
- }
-
- // Read Result
- resLen, err := mc.readResultSetHeaderPacket()
- if err == nil && resLen > 0 {
- if err = mc.readUntilEOF(); err != nil {
- return err
- }
-
- err = mc.readUntilEOF()
- }
-
- return err
-}
-
-func (mc *mysqlConn) Query(query string, args []driver.Value) (driver.Rows, error) {
- if mc.netConn == nil {
- errLog.Print(ErrInvalidConn)
- return nil, driver.ErrBadConn
- }
- if len(args) != 0 {
- if !mc.cfg.interpolateParams {
- return nil, driver.ErrSkip
- }
- // try client-side prepare to reduce roundtrip
- prepared, err := mc.interpolateParams(query, args)
- if err != nil {
- return nil, err
- }
- query = prepared
- args = nil
- }
- // Send command
- err := mc.writeCommandPacketStr(comQuery, query)
- if err == nil {
- // Read Result
- var resLen int
- resLen, err = mc.readResultSetHeaderPacket()
- if err == nil {
- rows := new(textRows)
- rows.mc = mc
-
- if resLen == 0 {
- // no columns, no more data
- return emptyRows{}, nil
- }
- // Columns
- rows.columns, err = mc.readColumns(resLen)
- return rows, err
- }
- }
- return nil, err
-}
-
-// Gets the value of the given MySQL System Variable
-// The returned byte slice is only valid until the next read
-func (mc *mysqlConn) getSystemVar(name string) ([]byte, error) {
- // Send command
- if err := mc.writeCommandPacketStr(comQuery, "SELECT @@"+name); err != nil {
- return nil, err
- }
-
- // Read Result
- resLen, err := mc.readResultSetHeaderPacket()
- if err == nil {
- rows := new(textRows)
- rows.mc = mc
-
- if resLen > 0 {
- // Columns
- if err := mc.readUntilEOF(); err != nil {
- return nil, err
- }
- }
-
- dest := make([]driver.Value, resLen)
- if err = rows.readRow(dest); err == nil {
- return dest[0].([]byte), mc.readUntilEOF()
- }
- }
- return nil, err
-}
diff --git a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/const.go b/Godeps/_workspace/src/github.com/go-sql-driver/mysql/const.go
deleted file mode 100644
index dddc12908..000000000
--- a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/const.go
+++ /dev/null
@@ -1,162 +0,0 @@
-// Go MySQL Driver - A MySQL-Driver for Go's database/sql package
-//
-// Copyright 2012 The Go-MySQL-Driver Authors. All rights reserved.
-//
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this file,
-// You can obtain one at http://mozilla.org/MPL/2.0/.
-
-package mysql
-
-const (
- minProtocolVersion byte = 10
- maxPacketSize = 1<<24 - 1
- timeFormat = "2006-01-02 15:04:05.999999"
-)
-
-// MySQL constants documentation:
-// http://dev.mysql.com/doc/internals/en/client-server-protocol.html
-
-const (
- iOK byte = 0x00
- iLocalInFile byte = 0xfb
- iEOF byte = 0xfe
- iERR byte = 0xff
-)
-
-// https://dev.mysql.com/doc/internals/en/capability-flags.html#packet-Protocol::CapabilityFlags
-type clientFlag uint32
-
-const (
- clientLongPassword clientFlag = 1 << iota
- clientFoundRows
- clientLongFlag
- clientConnectWithDB
- clientNoSchema
- clientCompress
- clientODBC
- clientLocalFiles
- clientIgnoreSpace
- clientProtocol41
- clientInteractive
- clientSSL
- clientIgnoreSIGPIPE
- clientTransactions
- clientReserved
- clientSecureConn
- clientMultiStatements
- clientMultiResults
- clientPSMultiResults
- clientPluginAuth
- clientConnectAttrs
- clientPluginAuthLenEncClientData
- clientCanHandleExpiredPasswords
- clientSessionTrack
- clientDeprecateEOF
-)
-
-const (
- comQuit byte = iota + 1
- comInitDB
- comQuery
- comFieldList
- comCreateDB
- comDropDB
- comRefresh
- comShutdown
- comStatistics
- comProcessInfo
- comConnect
- comProcessKill
- comDebug
- comPing
- comTime
- comDelayedInsert
- comChangeUser
- comBinlogDump
- comTableDump
- comConnectOut
- comRegisterSlave
- comStmtPrepare
- comStmtExecute
- comStmtSendLongData
- comStmtClose
- comStmtReset
- comSetOption
- comStmtFetch
-)
-
-// https://dev.mysql.com/doc/internals/en/com-query-response.html#packet-Protocol::ColumnType
-const (
- fieldTypeDecimal byte = iota
- fieldTypeTiny
- fieldTypeShort
- fieldTypeLong
- fieldTypeFloat
- fieldTypeDouble
- fieldTypeNULL
- fieldTypeTimestamp
- fieldTypeLongLong
- fieldTypeInt24
- fieldTypeDate
- fieldTypeTime
- fieldTypeDateTime
- fieldTypeYear
- fieldTypeNewDate
- fieldTypeVarChar
- fieldTypeBit
-)
-const (
- fieldTypeNewDecimal byte = iota + 0xf6
- fieldTypeEnum
- fieldTypeSet
- fieldTypeTinyBLOB
- fieldTypeMediumBLOB
- fieldTypeLongBLOB
- fieldTypeBLOB
- fieldTypeVarString
- fieldTypeString
- fieldTypeGeometry
-)
-
-type fieldFlag uint16
-
-const (
- flagNotNULL fieldFlag = 1 << iota
- flagPriKey
- flagUniqueKey
- flagMultipleKey
- flagBLOB
- flagUnsigned
- flagZeroFill
- flagBinary
- flagEnum
- flagAutoIncrement
- flagTimestamp
- flagSet
- flagUnknown1
- flagUnknown2
- flagUnknown3
- flagUnknown4
-)
-
-// http://dev.mysql.com/doc/internals/en/status-flags.html
-type statusFlag uint16
-
-const (
- statusInTrans statusFlag = 1 << iota
- statusInAutocommit
- statusReserved // Not in documentation
- statusMoreResultsExists
- statusNoGoodIndexUsed
- statusNoIndexUsed
- statusCursorExists
- statusLastRowSent
- statusDbDropped
- statusNoBackslashEscapes
- statusMetadataChanged
- statusQueryWasSlow
- statusPsOutParams
- statusInTransReadonly
- statusSessionStateChanged
-)
diff --git a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/driver.go b/Godeps/_workspace/src/github.com/go-sql-driver/mysql/driver.go
deleted file mode 100644
index d310624ad..000000000
--- a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/driver.go
+++ /dev/null
@@ -1,149 +0,0 @@
-// Copyright 2012 The Go-MySQL-Driver Authors. All rights reserved.
-//
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this file,
-// You can obtain one at http://mozilla.org/MPL/2.0/.
-
-// Go MySQL Driver - A MySQL-Driver for Go's database/sql package
-//
-// The driver should be used via the database/sql package:
-//
-// import "database/sql"
-// import _ "github.com/go-sql-driver/mysql"
-//
-// db, err := sql.Open("mysql", "user:password@/dbname")
-//
-// See https://github.com/go-sql-driver/mysql#usage for details
-package mysql
-
-import (
- "database/sql"
- "database/sql/driver"
- "net"
-)
-
-// This struct is exported to make the driver directly accessible.
-// In general the driver is used via the database/sql package.
-type MySQLDriver struct{}
-
-// DialFunc is a function which can be used to establish the network connection.
-// Custom dial functions must be registered with RegisterDial
-type DialFunc func(addr string) (net.Conn, error)
-
-var dials map[string]DialFunc
-
-// RegisterDial registers a custom dial function. It can then be used by the
-// network address mynet(addr), where mynet is the registered new network.
-// addr is passed as a parameter to the dial function.
-func RegisterDial(net string, dial DialFunc) {
- if dials == nil {
- dials = make(map[string]DialFunc)
- }
- dials[net] = dial
-}
-
-// Open new Connection.
-// See https://github.com/go-sql-driver/mysql#dsn-data-source-name for how
-// the DSN string is formated
-func (d MySQLDriver) Open(dsn string) (driver.Conn, error) {
- var err error
-
- // New mysqlConn
- mc := &mysqlConn{
- maxPacketAllowed: maxPacketSize,
- maxWriteSize: maxPacketSize - 1,
- }
- mc.cfg, err = parseDSN(dsn)
- if err != nil {
- return nil, err
- }
-
- // Connect to Server
- if dial, ok := dials[mc.cfg.net]; ok {
- mc.netConn, err = dial(mc.cfg.addr)
- } else {
- nd := net.Dialer{Timeout: mc.cfg.timeout}
- mc.netConn, err = nd.Dial(mc.cfg.net, mc.cfg.addr)
- }
- if err != nil {
- return nil, err
- }
-
- // Enable TCP Keepalives on TCP connections
- if tc, ok := mc.netConn.(*net.TCPConn); ok {
- if err := tc.SetKeepAlive(true); err != nil {
- // Don't send COM_QUIT before handshake.
- mc.netConn.Close()
- mc.netConn = nil
- return nil, err
- }
- }
-
- mc.buf = newBuffer(mc.netConn)
-
- // Reading Handshake Initialization Packet
- cipher, err := mc.readInitPacket()
- if err != nil {
- mc.Close()
- return nil, err
- }
-
- // Send Client Authentication Packet
- if err = mc.writeAuthPacket(cipher); err != nil {
- mc.Close()
- return nil, err
- }
-
- // Read Result Packet
- err = mc.readResultOK()
- if err != nil {
- // Retry with old authentication method, if allowed
- if mc.cfg != nil && mc.cfg.allowOldPasswords && err == ErrOldPassword {
- if err = mc.writeOldAuthPacket(cipher); err != nil {
- mc.Close()
- return nil, err
- }
- if err = mc.readResultOK(); err != nil {
- mc.Close()
- return nil, err
- }
- } else if mc.cfg != nil && mc.cfg.allowCleartextPasswords && err == ErrCleartextPassword {
- if err = mc.writeClearAuthPacket(); err != nil {
- mc.Close()
- return nil, err
- }
- if err = mc.readResultOK(); err != nil {
- mc.Close()
- return nil, err
- }
- } else {
- mc.Close()
- return nil, err
- }
-
- }
-
- // Get max allowed packet size
- maxap, err := mc.getSystemVar("max_allowed_packet")
- if err != nil {
- mc.Close()
- return nil, err
- }
- mc.maxPacketAllowed = stringToInt(maxap) - 1
- if mc.maxPacketAllowed < maxPacketSize {
- mc.maxWriteSize = mc.maxPacketAllowed
- }
-
- // Handle DSN Params
- err = mc.handleParams()
- if err != nil {
- mc.Close()
- return nil, err
- }
-
- return mc, nil
-}
-
-func init() {
- sql.Register("mysql", &MySQLDriver{})
-}
diff --git a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/errors.go b/Godeps/_workspace/src/github.com/go-sql-driver/mysql/errors.go
deleted file mode 100644
index 44cf30db6..000000000
--- a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/errors.go
+++ /dev/null
@@ -1,131 +0,0 @@
-// Go MySQL Driver - A MySQL-Driver for Go's database/sql package
-//
-// Copyright 2013 The Go-MySQL-Driver Authors. All rights reserved.
-//
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this file,
-// You can obtain one at http://mozilla.org/MPL/2.0/.
-
-package mysql
-
-import (
- "database/sql/driver"
- "errors"
- "fmt"
- "io"
- "log"
- "os"
-)
-
-// Various errors the driver might return. Can change between driver versions.
-var (
- ErrInvalidConn = errors.New("Invalid Connection")
- ErrMalformPkt = errors.New("Malformed Packet")
- ErrNoTLS = errors.New("TLS encryption requested but server does not support TLS")
- ErrOldPassword = errors.New("This user requires old password authentication. If you still want to use it, please add 'allowOldPasswords=1' to your DSN. See also https://github.com/go-sql-driver/mysql/wiki/old_passwords")
- ErrCleartextPassword = errors.New("This user requires clear text authentication. If you still want to use it, please add 'allowCleartextPasswords=1' to your DSN.")
- ErrUnknownPlugin = errors.New("The authentication plugin is not supported.")
- ErrOldProtocol = errors.New("MySQL-Server does not support required Protocol 41+")
- ErrPktSync = errors.New("Commands out of sync. You can't run this command now")
- ErrPktSyncMul = errors.New("Commands out of sync. Did you run multiple statements at once?")
- ErrPktTooLarge = errors.New("Packet for query is too large. You can change this value on the server by adjusting the 'max_allowed_packet' variable.")
- ErrBusyBuffer = errors.New("Busy buffer")
-)
-
-var errLog Logger = log.New(os.Stderr, "[MySQL] ", log.Ldate|log.Ltime|log.Lshortfile)
-
-// Logger is used to log critical error messages.
-type Logger interface {
- Print(v ...interface{})
-}
-
-// SetLogger is used to set the logger for critical errors.
-// The initial logger is os.Stderr.
-func SetLogger(logger Logger) error {
- if logger == nil {
- return errors.New("logger is nil")
- }
- errLog = logger
- return nil
-}
-
-// MySQLError is an error type which represents a single MySQL error
-type MySQLError struct {
- Number uint16
- Message string
-}
-
-func (me *MySQLError) Error() string {
- return fmt.Sprintf("Error %d: %s", me.Number, me.Message)
-}
-
-// MySQLWarnings is an error type which represents a group of one or more MySQL
-// warnings
-type MySQLWarnings []MySQLWarning
-
-func (mws MySQLWarnings) Error() string {
- var msg string
- for i, warning := range mws {
- if i > 0 {
- msg += "\r\n"
- }
- msg += fmt.Sprintf(
- "%s %s: %s",
- warning.Level,
- warning.Code,
- warning.Message,
- )
- }
- return msg
-}
-
-// MySQLWarning is an error type which represents a single MySQL warning.
-// Warnings are returned in groups only. See MySQLWarnings
-type MySQLWarning struct {
- Level string
- Code string
- Message string
-}
-
-func (mc *mysqlConn) getWarnings() (err error) {
- rows, err := mc.Query("SHOW WARNINGS", nil)
- if err != nil {
- return
- }
-
- var warnings = MySQLWarnings{}
- var values = make([]driver.Value, 3)
-
- for {
- err = rows.Next(values)
- switch err {
- case nil:
- warning := MySQLWarning{}
-
- if raw, ok := values[0].([]byte); ok {
- warning.Level = string(raw)
- } else {
- warning.Level = fmt.Sprintf("%s", values[0])
- }
- if raw, ok := values[1].([]byte); ok {
- warning.Code = string(raw)
- } else {
- warning.Code = fmt.Sprintf("%s", values[1])
- }
- if raw, ok := values[2].([]byte); ok {
- warning.Message = string(raw)
- } else {
- warning.Message = fmt.Sprintf("%s", values[0])
- }
-
- warnings = append(warnings, warning)
-
- case io.EOF:
- return warnings
-
- default:
- rows.Close()
- return
- }
- }
-}
diff --git a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/infile.go b/Godeps/_workspace/src/github.com/go-sql-driver/mysql/infile.go
deleted file mode 100644
index 84c53a99c..000000000
--- a/Godeps/_workspace/src/github.com/go-sql-driver/mysql/infile.go
+++ /dev/null
@@ -1,182 +0,0 @@
-// Go MySQL Driver - A MySQL-Driver for Go's database/sql package
-//
-// Copyright 2013 The Go-MySQL-Driver Authors. All rights reserved.
-//
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this file,
-// You can obtain one at http://mozilla.org/MPL/2.0/.
-
-package mysql
-
-import (
- "fmt"
- "io"
- "os"
- "strings"
- "sync"
-)
-
-var (
- fileRegister map[string]bool
- fileRegisterLock sync.RWMutex
- readerRegister map[string]func() io.Reader
- readerRegisterLock sync.RWMutex
-)
-
-// RegisterLocalFile adds the given file to the file whitelist,
-// so that it can be used by "LOAD DATA LOCAL INFILE <filepath>".