├── .dockerignore ├── .gitignore ├── .travis.yml ├── Dockerfile ├── LICENSE.md ├── Makefile ├── README.md ├── config └── config.go ├── docs ├── APIv1.md ├── APIv2.md ├── APIv2 │ ├── swagger-2.0.json │ └── swagger-2.0.yaml ├── Auth.md ├── BUILD.md ├── CONFIG.md ├── DEPLOY.md ├── JIM.md ├── LIBRARIES.md ├── MailHog.png ├── RELEASES.md └── example-auth ├── main.go ├── snapcraft.yaml └── vendor ├── github.com ├── gorilla │ ├── context │ │ ├── LICENSE │ │ ├── README.md │ │ ├── context.go │ │ └── doc.go │ ├── mux │ │ ├── LICENSE │ │ ├── README.md │ │ ├── context_gorilla.go │ │ ├── context_native.go │ │ ├── doc.go │ │ ├── mux.go │ │ ├── regexp.go │ │ └── route.go │ ├── pat │ │ ├── LICENSE │ │ ├── README.md │ │ ├── doc.go │ │ └── pat.go │ └── websocket │ │ ├── AUTHORS │ │ ├── LICENSE │ │ ├── README.md │ │ ├── client.go │ │ ├── client_clone.go │ │ ├── client_clone_legacy.go │ │ ├── compression.go │ │ ├── conn.go │ │ ├── conn_read.go │ │ ├── conn_read_legacy.go │ │ ├── doc.go │ │ ├── json.go │ │ ├── mask.go │ │ ├── mask_safe.go │ │ ├── prepared.go │ │ ├── server.go │ │ └── util.go ├── ian-kent │ ├── envconf │ │ ├── LICENSE.md │ │ ├── README.md │ │ └── envconf.go │ ├── go-log │ │ ├── LICENSE.md │ │ ├── appenders │ │ │ ├── appender.go │ │ │ ├── console.go │ │ │ ├── fluentd.go │ │ │ ├── multiple_appender.go │ │ │ ├── rollingfile.go │ │ │ ├── rollingfile_test.log │ │ │ └── rollingfile_test.log.1 │ │ ├── layout │ │ │ ├── basic.go │ │ │ ├── layout.go │ │ │ └── pattern.go │ │ ├── levels │ │ │ └── levels.go │ │ ├── log │ │ │ └── log.go │ │ └── logger │ │ │ └── logger.go │ ├── goose │ │ ├── LICENSE.md │ │ ├── README.md │ │ └── goose.go │ └── linkio │ │ ├── README.md │ │ └── linkio.go ├── jtolds │ └── gls │ │ ├── LICENSE │ │ ├── README.md │ │ ├── context.go │ │ ├── gen_sym.go │ │ ├── gid.go │ │ ├── id_pool.go │ │ ├── stack_tags.go │ │ ├── stack_tags_js.go │ │ └── stack_tags_main.go ├── mailhog │ ├── MailHog-Server │ │ ├── LICENSE.md │ │ ├── Makefile │ │ ├── README.md │ │ ├── api │ │ │ ├── api.go │ │ │ ├── v1.go │ │ │ └── v2.go │ │ ├── config │ │ │ └── config.go │ │ ├── main.go │ │ ├── monkey │ │ │ ├── jim.go │ │ │ └── monkey.go │ │ ├── smtp │ │ │ ├── session.go │ │ │ ├── session_test.go │ │ │ └── smtp.go │ │ └── websockets │ │ │ ├── connection.go │ │ │ └── hub.go │ ├── MailHog-UI │ │ ├── LICENSE.md │ │ ├── Makefile │ │ ├── README.md │ │ ├── assets │ │ │ └── assets.go │ │ ├── config │ │ │ └── config.go │ │ ├── main.go │ │ └── web │ │ │ └── web.go │ ├── data │ │ ├── LICENSE.md │ │ ├── README.md │ │ └── message.go │ ├── http │ │ ├── LICENSE.md │ │ ├── README.md │ │ └── server.go │ ├── mhsendmail │ │ ├── LICENSE.md │ │ └── cmd │ │ │ └── cmd.go │ ├── smtp │ │ ├── LICENSE.md │ │ ├── README.md │ │ ├── protocol.go │ │ ├── reply.go │ │ └── state.go │ └── storage │ │ ├── LICENSE.md │ │ ├── README.md │ │ ├── maildir.go │ │ ├── memory.go │ │ ├── mongodb.go │ │ └── storage.go ├── philhofer │ └── fwd │ │ ├── LICENSE.md │ │ ├── README.md │ │ ├── reader.go │ │ ├── writer.go │ │ ├── writer_appengine.go │ │ └── writer_unsafe.go ├── smartystreets │ ├── assertions │ │ ├── CONTRIBUTING.md │ │ ├── LICENSE.md │ │ ├── README.md │ │ ├── collections.go │ │ ├── doc.go │ │ ├── equality.go │ │ ├── filter.go │ │ ├── internal │ │ │ ├── go-render │ │ │ │ ├── LICENSE │ │ │ │ └── render │ │ │ │ │ └── render.go │ │ │ └── oglematchers │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── any_of.go │ │ │ │ ├── contains.go │ │ │ │ ├── deep_equals.go │ │ │ │ ├── equals.go │ │ │ │ ├── greater_or_equal.go │ │ │ │ ├── greater_than.go │ │ │ │ ├── less_or_equal.go │ │ │ │ ├── less_than.go │ │ │ │ ├── matcher.go │ │ │ │ ├── not.go │ │ │ │ └── transform_description.go │ │ ├── messages.go │ │ ├── panic.go │ │ ├── quantity.go │ │ ├── serializer.go │ │ ├── strings.go │ │ ├── time.go │ │ └── type.go │ └── goconvey │ │ ├── LICENSE.md │ │ └── convey │ │ ├── assertions.go │ │ ├── context.go │ │ ├── convey.goconvey │ │ ├── discovery.go │ │ ├── doc.go │ │ ├── gotest │ │ └── utils.go │ │ ├── init.go │ │ ├── nilReporter.go │ │ └── reporting │ │ ├── console.go │ │ ├── doc.go │ │ ├── dot.go │ │ ├── gotest.go │ │ ├── init.go │ │ ├── json.go │ │ ├── printer.go │ │ ├── problems.go │ │ ├── reporter.go │ │ ├── reporting.goconvey │ │ ├── reports.go │ │ ├── statistics.go │ │ └── story.go ├── spf13 │ └── pflag │ │ ├── LICENSE │ │ ├── README.md │ │ ├── bool.go │ │ ├── count.go │ │ ├── duration.go │ │ ├── flag.go │ │ ├── float32.go │ │ ├── float64.go │ │ ├── golangflag.go │ │ ├── int.go │ │ ├── int32.go │ │ ├── int64.go │ │ ├── int8.go │ │ ├── int_slice.go │ │ ├── ip.go │ │ ├── ipmask.go │ │ ├── ipnet.go │ │ ├── string.go │ │ ├── string_slice.go │ │ ├── uint.go │ │ ├── uint16.go │ │ ├── uint32.go │ │ ├── uint64.go │ │ └── uint8.go ├── t-k │ └── fluent-logger-golang │ │ ├── LICENSE │ │ └── fluent │ │ ├── fluent.go │ │ ├── proto.go │ │ ├── proto_gen.go │ │ └── version.go └── tinylib │ └── msgp │ ├── LICENSE │ └── msgp │ ├── advise_linux.go │ ├── advise_other.go │ ├── appengine.go │ ├── circular.go │ ├── defs.go │ ├── edit.go │ ├── elsize.go │ ├── errors.go │ ├── extension.go │ ├── file.go │ ├── file_port.go │ ├── integers.go │ ├── json.go │ ├── json_bytes.go │ ├── number.go │ ├── read.go │ ├── read_bytes.go │ ├── size.go │ ├── unsafe.go │ ├── write.go │ └── write_bytes.go ├── golang.org └── x │ └── crypto │ ├── LICENSE │ ├── PATENTS │ ├── bcrypt │ ├── base64.go │ └── bcrypt.go │ └── blowfish │ ├── block.go │ ├── cipher.go │ └── const.go ├── gopkg.in └── mgo.v2 │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── auth.go │ ├── bson │ ├── LICENSE │ ├── bson.go │ ├── decode.go │ └── encode.go │ ├── bulk.go │ ├── cluster.go │ ├── doc.go │ ├── gridfs.go │ ├── internal │ ├── sasl │ │ ├── sasl.c │ │ ├── sasl.go │ │ ├── sasl_windows.c │ │ ├── sasl_windows.go │ │ ├── sasl_windows.h │ │ ├── sspi_windows.c │ │ └── sspi_windows.h │ └── scram │ │ └── scram.go │ ├── log.go │ ├── queue.go │ ├── raceoff.go │ ├── raceon.go │ ├── saslimpl.go │ ├── saslstub.go │ ├── server.go │ ├── session.go │ ├── socket.go │ └── stats.go └── vendor.json /.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.6 4 | - tip 5 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # MailHog Dockerfile 3 | # 4 | 5 | FROM golang:1.18-alpine as builder 6 | 7 | # Install MailHog: 8 | RUN apk --no-cache add --virtual build-dependencies \ 9 | git \ 10 | && mkdir -p /root/gocode \ 11 | && export GOPATH=/root/gocode \ 12 | && go install github.com/mailhog/MailHog@latest 13 | 14 | FROM alpine:3 15 | # Add mailhog user/group with uid/gid 1000. 16 | # This is a workaround for boot2docker issue #581, see 17 | # https://github.com/boot2docker/boot2docker/issues/581 18 | RUN adduser -D -u 1000 mailhog 19 | 20 | COPY --from=builder /root/gocode/bin/MailHog /usr/local/bin/ 21 | 22 | USER mailhog 23 | 24 | WORKDIR /home/mailhog 25 | 26 | ENTRYPOINT ["MailHog"] 27 | 28 | # Expose the SMTP and HTTP ports: 29 | EXPOSE 1025 8025 30 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 - 2016 Ian Kent 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | VERSION=1.0.0 2 | 3 | all: fmt combined 4 | 5 | combined: 6 | go install . 7 | 8 | release: tag release-deps 9 | gox -ldflags "-X main.version=${VERSION}" -output="build/{{.Dir}}_{{.OS}}_{{.Arch}}" . 10 | 11 | fmt: 12 | go fmt ./... 13 | 14 | release-deps: 15 | go get github.com/mitchellh/gox 16 | 17 | pull: 18 | git pull 19 | cd ../data; git pull 20 | cd ../http; git pull 21 | cd ../MailHog-Server; git pull 22 | cd ../MailHog-UI; git pull 23 | cd ../smtp; git pull 24 | cd ../storage; git pull 25 | 26 | tag: 27 | git tag -a -m 'v${VERSION}' v${VERSION} && git push origin v${VERSION} 28 | cd ../data; git tag -a -m 'v${VERSION}' v${VERSION} && git push origin v${VERSION} 29 | cd ../http; git tag -a -m 'v${VERSION}' v${VERSION} && git push origin v${VERSION} 30 | cd ../MailHog-Server; git tag -a -m 'v${VERSION}' v${VERSION} && git push origin v${VERSION} 31 | cd ../MailHog-UI; git tag -a -m 'v${VERSION}' v${VERSION} && git push origin v${VERSION} 32 | cd ../smtp; git tag -a -m 'v${VERSION}' v${VERSION} && git push origin v${VERSION} 33 | cd ../storage; git tag -a -m 'v${VERSION}' v${VERSION} && git push origin v${VERSION} 34 | 35 | .PHONY: all combined release fmt release-deps pull tag 36 | -------------------------------------------------------------------------------- /config/config.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "flag" 5 | 6 | "github.com/ian-kent/envconf" 7 | ) 8 | 9 | func DefaultConfig() *Config { 10 | return &Config{ 11 | AuthFile: "", 12 | } 13 | } 14 | 15 | type Config struct { 16 | AuthFile string 17 | WebPath string 18 | } 19 | 20 | var cfg = DefaultConfig() 21 | 22 | func Configure() *Config { 23 | 24 | //sanitize webpath 25 | //add a leading slash 26 | if cfg.WebPath != "" && !(cfg.WebPath[0] == '/') { 27 | cfg.WebPath = "/" + cfg.WebPath 28 | } 29 | 30 | return cfg 31 | } 32 | 33 | func RegisterFlags() { 34 | flag.StringVar(&cfg.AuthFile, "auth-file", envconf.FromEnvP("MH_AUTH_FILE", "").(string), "A username:bcryptpw mapping file") 35 | flag.StringVar(&cfg.WebPath, "ui-web-path", envconf.FromEnvP("MH_UI_WEB_PATH", "").(string), "WebPath under which the UI is served (without leading or trailing slashes), e.g. 'mailhog'. Value defaults to ''") 36 | } 37 | -------------------------------------------------------------------------------- /docs/APIv1.md: -------------------------------------------------------------------------------- 1 | MailHog API v1 2 | ============== 3 | 4 | The v1 API is a RESTful HTTP JSON API. 5 | 6 | ### GET /api/v1/events 7 | 8 | Streams new messages using EventSource and chunked encoding 9 | 10 | ### GET /api/v1/messages 11 | 12 | Lists all messages excluding message content 13 | 14 | ### DELETE /api/v1/messages 15 | 16 | Deletes all messages 17 | 18 | Returns a ```200``` response code if message deletion was successful. 19 | 20 | ### GET /api/v1/messages/{ message_id } 21 | 22 | Returns an individual message including message content 23 | 24 | ### DELETE /api/v1/messages/{ message_id } 25 | 26 | Delete an individual message 27 | 28 | Returns a ```200``` response code if message deletion was successful. 29 | 30 | ### GET /api/v1/messages/{ message_id }/download 31 | 32 | Download the complete message 33 | 34 | ### GET /api/v1/messages/{ message_id }/mime/part/{ part_index }/download 35 | 36 | Download a MIME part 37 | 38 | ### POST /api/v1/messages/{ message_id }/release 39 | 40 | Release the message to an SMTP server 41 | 42 | Send a JSON body specifying the recipient, SMTP hostname and port number: 43 | 44 | ```json 45 | { 46 | "Host": "mail.example.com", 47 | "Post": "25", 48 | "Email": "someone@example.com" 49 | } 50 | ``` 51 | 52 | Returns a ```200``` response code if message delivery was successful. 53 | -------------------------------------------------------------------------------- /docs/APIv2.md: -------------------------------------------------------------------------------- 1 | MailHog API v2 2 | ============== 3 | 4 | The v2 API is hopefully less of a mess than v1. 5 | 6 | The specification is written in [Swagger 2.0](http://swagger.io/). 7 | 8 | See the YAML and JSON specifications in the [APIv2](./APIv2) directory. 9 | -------------------------------------------------------------------------------- /docs/Auth.md: -------------------------------------------------------------------------------- 1 | Authentication 2 | ============== 3 | 4 | HTTP basic authentication is supported using a password file. 5 | 6 | See [example-auth](example-auth) for an example (the password is `test`). 7 | 8 | Authentication applies to all HTTP requests, including static content 9 | and API endpoints. 10 | 11 | ### Password file format 12 | 13 | The password file format is: 14 | 15 | * One user per line 16 | * `username:password` 17 | * Password is bcrypted 18 | 19 | By default, a bcrypt difficulty of 4 is used to reduce page load times. 20 | 21 | ### Generating a bcrypted password 22 | 23 | You can use a MailHog shortcut to generate a bcrypted password: 24 | 25 | MailHog bcrypt 26 | 27 | ### Enabling HTTP authentication 28 | 29 | To enable authentication, pass an `-auth-file` flag to MailHog: 30 | 31 | MailHog -auth-file=docs/example-auth 32 | 33 | This also works if you're running MailHog-UI and MailHog-Server separately: 34 | 35 | MailHog-Server -auth-file=docs/example-auth 36 | MailHog-UI -auth-file=docs/example-auth 37 | 38 | ## Future compatibility 39 | 40 | Authentication has been a bit of an experiment. 41 | 42 | The exact implementation may change over time, e.g. using sessions in the UI 43 | and tokens for the API to avoid frequently bcrypting passwords. 44 | -------------------------------------------------------------------------------- /docs/BUILD.md: -------------------------------------------------------------------------------- 1 | Building MailHog 2 | ================ 3 | 4 | MailHog is built using `make`, and using [this Makefile](../Makefile). 5 | 6 | If you aren't making any code changes, you can install MailHog using 7 | `go get github.com/mailhog/MailHog`, since [mailhog/MailHog-UI/assets/assets.go](https://github.com/mailhog/MailHog-UI/blob/master/assets/assets.go) 8 | is already pre-compiled and committed to this repository. 9 | 10 | ### Why do I need a Makefile? 11 | 12 | MailHog has HTML, CSS and Javascript assets which need to be converted 13 | to a go source file using [go-bindata](https://github.com/jteeuwen/go-bindata). 14 | 15 | This must happen before running `go build` or `go install` to avoid compilation 16 | errors (e.g., `no buildable Go source files in MailHog-UI/assets`). 17 | 18 | ### go generate 19 | 20 | The build should be updated to use `go generate` (added in Go 1.4) to 21 | preprocess static assets into go source files. 22 | 23 | However, this will break backwards compatibility with Go 1.2/1.3. 24 | 25 | ### Building a release 26 | 27 | Releases are built using [gox](https://github.com/mitchellh/gox). 28 | 29 | Run `make release` to cross-compile for all available platforms. 30 | -------------------------------------------------------------------------------- /docs/CONFIG.md: -------------------------------------------------------------------------------- 1 | Configuring MailHog 2 | =================== 3 | 4 | You can configure MailHog using command line options or environment variables: 5 | 6 | | Environment | Command line | Default | Description 7 | | ------------------- | --------------- | --------------- | ----------- 8 | | MH_CORS_ORIGIN | -cors-origin | | If set, an Access-Control-Allow-Origin header is returned for API endpoints 9 | | MH_HOSTNAME | -hostname | mailhog.example | Hostname to use for EHLO/HELO and message IDs 10 | | MH_API_BIND_ADDR | -api-bind-addr | 0.0.0.0:8025 | Interface and port for HTTP API server to bind to 11 | | MH_UI_BIND_ADDR | -ui-bind-addr | 0.0.0.0:8025 | Interface and port for HTTP UI server to bind to 12 | | MH_MAILDIR_PATH | -maildir-path | | Maildir path (for maildir storage backend) 13 | | MH_MONGO_COLLECTION | -mongo-coll | messages | MongoDB collection name for message storage 14 | | MH_MONGO_DB | -mongo-db | mailhog | MongoDB database name for message storage 15 | | MH_MONGO_URI | -mongo-uri | 127.0.0.1:27017 | MongoDB host and port 16 | | MH_SMTP_BIND_ADDR | -smtp-bind-addr | 0.0.0.0:1025 | Interface and port for SMTP server to bind to 17 | | MH_STORAGE | -storage | memory | Set message storage: memory / mongodb / maildir 18 | | MH_OUTGOING_SMTP | -outgoing-smtp | | JSON file defining outgoing SMTP servers 19 | | MH_UI_WEB_PATH | -ui-web-path | | WebPath under which the UI is served (without leading or trailing slashes), e.g. 'mailhog' 20 | | MH_AUTH_FILE | -auth-file | | A username:bcryptpw mapping file 21 | 22 | #### Note on HTTP bind addresses 23 | 24 | If `api-bind-addr` and `ui-bind-addr` are identical, a single listener will 25 | be used allowing both to co-exist on one port. 26 | 27 | The values must match in a string comparison. Resolving to the same host and 28 | port combination isn't enough. 29 | 30 | ### Outgoing SMTP configuration 31 | 32 | Outgoing SMTP servers can be set in web UI when releasing a message, and can 33 | be temporarily persisted for later use in the same session. 34 | 35 | To make outgoing SMTP servers permanently available, create a JSON file with 36 | the following structure, and set `MH_OUTGOING_SMTP` or `-outgoing-smtp`. 37 | 38 | ```json 39 | { 40 | "server name": { 41 | "name": "server name", 42 | "host": "...", 43 | "port": "587", 44 | "email": "...", 45 | "username": "...", 46 | "password": "...", 47 | "mechanism": "PLAIN" 48 | } 49 | } 50 | ``` 51 | 52 | Only `name`, `host` and `port` are required. 53 | 54 | `mechanism` can be `PLAIN` or `CRAM-MD5`. 55 | 56 | ### Firewalls and proxies 57 | 58 | If you have MailHog behind a firewall, you'll need ports `8025` and `1025` by default. 59 | 60 | You can override this using `-api-bind-addr`, `-ui-bind-addr` and `-smtp-bind-addr` configuration options. 61 | 62 | If you're using MailHog behind a reverse proxy, e.g. nginx, make sure WebSocket connections 63 | are also supported and configured - see [this issue](https://github.com/mailhog/MailHog/issues/117) for information. 64 | -------------------------------------------------------------------------------- /docs/DEPLOY.md: -------------------------------------------------------------------------------- 1 | Deploying MailHog 2 | ================= 3 | 4 | ### Command line 5 | 6 | You can run MailHog locally from the command line. 7 | 8 | go get github.com/mailhog/MailHog 9 | MailHog -h 10 | 11 | To configure MailHog, use the environment variables or command line flags 12 | described in the [CONFIG](CONFIG.md). 13 | 14 | ### Using supervisord/upstart/etc 15 | 16 | MailHog can be started as a daemon using supervisord/upstart/etc. 17 | 18 | See [this example init script](https://github.com/geerlingguy/ansible-role-mailhog/blob/master/templates/mailhog.init.j2) 19 | and [this Ansible role](https://github.com/geerlingguy/ansible-role-mailhog) by [geerlingguy](https://github.com/geerlingguy). 20 | 21 | If installed with Homebrew on OSX you can have launchd start mailhog now and restart at login: 22 | brew services start mailhog 23 | 24 | ### Docker 25 | 26 | The example [Dockerfile](../Dockerfile) can be used to run MailHog in a [Docker](https://www.docker.com/) container. 27 | 28 | You can run it directly from Docker Hub (thanks [humboldtux](https://github.com/humboldtux)) 29 | 30 | docker run -d -p 1025:1025 -p 8025:8025 mailhog/mailhog 31 | 32 | To mount the Maildir to the local filesystem, you can use a volume: 33 | 34 | docker run -d -e "MH_STORAGE=maildir" -v $PWD/maildir:/maildir -p 1025:1025 -p 8025:8025 mailhog/mailhog 35 | 36 | ### Elastic Beanstalk 37 | 38 | You can deploy MailHog using [AWS Elastic Beanstalk](http://aws.amazon.com/elasticbeanstalk/). 39 | 40 | 1. Open the Elastic Beanstalk console 41 | 2. Create a zip file containing the Dockerfile and MailHog binary 42 | 3. Create a new Elastic Beanstalk application 43 | 4. Launch a new environment and upload the zip file 44 | 45 | **Note** You'll need to reconfigure nginx in Elastic Beanstalk to expose both 46 | ports as TCP, since by default it proxies the first exposed port to port 80 as HTTP. 47 | 48 | If you're using in-memory storage, you can only use a single instance of 49 | MailHog. To use a load balanced EB application, use MongoDB backed storage. 50 | 51 | To configure your Elastic Beanstalk MailHog instance, either: 52 | 53 | * Set environment variables using the Elastic Beanstalk console 54 | * Edit the Dockerfile to pass in command line arguments 55 | 56 | You may face restrictions on outbound SMTP from EC2, for example if you are 57 | releasing messages to real SMTP servers. 58 | 59 | ### SaltStack 60 | 61 | For deploying MailHog using [SaltStack](https://github.com/saltstack/salt), there's a 62 | [SaltStack Formula](https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html) 63 | available in [github.com/ssc-services/salt-formulas-public](https://github.com/ssc-services/salt-formulas-public/tree/master/mailhog). 64 | -------------------------------------------------------------------------------- /docs/JIM.md: -------------------------------------------------------------------------------- 1 | Introduction to Jim 2 | =================== 3 | 4 | Jim is the MailHog Chaos Monkey, inspired by Netflix. 5 | 6 | You can invite Jim to the party using the `invite-jim` flag: 7 | 8 | MailHog -invite-jim 9 | 10 | With Jim around, things aren't going to work how you expect. 11 | 12 | ### What can Jim do? 13 | 14 | * Reject connections 15 | * Rate limit connections 16 | * Reject authentication 17 | * Reject senders 18 | * Reject recipients 19 | 20 | It does this randomly, but within defined parameters. 21 | 22 | You can control these using the following command line flags: 23 | 24 | | Flag | Default | Description 25 | | --------------------- | ------- | ---- 26 | | -invite-jim | false | Set to true to invite Jim 27 | | -jim-disconnect | 0.005 | Chance of randomly disconnecting a session 28 | | -jim-accept | 0.99 | Chance of accepting an incoming connection 29 | | -jim-linkspeed-affect | 0.1 | Chance of applying a rate limit 30 | | -jim-linkspeed-min | 1024 | Minimum link speed (in bytes per second) 31 | | -jim-linkspeed-max | 10240 | Maximum link speed (in bytes per second) 32 | | -jim-reject-sender | 0.05 | Chance of rejecting a MAIL FROM command 33 | | -jim-reject-recipient | 0.05 | Chance of rejecting a RCPT TO command 34 | | -jim-reject-auth | 0.05 | Chance of rejecting an AUTH command 35 | 36 | If you enable Jim, you enable all parts. To disable individual parts, set the chance 37 | of it happening to 0, e.g. to disable connection rate limiting: 38 | 39 | MailHog -invite-jim -jim-linkspeed-affect=0 40 | 41 | ### Examples 42 | 43 | Always rate limit to 1 byte per second: 44 | 45 | MailHog -invite-jim -jim-linkspeed-affect=1 -jim-linkspeed-max=1 -jim-linkspeed-min=1 46 | 47 | Disconnect clients after approximately 5 commands: 48 | 49 | MailHog -invite-jim -jim-disconnect=0.2 50 | 51 | Simulate a mobile connection (at 10-100kbps) for 10% of clients: 52 | 53 | MailHog -invite-jim -jim-linkspeed-affect=0.1 -jim-linkspeed-min=1250 -jim-linkspeed-max=12500 54 | -------------------------------------------------------------------------------- /docs/LIBRARIES.md: -------------------------------------------------------------------------------- 1 | MailHog libraries 2 | ================= 3 | 4 | If you've created a MailHog client library, open a pull request and add it! 5 | 6 | * [APIv2 library for NodeJS](https://github.com/blueimp/mailhog-node) 7 | * [APIv1/APIv2 library for PHP](https://github.com/rpkamp/mailhog-client) 8 | -------------------------------------------------------------------------------- /docs/MailHog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mailhog/MailHog/e6fa06877ef61ea82bbef234d94bdc75cca478d1/docs/MailHog.png -------------------------------------------------------------------------------- /docs/example-auth: -------------------------------------------------------------------------------- 1 | test:$2a$04$qxRo.ftFoNep7ld/5jfKtuBTnGqff/fZVyj53mUC5sVf9dtDLAi/S 2 | -------------------------------------------------------------------------------- /snapcraft.yaml: -------------------------------------------------------------------------------- 1 | name: mailhog 2 | summary: Web and API based SMTP testing 3 | description: | 4 | MailHog is an email testing tool for developers: 5 | * Configure your application to use MailHog for SMTP delivery 6 | * View messages in the web UI, or retrieve them with the JSON API 7 | * Optionally release messages to real SMTP servers for delivery 8 | version: "master" 9 | confinement: strict 10 | grade: stable 11 | apps: 12 | mailhog: 13 | command: MailHog 14 | plugs: [network-bind] 15 | daemon: simple 16 | parts: 17 | mailhog: 18 | plugin: go 19 | go-packages: 20 | - github.com/mailhog/MailHog 21 | build-packages: 22 | - git 23 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/README.md: -------------------------------------------------------------------------------- 1 | context 2 | ======= 3 | [![Build Status](https://travis-ci.org/gorilla/context.png?branch=master)](https://travis-ci.org/gorilla/context) 4 | 5 | gorilla/context is a general purpose registry for global request variables. 6 | 7 | > Note: gorilla/context, having been born well before `context.Context` existed, does not play well 8 | > with the shallow copying of the request that [`http.Request.WithContext`](https://golang.org/pkg/net/http/#Request.WithContext) (added to net/http Go 1.7 onwards) performs. You should either use *just* gorilla/context, or moving forward, the new `http.Request.Context()`. 9 | 10 | Read the full documentation here: http://www.gorillatoolkit.org/pkg/context 11 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Gorilla Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | Package context stores values shared during a request lifetime. 7 | 8 | Note: gorilla/context, having been born well before `context.Context` existed, 9 | does not play well > with the shallow copying of the request that 10 | [`http.Request.WithContext`](https://golang.org/pkg/net/http/#Request.WithContext) 11 | (added to net/http Go 1.7 onwards) performs. You should either use *just* 12 | gorilla/context, or moving forward, the new `http.Request.Context()`. 13 | 14 | For example, a router can set variables extracted from the URL and later 15 | application handlers can access those values, or it can be used to store 16 | sessions values to be saved at the end of a request. There are several 17 | others common uses. 18 | 19 | The idea was posted by Brad Fitzpatrick to the go-nuts mailing list: 20 | 21 | http://groups.google.com/group/golang-nuts/msg/e2d679d303aa5d53 22 | 23 | Here's the basic usage: first define the keys that you will need. The key 24 | type is interface{} so a key can be of any type that supports equality. 25 | Here we define a key using a custom int type to avoid name collisions: 26 | 27 | package foo 28 | 29 | import ( 30 | "github.com/gorilla/context" 31 | ) 32 | 33 | type key int 34 | 35 | const MyKey key = 0 36 | 37 | Then set a variable. Variables are bound to an http.Request object, so you 38 | need a request instance to set a value: 39 | 40 | context.Set(r, MyKey, "bar") 41 | 42 | The application can later access the variable using the same key you provided: 43 | 44 | func MyHandler(w http.ResponseWriter, r *http.Request) { 45 | // val is "bar". 46 | val := context.Get(r, foo.MyKey) 47 | 48 | // returns ("bar", true) 49 | val, ok := context.GetOk(r, foo.MyKey) 50 | // ... 51 | } 52 | 53 | And that's all about the basic usage. We discuss some other ideas below. 54 | 55 | Any type can be stored in the context. To enforce a given type, make the key 56 | private and wrap Get() and Set() to accept and return values of a specific 57 | type: 58 | 59 | type key int 60 | 61 | const mykey key = 0 62 | 63 | // GetMyKey returns a value for this package from the request values. 64 | func GetMyKey(r *http.Request) SomeType { 65 | if rv := context.Get(r, mykey); rv != nil { 66 | return rv.(SomeType) 67 | } 68 | return nil 69 | } 70 | 71 | // SetMyKey sets a value for this package in the request values. 72 | func SetMyKey(r *http.Request, val SomeType) { 73 | context.Set(r, mykey, val) 74 | } 75 | 76 | Variables must be cleared at the end of a request, to remove all values 77 | that were stored. This can be done in an http.Handler, after a request was 78 | served. Just call Clear() passing the request: 79 | 80 | context.Clear(r) 81 | 82 | ...or use ClearHandler(), which conveniently wraps an http.Handler to clear 83 | variables at the end of a request lifetime. 84 | 85 | The Routers from the packages gorilla/mux and gorilla/pat call Clear() 86 | so if you are using either of them you don't need to clear the context manually. 87 | */ 88 | package context 89 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/context_gorilla.go: -------------------------------------------------------------------------------- 1 | // +build !go1.7 2 | 3 | package mux 4 | 5 | import ( 6 | "net/http" 7 | 8 | "github.com/gorilla/context" 9 | ) 10 | 11 | func contextGet(r *http.Request, key interface{}) interface{} { 12 | return context.Get(r, key) 13 | } 14 | 15 | func contextSet(r *http.Request, key, val interface{}) *http.Request { 16 | if val == nil { 17 | return r 18 | } 19 | 20 | context.Set(r, key, val) 21 | return r 22 | } 23 | 24 | func contextClear(r *http.Request) { 25 | context.Clear(r) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/context_native.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | 3 | package mux 4 | 5 | import ( 6 | "context" 7 | "net/http" 8 | ) 9 | 10 | func contextGet(r *http.Request, key interface{}) interface{} { 11 | return r.Context().Value(key) 12 | } 13 | 14 | func contextSet(r *http.Request, key, val interface{}) *http.Request { 15 | if val == nil { 16 | return r 17 | } 18 | 19 | return r.WithContext(context.WithValue(r.Context(), key, val)) 20 | } 21 | 22 | func contextClear(r *http.Request) { 23 | return 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/pat/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/pat/README.md: -------------------------------------------------------------------------------- 1 | pat 2 | === 3 | [![GoDoc](https://godoc.org/github.com/gorilla/pat?status.svg)](https://godoc.org/github.com/gorilla/pat) 4 | [![Build Status](https://travis-ci.org/gorilla/pat.svg?branch=master)](https://travis-ci.org/gorilla/pat) 5 | 6 | ### How to use? 7 | 8 | pat is pretty simple. The documentation lives [here](http://www.gorillatoolkit.org/pkg/pat). 9 | 10 | ### Install 11 | With a properly configured Go toolchain: 12 | ```sh 13 | go get github.com/gorilla/pat 14 | ``` 15 | 16 | ### Example 17 | 18 | Here's an example of a RESTful api: 19 | 20 | ```go 21 | package main 22 | 23 | import ( 24 | "log" 25 | "net/http" 26 | 27 | "github.com/gorilla/pat" 28 | ) 29 | 30 | func homeHandler(wr http.ResponseWriter, req *http.Request) { 31 | wr.WriteHeader(http.StatusOK) 32 | wr.Write([]byte("Yay! We're home, Jim!")) 33 | } 34 | 35 | func getAllTheThings(wr http.ResponseWriter, req *http.Request) { 36 | wr.WriteHeader(http.StatusOK) 37 | wr.Write([]byte("Look, Jim! Get all the things!")) 38 | } 39 | 40 | func putOneThing(wr http.ResponseWriter, req *http.Request) { 41 | wr.WriteHeader(http.StatusOK) 42 | wr.Write([]byte("Look, Jim! Put one thing!")) 43 | } 44 | 45 | func deleteOneThing(wr http.ResponseWriter, req *http.Request) { 46 | wr.WriteHeader(http.StatusOK) 47 | wr.Write([]byte("Look, Jim! Delete one thing!")) 48 | } 49 | 50 | func main() { 51 | router := pat.New() 52 | 53 | router.Get("/things", getAllTheThings) 54 | 55 | router.Put("/things/{id}", putOneThing) 56 | router.Delete("/things/{id}", deleteOneThing) 57 | 58 | router.Get("/", homeHandler) 59 | 60 | http.Handle("/", router) 61 | 62 | log.Print("Listening on 127.0.0.1:8000...") 63 | log.Fatal(http.ListenAndServe(":8000", nil)) 64 | } 65 | ``` 66 | Notice how the routes descend? That's because Pat will take the first route 67 | that matches. For your own testing, take the line ```router.Get("/", 68 | homeHandler)``` and put it above the other routes and run the example. When you 69 | try to curl any of the routes, you'll only get what the homeHandler returns. 70 | Design your routes carefully. 71 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/pat/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Gorilla Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | Package gorilla/pat is a request router and dispatcher with a pat-like 7 | interface. It is an alternative to gorilla/mux that showcases how it can 8 | be used as a base for different API flavors. Package pat is documented at: 9 | 10 | http://godoc.org/github.com/bmizerany/pat 11 | 12 | Let's start registering a couple of URL paths and handlers: 13 | 14 | func main() { 15 | r := pat.New() 16 | r.Get("/products", ProductsHandler) 17 | r.Get("/articles", ArticlesHandler) 18 | r.Get("/", HomeHandler) 19 | http.Handle("/", r) 20 | } 21 | 22 | Here we register three routes mapping URL paths to handlers. This is 23 | equivalent to how http.HandleFunc() works: if an incoming GET request matches 24 | one of the paths, the corresponding handler is called passing 25 | (http.ResponseWriter, *http.Request) as parameters. 26 | 27 | Note: gorilla/pat matches path prefixes, so you must register the most 28 | specific paths first. 29 | 30 | Note: differently from pat, these methods accept a handler function, and not an 31 | http.Handler. We think this is shorter and more convenient. To set an 32 | http.Handler, use the Add() method. 33 | 34 | Paths can have variables. They are defined using the format {name} or 35 | {name:pattern}. If a regular expression pattern is not defined, the matched 36 | variable will be anything until the next slash. For example: 37 | 38 | r := pat.New() 39 | r.Get("/articles/{category}/{id:[0-9]+}", ArticleHandler) 40 | r.Get("/articles/{category}/", ArticlesCategoryHandler) 41 | r.Get("/products/{key}", ProductHandler) 42 | 43 | The names are used to create a map of route variables which are stored in the 44 | URL query, prefixed by a colon: 45 | 46 | category := req.URL.Query().Get(":category") 47 | 48 | As in the gorilla/mux package, other matchers can be added to the registered 49 | routes and URLs can be reversed as well. To build a URL for a route, first 50 | add a name to it: 51 | 52 | r.Get("/products/{key}", ProductHandler).Name("product") 53 | 54 | Then you can get it using the name and generate a URL: 55 | 56 | url, err := r.GetRoute("product").URL("key", "transmogrifier") 57 | 58 | ...and the result will be a url.URL with the following path: 59 | 60 | "/products/transmogrifier" 61 | 62 | Check the mux documentation for more details about URL building and extra 63 | matchers: 64 | 65 | http://gorilla-web.appspot.com/pkg/mux/ 66 | */ 67 | package pat 68 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of Gorilla WebSocket authors for copyright 2 | # purposes. 3 | # 4 | # Please keep the list sorted. 5 | 6 | Gary Burd 7 | Joachim Bauch 8 | 9 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 The Gorilla WebSocket Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 17 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 21 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/client_clone.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.8 6 | 7 | package websocket 8 | 9 | import "crypto/tls" 10 | 11 | func cloneTLSConfig(cfg *tls.Config) *tls.Config { 12 | if cfg == nil { 13 | return &tls.Config{} 14 | } 15 | return cfg.Clone() 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/client_clone_legacy.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.8 6 | 7 | package websocket 8 | 9 | import "crypto/tls" 10 | 11 | // cloneTLSConfig clones all public fields except the fields 12 | // SessionTicketsDisabled and SessionTicketKey. This avoids copying the 13 | // sync.Mutex in the sync.Once and makes it safe to call cloneTLSConfig on a 14 | // config in active use. 15 | func cloneTLSConfig(cfg *tls.Config) *tls.Config { 16 | if cfg == nil { 17 | return &tls.Config{} 18 | } 19 | return &tls.Config{ 20 | Rand: cfg.Rand, 21 | Time: cfg.Time, 22 | Certificates: cfg.Certificates, 23 | NameToCertificate: cfg.NameToCertificate, 24 | GetCertificate: cfg.GetCertificate, 25 | RootCAs: cfg.RootCAs, 26 | NextProtos: cfg.NextProtos, 27 | ServerName: cfg.ServerName, 28 | ClientAuth: cfg.ClientAuth, 29 | ClientCAs: cfg.ClientCAs, 30 | InsecureSkipVerify: cfg.InsecureSkipVerify, 31 | CipherSuites: cfg.CipherSuites, 32 | PreferServerCipherSuites: cfg.PreferServerCipherSuites, 33 | ClientSessionCache: cfg.ClientSessionCache, 34 | MinVersion: cfg.MinVersion, 35 | MaxVersion: cfg.MaxVersion, 36 | CurvePreferences: cfg.CurvePreferences, 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/conn_read.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.5 6 | 7 | package websocket 8 | 9 | import "io" 10 | 11 | func (c *Conn) read(n int) ([]byte, error) { 12 | p, err := c.br.Peek(n) 13 | if err == io.EOF { 14 | err = errUnexpectedEOF 15 | } 16 | c.br.Discard(len(p)) 17 | return p, err 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/conn_read_legacy.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.5 6 | 7 | package websocket 8 | 9 | import "io" 10 | 11 | func (c *Conn) read(n int) ([]byte, error) { 12 | p, err := c.br.Peek(n) 13 | if err == io.EOF { 14 | err = errUnexpectedEOF 15 | } 16 | if len(p) > 0 { 17 | // advance over the bytes just read 18 | io.ReadFull(c.br, p) 19 | } 20 | return p, err 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/json.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package websocket 6 | 7 | import ( 8 | "encoding/json" 9 | "io" 10 | ) 11 | 12 | // WriteJSON is deprecated, use c.WriteJSON instead. 13 | func WriteJSON(c *Conn, v interface{}) error { 14 | return c.WriteJSON(v) 15 | } 16 | 17 | // WriteJSON writes the JSON encoding of v to the connection. 18 | // 19 | // See the documentation for encoding/json Marshal for details about the 20 | // conversion of Go values to JSON. 21 | func (c *Conn) WriteJSON(v interface{}) error { 22 | w, err := c.NextWriter(TextMessage) 23 | if err != nil { 24 | return err 25 | } 26 | err1 := json.NewEncoder(w).Encode(v) 27 | err2 := w.Close() 28 | if err1 != nil { 29 | return err1 30 | } 31 | return err2 32 | } 33 | 34 | // ReadJSON is deprecated, use c.ReadJSON instead. 35 | func ReadJSON(c *Conn, v interface{}) error { 36 | return c.ReadJSON(v) 37 | } 38 | 39 | // ReadJSON reads the next JSON-encoded message from the connection and stores 40 | // it in the value pointed to by v. 41 | // 42 | // See the documentation for the encoding/json Unmarshal function for details 43 | // about the conversion of JSON to a Go value. 44 | func (c *Conn) ReadJSON(v interface{}) error { 45 | _, r, err := c.NextReader() 46 | if err != nil { 47 | return err 48 | } 49 | err = json.NewDecoder(r).Decode(v) 50 | if err == io.EOF { 51 | // One value is expected in the message. 52 | err = io.ErrUnexpectedEOF 53 | } 54 | return err 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/mask.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. Use of 2 | // this source code is governed by a BSD-style license that can be found in the 3 | // LICENSE file. 4 | 5 | // +build !appengine 6 | 7 | package websocket 8 | 9 | import "unsafe" 10 | 11 | const wordSize = int(unsafe.Sizeof(uintptr(0))) 12 | 13 | func maskBytes(key [4]byte, pos int, b []byte) int { 14 | 15 | // Mask one byte at a time for small buffers. 16 | if len(b) < 2*wordSize { 17 | for i := range b { 18 | b[i] ^= key[pos&3] 19 | pos++ 20 | } 21 | return pos & 3 22 | } 23 | 24 | // Mask one byte at a time to word boundary. 25 | if n := int(uintptr(unsafe.Pointer(&b[0]))) % wordSize; n != 0 { 26 | n = wordSize - n 27 | for i := range b[:n] { 28 | b[i] ^= key[pos&3] 29 | pos++ 30 | } 31 | b = b[n:] 32 | } 33 | 34 | // Create aligned word size key. 35 | var k [wordSize]byte 36 | for i := range k { 37 | k[i] = key[(pos+i)&3] 38 | } 39 | kw := *(*uintptr)(unsafe.Pointer(&k)) 40 | 41 | // Mask one word at a time. 42 | n := (len(b) / wordSize) * wordSize 43 | for i := 0; i < n; i += wordSize { 44 | *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&b[0])) + uintptr(i))) ^= kw 45 | } 46 | 47 | // Mask one byte at a time for remaining bytes. 48 | b = b[n:] 49 | for i := range b { 50 | b[i] ^= key[pos&3] 51 | pos++ 52 | } 53 | 54 | return pos & 3 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/mask_safe.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. Use of 2 | // this source code is governed by a BSD-style license that can be found in the 3 | // LICENSE file. 4 | 5 | // +build appengine 6 | 7 | package websocket 8 | 9 | func maskBytes(key [4]byte, pos int, b []byte) int { 10 | for i := range b { 11 | b[i] ^= key[pos&3] 12 | pos++ 13 | } 14 | return pos & 3 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/ian-kent/envconf/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Ian Kent 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/ian-kent/envconf/README.md: -------------------------------------------------------------------------------- 1 | envconf 2 | ======= 3 | 4 | Configure your Go application from the environment. 5 | 6 | Supports most basic Go types and works nicely with the built in `flag` package. 7 | 8 | ```go 9 | package main 10 | 11 | import( 12 | "flag" 13 | "fmt" 14 | . "github.com/ian-kent/envconf" 15 | ) 16 | 17 | func main() { 18 | count := flag.Int("count", FromEnvP("COUNT", 15).(int), "Count target") 19 | flag.Parse() 20 | for i := 1; i <= *count; i++ { 21 | fmt.Printf("%d\n", i) 22 | } 23 | } 24 | ``` 25 | 26 | ## Licence 27 | 28 | Copyright ©‎ 2014, Ian Kent (http://iankent.uk). 29 | 30 | Released under MIT license, see [LICENSE](LICENSE.md) for details. 31 | -------------------------------------------------------------------------------- /vendor/github.com/ian-kent/envconf/envconf.go: -------------------------------------------------------------------------------- 1 | package envconf 2 | 3 | import ( 4 | "errors" 5 | "os" 6 | "strconv" 7 | "strings" 8 | ) 9 | 10 | var ( 11 | // ErrUnsupportedType is returned if the type passed in is unsupported 12 | ErrUnsupportedType = errors.New("Unsupported type") 13 | ) 14 | 15 | // FromEnvP is the same as FromEnv, but panics on error 16 | func FromEnvP(env string, value interface{}) interface{} { 17 | ev, err := FromEnv(env, value) 18 | if err != nil { 19 | panic(err) 20 | } 21 | return ev 22 | } 23 | 24 | // FromEnv returns the environment variable specified by env 25 | // using the type of value 26 | func FromEnv(env string, value interface{}) (interface{}, error) { 27 | envs := os.Environ() 28 | found := false 29 | for _, e := range envs { 30 | if strings.HasPrefix(e, env+"=") { 31 | found = true 32 | break 33 | } 34 | } 35 | 36 | if !found { 37 | return value, nil 38 | } 39 | 40 | ev := os.Getenv(env) 41 | 42 | switch value.(type) { 43 | case string: 44 | vt := interface{}(ev) 45 | return vt, nil 46 | case int: 47 | i, e := strconv.ParseInt(ev, 10, 64) 48 | return int(i), e 49 | case int8: 50 | i, e := strconv.ParseInt(ev, 10, 8) 51 | return int8(i), e 52 | case int16: 53 | i, e := strconv.ParseInt(ev, 10, 16) 54 | return int16(i), e 55 | case int32: 56 | i, e := strconv.ParseInt(ev, 10, 32) 57 | return int32(i), e 58 | case int64: 59 | i, e := strconv.ParseInt(ev, 10, 64) 60 | return i, e 61 | case uint: 62 | i, e := strconv.ParseUint(ev, 10, 64) 63 | return uint(i), e 64 | case uint8: 65 | i, e := strconv.ParseUint(ev, 10, 8) 66 | return uint8(i), e 67 | case uint16: 68 | i, e := strconv.ParseUint(ev, 10, 16) 69 | return uint16(i), e 70 | case uint32: 71 | i, e := strconv.ParseUint(ev, 10, 32) 72 | return uint32(i), e 73 | case uint64: 74 | i, e := strconv.ParseUint(ev, 10, 64) 75 | return i, e 76 | case float32: 77 | i, e := strconv.ParseFloat(ev, 32) 78 | return float32(i), e 79 | case float64: 80 | i, e := strconv.ParseFloat(ev, 64) 81 | return float64(i), e 82 | case bool: 83 | i, e := strconv.ParseBool(ev) 84 | return i, e 85 | default: 86 | return value, ErrUnsupportedType 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /vendor/github.com/ian-kent/go-log/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Ian Kent 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/ian-kent/go-log/appenders/appender.go: -------------------------------------------------------------------------------- 1 | package appenders 2 | 3 | /* 4 | 5 | Appenders control the flow of data from a logger to an output. 6 | 7 | For example, a Console appender outputs log data to stdout. 8 | 9 | Satisfy the Appender interface to implement your own log appender. 10 | 11 | */ 12 | 13 | import ( 14 | "github.com/ian-kent/go-log/layout" 15 | "github.com/ian-kent/go-log/levels" 16 | ) 17 | 18 | type Appender interface { 19 | Write(level levels.LogLevel, message string, args ...interface{}) 20 | Layout() layout.Layout 21 | SetLayout(layout.Layout) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/ian-kent/go-log/appenders/console.go: -------------------------------------------------------------------------------- 1 | package appenders 2 | 3 | import ( 4 | "fmt" 5 | "github.com/ian-kent/go-log/layout" 6 | "github.com/ian-kent/go-log/levels" 7 | ) 8 | 9 | type consoleAppender struct { 10 | Appender 11 | layout layout.Layout 12 | } 13 | 14 | func Console() *consoleAppender { 15 | a := &consoleAppender{ 16 | layout: layout.Default(), 17 | } 18 | return a 19 | } 20 | 21 | func (a *consoleAppender) Write(level levels.LogLevel, message string, args ...interface{}) { 22 | fmt.Println(a.Layout().Format(level, message, args...)) 23 | } 24 | 25 | func (a *consoleAppender) Layout() layout.Layout { 26 | return a.layout 27 | } 28 | 29 | func (a *consoleAppender) SetLayout(layout layout.Layout) { 30 | a.layout = layout 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/ian-kent/go-log/appenders/fluentd.go: -------------------------------------------------------------------------------- 1 | package appenders 2 | 3 | // TODO add tests 4 | 5 | import ( 6 | "github.com/ian-kent/go-log/layout" 7 | "github.com/ian-kent/go-log/levels" 8 | "github.com/t-k/fluent-logger-golang/fluent" 9 | ) 10 | 11 | type fluentdAppender struct { 12 | Appender 13 | layout layout.Layout 14 | fluent *fluent.Fluent 15 | fluentConfig fluent.Config 16 | } 17 | 18 | func SafeFluentd(config fluent.Config) (*fluentdAppender, error) { 19 | a := &fluentdAppender{ 20 | layout: layout.Default(), 21 | fluentConfig: config, 22 | } 23 | if err := a.Open(); err != nil { 24 | return nil, err 25 | } 26 | return a, nil 27 | } 28 | 29 | func Fluentd(config fluent.Config) *fluentdAppender { 30 | a, _ := SafeFluentd(config) 31 | return a 32 | } 33 | 34 | func (a *fluentdAppender) Close() { 35 | a.fluent.Close() 36 | a.fluent = nil 37 | } 38 | 39 | func (a *fluentdAppender) Open() error { 40 | f, err := fluent.New(a.fluentConfig) 41 | if err != nil { 42 | return err 43 | } 44 | a.fluent = f 45 | return nil 46 | } 47 | 48 | func (a *fluentdAppender) Write(level levels.LogLevel, message string, args ...interface{}) { 49 | // FIXME 50 | // - use tag instead of "go-log" 51 | // - get layout to return the map 52 | var data = map[string]string{ 53 | "message": a.Layout().Format(level, message, args...), 54 | } 55 | a.fluent.Post("go-log", data) 56 | } 57 | 58 | func (a *fluentdAppender) Layout() layout.Layout { 59 | return a.layout 60 | } 61 | 62 | func (a *fluentdAppender) SetLayout(layout layout.Layout) { 63 | a.layout = layout 64 | } 65 | -------------------------------------------------------------------------------- /vendor/github.com/ian-kent/go-log/appenders/multiple_appender.go: -------------------------------------------------------------------------------- 1 | package appenders 2 | 3 | import ( 4 | "github.com/ian-kent/go-log/layout" 5 | "github.com/ian-kent/go-log/levels" 6 | ) 7 | 8 | type multipleAppender struct { 9 | currentLayout layout.Layout 10 | listOfAppenders []Appender 11 | } 12 | 13 | func Multiple(layout layout.Layout, appenders ...Appender) Appender { 14 | return &multipleAppender{ 15 | listOfAppenders: appenders, 16 | currentLayout: layout, 17 | } 18 | } 19 | 20 | func (this *multipleAppender) Layout() layout.Layout { 21 | return this.currentLayout 22 | } 23 | 24 | func (this *multipleAppender) SetLayout(l layout.Layout) { 25 | this.currentLayout = l 26 | } 27 | 28 | func (this *multipleAppender) Write(level levels.LogLevel, message string, args ...interface{}) { 29 | for _, appender := range this.listOfAppenders { 30 | appender.Write(level, message, args...) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/ian-kent/go-log/appenders/rollingfile.go: -------------------------------------------------------------------------------- 1 | package appenders 2 | 3 | import ( 4 | "fmt" 5 | "github.com/ian-kent/go-log/layout" 6 | "github.com/ian-kent/go-log/levels" 7 | "os" 8 | "strconv" 9 | "strings" 10 | "sync" 11 | ) 12 | 13 | type rollingFileAppender struct { 14 | Appender 15 | layout layout.Layout 16 | MaxFileSize int64 17 | MaxBackupIndex int 18 | 19 | filename string 20 | file *os.File 21 | append bool 22 | writeMutex sync.Mutex 23 | 24 | bytesWritten int64 25 | } 26 | 27 | func RollingFile(filename string, append bool) *rollingFileAppender { 28 | a := &rollingFileAppender{ 29 | layout: layout.Default(), 30 | MaxFileSize: 104857600, 31 | MaxBackupIndex: 1, 32 | append: append, 33 | bytesWritten: 0, 34 | } 35 | err := a.SetFilename(filename) 36 | if err != nil { 37 | fmt.Printf("Error opening file: %s\n", err) 38 | return nil 39 | } 40 | return a 41 | } 42 | 43 | func (a *rollingFileAppender) Close() { 44 | if a.file != nil { 45 | a.file.Close() 46 | a.file = nil 47 | } 48 | } 49 | 50 | func (a *rollingFileAppender) Write(level levels.LogLevel, message string, args ...interface{}) { 51 | m := a.Layout().Format(level, message, args...) 52 | if !strings.HasSuffix(m, "\n") { 53 | m += "\n" 54 | } 55 | 56 | a.writeMutex.Lock() 57 | a.file.Write([]byte(m)) 58 | 59 | a.bytesWritten += int64(len(m)) 60 | if a.bytesWritten >= a.MaxFileSize { 61 | a.bytesWritten = 0 62 | a.rotateFile() 63 | } 64 | 65 | a.writeMutex.Unlock() 66 | } 67 | 68 | func (a *rollingFileAppender) Layout() layout.Layout { 69 | return a.layout 70 | } 71 | 72 | func (a *rollingFileAppender) SetLayout(layout layout.Layout) { 73 | a.layout = layout 74 | } 75 | 76 | func (a *rollingFileAppender) Filename() string { 77 | return a.filename 78 | } 79 | 80 | func (a *rollingFileAppender) SetFilename(filename string) error { 81 | if a.filename != filename || a.file == nil { 82 | a.closeFile() 83 | a.filename = filename 84 | err := a.openFile() 85 | return err 86 | } 87 | return nil 88 | } 89 | 90 | func (a *rollingFileAppender) rotateFile() { 91 | a.closeFile() 92 | 93 | lastFile := a.filename + "." + strconv.Itoa(a.MaxBackupIndex) 94 | if _, err := os.Stat(lastFile); err == nil { 95 | os.Remove(lastFile) 96 | } 97 | 98 | for n := a.MaxBackupIndex; n > 0; n-- { 99 | f1 := a.filename + "." + strconv.Itoa(n) 100 | f2 := a.filename + "." + strconv.Itoa(n+1) 101 | os.Rename(f1, f2) 102 | } 103 | 104 | os.Rename(a.filename, a.filename+".1") 105 | 106 | a.openFile() 107 | } 108 | func (a *rollingFileAppender) closeFile() { 109 | if a.file != nil { 110 | a.file.Close() 111 | a.file = nil 112 | } 113 | } 114 | func (a *rollingFileAppender) openFile() error { 115 | mode := os.O_WRONLY | os.O_APPEND | os.O_CREATE 116 | if !a.append { 117 | mode = os.O_WRONLY | os.O_CREATE 118 | } 119 | f, err := os.OpenFile(a.filename, mode, 0666) 120 | a.file = f 121 | return err 122 | } 123 | -------------------------------------------------------------------------------- /vendor/github.com/ian-kent/go-log/appenders/rollingfile_test.log: -------------------------------------------------------------------------------- 1 | Yet another test 2 | -------------------------------------------------------------------------------- /vendor/github.com/ian-kent/go-log/appenders/rollingfile_test.log.1: -------------------------------------------------------------------------------- 1 | Test message 2 | Another test 3 | -------------------------------------------------------------------------------- /vendor/github.com/ian-kent/go-log/layout/basic.go: -------------------------------------------------------------------------------- 1 | package layout 2 | 3 | import ( 4 | "fmt" 5 | "github.com/ian-kent/go-log/levels" 6 | ) 7 | 8 | type basicLayout struct { 9 | Layout 10 | } 11 | 12 | func Basic() *basicLayout { 13 | return &basicLayout{} 14 | } 15 | 16 | func (a *basicLayout) Format(level levels.LogLevel, message string, args ...interface{}) string { 17 | return fmt.Sprintf(message, args...) 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/ian-kent/go-log/layout/layout.go: -------------------------------------------------------------------------------- 1 | package layout 2 | 3 | /* 4 | 5 | Layouts control the formatting of data into a printable log string. 6 | 7 | For example, the Basic layout passes the log message and arguments 8 | through fmt.Sprintf. 9 | 10 | Satisfy the Layout interface to implement your own log layout. 11 | 12 | */ 13 | 14 | import ( 15 | "github.com/ian-kent/go-log/levels" 16 | ) 17 | 18 | type Layout interface { 19 | Format(level levels.LogLevel, message string, args ...interface{}) string 20 | } 21 | 22 | func Default() Layout { 23 | return Basic() 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/ian-kent/go-log/layout/pattern.go: -------------------------------------------------------------------------------- 1 | package layout 2 | 3 | import ( 4 | "fmt" 5 | "path/filepath" 6 | "regexp" 7 | "runtime" 8 | "strconv" 9 | "strings" 10 | "time" 11 | 12 | "github.com/ian-kent/go-log/levels" 13 | ) 14 | 15 | // http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html 16 | 17 | // DefaultTimeLayout is the default layout used by %d 18 | var DefaultTimeLayout = "2006-01-02 15:04:05.000000000 -0700 MST" 19 | 20 | // LegacyDefaultTimeLayout is the legacy (non-zero padded) time layout. 21 | // Set layout.DefaultTimeLayout = layout.LegacyDefaultTimeLayout to revert behaviour. 22 | var LegacyDefaultTimeLayout = "2006-01-02 15:04:05.999999999 -0700 MST" 23 | 24 | type patternLayout struct { 25 | Layout 26 | Pattern string 27 | created int64 28 | re *regexp.Regexp 29 | } 30 | 31 | type caller struct { 32 | pc uintptr 33 | file string 34 | line int 35 | ok bool 36 | pkg string 37 | fullpkg string 38 | filename string 39 | } 40 | 41 | func Pattern(pattern string) *patternLayout { 42 | return &patternLayout{ 43 | Pattern: pattern, 44 | re: regexp.MustCompile("%(\\w|%)(?:{([^}]+)})?"), 45 | created: time.Now().UnixNano(), 46 | } 47 | } 48 | 49 | func getCaller() *caller { 50 | pc, file, line, ok := runtime.Caller(2) 51 | 52 | // TODO feels nasty? 53 | dir, fn := filepath.Split(file) 54 | bits := strings.Split(dir, "/") 55 | pkg := bits[len(bits)-2] 56 | 57 | if ok { 58 | return &caller{pc, file, line, ok, pkg, pkg, fn} 59 | } 60 | return nil 61 | } 62 | 63 | func (a *patternLayout) Format(level levels.LogLevel, message string, args ...interface{}) string { 64 | 65 | // TODO 66 | // padding, e.g. %20c, %-20c, %.30c, %20.30c, %-20.30c 67 | // %t - thread name 68 | // %M - function name 69 | 70 | caller := getCaller() 71 | r := time.Now().UnixNano() 72 | 73 | msg := a.re.ReplaceAllStringFunc(a.Pattern, func(m string) string { 74 | parts := a.re.FindStringSubmatch(m) 75 | switch parts[1] { 76 | // FIXME 77 | // %c and %C should probably return the logger name, not the package 78 | // name, since that's how the logger is created in the first place! 79 | case "c": 80 | return caller.pkg 81 | case "C": 82 | return caller.pkg 83 | case "d": 84 | // FIXME specifier, e.g. %d{HH:mm:ss,SSS} 85 | return time.Now().Format(DefaultTimeLayout) 86 | case "F": 87 | return caller.file 88 | case "l": 89 | return fmt.Sprintf("%s/%s:%d", caller.pkg, caller.filename, caller.line) 90 | case "L": 91 | return strconv.Itoa(caller.line) 92 | case "m": 93 | return fmt.Sprintf(message, args...) 94 | case "n": 95 | // FIXME platform-specific? 96 | return "\n" 97 | case "p": 98 | return levels.LogLevelsToString[level] 99 | case "r": 100 | return strconv.FormatInt((r-a.created)/100000, 10) 101 | case "x": 102 | return "" // NDC 103 | case "X": 104 | return "" // MDC (must specify key) 105 | case "%": 106 | return "%" 107 | } 108 | return m 109 | }) 110 | 111 | return msg 112 | } 113 | -------------------------------------------------------------------------------- /vendor/github.com/ian-kent/go-log/levels/levels.go: -------------------------------------------------------------------------------- 1 | package levels 2 | 3 | type LogLevel int 4 | 5 | const ( 6 | FATAL LogLevel = iota 7 | ERROR 8 | INFO 9 | WARN 10 | DEBUG 11 | TRACE 12 | INHERIT 13 | ) 14 | 15 | var StringToLogLevels = map[string]LogLevel{ 16 | "TRACE": TRACE, 17 | "DEBUG": DEBUG, 18 | "WARN": WARN, 19 | "INFO": INFO, 20 | "ERROR": ERROR, 21 | "FATAL": FATAL, 22 | "INHERIT": INHERIT, 23 | } 24 | 25 | var LogLevelsToString = map[LogLevel]string{ 26 | TRACE: "TRACE", 27 | DEBUG: "DEBUG", 28 | WARN: "WARN", 29 | INFO: "INFO", 30 | ERROR: "ERROR", 31 | FATAL: "FATAL", 32 | INHERIT: "INHERIT", 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/ian-kent/go-log/log/log.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "github.com/ian-kent/go-log/levels" 5 | "github.com/ian-kent/go-log/logger" 6 | "strings" 7 | ) 8 | 9 | var global logger.Logger 10 | 11 | // Converts a string level (e.g. DEBUG) to a LogLevel 12 | func Stol(level string) levels.LogLevel { 13 | return levels.StringToLogLevels[strings.ToUpper(level)] 14 | } 15 | 16 | // Returns a Logger instance 17 | // 18 | // If no arguments are given, the global/root logger 19 | // instance will be returned. 20 | // 21 | // If at least one argument is given, the logger instance 22 | // for that namespace will be returned. 23 | func Logger(args ...string) logger.Logger { 24 | var name string 25 | if len(args) > 0 { 26 | name = args[0] 27 | } else { 28 | name = "" 29 | } 30 | 31 | if global == nil { 32 | global = logger.New("") 33 | global.SetLevel(levels.DEBUG) 34 | } 35 | 36 | l := global.GetLogger(name) 37 | 38 | return l 39 | } 40 | 41 | func Log(level levels.LogLevel, params ...interface{}) { 42 | Logger().Log(level, params...) 43 | } 44 | 45 | func Level(level levels.LogLevel) { Logger().Level() } 46 | func Debug(params ...interface{}) { Log(levels.DEBUG, params...) } 47 | func Info(params ...interface{}) { Log(levels.INFO, params...) } 48 | func Warn(params ...interface{}) { Log(levels.WARN, params...) } 49 | func Error(params ...interface{}) { Log(levels.ERROR, params...) } 50 | func Trace(params ...interface{}) { Log(levels.TRACE, params...) } 51 | func Fatal(params ...interface{}) { Log(levels.FATAL, params...) } 52 | func Printf(params ...interface{}) { Log(levels.INFO, params...) } 53 | func Println(params ...interface{}) { Log(levels.INFO, params...) } 54 | func Fatalf(params ...interface{}) { Log(levels.FATAL, params...) } 55 | -------------------------------------------------------------------------------- /vendor/github.com/ian-kent/goose/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Ian Kent 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/ian-kent/goose/README.md: -------------------------------------------------------------------------------- 1 | Goose - Go Server-Sent Events [![GoDoc](https://godoc.org/github.com/ian-kent/goose?status.svg)](https://godoc.org/github.com/ian-kent/goose) 2 | ============================= 3 | 4 | Goose implements Server-Sent Events in Go. 5 | 6 | See [this example](example/main.go). 7 | 8 | ### Licence 9 | 10 | Copyright ©‎ 2014, Ian Kent (http://www.iankent.eu). 11 | 12 | Released under MIT license, see [LICENSE](LICENSE.md) for details. 13 | -------------------------------------------------------------------------------- /vendor/github.com/ian-kent/goose/goose.go: -------------------------------------------------------------------------------- 1 | package goose 2 | 3 | import ( 4 | "bufio" 5 | "errors" 6 | "fmt" 7 | "net" 8 | "net/http" 9 | "strings" 10 | "sync" 11 | ) 12 | 13 | var ( 14 | // ErrUnableToHijackRequest is returned by AddReceiver if the type 15 | // conversion to http.Hijacker is unsuccessful 16 | ErrUnableToHijackRequest = errors.New("Unable to hijack request") 17 | ) 18 | 19 | // EventStream represents a collection of receivers 20 | type EventStream struct { 21 | mutex *sync.Mutex 22 | receivers map[net.Conn]*EventReceiver 23 | } 24 | 25 | // NewEventStream creates a new event stream 26 | func NewEventStream() *EventStream { 27 | return &EventStream{ 28 | mutex: new(sync.Mutex), 29 | receivers: make(map[net.Conn]*EventReceiver), 30 | } 31 | } 32 | 33 | // EventReceiver represents a hijacked HTTP connection 34 | type EventReceiver struct { 35 | stream *EventStream 36 | conn net.Conn 37 | bufrw *bufio.ReadWriter 38 | } 39 | 40 | // Notify sends the event to all event stream receivers 41 | func (es *EventStream) Notify(event string, bytes []byte) { 42 | // TODO reader? 43 | 44 | lines := strings.Split(string(bytes), "\n") 45 | 46 | data := "" 47 | for _, l := range lines { 48 | data += event + ": " + l + "\n" 49 | } 50 | 51 | sz := len(data) + 1 52 | size := fmt.Sprintf("%X", sz) 53 | 54 | for _, er := range es.receivers { 55 | go er.send(size, data) 56 | } 57 | } 58 | 59 | func (er *EventReceiver) send(size, data string) { 60 | _, err := er.write([]byte(size + "\r\n")) 61 | if err != nil { 62 | return 63 | } 64 | 65 | lines := strings.Split(data, "\n") 66 | for _, ln := range lines { 67 | _, err = er.write([]byte(ln + "\n")) 68 | if err != nil { 69 | return 70 | } 71 | } 72 | er.write([]byte("\r\n")) 73 | } 74 | 75 | func (er *EventReceiver) write(bytes []byte) (int, error) { 76 | n, err := er.bufrw.Write(bytes) 77 | 78 | if err != nil { 79 | er.stream.mutex.Lock() 80 | delete(er.stream.receivers, er.conn) 81 | er.stream.mutex.Unlock() 82 | er.conn.Close() 83 | return n, err 84 | } 85 | 86 | err = er.bufrw.Flush() 87 | if err != nil { 88 | er.stream.mutex.Lock() 89 | delete(er.stream.receivers, er.conn) 90 | er.stream.mutex.Unlock() 91 | er.conn.Close() 92 | } 93 | 94 | return n, err 95 | } 96 | 97 | // AddReceiver hijacks a http.ResponseWriter and attaches it to the event stream 98 | func (es *EventStream) AddReceiver(w http.ResponseWriter) (*EventReceiver, error) { 99 | w.Header().Set("Content-Type", "text/event-stream") 100 | w.Header().Set("Cache-Control", "no-cache") 101 | w.Header().Set("Connection", "keep-alive") 102 | 103 | w.WriteHeader(200) 104 | 105 | hj, ok := w.(http.Hijacker) 106 | if !ok { 107 | return nil, ErrUnableToHijackRequest 108 | } 109 | 110 | hjConn, hjBufrw, err := hj.Hijack() 111 | if err != nil { 112 | return nil, err 113 | } 114 | 115 | rec := &EventReceiver{es, hjConn, hjBufrw} 116 | 117 | es.mutex.Lock() 118 | es.receivers[hjConn] = rec 119 | es.mutex.Unlock() 120 | 121 | return rec, nil 122 | } 123 | -------------------------------------------------------------------------------- /vendor/github.com/ian-kent/linkio/README.md: -------------------------------------------------------------------------------- 1 | linkio [![GoDoc](https://godoc.org/github.com/ian-kent/linkio?status.svg)](https://godoc.org/github.com/ian-kent/linkio) [![Build Status](https://travis-ci.org/ian-kent/linkio.svg?branch=master)](https://travis-ci.org/ian-kent/linkio) 2 | ====== 3 | 4 | linkio provides an io.Reader and io.Writer that simulate a network connection of a certain speed, e.g. to simulate a mobile connection. 5 | 6 | ### Quick start 7 | 8 | You can use `linkio` to wrap existing io.Reader and io.Writer interfaces: 9 | 10 | ```go 11 | // Create a new link at 512kbps 12 | link = linkio.NewLink(512 * linkio.KilobitPerSecond) 13 | 14 | // Open a connection 15 | conn, err := net.Dial("tcp", "google.com:80") 16 | if err != nil { 17 | // handle error 18 | } 19 | 20 | // Create a link reader/writer 21 | linkReader := link.NewLinkReader(io.Reader(conn)) 22 | linkWriter := link.NewLinkWriter(io.Writer(conn)) 23 | 24 | // Use them as you would normally... 25 | fmt.Fprintf(linkWriter, "GET / HTTP/1.0\r\n\r\n") 26 | status, err := bufio.NewReader(linkReader).ReadString('\n') 27 | 28 | ``` 29 | 30 | ### LICENSE 31 | 32 | This code is originally a fork of [code.google.com/p/jra-go/linkio](https://code.google.com/p/jra-go/source/browse/#hg%2Flinkio). 33 | 34 | The source contained this license text: 35 | 36 | Use of this source code is governed by a BSD-style 37 | license that can be found in the LICENSE file. 38 | 39 | There is no LICENSE file, but it [may be referring to this](http://opensource.org/licenses/BSD-3-Clause). 40 | 41 | Any modifications since the initial commit are Copyright ©‎ 2014, Ian Kent (http://iankent.uk), and are released under the terms of the [MIT License](http://opensource.org/licenses/MIT). 42 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Space Monkey, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/gen_sym.go: -------------------------------------------------------------------------------- 1 | package gls 2 | 3 | import ( 4 | "sync" 5 | ) 6 | 7 | var ( 8 | keyMtx sync.Mutex 9 | keyCounter uint64 10 | ) 11 | 12 | // ContextKey is a throwaway value you can use as a key to a ContextManager 13 | type ContextKey struct{ id uint64 } 14 | 15 | // GenSym will return a brand new, never-before-used ContextKey 16 | func GenSym() ContextKey { 17 | keyMtx.Lock() 18 | defer keyMtx.Unlock() 19 | keyCounter += 1 20 | return ContextKey{id: keyCounter} 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/gid.go: -------------------------------------------------------------------------------- 1 | package gls 2 | 3 | var ( 4 | stackTagPool = &idPool{} 5 | ) 6 | 7 | // Will return this goroutine's identifier if set. If you always need a 8 | // goroutine identifier, you should use EnsureGoroutineId which will make one 9 | // if there isn't one already. 10 | func GetGoroutineId() (gid uint, ok bool) { 11 | return readStackTag() 12 | } 13 | 14 | // Will call cb with the current goroutine identifier. If one hasn't already 15 | // been generated, one will be created and set first. The goroutine identifier 16 | // might be invalid after cb returns. 17 | func EnsureGoroutineId(cb func(gid uint)) { 18 | if gid, ok := readStackTag(); ok { 19 | cb(gid) 20 | return 21 | } 22 | gid := stackTagPool.Acquire() 23 | defer stackTagPool.Release(gid) 24 | addStackTag(gid, func() { cb(gid) }) 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/id_pool.go: -------------------------------------------------------------------------------- 1 | package gls 2 | 3 | // though this could probably be better at keeping ids smaller, the goal of 4 | // this class is to keep a registry of the smallest unique integer ids 5 | // per-process possible 6 | 7 | import ( 8 | "sync" 9 | ) 10 | 11 | type idPool struct { 12 | mtx sync.Mutex 13 | released []uint 14 | max_id uint 15 | } 16 | 17 | func (p *idPool) Acquire() (id uint) { 18 | p.mtx.Lock() 19 | defer p.mtx.Unlock() 20 | if len(p.released) > 0 { 21 | id = p.released[len(p.released)-1] 22 | p.released = p.released[:len(p.released)-1] 23 | return id 24 | } 25 | id = p.max_id 26 | p.max_id++ 27 | return id 28 | } 29 | 30 | func (p *idPool) Release(id uint) { 31 | p.mtx.Lock() 32 | defer p.mtx.Unlock() 33 | p.released = append(p.released, id) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/stack_tags_js.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package gls 4 | 5 | // This file is used for GopherJS builds, which don't have normal runtime 6 | // stack trace support 7 | 8 | import ( 9 | "strconv" 10 | "strings" 11 | 12 | "github.com/gopherjs/gopherjs/js" 13 | ) 14 | 15 | const ( 16 | jsFuncNamePrefix = "github_com_jtolds_gls_mark" 17 | ) 18 | 19 | func jsMarkStack() (f []uintptr) { 20 | lines := strings.Split( 21 | js.Global.Get("Error").New().Get("stack").String(), "\n") 22 | f = make([]uintptr, 0, len(lines)) 23 | for i, line := range lines { 24 | line = strings.TrimSpace(line) 25 | if line == "" { 26 | continue 27 | } 28 | if i == 0 { 29 | if line != "Error" { 30 | panic("didn't understand js stack trace") 31 | } 32 | continue 33 | } 34 | fields := strings.Fields(line) 35 | if len(fields) < 2 || fields[0] != "at" { 36 | panic("didn't understand js stack trace") 37 | } 38 | 39 | pos := strings.Index(fields[1], jsFuncNamePrefix) 40 | if pos < 0 { 41 | continue 42 | } 43 | pos += len(jsFuncNamePrefix) 44 | if pos >= len(fields[1]) { 45 | panic("didn't understand js stack trace") 46 | } 47 | char := string(fields[1][pos]) 48 | switch char { 49 | case "S": 50 | f = append(f, uintptr(0)) 51 | default: 52 | val, err := strconv.ParseUint(char, 16, 8) 53 | if err != nil { 54 | panic("didn't understand js stack trace") 55 | } 56 | f = append(f, uintptr(val)+1) 57 | } 58 | } 59 | return f 60 | } 61 | 62 | func findPtr() uintptr { 63 | funcs := jsMarkStack() 64 | if len(funcs) == 0 { 65 | panic("failed to find function pointer") 66 | } 67 | return funcs[0] 68 | } 69 | 70 | func getStack(offset, amount int) []uintptr { 71 | if offset != 0 { 72 | return nil 73 | } 74 | return jsMarkStack() 75 | } 76 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/stack_tags_main.go: -------------------------------------------------------------------------------- 1 | // +build !js 2 | 3 | package gls 4 | 5 | // This file is used for standard Go builds, which have the expected runtime 6 | // support 7 | 8 | import ( 9 | "runtime" 10 | ) 11 | 12 | func getStack(offset, amount int) []uintptr { 13 | stack := make([]uintptr, amount) 14 | return stack[:runtime.Callers(offset, stack)] 15 | } 16 | 17 | func findPtr() uintptr { 18 | pc, _, _, ok := runtime.Caller(3) 19 | if !ok { 20 | panic("failed to find function pointer") 21 | } 22 | return pc 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/MailHog-Server/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 - 2016 Ian Kent 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/MailHog-Server/Makefile: -------------------------------------------------------------------------------- 1 | DEPS = $(go list -f '{{range .TestImports}}{{.}} {{end}}' ./...) 2 | 3 | all: release-deps fmt combined 4 | 5 | combined: 6 | go install . 7 | 8 | release: 9 | gox -output="build/{{.Dir}}_{{.OS}}_{{.Arch}}" . 10 | 11 | fmt: 12 | go fmt ./... 13 | 14 | release-deps: 15 | go get github.com/mitchellh/gox 16 | 17 | .PNONY: all combined release fmt release-deps 18 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/MailHog-Server/README.md: -------------------------------------------------------------------------------- 1 | MailHog Server [![Build Status](https://travis-ci.org/mailhog/MailHog-Server.svg?branch=master)](https://travis-ci.org/mailhog/MailHog-Server) 2 | ========= 3 | 4 | MailHog-Server is the MailHog SMTP and HTTP API server. 5 | 6 | ### Licence 7 | 8 | Copyright ©‎ 2014 - 2016, Ian Kent (http://iankent.uk) 9 | 10 | Released under MIT license, see [LICENSE](LICENSE.md) for details. 11 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/MailHog-Server/api/api.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | gohttp "net/http" 5 | 6 | "github.com/gorilla/pat" 7 | "github.com/mailhog/MailHog-Server/config" 8 | ) 9 | 10 | func CreateAPI(conf *config.Config, r gohttp.Handler) { 11 | apiv1 := createAPIv1(conf, r.(*pat.Router)) 12 | apiv2 := createAPIv2(conf, r.(*pat.Router)) 13 | 14 | go func() { 15 | for { 16 | select { 17 | case msg := <-conf.MessageChan: 18 | apiv1.messageChan <- msg 19 | apiv2.messageChan <- msg 20 | } 21 | } 22 | }() 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/MailHog-Server/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "os" 6 | 7 | gohttp "net/http" 8 | 9 | "github.com/ian-kent/go-log/log" 10 | "github.com/mailhog/MailHog-Server/api" 11 | "github.com/mailhog/MailHog-Server/config" 12 | "github.com/mailhog/MailHog-Server/smtp" 13 | "github.com/mailhog/MailHog-UI/assets" 14 | comcfg "github.com/mailhog/MailHog/config" 15 | "github.com/mailhog/http" 16 | ) 17 | 18 | var conf *config.Config 19 | var comconf *comcfg.Config 20 | var exitCh chan int 21 | 22 | func configure() { 23 | comcfg.RegisterFlags() 24 | config.RegisterFlags() 25 | flag.Parse() 26 | conf = config.Configure() 27 | comconf = comcfg.Configure() 28 | } 29 | 30 | func main() { 31 | configure() 32 | 33 | if comconf.AuthFile != "" { 34 | http.AuthFile(comconf.AuthFile) 35 | } 36 | 37 | exitCh = make(chan int) 38 | cb := func(r gohttp.Handler) { 39 | api.CreateAPI(conf, r) 40 | } 41 | go http.Listen(conf.APIBindAddr, assets.Asset, exitCh, cb) 42 | go smtp.Listen(conf, exitCh) 43 | 44 | for { 45 | select { 46 | case <-exitCh: 47 | log.Printf("Received exit signal") 48 | os.Exit(0) 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/MailHog-Server/monkey/monkey.go: -------------------------------------------------------------------------------- 1 | package monkey 2 | 3 | import ( 4 | "net" 5 | 6 | "github.com/ian-kent/linkio" 7 | ) 8 | 9 | // ChaosMonkey should be implemented by chaos monkeys! 10 | type ChaosMonkey interface { 11 | RegisterFlags() 12 | Configure(func(string, ...interface{})) 13 | 14 | // Accept is called for each incoming connection. Returning false closes the connection. 15 | Accept(conn net.Conn) bool 16 | // LinkSpeed sets the maximum connection throughput (in one direction) 17 | LinkSpeed() *linkio.Throughput 18 | 19 | // ValidRCPT is called for the RCPT command. Returning false signals an invalid recipient. 20 | ValidRCPT(rcpt string) bool 21 | // ValidMAIL is called for the MAIL command. Returning false signals an invalid sender. 22 | ValidMAIL(mail string) bool 23 | // ValidAUTH is called after authentication. Returning false signals invalid authentication. 24 | ValidAUTH(mechanism string, args ...string) bool 25 | 26 | // Disconnect is called after every read. Returning true will close the connection. 27 | Disconnect() bool 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/MailHog-Server/smtp/smtp.go: -------------------------------------------------------------------------------- 1 | package smtp 2 | 3 | import ( 4 | "io" 5 | "log" 6 | "net" 7 | 8 | "github.com/mailhog/MailHog-Server/config" 9 | ) 10 | 11 | func Listen(cfg *config.Config, exitCh chan int) *net.TCPListener { 12 | log.Printf("[SMTP] Binding to address: %s\n", cfg.SMTPBindAddr) 13 | ln, err := net.Listen("tcp", cfg.SMTPBindAddr) 14 | if err != nil { 15 | log.Fatalf("[SMTP] Error listening on socket: %s\n", err) 16 | } 17 | defer ln.Close() 18 | 19 | for { 20 | conn, err := ln.Accept() 21 | if err != nil { 22 | log.Printf("[SMTP] Error accepting connection: %s\n", err) 23 | continue 24 | } 25 | 26 | if cfg.Monkey != nil { 27 | ok := cfg.Monkey.Accept(conn) 28 | if !ok { 29 | conn.Close() 30 | continue 31 | } 32 | } 33 | 34 | go Accept( 35 | conn.(*net.TCPConn).RemoteAddr().String(), 36 | io.ReadWriteCloser(conn), 37 | cfg.Storage, 38 | cfg.MessageChan, 39 | cfg.Hostname, 40 | cfg.Monkey, 41 | ) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/MailHog-Server/websockets/connection.go: -------------------------------------------------------------------------------- 1 | package websockets 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/gorilla/websocket" 7 | ) 8 | 9 | const ( 10 | // Time allowed to write a message to the peer. 11 | writeWait = 10 * time.Second 12 | // Time allowed to read the next pong message from the peer. 13 | pongWait = 60 * time.Second 14 | // Send pings to peer with this period. Must be less than pongWait. 15 | pingPeriod = (pongWait * 9) / 10 16 | // Maximum message size allowed from peer. Set to minimum allowed value as we don't expect the client to send non-control messages. 17 | maxMessageSize = 1 18 | ) 19 | 20 | type connection struct { 21 | hub *Hub 22 | ws *websocket.Conn 23 | send chan interface{} 24 | } 25 | 26 | func (c *connection) readLoop() { 27 | defer func() { 28 | c.hub.unregisterChan <- c 29 | c.ws.Close() 30 | }() 31 | c.ws.SetReadLimit(maxMessageSize) 32 | c.ws.SetReadDeadline(time.Now().Add(pongWait)) 33 | c.ws.SetPongHandler(func(string) error { c.ws.SetReadDeadline(time.Now().Add(pongWait)); return nil }) 34 | for { 35 | if _, _, err := c.ws.NextReader(); err != nil { 36 | return 37 | } 38 | } 39 | } 40 | 41 | func (c *connection) writeLoop() { 42 | ticker := time.NewTicker(pingPeriod) 43 | defer func() { 44 | ticker.Stop() 45 | c.ws.Close() 46 | }() 47 | for { 48 | select { 49 | case message, ok := <-c.send: 50 | if !ok { 51 | c.writeControl(websocket.CloseMessage) 52 | return 53 | } 54 | if err := c.writeJSON(message); err != nil { 55 | return 56 | } 57 | case <-ticker.C: 58 | if err := c.writeControl(websocket.PingMessage); err != nil { 59 | return 60 | } 61 | } 62 | } 63 | } 64 | 65 | func (c *connection) writeJSON(message interface{}) error { 66 | c.ws.SetWriteDeadline(time.Now().Add(writeWait)) 67 | return c.ws.WriteJSON(message) 68 | } 69 | 70 | func (c *connection) writeControl(messageType int) error { 71 | c.ws.SetWriteDeadline(time.Now().Add(writeWait)) 72 | return c.ws.WriteMessage(messageType, []byte{}) 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/MailHog-Server/websockets/hub.go: -------------------------------------------------------------------------------- 1 | package websockets 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/gorilla/websocket" 7 | "github.com/ian-kent/go-log/log" 8 | ) 9 | 10 | type Hub struct { 11 | upgrader websocket.Upgrader 12 | connections map[*connection]bool 13 | messages chan interface{} 14 | registerChan chan *connection 15 | unregisterChan chan *connection 16 | } 17 | 18 | func NewHub() *Hub { 19 | hub := &Hub{ 20 | upgrader: websocket.Upgrader{ 21 | ReadBufferSize: 256, 22 | WriteBufferSize: 4096, 23 | CheckOrigin: func(r *http.Request) bool { 24 | return true 25 | }, 26 | }, 27 | connections: make(map[*connection]bool), 28 | messages: make(chan interface{}), 29 | registerChan: make(chan *connection), 30 | unregisterChan: make(chan *connection), 31 | } 32 | go hub.run() 33 | return hub 34 | } 35 | 36 | func (h *Hub) run() { 37 | for { 38 | select { 39 | case c := <-h.registerChan: 40 | h.connections[c] = true 41 | case c := <-h.unregisterChan: 42 | h.unregister(c) 43 | case m := <-h.messages: 44 | for c := range h.connections { 45 | select { 46 | case c.send <- m: 47 | default: 48 | h.unregister(c) 49 | } 50 | } 51 | } 52 | } 53 | } 54 | 55 | func (h *Hub) unregister(c *connection) { 56 | if _, ok := h.connections[c]; ok { 57 | close(c.send) 58 | delete(h.connections, c) 59 | } 60 | } 61 | 62 | func (h *Hub) Serve(w http.ResponseWriter, r *http.Request) { 63 | ws, err := h.upgrader.Upgrade(w, r, nil) 64 | if err != nil { 65 | log.Println(err) 66 | return 67 | } 68 | c := &connection{hub: h, ws: ws, send: make(chan interface{}, 256)} 69 | h.registerChan <- c 70 | go c.writeLoop() 71 | go c.readLoop() 72 | } 73 | 74 | func (h *Hub) Broadcast(data interface{}) { 75 | h.messages <- data 76 | } 77 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/MailHog-UI/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 - 2016 Ian Kent 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/MailHog-UI/Makefile: -------------------------------------------------------------------------------- 1 | all: bindata fmt ui 2 | 3 | ui: 4 | go install . 5 | 6 | bindata: bindata-deps 7 | -rm assets/assets.go 8 | go-bindata -o assets/assets.go -pkg assets assets/... 9 | 10 | bindata-deps: 11 | go get github.com/jteeuwen/go-bindata/... 12 | 13 | fmt: 14 | go fmt ./... 15 | 16 | .PNONY: all ui bindata bindata-deps fmt 17 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/MailHog-UI/README.md: -------------------------------------------------------------------------------- 1 | MailHog UI [![Build Status](https://travis-ci.org/mailhog/MailHog-UI.svg?branch=master)](https://travis-ci.org/mailhog/MailHog-UI) 2 | ========= 3 | 4 | MailHog-UI is the MailHog web based user interface. 5 | 6 | ### Licence 7 | 8 | Copyright ©‎ 2014 - 2016, Ian Kent (http://iankent.uk) 9 | 10 | Released under MIT license, see [LICENSE](LICENSE.md) for details. 11 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/MailHog-UI/config/config.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "flag" 5 | 6 | "github.com/ian-kent/envconf" 7 | ) 8 | 9 | func DefaultConfig() *Config { 10 | return &Config{ 11 | APIHost: "", 12 | UIBindAddr: "0.0.0.0:8025", 13 | WebPath: "", 14 | } 15 | } 16 | 17 | type Config struct { 18 | APIHost string 19 | UIBindAddr string 20 | WebPath string 21 | } 22 | 23 | var cfg = DefaultConfig() 24 | 25 | func Configure() *Config { 26 | return cfg 27 | } 28 | 29 | func RegisterFlags() { 30 | flag.StringVar(&cfg.APIHost, "api-host", envconf.FromEnvP("MH_API_HOST", "").(string), "API URL for MailHog UI to connect to, e.g. http://some.host:1234") 31 | flag.StringVar(&cfg.UIBindAddr, "ui-bind-addr", envconf.FromEnvP("MH_UI_BIND_ADDR", "0.0.0.0:8025").(string), "HTTP bind interface and port for UI, e.g. 0.0.0.0:8025 or just :8025") 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/MailHog-UI/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "os" 6 | 7 | gohttp "net/http" 8 | 9 | "github.com/gorilla/pat" 10 | "github.com/ian-kent/go-log/log" 11 | "github.com/mailhog/MailHog-UI/assets" 12 | "github.com/mailhog/MailHog-UI/config" 13 | "github.com/mailhog/MailHog-UI/web" 14 | comcfg "github.com/mailhog/MailHog/config" 15 | "github.com/mailhog/http" 16 | ) 17 | 18 | var conf *config.Config 19 | var comconf *comcfg.Config 20 | var exitCh chan int 21 | 22 | func configure() { 23 | comcfg.RegisterFlags() 24 | config.RegisterFlags() 25 | flag.Parse() 26 | conf = config.Configure() 27 | comconf = comcfg.Configure() 28 | // FIXME hacky 29 | web.APIHost = conf.APIHost 30 | } 31 | 32 | func main() { 33 | configure() 34 | 35 | // FIXME need to make API URL configurable 36 | 37 | if comconf.AuthFile != "" { 38 | http.AuthFile(comconf.AuthFile) 39 | } 40 | 41 | exitCh = make(chan int) 42 | cb := func(r gohttp.Handler) { 43 | web.CreateWeb(conf, r.(*pat.Router), assets.Asset) 44 | } 45 | go http.Listen(conf.UIBindAddr, assets.Asset, exitCh, cb) 46 | 47 | for { 48 | select { 49 | case <-exitCh: 50 | log.Printf("Received exit signal") 51 | os.Exit(0) 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/data/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Ian Kent 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/data/README.md: -------------------------------------------------------------------------------- 1 | MailHog data library [![GoDoc](https://godoc.org/github.com/mailhog/data?status.svg)](https://godoc.org/github.com/mailhog/data) [![Build Status](https://travis-ci.org/mailhog/data.svg?branch=master)](https://travis-ci.org/mailhog/data) 2 | ========= 3 | 4 | `github.com/mailhog/data` implements a data library 5 | 6 | ### Licence 7 | 8 | Copyright ©‎ 2014-2015, Ian Kent (http://iankent.uk) 9 | 10 | Released under MIT license, see [LICENSE](LICENSE.md) for details. 11 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/http/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Ian Kent 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/http/README.md: -------------------------------------------------------------------------------- 1 | MailHog HTTP utilities [![GoDoc](https://godoc.org/github.com/mailhog/http?status.svg)](https://godoc.org/github.com/mailhog/http) [![Build Status](https://travis-ci.org/mailhog/http.svg?branch=master)](https://travis-ci.org/mailhog/http) 2 | ========= 3 | 4 | `github.com/mailhog/http` provides HTTP utilities used by MailHog-UI and MailHog-Server. 5 | 6 | ### Licence 7 | 8 | Copyright ©‎ 2014-2015, Ian Kent (http://iankent.uk) 9 | 10 | Released under MIT license, see [LICENSE](LICENSE.md) for details. 11 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/http/server.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | "io/ioutil" 7 | "net/http" 8 | "os" 9 | "strings" 10 | 11 | "github.com/gorilla/pat" 12 | "github.com/ian-kent/go-log/log" 13 | "golang.org/x/crypto/bcrypt" 14 | ) 15 | 16 | // Authorised should be given a function to enable HTTP Basic Authentication 17 | var Authorised func(string, string) bool 18 | var users map[string]string 19 | 20 | // AuthFile sets Authorised to a function which validates against file 21 | func AuthFile(file string) { 22 | users = make(map[string]string) 23 | 24 | b, err := ioutil.ReadFile(file) 25 | if err != nil { 26 | log.Fatalf("[HTTP] Error reading auth-file: %s", err) 27 | // FIXME - go-log 28 | os.Exit(1) 29 | } 30 | 31 | buf := bytes.NewBuffer(b) 32 | 33 | for { 34 | l, err := buf.ReadString('\n') 35 | l = strings.TrimSpace(l) 36 | if len(l) > 0 { 37 | p := strings.SplitN(l, ":", 2) 38 | if len(p) < 2 { 39 | log.Fatalf("[HTTP] Error reading auth-file, invalid line: %s", l) 40 | // FIXME - go-log 41 | os.Exit(1) 42 | } 43 | users[p[0]] = p[1] 44 | } 45 | switch { 46 | case err == io.EOF: 47 | break 48 | case err != nil: 49 | log.Fatalf("[HTTP] Error reading auth-file: %s", err) 50 | // FIXME - go-log 51 | os.Exit(1) 52 | break 53 | } 54 | if err == io.EOF { 55 | break 56 | } else if err != nil { 57 | } 58 | } 59 | 60 | log.Printf("[HTTP] Loaded %d users from %s", len(users), file) 61 | 62 | Authorised = func(u, pw string) bool { 63 | hpw, ok := users[u] 64 | if !ok { 65 | return false 66 | } 67 | 68 | err := bcrypt.CompareHashAndPassword([]byte(hpw), []byte(pw)) 69 | if err != nil { 70 | return false 71 | } 72 | 73 | return true 74 | } 75 | } 76 | 77 | // BasicAuthHandler is middleware to check HTTP Basic Authentication 78 | // if an authorisation function is defined. 79 | func BasicAuthHandler(h http.Handler) http.Handler { 80 | f := func(w http.ResponseWriter, req *http.Request) { 81 | if Authorised == nil { 82 | h.ServeHTTP(w, req) 83 | return 84 | } 85 | 86 | u, pw, ok := req.BasicAuth() 87 | if !ok || !Authorised(u, pw) { 88 | w.Header().Set("WWW-Authenticate", "Basic") 89 | w.WriteHeader(401) 90 | return 91 | } 92 | h.ServeHTTP(w, req) 93 | } 94 | 95 | return http.HandlerFunc(f) 96 | } 97 | 98 | // Listen binds to httpBindAddr 99 | func Listen(httpBindAddr string, Asset func(string) ([]byte, error), exitCh chan int, registerCallback func(http.Handler)) { 100 | log.Info("[HTTP] Binding to address: %s", httpBindAddr) 101 | 102 | pat := pat.New() 103 | registerCallback(pat) 104 | 105 | //compress := handlers.CompressHandler(pat) 106 | auth := BasicAuthHandler(pat) //compress) 107 | 108 | err := http.ListenAndServe(httpBindAddr, auth) 109 | if err != nil { 110 | log.Fatalf("[HTTP] Error binding to address %s: %s", httpBindAddr, err) 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/mhsendmail/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 - 2016 Ian Kent 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/mhsendmail/cmd/cmd.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "io/ioutil" 7 | "log" 8 | "net/mail" 9 | "net/smtp" 10 | "os" 11 | "os/user" 12 | ) 13 | 14 | import flag "github.com/spf13/pflag" 15 | 16 | // Go runs the MailHog sendmail replacement. 17 | func Go() { 18 | host, err := os.Hostname() 19 | if err != nil { 20 | host = "localhost" 21 | } 22 | 23 | username := "nobody" 24 | user, err := user.Current() 25 | if err == nil && user != nil && len(user.Username) > 0 { 26 | username = user.Username 27 | } 28 | 29 | fromAddr := username + "@" + host 30 | smtpAddr := "localhost:1025" 31 | var recip []string 32 | 33 | // defaults from envars if provided 34 | if len(os.Getenv("MH_SENDMAIL_SMTP_ADDR")) > 0 { 35 | smtpAddr = os.Getenv("MH_SENDMAIL_SMTP_ADDR") 36 | } 37 | if len(os.Getenv("MH_SENDMAIL_FROM")) > 0 { 38 | fromAddr = os.Getenv("MH_SENDMAIL_FROM") 39 | } 40 | 41 | var verbose bool 42 | 43 | // override defaults from cli flags 44 | flag.StringVar(&smtpAddr, "smtp-addr", smtpAddr, "SMTP server address") 45 | flag.StringVarP(&fromAddr, "from", "f", fromAddr, "SMTP sender") 46 | flag.BoolP("long-i", "i", true, "Ignored. This flag exists for sendmail compatibility.") 47 | flag.BoolP("long-t", "t", true, "Ignored. This flag exists for sendmail compatibility.") 48 | flag.BoolVarP(&verbose, "verbose", "v", false, "Verbose mode (sends debug output to stderr)") 49 | flag.Parse() 50 | 51 | // allow recipient to be passed as an argument 52 | recip = flag.Args() 53 | 54 | if verbose { 55 | fmt.Fprintln(os.Stderr, smtpAddr, fromAddr) 56 | } 57 | 58 | body, err := ioutil.ReadAll(os.Stdin) 59 | if err != nil { 60 | fmt.Fprintln(os.Stderr, "error reading stdin") 61 | os.Exit(11) 62 | } 63 | 64 | msg, err := mail.ReadMessage(bytes.NewReader(body)) 65 | if err != nil { 66 | fmt.Fprintln(os.Stderr, "error parsing message body") 67 | os.Exit(11) 68 | } 69 | 70 | if len(recip) == 0 { 71 | // We only need to parse the message to get a recipient if none where 72 | // provided on the command line. 73 | recip = append(recip, msg.Header.Get("To")) 74 | } 75 | 76 | err = smtp.SendMail(smtpAddr, nil, fromAddr, recip, body) 77 | if err != nil { 78 | fmt.Fprintln(os.Stderr, "error sending mail") 79 | log.Fatal(err) 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/smtp/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Ian Kent 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/smtp/state.go: -------------------------------------------------------------------------------- 1 | package smtp 2 | 3 | // State represents the state of an SMTP conversation 4 | type State int 5 | 6 | // SMTP message conversation states 7 | const ( 8 | INVALID = State(-1) 9 | ESTABLISH = State(iota) 10 | AUTHPLAIN 11 | AUTHLOGIN 12 | AUTHLOGIN2 13 | AUTHCRAMMD5 14 | MAIL 15 | RCPT 16 | DATA 17 | DONE 18 | ) 19 | 20 | // StateMap provides string representations of SMTP conversation states 21 | var StateMap = map[State]string{ 22 | INVALID: "INVALID", 23 | ESTABLISH: "ESTABLISH", 24 | AUTHPLAIN: "AUTHPLAIN", 25 | AUTHLOGIN: "AUTHLOGIN", 26 | AUTHLOGIN2: "AUTHLOGIN2", 27 | AUTHCRAMMD5: "AUTHCRAMMD5", 28 | MAIL: "MAIL", 29 | RCPT: "RCPT", 30 | DATA: "DATA", 31 | DONE: "DONE", 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/storage/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 - 2016 Ian Kent 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/storage/README.md: -------------------------------------------------------------------------------- 1 | MailHog storage backends [![GoDoc](https://godoc.org/github.com/mailhog/storage?status.svg)](https://godoc.org/github.com/mailhog/storage) [![Build Status](https://travis-ci.org/mailhog/storage.svg?branch=master)](https://travis-ci.org/mailhog/storage) 2 | ========= 3 | 4 | `github.com/mailhog/storage` implements MailHog storage backends: 5 | 6 | * In-memory 7 | * MongoDB 8 | 9 | You should implement `storage.Storage` interface to provide your 10 | own storage backend. 11 | 12 | ### Licence 13 | 14 | Copyright ©‎ 2014 - 2016, Ian Kent (http://iankent.uk) 15 | 16 | Released under MIT license, see [LICENSE](LICENSE.md) for details. 17 | -------------------------------------------------------------------------------- /vendor/github.com/mailhog/storage/storage.go: -------------------------------------------------------------------------------- 1 | package storage 2 | 3 | import "github.com/mailhog/data" 4 | 5 | // Storage represents a storage backend 6 | type Storage interface { 7 | Store(m *data.Message) (string, error) 8 | List(start, limit int) (*data.Messages, error) 9 | Search(kind, query string, start, limit int) (*data.Messages, int, error) 10 | Count() int 11 | DeleteOne(id string) error 12 | DeleteAll() error 13 | Load(id string) (*data.Message, error) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/philhofer/fwd/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-2015, Philip Hofer 2 | 3 | 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: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | 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. -------------------------------------------------------------------------------- /vendor/github.com/philhofer/fwd/writer_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package fwd 4 | 5 | func unsafestr(s string) []byte { return []byte(s) } 6 | -------------------------------------------------------------------------------- /vendor/github.com/philhofer/fwd/writer_unsafe.go: -------------------------------------------------------------------------------- 1 | // +build !appengine 2 | 3 | package fwd 4 | 5 | import ( 6 | "reflect" 7 | "unsafe" 8 | ) 9 | 10 | // unsafe cast string as []byte 11 | func unsafestr(b string) []byte { 12 | l := len(b) 13 | return *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{ 14 | Len: l, 15 | Cap: l, 16 | Data: (*reflect.StringHeader)(unsafe.Pointer(&b)).Data, 17 | })) 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | In general, the code posted to the [SmartyStreets github organization](https://github.com/smartystreets) is created to solve specific problems at SmartyStreets that are ancillary to our core products in the address verification industry and may or may not be useful to other organizations or developers. Our reason for posting said code isn't necessarily to solicit feedback or contributions from the community but more as a showcase of some of the approaches to solving problems we have adopted. 4 | 5 | Having stated that, we do consider issues raised by other githubbers as well as contributions submitted via pull requests. When submitting such a pull request, please follow these guidelines: 6 | 7 | - _Look before you leap:_ If the changes you plan to make are significant, it's in everyone's best interest for you to discuss them with a SmartyStreets team member prior to opening a pull request. 8 | - _License and ownership:_ If modifying the `LICENSE.md` file, limit your changes to fixing typographical mistakes. Do NOT modify the actual terms in the license or the copyright by **SmartyStreets, LLC**. Code submitted to SmartyStreets projects becomes property of SmartyStreets and must be compatible with the associated license. 9 | - _Testing:_ If the code you are submitting resides in packages/modules covered by automated tests, be sure to add passing tests that cover your changes and assert expected behavior and state. Submit the additional test cases as part of your change set. 10 | - _Style:_ Match your approach to **naming** and **formatting** with the surrounding code. Basically, the code you submit shouldn't stand out. 11 | - "Naming" refers to such constructs as variables, methods, functions, classes, structs, interfaces, packages, modules, directories, files, etc... 12 | - "Formatting" refers to such constructs as whitespace, horizontal line length, vertical function length, vertical file length, indentation, curly braces, etc... 13 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 SmartyStreets, LLC 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | 21 | NOTE: Various optional and subordinate components carry their own licensing 22 | requirements and restrictions. Use of those components is subject to the terms 23 | and conditions outlined the respective license of each component. 24 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/filter.go: -------------------------------------------------------------------------------- 1 | package assertions 2 | 3 | import "fmt" 4 | 5 | const ( 6 | success = "" 7 | needExactValues = "This assertion requires exactly %d comparison values (you provided %d)." 8 | needNonEmptyCollection = "This assertion requires at least 1 comparison value (you provided 0)." 9 | ) 10 | 11 | func need(needed int, expected []interface{}) string { 12 | if len(expected) != needed { 13 | return fmt.Sprintf(needExactValues, needed, len(expected)) 14 | } 15 | return success 16 | } 17 | 18 | func atLeast(minimum int, expected []interface{}) string { 19 | if len(expected) < 1 { 20 | return needNonEmptyCollection 21 | } 22 | return success 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/go-render/LICENSE: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 The Chromium Authors. All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/README.md: -------------------------------------------------------------------------------- 1 | [![GoDoc](https://godoc.org/github.com/smartystreets/assertions/internal/oglematchers?status.svg)](https://godoc.org/github.com/smartystreets/assertions/internal/oglematchers) 2 | 3 | `oglematchers` is a package for the Go programming language containing a set of 4 | matchers, useful in a testing or mocking framework, inspired by and mostly 5 | compatible with [Google Test][googletest] for C++ and 6 | [Google JS Test][google-js-test]. The package is used by the 7 | [ogletest][ogletest] testing framework and [oglemock][oglemock] mocking 8 | framework, which may be more directly useful to you, but can be generically used 9 | elsewhere as well. 10 | 11 | A "matcher" is simply an object with a `Matches` method defining a set of golang 12 | values matched by the matcher, and a `Description` method describing that set. 13 | For example, here are some matchers: 14 | 15 | ```go 16 | // Numbers 17 | Equals(17.13) 18 | LessThan(19) 19 | 20 | // Strings 21 | Equals("taco") 22 | HasSubstr("burrito") 23 | MatchesRegex("t.*o") 24 | 25 | // Combining matchers 26 | AnyOf(LessThan(17), GreaterThan(19)) 27 | ``` 28 | 29 | There are lots more; see [here][reference] for a reference. You can also add 30 | your own simply by implementing the `oglematchers.Matcher` interface. 31 | 32 | 33 | Installation 34 | ------------ 35 | 36 | First, make sure you have installed Go 1.0.2 or newer. See 37 | [here][golang-install] for instructions. 38 | 39 | Use the following command to install `oglematchers` and keep it up to date: 40 | 41 | go get -u github.com/smartystreets/assertions/internal/oglematchers 42 | 43 | 44 | Documentation 45 | ------------- 46 | 47 | See [here][reference] for documentation. Alternatively, you can install the 48 | package and then use `godoc`: 49 | 50 | godoc github.com/smartystreets/assertions/internal/oglematchers 51 | 52 | 53 | [reference]: http://godoc.org/github.com/smartystreets/assertions/internal/oglematchers 54 | [golang-install]: http://golang.org/doc/install.html 55 | [googletest]: http://code.google.com/p/googletest/ 56 | [google-js-test]: http://code.google.com/p/google-js-test/ 57 | [ogletest]: http://github.com/smartystreets/assertions/internal/ogletest 58 | [oglemock]: http://github.com/smartystreets/assertions/internal/oglemock 59 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/any_of.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "errors" 20 | "fmt" 21 | "reflect" 22 | "strings" 23 | ) 24 | 25 | // AnyOf accepts a set of values S and returns a matcher that follows the 26 | // algorithm below when considering a candidate c: 27 | // 28 | // 1. If there exists a value m in S such that m implements the Matcher 29 | // interface and m matches c, return true. 30 | // 31 | // 2. Otherwise, if there exists a value v in S such that v does not implement 32 | // the Matcher interface and the matcher Equals(v) matches c, return true. 33 | // 34 | // 3. Otherwise, if there is a value m in S such that m implements the Matcher 35 | // interface and m returns a fatal error for c, return that fatal error. 36 | // 37 | // 4. Otherwise, return false. 38 | // 39 | // This is akin to a logical OR operation for matchers, with non-matchers x 40 | // being treated as Equals(x). 41 | func AnyOf(vals ...interface{}) Matcher { 42 | // Get ahold of a type variable for the Matcher interface. 43 | var dummy *Matcher 44 | matcherType := reflect.TypeOf(dummy).Elem() 45 | 46 | // Create a matcher for each value, or use the value itself if it's already a 47 | // matcher. 48 | wrapped := make([]Matcher, len(vals)) 49 | for i, v := range vals { 50 | t := reflect.TypeOf(v) 51 | if t != nil && t.Implements(matcherType) { 52 | wrapped[i] = v.(Matcher) 53 | } else { 54 | wrapped[i] = Equals(v) 55 | } 56 | } 57 | 58 | return &anyOfMatcher{wrapped} 59 | } 60 | 61 | type anyOfMatcher struct { 62 | wrapped []Matcher 63 | } 64 | 65 | func (m *anyOfMatcher) Description() string { 66 | wrappedDescs := make([]string, len(m.wrapped)) 67 | for i, matcher := range m.wrapped { 68 | wrappedDescs[i] = matcher.Description() 69 | } 70 | 71 | return fmt.Sprintf("or(%s)", strings.Join(wrappedDescs, ", ")) 72 | } 73 | 74 | func (m *anyOfMatcher) Matches(c interface{}) (err error) { 75 | err = errors.New("") 76 | 77 | // Try each matcher in turn. 78 | for _, matcher := range m.wrapped { 79 | wrappedErr := matcher.Matches(c) 80 | 81 | // Return immediately if there's a match. 82 | if wrappedErr == nil { 83 | err = nil 84 | return 85 | } 86 | 87 | // Note the fatal error, if any. 88 | if _, isFatal := wrappedErr.(*FatalError); isFatal { 89 | err = wrappedErr 90 | } 91 | } 92 | 93 | return 94 | } 95 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/contains.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // Return a matcher that matches arrays slices with at least one element that 24 | // matches the supplied argument. If the argument x is not itself a Matcher, 25 | // this is equivalent to Contains(Equals(x)). 26 | func Contains(x interface{}) Matcher { 27 | var result containsMatcher 28 | var ok bool 29 | 30 | if result.elementMatcher, ok = x.(Matcher); !ok { 31 | result.elementMatcher = DeepEquals(x) 32 | } 33 | 34 | return &result 35 | } 36 | 37 | type containsMatcher struct { 38 | elementMatcher Matcher 39 | } 40 | 41 | func (m *containsMatcher) Description() string { 42 | return fmt.Sprintf("contains: %s", m.elementMatcher.Description()) 43 | } 44 | 45 | func (m *containsMatcher) Matches(candidate interface{}) error { 46 | // The candidate must be a slice or an array. 47 | v := reflect.ValueOf(candidate) 48 | if v.Kind() != reflect.Slice && v.Kind() != reflect.Array { 49 | return NewFatalError("which is not a slice or array") 50 | } 51 | 52 | // Check each element. 53 | for i := 0; i < v.Len(); i++ { 54 | elem := v.Index(i) 55 | if matchErr := m.elementMatcher.Matches(elem.Interface()); matchErr == nil { 56 | return nil 57 | } 58 | } 59 | 60 | return fmt.Errorf("") 61 | } 62 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/deep_equals.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "bytes" 20 | "errors" 21 | "fmt" 22 | "reflect" 23 | ) 24 | 25 | var byteSliceType reflect.Type = reflect.TypeOf([]byte{}) 26 | 27 | // DeepEquals returns a matcher that matches based on 'deep equality', as 28 | // defined by the reflect package. This matcher requires that values have 29 | // identical types to x. 30 | func DeepEquals(x interface{}) Matcher { 31 | return &deepEqualsMatcher{x} 32 | } 33 | 34 | type deepEqualsMatcher struct { 35 | x interface{} 36 | } 37 | 38 | func (m *deepEqualsMatcher) Description() string { 39 | xDesc := fmt.Sprintf("%v", m.x) 40 | xValue := reflect.ValueOf(m.x) 41 | 42 | // Special case: fmt.Sprintf presents nil slices as "[]", but 43 | // reflect.DeepEqual makes a distinction between nil and empty slices. Make 44 | // this less confusing. 45 | if xValue.Kind() == reflect.Slice && xValue.IsNil() { 46 | xDesc = "" 47 | } 48 | 49 | return fmt.Sprintf("deep equals: %s", xDesc) 50 | } 51 | 52 | func (m *deepEqualsMatcher) Matches(c interface{}) error { 53 | // Make sure the types match. 54 | ct := reflect.TypeOf(c) 55 | xt := reflect.TypeOf(m.x) 56 | 57 | if ct != xt { 58 | return NewFatalError(fmt.Sprintf("which is of type %v", ct)) 59 | } 60 | 61 | // Special case: handle byte slices more efficiently. 62 | cValue := reflect.ValueOf(c) 63 | xValue := reflect.ValueOf(m.x) 64 | 65 | if ct == byteSliceType && !cValue.IsNil() && !xValue.IsNil() { 66 | xBytes := m.x.([]byte) 67 | cBytes := c.([]byte) 68 | 69 | if bytes.Equal(cBytes, xBytes) { 70 | return nil 71 | } 72 | 73 | return errors.New("") 74 | } 75 | 76 | // Defer to the reflect package. 77 | if reflect.DeepEqual(m.x, c) { 78 | return nil 79 | } 80 | 81 | // Special case: if the comparison failed because c is the nil slice, given 82 | // an indication of this (since its value is printed as "[]"). 83 | if cValue.Kind() == reflect.Slice && cValue.IsNil() { 84 | return errors.New("which is nil") 85 | } 86 | 87 | return errors.New("") 88 | } 89 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // GreaterOrEqual returns a matcher that matches integer, floating point, or 24 | // strings values v such that v >= x. Comparison is not defined between numeric 25 | // and string types, but is defined between all integer and floating point 26 | // types. 27 | // 28 | // x must itself be an integer, floating point, or string type; otherwise, 29 | // GreaterOrEqual will panic. 30 | func GreaterOrEqual(x interface{}) Matcher { 31 | desc := fmt.Sprintf("greater than or equal to %v", x) 32 | 33 | // Special case: make it clear that strings are strings. 34 | if reflect.TypeOf(x).Kind() == reflect.String { 35 | desc = fmt.Sprintf("greater than or equal to \"%s\"", x) 36 | } 37 | 38 | return transformDescription(Not(LessThan(x)), desc) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_than.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // GreaterThan returns a matcher that matches integer, floating point, or 24 | // strings values v such that v > x. Comparison is not defined between numeric 25 | // and string types, but is defined between all integer and floating point 26 | // types. 27 | // 28 | // x must itself be an integer, floating point, or string type; otherwise, 29 | // GreaterThan will panic. 30 | func GreaterThan(x interface{}) Matcher { 31 | desc := fmt.Sprintf("greater than %v", x) 32 | 33 | // Special case: make it clear that strings are strings. 34 | if reflect.TypeOf(x).Kind() == reflect.String { 35 | desc = fmt.Sprintf("greater than \"%s\"", x) 36 | } 37 | 38 | return transformDescription(Not(LessOrEqual(x)), desc) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // LessOrEqual returns a matcher that matches integer, floating point, or 24 | // strings values v such that v <= x. Comparison is not defined between numeric 25 | // and string types, but is defined between all integer and floating point 26 | // types. 27 | // 28 | // x must itself be an integer, floating point, or string type; otherwise, 29 | // LessOrEqual will panic. 30 | func LessOrEqual(x interface{}) Matcher { 31 | desc := fmt.Sprintf("less than or equal to %v", x) 32 | 33 | // Special case: make it clear that strings are strings. 34 | if reflect.TypeOf(x).Kind() == reflect.String { 35 | desc = fmt.Sprintf("less than or equal to \"%s\"", x) 36 | } 37 | 38 | // Put LessThan last so that its error messages will be used in the event of 39 | // failure. 40 | return transformDescription(AnyOf(Equals(x), LessThan(x)), desc) 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/not.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "errors" 20 | "fmt" 21 | ) 22 | 23 | // Not returns a matcher that inverts the set of values matched by the wrapped 24 | // matcher. It does not transform the result for values for which the wrapped 25 | // matcher returns a fatal error. 26 | func Not(m Matcher) Matcher { 27 | return ¬Matcher{m} 28 | } 29 | 30 | type notMatcher struct { 31 | wrapped Matcher 32 | } 33 | 34 | func (m *notMatcher) Matches(c interface{}) (err error) { 35 | err = m.wrapped.Matches(c) 36 | 37 | // Did the wrapped matcher say yes? 38 | if err == nil { 39 | return errors.New("") 40 | } 41 | 42 | // Did the wrapped matcher return a fatal error? 43 | if _, isFatal := err.(*FatalError); isFatal { 44 | return err 45 | } 46 | 47 | // The wrapped matcher returned a non-fatal error. 48 | return nil 49 | } 50 | 51 | func (m *notMatcher) Description() string { 52 | return fmt.Sprintf("not(%s)", m.wrapped.Description()) 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | // transformDescription returns a matcher that is equivalent to the supplied 19 | // one, except that it has the supplied description instead of the one attached 20 | // to the existing matcher. 21 | func transformDescription(m Matcher, newDesc string) Matcher { 22 | return &transformDescriptionMatcher{newDesc, m} 23 | } 24 | 25 | type transformDescriptionMatcher struct { 26 | desc string 27 | wrappedMatcher Matcher 28 | } 29 | 30 | func (m *transformDescriptionMatcher) Description() string { 31 | return m.desc 32 | } 33 | 34 | func (m *transformDescriptionMatcher) Matches(c interface{}) error { 35 | return m.wrappedMatcher.Matches(c) 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/panic.go: -------------------------------------------------------------------------------- 1 | package assertions 2 | 3 | import "fmt" 4 | 5 | // ShouldPanic receives a void, niladic function and expects to recover a panic. 6 | func ShouldPanic(actual interface{}, expected ...interface{}) (message string) { 7 | if fail := need(0, expected); fail != success { 8 | return fail 9 | } 10 | 11 | action, _ := actual.(func()) 12 | 13 | if action == nil { 14 | message = shouldUseVoidNiladicFunction 15 | return 16 | } 17 | 18 | defer func() { 19 | recovered := recover() 20 | if recovered == nil { 21 | message = shouldHavePanicked 22 | } else { 23 | message = success 24 | } 25 | }() 26 | action() 27 | 28 | return 29 | } 30 | 31 | // ShouldNotPanic receives a void, niladic function and expects to execute the function without any panic. 32 | func ShouldNotPanic(actual interface{}, expected ...interface{}) (message string) { 33 | if fail := need(0, expected); fail != success { 34 | return fail 35 | } 36 | 37 | action, _ := actual.(func()) 38 | 39 | if action == nil { 40 | message = shouldUseVoidNiladicFunction 41 | return 42 | } 43 | 44 | defer func() { 45 | recovered := recover() 46 | if recovered != nil { 47 | message = fmt.Sprintf(shouldNotHavePanicked, recovered) 48 | } else { 49 | message = success 50 | } 51 | }() 52 | action() 53 | 54 | return 55 | } 56 | 57 | // ShouldPanicWith receives a void, niladic function and expects to recover a panic with the second argument as the content. 58 | func ShouldPanicWith(actual interface{}, expected ...interface{}) (message string) { 59 | if fail := need(1, expected); fail != success { 60 | return fail 61 | } 62 | 63 | action, _ := actual.(func()) 64 | 65 | if action == nil { 66 | message = shouldUseVoidNiladicFunction 67 | return 68 | } 69 | 70 | defer func() { 71 | recovered := recover() 72 | if recovered == nil { 73 | message = shouldHavePanicked 74 | } else { 75 | if equal := ShouldEqual(recovered, expected[0]); equal != success { 76 | message = serializer.serialize(expected[0], recovered, fmt.Sprintf(shouldHavePanickedWith, expected[0], recovered)) 77 | } else { 78 | message = success 79 | } 80 | } 81 | }() 82 | action() 83 | 84 | return 85 | } 86 | 87 | // ShouldNotPanicWith receives a void, niladic function and expects to recover a panic whose content differs from the second argument. 88 | func ShouldNotPanicWith(actual interface{}, expected ...interface{}) (message string) { 89 | if fail := need(1, expected); fail != success { 90 | return fail 91 | } 92 | 93 | action, _ := actual.(func()) 94 | 95 | if action == nil { 96 | message = shouldUseVoidNiladicFunction 97 | return 98 | } 99 | 100 | defer func() { 101 | recovered := recover() 102 | if recovered == nil { 103 | message = success 104 | } else { 105 | if equal := ShouldEqual(recovered, expected[0]); equal == success { 106 | message = fmt.Sprintf(shouldNotHavePanickedWith, expected[0]) 107 | } else { 108 | message = success 109 | } 110 | } 111 | }() 112 | action() 113 | 114 | return 115 | } 116 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/serializer.go: -------------------------------------------------------------------------------- 1 | package assertions 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | 7 | "github.com/smartystreets/assertions/internal/go-render/render" 8 | ) 9 | 10 | type Serializer interface { 11 | serialize(expected, actual interface{}, message string) string 12 | serializeDetailed(expected, actual interface{}, message string) string 13 | } 14 | 15 | type failureSerializer struct{} 16 | 17 | func (self *failureSerializer) serializeDetailed(expected, actual interface{}, message string) string { 18 | view := FailureView{ 19 | Message: message, 20 | Expected: render.Render(expected), 21 | Actual: render.Render(actual), 22 | } 23 | serialized, err := json.Marshal(view) 24 | if err != nil { 25 | return message 26 | } 27 | return string(serialized) 28 | } 29 | 30 | func (self *failureSerializer) serialize(expected, actual interface{}, message string) string { 31 | view := FailureView{ 32 | Message: message, 33 | Expected: fmt.Sprintf("%+v", expected), 34 | Actual: fmt.Sprintf("%+v", actual), 35 | } 36 | serialized, err := json.Marshal(view) 37 | if err != nil { 38 | return message 39 | } 40 | return string(serialized) 41 | } 42 | 43 | func newSerializer() *failureSerializer { 44 | return &failureSerializer{} 45 | } 46 | 47 | /////////////////////////////////////////////////////////////////////////////// 48 | 49 | // This struct is also declared in github.com/smartystreets/goconvey/convey/reporting. 50 | // The json struct tags should be equal in both declarations. 51 | type FailureView struct { 52 | Message string `json:"Message"` 53 | Expected string `json:"Expected"` 54 | Actual string `json:"Actual"` 55 | } 56 | 57 | /////////////////////////////////////////////////////// 58 | 59 | // noopSerializer just gives back the original message. This is useful when we are using 60 | // the assertions from a context other than the GoConvey Web UI, that requires the JSON 61 | // structure provided by the failureSerializer. 62 | type noopSerializer struct{} 63 | 64 | func (self *noopSerializer) serialize(expected, actual interface{}, message string) string { 65 | return message 66 | } 67 | func (self *noopSerializer) serializeDetailed(expected, actual interface{}, message string) string { 68 | return message 69 | } 70 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 SmartyStreets, LLC 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | 21 | NOTE: Various optional and subordinate components carry their own licensing 22 | requirements and restrictions. Use of those components is subject to the terms 23 | and conditions outlined the respective license of each component. 24 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/convey.goconvey: -------------------------------------------------------------------------------- 1 | #ignore 2 | -timeout=1s 3 | #-covermode=count 4 | #-coverpkg=github.com/smartystreets/goconvey/convey,github.com/smartystreets/goconvey/convey/gotest,github.com/smartystreets/goconvey/convey/reporting -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/discovery.go: -------------------------------------------------------------------------------- 1 | package convey 2 | 3 | type actionSpecifier uint8 4 | 5 | const ( 6 | noSpecifier actionSpecifier = iota 7 | skipConvey 8 | focusConvey 9 | ) 10 | 11 | type suite struct { 12 | Situation string 13 | Test t 14 | Focus bool 15 | Func func(C) // nil means skipped 16 | FailMode FailureMode 17 | } 18 | 19 | func newSuite(situation string, failureMode FailureMode, f func(C), test t, specifier actionSpecifier) *suite { 20 | ret := &suite{ 21 | Situation: situation, 22 | Test: test, 23 | Func: f, 24 | FailMode: failureMode, 25 | } 26 | switch specifier { 27 | case skipConvey: 28 | ret.Func = nil 29 | case focusConvey: 30 | ret.Focus = true 31 | } 32 | return ret 33 | } 34 | 35 | func discover(items []interface{}) *suite { 36 | name, items := parseName(items) 37 | test, items := parseGoTest(items) 38 | failure, items := parseFailureMode(items) 39 | action, items := parseAction(items) 40 | specifier, items := parseSpecifier(items) 41 | 42 | if len(items) != 0 { 43 | conveyPanic(parseError) 44 | } 45 | 46 | return newSuite(name, failure, action, test, specifier) 47 | } 48 | func item(items []interface{}) interface{} { 49 | if len(items) == 0 { 50 | conveyPanic(parseError) 51 | } 52 | return items[0] 53 | } 54 | func parseName(items []interface{}) (string, []interface{}) { 55 | if name, parsed := item(items).(string); parsed { 56 | return name, items[1:] 57 | } 58 | conveyPanic(parseError) 59 | panic("never get here") 60 | } 61 | func parseGoTest(items []interface{}) (t, []interface{}) { 62 | if test, parsed := item(items).(t); parsed { 63 | return test, items[1:] 64 | } 65 | return nil, items 66 | } 67 | func parseFailureMode(items []interface{}) (FailureMode, []interface{}) { 68 | if mode, parsed := item(items).(FailureMode); parsed { 69 | return mode, items[1:] 70 | } 71 | return FailureInherits, items 72 | } 73 | func parseAction(items []interface{}) (func(C), []interface{}) { 74 | switch x := item(items).(type) { 75 | case nil: 76 | return nil, items[1:] 77 | case func(C): 78 | return x, items[1:] 79 | case func(): 80 | return func(C) { x() }, items[1:] 81 | } 82 | conveyPanic(parseError) 83 | panic("never get here") 84 | } 85 | func parseSpecifier(items []interface{}) (actionSpecifier, []interface{}) { 86 | if len(items) == 0 { 87 | return noSpecifier, items 88 | } 89 | if spec, ok := items[0].(actionSpecifier); ok { 90 | return spec, items[1:] 91 | } 92 | conveyPanic(parseError) 93 | panic("never get here") 94 | } 95 | 96 | // This interface allows us to pass the *testing.T struct 97 | // throughout the internals of this package without ever 98 | // having to import the "testing" package. 99 | type t interface { 100 | Fail() 101 | } 102 | 103 | const parseError = "You must provide a name (string), then a *testing.T (if in outermost scope), an optional FailureMode, and then an action (func())." 104 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/gotest/utils.go: -------------------------------------------------------------------------------- 1 | // Package gotest contains internal functionality. Although this package 2 | // contains one or more exported names it is not intended for public 3 | // consumption. See the examples package for how to use this project. 4 | package gotest 5 | 6 | import ( 7 | "runtime" 8 | "strings" 9 | ) 10 | 11 | func ResolveExternalCaller() (file string, line int, name string) { 12 | var caller_id uintptr 13 | callers := runtime.Callers(0, callStack) 14 | 15 | for x := 0; x < callers; x++ { 16 | caller_id, file, line, _ = runtime.Caller(x) 17 | if strings.HasSuffix(file, "_test.go") || strings.HasSuffix(file, "_tests.go") { 18 | name = runtime.FuncForPC(caller_id).Name() 19 | return 20 | } 21 | } 22 | file, line, name = "", -1, "" 23 | return // panic? 24 | } 25 | 26 | const maxStackDepth = 100 // This had better be enough... 27 | 28 | var callStack []uintptr = make([]uintptr, maxStackDepth, maxStackDepth) 29 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/init.go: -------------------------------------------------------------------------------- 1 | package convey 2 | 3 | import ( 4 | "flag" 5 | "os" 6 | 7 | "github.com/jtolds/gls" 8 | "github.com/smartystreets/assertions" 9 | "github.com/smartystreets/goconvey/convey/reporting" 10 | ) 11 | 12 | func init() { 13 | assertions.GoConveyMode(true) 14 | 15 | declareFlags() 16 | 17 | ctxMgr = gls.NewContextManager() 18 | } 19 | 20 | func declareFlags() { 21 | flag.BoolVar(&json, "convey-json", false, "When true, emits results in JSON blocks. Default: 'false'") 22 | flag.BoolVar(&silent, "convey-silent", false, "When true, all output from GoConvey is suppressed.") 23 | flag.BoolVar(&story, "convey-story", false, "When true, emits story output, otherwise emits dot output. When not provided, this flag mirros the value of the '-test.v' flag") 24 | 25 | if noStoryFlagProvided() { 26 | story = verboseEnabled 27 | } 28 | 29 | // FYI: flag.Parse() is called from the testing package. 30 | } 31 | 32 | func noStoryFlagProvided() bool { 33 | return !story && !storyDisabled 34 | } 35 | 36 | func buildReporter() reporting.Reporter { 37 | selectReporter := os.Getenv("GOCONVEY_REPORTER") 38 | 39 | switch { 40 | case testReporter != nil: 41 | return testReporter 42 | case json || selectReporter == "json": 43 | return reporting.BuildJsonReporter() 44 | case silent || selectReporter == "silent": 45 | return reporting.BuildSilentReporter() 46 | case selectReporter == "dot": 47 | // Story is turned on when verbose is set, so we need to check for dot reporter first. 48 | return reporting.BuildDotReporter() 49 | case story || selectReporter == "story": 50 | return reporting.BuildStoryReporter() 51 | default: 52 | return reporting.BuildDotReporter() 53 | } 54 | } 55 | 56 | var ( 57 | ctxMgr *gls.ContextManager 58 | 59 | // only set by internal tests 60 | testReporter reporting.Reporter 61 | ) 62 | 63 | var ( 64 | json bool 65 | silent bool 66 | story bool 67 | 68 | verboseEnabled = flagFound("-test.v=true") 69 | storyDisabled = flagFound("-story=false") 70 | ) 71 | 72 | // flagFound parses the command line args manually for flags defined in other 73 | // packages. Like the '-v' flag from the "testing" package, for instance. 74 | func flagFound(flagValue string) bool { 75 | for _, arg := range os.Args { 76 | if arg == flagValue { 77 | return true 78 | } 79 | } 80 | return false 81 | } 82 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/nilReporter.go: -------------------------------------------------------------------------------- 1 | package convey 2 | 3 | import ( 4 | "github.com/smartystreets/goconvey/convey/reporting" 5 | ) 6 | 7 | type nilReporter struct{} 8 | 9 | func (self *nilReporter) BeginStory(story *reporting.StoryReport) {} 10 | func (self *nilReporter) Enter(scope *reporting.ScopeReport) {} 11 | func (self *nilReporter) Report(report *reporting.AssertionResult) {} 12 | func (self *nilReporter) Exit() {} 13 | func (self *nilReporter) EndStory() {} 14 | func (self *nilReporter) Write(p []byte) (int, error) { return len(p), nil } 15 | func newNilReporter() *nilReporter { return &nilReporter{} } 16 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/console.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | ) 7 | 8 | type console struct{} 9 | 10 | func (self *console) Write(p []byte) (n int, err error) { 11 | return fmt.Print(string(p)) 12 | } 13 | 14 | func NewConsole() io.Writer { 15 | return new(console) 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/doc.go: -------------------------------------------------------------------------------- 1 | // Package reporting contains internal functionality related 2 | // to console reporting and output. Although this package has 3 | // exported names is not intended for public consumption. See the 4 | // examples package for how to use this project. 5 | package reporting 6 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/dot.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import "fmt" 4 | 5 | type dot struct{ out *Printer } 6 | 7 | func (self *dot) BeginStory(story *StoryReport) {} 8 | 9 | func (self *dot) Enter(scope *ScopeReport) {} 10 | 11 | func (self *dot) Report(report *AssertionResult) { 12 | if report.Error != nil { 13 | fmt.Print(redColor) 14 | self.out.Insert(dotError) 15 | } else if report.Failure != "" { 16 | fmt.Print(yellowColor) 17 | self.out.Insert(dotFailure) 18 | } else if report.Skipped { 19 | fmt.Print(yellowColor) 20 | self.out.Insert(dotSkip) 21 | } else { 22 | fmt.Print(greenColor) 23 | self.out.Insert(dotSuccess) 24 | } 25 | fmt.Print(resetColor) 26 | } 27 | 28 | func (self *dot) Exit() {} 29 | 30 | func (self *dot) EndStory() {} 31 | 32 | func (self *dot) Write(content []byte) (written int, err error) { 33 | return len(content), nil // no-op 34 | } 35 | 36 | func NewDotReporter(out *Printer) *dot { 37 | self := new(dot) 38 | self.out = out 39 | return self 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/gotest.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | type gotestReporter struct{ test T } 4 | 5 | func (self *gotestReporter) BeginStory(story *StoryReport) { 6 | self.test = story.Test 7 | } 8 | 9 | func (self *gotestReporter) Enter(scope *ScopeReport) {} 10 | 11 | func (self *gotestReporter) Report(r *AssertionResult) { 12 | if !passed(r) { 13 | self.test.Fail() 14 | } 15 | } 16 | 17 | func (self *gotestReporter) Exit() {} 18 | 19 | func (self *gotestReporter) EndStory() { 20 | self.test = nil 21 | } 22 | 23 | func (self *gotestReporter) Write(content []byte) (written int, err error) { 24 | return len(content), nil // no-op 25 | } 26 | 27 | func NewGoTestReporter() *gotestReporter { 28 | return new(gotestReporter) 29 | } 30 | 31 | func passed(r *AssertionResult) bool { 32 | return r.Error == nil && r.Failure == "" 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/init.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import ( 4 | "os" 5 | "runtime" 6 | "strings" 7 | ) 8 | 9 | func init() { 10 | if !isColorableTerminal() { 11 | monochrome() 12 | } 13 | 14 | if runtime.GOOS == "windows" { 15 | success, failure, error_ = dotSuccess, dotFailure, dotError 16 | } 17 | } 18 | 19 | func BuildJsonReporter() Reporter { 20 | out := NewPrinter(NewConsole()) 21 | return NewReporters( 22 | NewGoTestReporter(), 23 | NewJsonReporter(out)) 24 | } 25 | func BuildDotReporter() Reporter { 26 | out := NewPrinter(NewConsole()) 27 | return NewReporters( 28 | NewGoTestReporter(), 29 | NewDotReporter(out), 30 | NewProblemReporter(out), 31 | consoleStatistics) 32 | } 33 | func BuildStoryReporter() Reporter { 34 | out := NewPrinter(NewConsole()) 35 | return NewReporters( 36 | NewGoTestReporter(), 37 | NewStoryReporter(out), 38 | NewProblemReporter(out), 39 | consoleStatistics) 40 | } 41 | func BuildSilentReporter() Reporter { 42 | out := NewPrinter(NewConsole()) 43 | return NewReporters( 44 | NewGoTestReporter(), 45 | NewSilentProblemReporter(out)) 46 | } 47 | 48 | var ( 49 | newline = "\n" 50 | success = "✔" 51 | failure = "✘" 52 | error_ = "🔥" 53 | skip = "⚠" 54 | dotSuccess = "." 55 | dotFailure = "x" 56 | dotError = "E" 57 | dotSkip = "S" 58 | errorTemplate = "* %s \nLine %d: - %v \n%s\n" 59 | failureTemplate = "* %s \nLine %d:\n%s\n" 60 | ) 61 | 62 | var ( 63 | greenColor = "\033[32m" 64 | yellowColor = "\033[33m" 65 | redColor = "\033[31m" 66 | resetColor = "\033[0m" 67 | ) 68 | 69 | var consoleStatistics = NewStatisticsReporter(NewPrinter(NewConsole())) 70 | 71 | func SuppressConsoleStatistics() { consoleStatistics.Suppress() } 72 | func PrintConsoleStatistics() { consoleStatistics.PrintSummary() } 73 | 74 | // QuiteMode disables all console output symbols. This is only meant to be used 75 | // for tests that are internal to goconvey where the output is distracting or 76 | // otherwise not needed in the test output. 77 | func QuietMode() { 78 | success, failure, error_, skip, dotSuccess, dotFailure, dotError, dotSkip = "", "", "", "", "", "", "", "" 79 | } 80 | 81 | func monochrome() { 82 | greenColor, yellowColor, redColor, resetColor = "", "", "", "" 83 | } 84 | 85 | func isColorableTerminal() bool { 86 | return strings.Contains(os.Getenv("TERM"), "color") 87 | } 88 | 89 | // This interface allows us to pass the *testing.T struct 90 | // throughout the internals of this tool without ever 91 | // having to import the "testing" package. 92 | type T interface { 93 | Fail() 94 | } 95 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/json.go: -------------------------------------------------------------------------------- 1 | // TODO: under unit test 2 | 3 | package reporting 4 | 5 | import ( 6 | "bytes" 7 | "encoding/json" 8 | "fmt" 9 | "strings" 10 | ) 11 | 12 | type JsonReporter struct { 13 | out *Printer 14 | currentKey []string 15 | current *ScopeResult 16 | index map[string]*ScopeResult 17 | scopes []*ScopeResult 18 | } 19 | 20 | func (self *JsonReporter) depth() int { return len(self.currentKey) } 21 | 22 | func (self *JsonReporter) BeginStory(story *StoryReport) {} 23 | 24 | func (self *JsonReporter) Enter(scope *ScopeReport) { 25 | self.currentKey = append(self.currentKey, scope.Title) 26 | ID := strings.Join(self.currentKey, "|") 27 | if _, found := self.index[ID]; !found { 28 | next := newScopeResult(scope.Title, self.depth(), scope.File, scope.Line) 29 | self.scopes = append(self.scopes, next) 30 | self.index[ID] = next 31 | } 32 | self.current = self.index[ID] 33 | } 34 | 35 | func (self *JsonReporter) Report(report *AssertionResult) { 36 | self.current.Assertions = append(self.current.Assertions, report) 37 | } 38 | 39 | func (self *JsonReporter) Exit() { 40 | self.currentKey = self.currentKey[:len(self.currentKey)-1] 41 | } 42 | 43 | func (self *JsonReporter) EndStory() { 44 | self.report() 45 | self.reset() 46 | } 47 | func (self *JsonReporter) report() { 48 | scopes := []string{} 49 | for _, scope := range self.scopes { 50 | serialized, err := json.Marshal(scope) 51 | if err != nil { 52 | self.out.Println(jsonMarshalFailure) 53 | panic(err) 54 | } 55 | var buffer bytes.Buffer 56 | json.Indent(&buffer, serialized, "", " ") 57 | scopes = append(scopes, buffer.String()) 58 | } 59 | self.out.Print(fmt.Sprintf("%s\n%s,\n%s\n", OpenJson, strings.Join(scopes, ","), CloseJson)) 60 | } 61 | func (self *JsonReporter) reset() { 62 | self.scopes = []*ScopeResult{} 63 | self.index = map[string]*ScopeResult{} 64 | self.currentKey = nil 65 | } 66 | 67 | func (self *JsonReporter) Write(content []byte) (written int, err error) { 68 | self.current.Output += string(content) 69 | return len(content), nil 70 | } 71 | 72 | func NewJsonReporter(out *Printer) *JsonReporter { 73 | self := new(JsonReporter) 74 | self.out = out 75 | self.reset() 76 | return self 77 | } 78 | 79 | const OpenJson = ">->->OPEN-JSON->->->" // "⌦" 80 | const CloseJson = "<-<-<-CLOSE-JSON<-<-<" // "⌫" 81 | const jsonMarshalFailure = ` 82 | 83 | GOCONVEY_JSON_MARSHALL_FAILURE: There was an error when attempting to convert test results to JSON. 84 | Please file a bug report and reference the code that caused this failure if possible. 85 | 86 | Here's the panic: 87 | 88 | ` 89 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/printer.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "strings" 7 | ) 8 | 9 | type Printer struct { 10 | out io.Writer 11 | prefix string 12 | } 13 | 14 | func (self *Printer) Println(message string, values ...interface{}) { 15 | formatted := self.format(message, values...) + newline 16 | self.out.Write([]byte(formatted)) 17 | } 18 | 19 | func (self *Printer) Print(message string, values ...interface{}) { 20 | formatted := self.format(message, values...) 21 | self.out.Write([]byte(formatted)) 22 | } 23 | 24 | func (self *Printer) Insert(text string) { 25 | self.out.Write([]byte(text)) 26 | } 27 | 28 | func (self *Printer) format(message string, values ...interface{}) string { 29 | var formatted string 30 | if len(values) == 0 { 31 | formatted = self.prefix + message 32 | } else { 33 | formatted = self.prefix + fmt.Sprintf(message, values...) 34 | } 35 | indented := strings.Replace(formatted, newline, newline+self.prefix, -1) 36 | return strings.TrimRight(indented, space) 37 | } 38 | 39 | func (self *Printer) Indent() { 40 | self.prefix += pad 41 | } 42 | 43 | func (self *Printer) Dedent() { 44 | if len(self.prefix) >= padLength { 45 | self.prefix = self.prefix[:len(self.prefix)-padLength] 46 | } 47 | } 48 | 49 | func NewPrinter(out io.Writer) *Printer { 50 | self := new(Printer) 51 | self.out = out 52 | return self 53 | } 54 | 55 | const space = " " 56 | const pad = space + space 57 | const padLength = len(pad) 58 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/problems.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import "fmt" 4 | 5 | type problem struct { 6 | silent bool 7 | out *Printer 8 | errors []*AssertionResult 9 | failures []*AssertionResult 10 | } 11 | 12 | func (self *problem) BeginStory(story *StoryReport) {} 13 | 14 | func (self *problem) Enter(scope *ScopeReport) {} 15 | 16 | func (self *problem) Report(report *AssertionResult) { 17 | if report.Error != nil { 18 | self.errors = append(self.errors, report) 19 | } else if report.Failure != "" { 20 | self.failures = append(self.failures, report) 21 | } 22 | } 23 | 24 | func (self *problem) Exit() {} 25 | 26 | func (self *problem) EndStory() { 27 | self.show(self.showErrors, redColor) 28 | self.show(self.showFailures, yellowColor) 29 | self.prepareForNextStory() 30 | } 31 | func (self *problem) show(display func(), color string) { 32 | if !self.silent { 33 | fmt.Print(color) 34 | } 35 | display() 36 | if !self.silent { 37 | fmt.Print(resetColor) 38 | } 39 | self.out.Dedent() 40 | } 41 | func (self *problem) showErrors() { 42 | for i, e := range self.errors { 43 | if i == 0 { 44 | self.out.Println("\nErrors:\n") 45 | self.out.Indent() 46 | } 47 | self.out.Println(errorTemplate, e.File, e.Line, e.Error, e.StackTrace) 48 | } 49 | } 50 | func (self *problem) showFailures() { 51 | for i, f := range self.failures { 52 | if i == 0 { 53 | self.out.Println("\nFailures:\n") 54 | self.out.Indent() 55 | } 56 | self.out.Println(failureTemplate, f.File, f.Line, f.Failure) 57 | } 58 | } 59 | 60 | func (self *problem) Write(content []byte) (written int, err error) { 61 | return len(content), nil // no-op 62 | } 63 | 64 | func NewProblemReporter(out *Printer) *problem { 65 | self := new(problem) 66 | self.out = out 67 | self.prepareForNextStory() 68 | return self 69 | } 70 | 71 | func NewSilentProblemReporter(out *Printer) *problem { 72 | self := NewProblemReporter(out) 73 | self.silent = true 74 | return self 75 | } 76 | 77 | func (self *problem) prepareForNextStory() { 78 | self.errors = []*AssertionResult{} 79 | self.failures = []*AssertionResult{} 80 | } 81 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/reporter.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import "io" 4 | 5 | type Reporter interface { 6 | BeginStory(story *StoryReport) 7 | Enter(scope *ScopeReport) 8 | Report(r *AssertionResult) 9 | Exit() 10 | EndStory() 11 | io.Writer 12 | } 13 | 14 | type reporters struct{ collection []Reporter } 15 | 16 | func (self *reporters) BeginStory(s *StoryReport) { self.foreach(func(r Reporter) { r.BeginStory(s) }) } 17 | func (self *reporters) Enter(s *ScopeReport) { self.foreach(func(r Reporter) { r.Enter(s) }) } 18 | func (self *reporters) Report(a *AssertionResult) { self.foreach(func(r Reporter) { r.Report(a) }) } 19 | func (self *reporters) Exit() { self.foreach(func(r Reporter) { r.Exit() }) } 20 | func (self *reporters) EndStory() { self.foreach(func(r Reporter) { r.EndStory() }) } 21 | 22 | func (self *reporters) Write(contents []byte) (written int, err error) { 23 | self.foreach(func(r Reporter) { 24 | written, err = r.Write(contents) 25 | }) 26 | return written, err 27 | } 28 | 29 | func (self *reporters) foreach(action func(Reporter)) { 30 | for _, r := range self.collection { 31 | action(r) 32 | } 33 | } 34 | 35 | func NewReporters(collection ...Reporter) *reporters { 36 | self := new(reporters) 37 | self.collection = collection 38 | return self 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey: -------------------------------------------------------------------------------- 1 | #ignore 2 | -timeout=1s 3 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/statistics.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import ( 4 | "fmt" 5 | "sync" 6 | ) 7 | 8 | func (self *statistics) BeginStory(story *StoryReport) {} 9 | 10 | func (self *statistics) Enter(scope *ScopeReport) {} 11 | 12 | func (self *statistics) Report(report *AssertionResult) { 13 | self.Lock() 14 | defer self.Unlock() 15 | 16 | if !self.failing && report.Failure != "" { 17 | self.failing = true 18 | } 19 | if !self.erroring && report.Error != nil { 20 | self.erroring = true 21 | } 22 | if report.Skipped { 23 | self.skipped += 1 24 | } else { 25 | self.total++ 26 | } 27 | } 28 | 29 | func (self *statistics) Exit() {} 30 | 31 | func (self *statistics) EndStory() { 32 | self.Lock() 33 | defer self.Unlock() 34 | 35 | if !self.suppressed { 36 | self.printSummaryLocked() 37 | } 38 | } 39 | 40 | func (self *statistics) Suppress() { 41 | self.Lock() 42 | defer self.Unlock() 43 | self.suppressed = true 44 | } 45 | 46 | func (self *statistics) PrintSummary() { 47 | self.Lock() 48 | defer self.Unlock() 49 | self.printSummaryLocked() 50 | } 51 | 52 | func (self *statistics) printSummaryLocked() { 53 | self.reportAssertionsLocked() 54 | self.reportSkippedSectionsLocked() 55 | self.completeReportLocked() 56 | } 57 | func (self *statistics) reportAssertionsLocked() { 58 | self.decideColorLocked() 59 | self.out.Print("\n%d total %s", self.total, plural("assertion", self.total)) 60 | } 61 | func (self *statistics) decideColorLocked() { 62 | if self.failing && !self.erroring { 63 | fmt.Print(yellowColor) 64 | } else if self.erroring { 65 | fmt.Print(redColor) 66 | } else { 67 | fmt.Print(greenColor) 68 | } 69 | } 70 | func (self *statistics) reportSkippedSectionsLocked() { 71 | if self.skipped > 0 { 72 | fmt.Print(yellowColor) 73 | self.out.Print(" (one or more sections skipped)") 74 | } 75 | } 76 | func (self *statistics) completeReportLocked() { 77 | fmt.Print(resetColor) 78 | self.out.Print("\n") 79 | self.out.Print("\n") 80 | } 81 | 82 | func (self *statistics) Write(content []byte) (written int, err error) { 83 | return len(content), nil // no-op 84 | } 85 | 86 | func NewStatisticsReporter(out *Printer) *statistics { 87 | self := statistics{} 88 | self.out = out 89 | return &self 90 | } 91 | 92 | type statistics struct { 93 | sync.Mutex 94 | 95 | out *Printer 96 | total int 97 | failing bool 98 | erroring bool 99 | skipped int 100 | suppressed bool 101 | } 102 | 103 | func plural(word string, count int) string { 104 | if count == 1 { 105 | return word 106 | } 107 | return word + "s" 108 | } 109 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/story.go: -------------------------------------------------------------------------------- 1 | // TODO: in order for this reporter to be completely honest 2 | // we need to retrofit to be more like the json reporter such that: 3 | // 1. it maintains ScopeResult collections, which count assertions 4 | // 2. it reports only after EndStory(), so that all tick marks 5 | // are placed near the appropriate title. 6 | // 3. Under unit test 7 | 8 | package reporting 9 | 10 | import ( 11 | "fmt" 12 | "strings" 13 | ) 14 | 15 | type story struct { 16 | out *Printer 17 | titlesById map[string]string 18 | currentKey []string 19 | } 20 | 21 | func (self *story) BeginStory(story *StoryReport) {} 22 | 23 | func (self *story) Enter(scope *ScopeReport) { 24 | self.out.Indent() 25 | 26 | self.currentKey = append(self.currentKey, scope.Title) 27 | ID := strings.Join(self.currentKey, "|") 28 | 29 | if _, found := self.titlesById[ID]; !found { 30 | self.out.Println("") 31 | self.out.Print(scope.Title) 32 | self.out.Insert(" ") 33 | self.titlesById[ID] = scope.Title 34 | } 35 | } 36 | 37 | func (self *story) Report(report *AssertionResult) { 38 | if report.Error != nil { 39 | fmt.Print(redColor) 40 | self.out.Insert(error_) 41 | } else if report.Failure != "" { 42 | fmt.Print(yellowColor) 43 | self.out.Insert(failure) 44 | } else if report.Skipped { 45 | fmt.Print(yellowColor) 46 | self.out.Insert(skip) 47 | } else { 48 | fmt.Print(greenColor) 49 | self.out.Insert(success) 50 | } 51 | fmt.Print(resetColor) 52 | } 53 | 54 | func (self *story) Exit() { 55 | self.out.Dedent() 56 | self.currentKey = self.currentKey[:len(self.currentKey)-1] 57 | } 58 | 59 | func (self *story) EndStory() { 60 | self.titlesById = make(map[string]string) 61 | self.out.Println("\n") 62 | } 63 | 64 | func (self *story) Write(content []byte) (written int, err error) { 65 | return len(content), nil // no-op 66 | } 67 | 68 | func NewStoryReporter(out *Printer) *story { 69 | self := new(story) 70 | self.out = out 71 | self.titlesById = make(map[string]string) 72 | return self 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Alex Ogier. All rights reserved. 2 | Copyright (c) 2012 The Go Authors. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/count.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // -- count Value 9 | type countValue int 10 | 11 | func newCountValue(val int, p *int) *countValue { 12 | *p = val 13 | return (*countValue)(p) 14 | } 15 | 16 | func (i *countValue) Set(s string) error { 17 | v, err := strconv.ParseInt(s, 0, 64) 18 | // -1 means that no specific value was passed, so increment 19 | if v == -1 { 20 | *i = countValue(*i + 1) 21 | } else { 22 | *i = countValue(v) 23 | } 24 | return err 25 | } 26 | 27 | func (i *countValue) Type() string { 28 | return "count" 29 | } 30 | 31 | func (i *countValue) String() string { return fmt.Sprintf("%v", *i) } 32 | 33 | func countConv(sval string) (interface{}, error) { 34 | i, err := strconv.Atoi(sval) 35 | if err != nil { 36 | return nil, err 37 | } 38 | return i, nil 39 | } 40 | 41 | // GetCount return the int value of a flag with the given name 42 | func (f *FlagSet) GetCount(name string) (int, error) { 43 | val, err := f.getFlagType(name, "count", countConv) 44 | if err != nil { 45 | return 0, err 46 | } 47 | return val.(int), nil 48 | } 49 | 50 | // CountVar defines a count flag with specified name, default value, and usage string. 51 | // The argument p points to an int variable in which to store the value of the flag. 52 | // A count flag will add 1 to its value evey time it is found on the command line 53 | func (f *FlagSet) CountVar(p *int, name string, usage string) { 54 | f.CountVarP(p, name, "", usage) 55 | } 56 | 57 | // CountVarP is like CountVar only take a shorthand for the flag name. 58 | func (f *FlagSet) CountVarP(p *int, name, shorthand string, usage string) { 59 | flag := f.VarPF(newCountValue(0, p), name, shorthand, usage) 60 | flag.NoOptDefVal = "-1" 61 | } 62 | 63 | // CountVar like CountVar only the flag is placed on the CommandLine instead of a given flag set 64 | func CountVar(p *int, name string, usage string) { 65 | CommandLine.CountVar(p, name, usage) 66 | } 67 | 68 | // CountVarP is like CountVar only take a shorthand for the flag name. 69 | func CountVarP(p *int, name, shorthand string, usage string) { 70 | CommandLine.CountVarP(p, name, shorthand, usage) 71 | } 72 | 73 | // Count defines a count flag with specified name, default value, and usage string. 74 | // The return value is the address of an int variable that stores the value of the flag. 75 | // A count flag will add 1 to its value evey time it is found on the command line 76 | func (f *FlagSet) Count(name string, usage string) *int { 77 | p := new(int) 78 | f.CountVarP(p, name, "", usage) 79 | return p 80 | } 81 | 82 | // CountP is like Count only takes a shorthand for the flag name. 83 | func (f *FlagSet) CountP(name, shorthand string, usage string) *int { 84 | p := new(int) 85 | f.CountVarP(p, name, shorthand, usage) 86 | return p 87 | } 88 | 89 | // Count like Count only the flag is placed on the CommandLine isntead of a given flag set 90 | func Count(name string, usage string) *int { 91 | return CommandLine.CountP(name, "", usage) 92 | } 93 | 94 | // CountP is like Count only takes a shorthand for the flag name. 95 | func CountP(name, shorthand string, usage string) *int { 96 | return CommandLine.CountP(name, shorthand, usage) 97 | } 98 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/golangflag.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package pflag 6 | 7 | import ( 8 | goflag "flag" 9 | "fmt" 10 | "reflect" 11 | "strings" 12 | ) 13 | 14 | var _ = fmt.Print 15 | 16 | // flagValueWrapper implements pflag.Value around a flag.Value. The main 17 | // difference here is the addition of the Type method that returns a string 18 | // name of the type. As this is generally unknown, we approximate that with 19 | // reflection. 20 | type flagValueWrapper struct { 21 | inner goflag.Value 22 | flagType string 23 | } 24 | 25 | // We are just copying the boolFlag interface out of goflag as that is what 26 | // they use to decide if a flag should get "true" when no arg is given. 27 | type goBoolFlag interface { 28 | goflag.Value 29 | IsBoolFlag() bool 30 | } 31 | 32 | func wrapFlagValue(v goflag.Value) Value { 33 | // If the flag.Value happens to also be a pflag.Value, just use it directly. 34 | if pv, ok := v.(Value); ok { 35 | return pv 36 | } 37 | 38 | pv := &flagValueWrapper{ 39 | inner: v, 40 | } 41 | 42 | t := reflect.TypeOf(v) 43 | if t.Kind() == reflect.Interface || t.Kind() == reflect.Ptr { 44 | t = t.Elem() 45 | } 46 | 47 | pv.flagType = strings.TrimSuffix(t.Name(), "Value") 48 | return pv 49 | } 50 | 51 | func (v *flagValueWrapper) String() string { 52 | return v.inner.String() 53 | } 54 | 55 | func (v *flagValueWrapper) Set(s string) error { 56 | return v.inner.Set(s) 57 | } 58 | 59 | func (v *flagValueWrapper) Type() string { 60 | return v.flagType 61 | } 62 | 63 | // PFlagFromGoFlag will return a *pflag.Flag given a *flag.Flag 64 | // If the *flag.Flag.Name was a single character (ex: `v`) it will be accessiblei 65 | // with both `-v` and `--v` in flags. If the golang flag was more than a single 66 | // character (ex: `verbose`) it will only be accessible via `--verbose` 67 | func PFlagFromGoFlag(goflag *goflag.Flag) *Flag { 68 | // Remember the default value as a string; it won't change. 69 | flag := &Flag{ 70 | Name: goflag.Name, 71 | Usage: goflag.Usage, 72 | Value: wrapFlagValue(goflag.Value), 73 | // Looks like golang flags don't set DefValue correctly :-( 74 | //DefValue: goflag.DefValue, 75 | DefValue: goflag.Value.String(), 76 | } 77 | // Ex: if the golang flag was -v, allow both -v and --v to work 78 | if len(flag.Name) == 1 { 79 | flag.Shorthand = flag.Name 80 | } 81 | if fv, ok := goflag.Value.(goBoolFlag); ok && fv.IsBoolFlag() { 82 | flag.NoOptDefVal = "true" 83 | } 84 | return flag 85 | } 86 | 87 | // AddGoFlag will add the given *flag.Flag to the pflag.FlagSet 88 | func (f *FlagSet) AddGoFlag(goflag *goflag.Flag) { 89 | if f.Lookup(goflag.Name) != nil { 90 | return 91 | } 92 | newflag := PFlagFromGoFlag(goflag) 93 | f.AddFlag(newflag) 94 | } 95 | 96 | // AddGoFlagSet will add the given *flag.FlagSet to the pflag.FlagSet 97 | func (f *FlagSet) AddGoFlagSet(newSet *goflag.FlagSet) { 98 | if newSet == nil { 99 | return 100 | } 101 | newSet.VisitAll(func(goflag *goflag.Flag) { 102 | f.AddGoFlag(goflag) 103 | }) 104 | } 105 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/int.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // -- int Value 9 | type intValue int 10 | 11 | func newIntValue(val int, p *int) *intValue { 12 | *p = val 13 | return (*intValue)(p) 14 | } 15 | 16 | func (i *intValue) Set(s string) error { 17 | v, err := strconv.ParseInt(s, 0, 64) 18 | *i = intValue(v) 19 | return err 20 | } 21 | 22 | func (i *intValue) Type() string { 23 | return "int" 24 | } 25 | 26 | func (i *intValue) String() string { return fmt.Sprintf("%v", *i) } 27 | 28 | func intConv(sval string) (interface{}, error) { 29 | return strconv.Atoi(sval) 30 | } 31 | 32 | // GetInt return the int value of a flag with the given name 33 | func (f *FlagSet) GetInt(name string) (int, error) { 34 | val, err := f.getFlagType(name, "int", intConv) 35 | if err != nil { 36 | return 0, err 37 | } 38 | return val.(int), nil 39 | } 40 | 41 | // IntVar defines an int flag with specified name, default value, and usage string. 42 | // The argument p points to an int variable in which to store the value of the flag. 43 | func (f *FlagSet) IntVar(p *int, name string, value int, usage string) { 44 | f.VarP(newIntValue(value, p), name, "", usage) 45 | } 46 | 47 | // IntVarP is like IntVar, but accepts a shorthand letter that can be used after a single dash. 48 | func (f *FlagSet) IntVarP(p *int, name, shorthand string, value int, usage string) { 49 | f.VarP(newIntValue(value, p), name, shorthand, usage) 50 | } 51 | 52 | // IntVar defines an int flag with specified name, default value, and usage string. 53 | // The argument p points to an int variable in which to store the value of the flag. 54 | func IntVar(p *int, name string, value int, usage string) { 55 | CommandLine.VarP(newIntValue(value, p), name, "", usage) 56 | } 57 | 58 | // IntVarP is like IntVar, but accepts a shorthand letter that can be used after a single dash. 59 | func IntVarP(p *int, name, shorthand string, value int, usage string) { 60 | CommandLine.VarP(newIntValue(value, p), name, shorthand, usage) 61 | } 62 | 63 | // Int defines an int flag with specified name, default value, and usage string. 64 | // The return value is the address of an int variable that stores the value of the flag. 65 | func (f *FlagSet) Int(name string, value int, usage string) *int { 66 | p := new(int) 67 | f.IntVarP(p, name, "", value, usage) 68 | return p 69 | } 70 | 71 | // IntP is like Int, but accepts a shorthand letter that can be used after a single dash. 72 | func (f *FlagSet) IntP(name, shorthand string, value int, usage string) *int { 73 | p := new(int) 74 | f.IntVarP(p, name, shorthand, value, usage) 75 | return p 76 | } 77 | 78 | // Int defines an int flag with specified name, default value, and usage string. 79 | // The return value is the address of an int variable that stores the value of the flag. 80 | func Int(name string, value int, usage string) *int { 81 | return CommandLine.IntP(name, "", value, usage) 82 | } 83 | 84 | // IntP is like Int, but accepts a shorthand letter that can be used after a single dash. 85 | func IntP(name, shorthand string, value int, usage string) *int { 86 | return CommandLine.IntP(name, shorthand, value, usage) 87 | } 88 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/int64.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // -- int64 Value 9 | type int64Value int64 10 | 11 | func newInt64Value(val int64, p *int64) *int64Value { 12 | *p = val 13 | return (*int64Value)(p) 14 | } 15 | 16 | func (i *int64Value) Set(s string) error { 17 | v, err := strconv.ParseInt(s, 0, 64) 18 | *i = int64Value(v) 19 | return err 20 | } 21 | 22 | func (i *int64Value) Type() string { 23 | return "int64" 24 | } 25 | 26 | func (i *int64Value) String() string { return fmt.Sprintf("%v", *i) } 27 | 28 | func int64Conv(sval string) (interface{}, error) { 29 | return strconv.ParseInt(sval, 0, 64) 30 | } 31 | 32 | // GetInt64 return the int64 value of a flag with the given name 33 | func (f *FlagSet) GetInt64(name string) (int64, error) { 34 | val, err := f.getFlagType(name, "int64", int64Conv) 35 | if err != nil { 36 | return 0, err 37 | } 38 | return val.(int64), nil 39 | } 40 | 41 | // Int64Var defines an int64 flag with specified name, default value, and usage string. 42 | // The argument p points to an int64 variable in which to store the value of the flag. 43 | func (f *FlagSet) Int64Var(p *int64, name string, value int64, usage string) { 44 | f.VarP(newInt64Value(value, p), name, "", usage) 45 | } 46 | 47 | // Int64VarP is like Int64Var, but accepts a shorthand letter that can be used after a single dash. 48 | func (f *FlagSet) Int64VarP(p *int64, name, shorthand string, value int64, usage string) { 49 | f.VarP(newInt64Value(value, p), name, shorthand, usage) 50 | } 51 | 52 | // Int64Var defines an int64 flag with specified name, default value, and usage string. 53 | // The argument p points to an int64 variable in which to store the value of the flag. 54 | func Int64Var(p *int64, name string, value int64, usage string) { 55 | CommandLine.VarP(newInt64Value(value, p), name, "", usage) 56 | } 57 | 58 | // Int64VarP is like Int64Var, but accepts a shorthand letter that can be used after a single dash. 59 | func Int64VarP(p *int64, name, shorthand string, value int64, usage string) { 60 | CommandLine.VarP(newInt64Value(value, p), name, shorthand, usage) 61 | } 62 | 63 | // Int64 defines an int64 flag with specified name, default value, and usage string. 64 | // The return value is the address of an int64 variable that stores the value of the flag. 65 | func (f *FlagSet) Int64(name string, value int64, usage string) *int64 { 66 | p := new(int64) 67 | f.Int64VarP(p, name, "", value, usage) 68 | return p 69 | } 70 | 71 | // Int64P is like Int64, but accepts a shorthand letter that can be used after a single dash. 72 | func (f *FlagSet) Int64P(name, shorthand string, value int64, usage string) *int64 { 73 | p := new(int64) 74 | f.Int64VarP(p, name, shorthand, value, usage) 75 | return p 76 | } 77 | 78 | // Int64 defines an int64 flag with specified name, default value, and usage string. 79 | // The return value is the address of an int64 variable that stores the value of the flag. 80 | func Int64(name string, value int64, usage string) *int64 { 81 | return CommandLine.Int64P(name, "", value, usage) 82 | } 83 | 84 | // Int64P is like Int64, but accepts a shorthand letter that can be used after a single dash. 85 | func Int64P(name, shorthand string, value int64, usage string) *int64 { 86 | return CommandLine.Int64P(name, shorthand, value, usage) 87 | } 88 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/int8.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // -- int8 Value 9 | type int8Value int8 10 | 11 | func newInt8Value(val int8, p *int8) *int8Value { 12 | *p = val 13 | return (*int8Value)(p) 14 | } 15 | 16 | func (i *int8Value) Set(s string) error { 17 | v, err := strconv.ParseInt(s, 0, 8) 18 | *i = int8Value(v) 19 | return err 20 | } 21 | 22 | func (i *int8Value) Type() string { 23 | return "int8" 24 | } 25 | 26 | func (i *int8Value) String() string { return fmt.Sprintf("%v", *i) } 27 | 28 | func int8Conv(sval string) (interface{}, error) { 29 | v, err := strconv.ParseInt(sval, 0, 8) 30 | if err != nil { 31 | return 0, err 32 | } 33 | return int8(v), nil 34 | } 35 | 36 | // GetInt8 return the int8 value of a flag with the given name 37 | func (f *FlagSet) GetInt8(name string) (int8, error) { 38 | val, err := f.getFlagType(name, "int8", int8Conv) 39 | if err != nil { 40 | return 0, err 41 | } 42 | return val.(int8), nil 43 | } 44 | 45 | // Int8Var defines an int8 flag with specified name, default value, and usage string. 46 | // The argument p points to an int8 variable in which to store the value of the flag. 47 | func (f *FlagSet) Int8Var(p *int8, name string, value int8, usage string) { 48 | f.VarP(newInt8Value(value, p), name, "", usage) 49 | } 50 | 51 | // Int8VarP is like Int8Var, but accepts a shorthand letter that can be used after a single dash. 52 | func (f *FlagSet) Int8VarP(p *int8, name, shorthand string, value int8, usage string) { 53 | f.VarP(newInt8Value(value, p), name, shorthand, usage) 54 | } 55 | 56 | // Int8Var defines an int8 flag with specified name, default value, and usage string. 57 | // The argument p points to an int8 variable in which to store the value of the flag. 58 | func Int8Var(p *int8, name string, value int8, usage string) { 59 | CommandLine.VarP(newInt8Value(value, p), name, "", usage) 60 | } 61 | 62 | // Int8VarP is like Int8Var, but accepts a shorthand letter that can be used after a single dash. 63 | func Int8VarP(p *int8, name, shorthand string, value int8, usage string) { 64 | CommandLine.VarP(newInt8Value(value, p), name, shorthand, usage) 65 | } 66 | 67 | // Int8 defines an int8 flag with specified name, default value, and usage string. 68 | // The return value is the address of an int8 variable that stores the value of the flag. 69 | func (f *FlagSet) Int8(name string, value int8, usage string) *int8 { 70 | p := new(int8) 71 | f.Int8VarP(p, name, "", value, usage) 72 | return p 73 | } 74 | 75 | // Int8P is like Int8, but accepts a shorthand letter that can be used after a single dash. 76 | func (f *FlagSet) Int8P(name, shorthand string, value int8, usage string) *int8 { 77 | p := new(int8) 78 | f.Int8VarP(p, name, shorthand, value, usage) 79 | return p 80 | } 81 | 82 | // Int8 defines an int8 flag with specified name, default value, and usage string. 83 | // The return value is the address of an int8 variable that stores the value of the flag. 84 | func Int8(name string, value int8, usage string) *int8 { 85 | return CommandLine.Int8P(name, "", value, usage) 86 | } 87 | 88 | // Int8P is like Int8, but accepts a shorthand letter that can be used after a single dash. 89 | func Int8P(name, shorthand string, value int8, usage string) *int8 { 90 | return CommandLine.Int8P(name, shorthand, value, usage) 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/string.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import "fmt" 4 | 5 | // -- string Value 6 | type stringValue string 7 | 8 | func newStringValue(val string, p *string) *stringValue { 9 | *p = val 10 | return (*stringValue)(p) 11 | } 12 | 13 | func (s *stringValue) Set(val string) error { 14 | *s = stringValue(val) 15 | return nil 16 | } 17 | func (s *stringValue) Type() string { 18 | return "string" 19 | } 20 | 21 | func (s *stringValue) String() string { return fmt.Sprintf("%s", *s) } 22 | 23 | func stringConv(sval string) (interface{}, error) { 24 | return sval, nil 25 | } 26 | 27 | // GetString return the string value of a flag with the given name 28 | func (f *FlagSet) GetString(name string) (string, error) { 29 | val, err := f.getFlagType(name, "string", stringConv) 30 | if err != nil { 31 | return "", err 32 | } 33 | return val.(string), nil 34 | } 35 | 36 | // StringVar defines a string flag with specified name, default value, and usage string. 37 | // The argument p points to a string variable in which to store the value of the flag. 38 | func (f *FlagSet) StringVar(p *string, name string, value string, usage string) { 39 | f.VarP(newStringValue(value, p), name, "", usage) 40 | } 41 | 42 | // StringVarP is like StringVar, but accepts a shorthand letter that can be used after a single dash. 43 | func (f *FlagSet) StringVarP(p *string, name, shorthand string, value string, usage string) { 44 | f.VarP(newStringValue(value, p), name, shorthand, usage) 45 | } 46 | 47 | // StringVar defines a string flag with specified name, default value, and usage string. 48 | // The argument p points to a string variable in which to store the value of the flag. 49 | func StringVar(p *string, name string, value string, usage string) { 50 | CommandLine.VarP(newStringValue(value, p), name, "", usage) 51 | } 52 | 53 | // StringVarP is like StringVar, but accepts a shorthand letter that can be used after a single dash. 54 | func StringVarP(p *string, name, shorthand string, value string, usage string) { 55 | CommandLine.VarP(newStringValue(value, p), name, shorthand, usage) 56 | } 57 | 58 | // String defines a string flag with specified name, default value, and usage string. 59 | // The return value is the address of a string variable that stores the value of the flag. 60 | func (f *FlagSet) String(name string, value string, usage string) *string { 61 | p := new(string) 62 | f.StringVarP(p, name, "", value, usage) 63 | return p 64 | } 65 | 66 | // StringP is like String, but accepts a shorthand letter that can be used after a single dash. 67 | func (f *FlagSet) StringP(name, shorthand string, value string, usage string) *string { 68 | p := new(string) 69 | f.StringVarP(p, name, shorthand, value, usage) 70 | return p 71 | } 72 | 73 | // String defines a string flag with specified name, default value, and usage string. 74 | // The return value is the address of a string variable that stores the value of the flag. 75 | func String(name string, value string, usage string) *string { 76 | return CommandLine.StringP(name, "", value, usage) 77 | } 78 | 79 | // StringP is like String, but accepts a shorthand letter that can be used after a single dash. 80 | func StringP(name, shorthand string, value string, usage string) *string { 81 | return CommandLine.StringP(name, shorthand, value, usage) 82 | } 83 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/uint.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // -- uint Value 9 | type uintValue uint 10 | 11 | func newUintValue(val uint, p *uint) *uintValue { 12 | *p = val 13 | return (*uintValue)(p) 14 | } 15 | 16 | func (i *uintValue) Set(s string) error { 17 | v, err := strconv.ParseUint(s, 0, 64) 18 | *i = uintValue(v) 19 | return err 20 | } 21 | 22 | func (i *uintValue) Type() string { 23 | return "uint" 24 | } 25 | 26 | func (i *uintValue) String() string { return fmt.Sprintf("%v", *i) } 27 | 28 | func uintConv(sval string) (interface{}, error) { 29 | v, err := strconv.ParseUint(sval, 0, 0) 30 | if err != nil { 31 | return 0, err 32 | } 33 | return uint(v), nil 34 | } 35 | 36 | // GetUint return the uint value of a flag with the given name 37 | func (f *FlagSet) GetUint(name string) (uint, error) { 38 | val, err := f.getFlagType(name, "uint", uintConv) 39 | if err != nil { 40 | return 0, err 41 | } 42 | return val.(uint), nil 43 | } 44 | 45 | // UintVar defines a uint flag with specified name, default value, and usage string. 46 | // The argument p points to a uint variable in which to store the value of the flag. 47 | func (f *FlagSet) UintVar(p *uint, name string, value uint, usage string) { 48 | f.VarP(newUintValue(value, p), name, "", usage) 49 | } 50 | 51 | // UintVarP is like UintVar, but accepts a shorthand letter that can be used after a single dash. 52 | func (f *FlagSet) UintVarP(p *uint, name, shorthand string, value uint, usage string) { 53 | f.VarP(newUintValue(value, p), name, shorthand, usage) 54 | } 55 | 56 | // UintVar defines a uint flag with specified name, default value, and usage string. 57 | // The argument p points to a uint variable in which to store the value of the flag. 58 | func UintVar(p *uint, name string, value uint, usage string) { 59 | CommandLine.VarP(newUintValue(value, p), name, "", usage) 60 | } 61 | 62 | // UintVarP is like UintVar, but accepts a shorthand letter that can be used after a single dash. 63 | func UintVarP(p *uint, name, shorthand string, value uint, usage string) { 64 | CommandLine.VarP(newUintValue(value, p), name, shorthand, usage) 65 | } 66 | 67 | // Uint defines a uint flag with specified name, default value, and usage string. 68 | // The return value is the address of a uint variable that stores the value of the flag. 69 | func (f *FlagSet) Uint(name string, value uint, usage string) *uint { 70 | p := new(uint) 71 | f.UintVarP(p, name, "", value, usage) 72 | return p 73 | } 74 | 75 | // UintP is like Uint, but accepts a shorthand letter that can be used after a single dash. 76 | func (f *FlagSet) UintP(name, shorthand string, value uint, usage string) *uint { 77 | p := new(uint) 78 | f.UintVarP(p, name, shorthand, value, usage) 79 | return p 80 | } 81 | 82 | // Uint defines a uint flag with specified name, default value, and usage string. 83 | // The return value is the address of a uint variable that stores the value of the flag. 84 | func Uint(name string, value uint, usage string) *uint { 85 | return CommandLine.UintP(name, "", value, usage) 86 | } 87 | 88 | // UintP is like Uint, but accepts a shorthand letter that can be used after a single dash. 89 | func UintP(name, shorthand string, value uint, usage string) *uint { 90 | return CommandLine.UintP(name, shorthand, value, usage) 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/uint8.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // -- uint8 Value 9 | type uint8Value uint8 10 | 11 | func newUint8Value(val uint8, p *uint8) *uint8Value { 12 | *p = val 13 | return (*uint8Value)(p) 14 | } 15 | 16 | func (i *uint8Value) Set(s string) error { 17 | v, err := strconv.ParseUint(s, 0, 8) 18 | *i = uint8Value(v) 19 | return err 20 | } 21 | 22 | func (i *uint8Value) Type() string { 23 | return "uint8" 24 | } 25 | 26 | func (i *uint8Value) String() string { return fmt.Sprintf("%v", *i) } 27 | 28 | func uint8Conv(sval string) (interface{}, error) { 29 | v, err := strconv.ParseUint(sval, 0, 8) 30 | if err != nil { 31 | return 0, err 32 | } 33 | return uint8(v), nil 34 | } 35 | 36 | // GetUint8 return the uint8 value of a flag with the given name 37 | func (f *FlagSet) GetUint8(name string) (uint8, error) { 38 | val, err := f.getFlagType(name, "uint8", uint8Conv) 39 | if err != nil { 40 | return 0, err 41 | } 42 | return val.(uint8), nil 43 | } 44 | 45 | // Uint8Var defines a uint8 flag with specified name, default value, and usage string. 46 | // The argument p points to a uint8 variable in which to store the value of the flag. 47 | func (f *FlagSet) Uint8Var(p *uint8, name string, value uint8, usage string) { 48 | f.VarP(newUint8Value(value, p), name, "", usage) 49 | } 50 | 51 | // Uint8VarP is like Uint8Var, but accepts a shorthand letter that can be used after a single dash. 52 | func (f *FlagSet) Uint8VarP(p *uint8, name, shorthand string, value uint8, usage string) { 53 | f.VarP(newUint8Value(value, p), name, shorthand, usage) 54 | } 55 | 56 | // Uint8Var defines a uint8 flag with specified name, default value, and usage string. 57 | // The argument p points to a uint8 variable in which to store the value of the flag. 58 | func Uint8Var(p *uint8, name string, value uint8, usage string) { 59 | CommandLine.VarP(newUint8Value(value, p), name, "", usage) 60 | } 61 | 62 | // Uint8VarP is like Uint8Var, but accepts a shorthand letter that can be used after a single dash. 63 | func Uint8VarP(p *uint8, name, shorthand string, value uint8, usage string) { 64 | CommandLine.VarP(newUint8Value(value, p), name, shorthand, usage) 65 | } 66 | 67 | // Uint8 defines a uint8 flag with specified name, default value, and usage string. 68 | // The return value is the address of a uint8 variable that stores the value of the flag. 69 | func (f *FlagSet) Uint8(name string, value uint8, usage string) *uint8 { 70 | p := new(uint8) 71 | f.Uint8VarP(p, name, "", value, usage) 72 | return p 73 | } 74 | 75 | // Uint8P is like Uint8, but accepts a shorthand letter that can be used after a single dash. 76 | func (f *FlagSet) Uint8P(name, shorthand string, value uint8, usage string) *uint8 { 77 | p := new(uint8) 78 | f.Uint8VarP(p, name, shorthand, value, usage) 79 | return p 80 | } 81 | 82 | // Uint8 defines a uint8 flag with specified name, default value, and usage string. 83 | // The return value is the address of a uint8 variable that stores the value of the flag. 84 | func Uint8(name string, value uint8, usage string) *uint8 { 85 | return CommandLine.Uint8P(name, "", value, usage) 86 | } 87 | 88 | // Uint8P is like Uint8, but accepts a shorthand letter that can be used after a single dash. 89 | func Uint8P(name, shorthand string, value uint8, usage string) *uint8 { 90 | return CommandLine.Uint8P(name, shorthand, value, usage) 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/t-k/fluent-logger-golang/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Tatsuo Kaniwa 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /vendor/github.com/t-k/fluent-logger-golang/fluent/proto.go: -------------------------------------------------------------------------------- 1 | //go:generate msgp 2 | 3 | package fluent 4 | 5 | //msgp:tuple Entry 6 | type Entry struct { 7 | Time int64 `msg:"time"` 8 | Record interface{} `msg:"record"` 9 | } 10 | 11 | //msgp:tuple Forward 12 | type Forward struct { 13 | Tag string `msg:"tag"` 14 | Entries []Entry `msg:"entries"` 15 | Option interface{} `msg:"option"` 16 | } 17 | 18 | //msgp:tuple Message 19 | type Message struct { 20 | Tag string `msg:"tag"` 21 | Time int64 `msg:"time"` 22 | Record interface{} `msg:"record"` 23 | Option interface{} `msg:"option"` 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/t-k/fluent-logger-golang/fluent/version.go: -------------------------------------------------------------------------------- 1 | package fluent 2 | 3 | const Version = "0.5.1" 4 | -------------------------------------------------------------------------------- /vendor/github.com/tinylib/msgp/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Philip Hofer 2 | Portions Copyright (c) 2009 The Go Authors (license at http://golang.org) where indicated 3 | 4 | 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: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | 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. -------------------------------------------------------------------------------- /vendor/github.com/tinylib/msgp/msgp/advise_linux.go: -------------------------------------------------------------------------------- 1 | // +build linux,!appengine 2 | 3 | package msgp 4 | 5 | import ( 6 | "os" 7 | "syscall" 8 | ) 9 | 10 | func adviseRead(mem []byte) { 11 | syscall.Madvise(mem, syscall.MADV_SEQUENTIAL|syscall.MADV_WILLNEED) 12 | } 13 | 14 | func adviseWrite(mem []byte) { 15 | syscall.Madvise(mem, syscall.MADV_SEQUENTIAL) 16 | } 17 | 18 | func fallocate(f *os.File, sz int64) error { 19 | err := syscall.Fallocate(int(f.Fd()), 0, 0, sz) 20 | if err == syscall.ENOTSUP { 21 | return f.Truncate(sz) 22 | } 23 | return err 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/tinylib/msgp/msgp/advise_other.go: -------------------------------------------------------------------------------- 1 | // +build !linux appengine 2 | 3 | package msgp 4 | 5 | import ( 6 | "os" 7 | ) 8 | 9 | // TODO: darwin, BSD support 10 | 11 | func adviseRead(mem []byte) {} 12 | 13 | func adviseWrite(mem []byte) {} 14 | 15 | func fallocate(f *os.File, sz int64) error { 16 | return f.Truncate(sz) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/tinylib/msgp/msgp/appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package msgp 4 | 5 | // let's just assume appengine 6 | // uses 64-bit hardware... 7 | const smallint = false 8 | 9 | func UnsafeString(b []byte) string { 10 | return string(b) 11 | } 12 | 13 | func UnsafeBytes(s string) []byte { 14 | return []byte(s) 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/tinylib/msgp/msgp/circular.go: -------------------------------------------------------------------------------- 1 | package msgp 2 | 3 | type timer interface { 4 | StartTimer() 5 | StopTimer() 6 | } 7 | 8 | // EndlessReader is an io.Reader 9 | // that loops over the same data 10 | // endlessly. It is used for benchmarking. 11 | type EndlessReader struct { 12 | tb timer 13 | data []byte 14 | offset int 15 | } 16 | 17 | // NewEndlessReader returns a new endless reader 18 | func NewEndlessReader(b []byte, tb timer) *EndlessReader { 19 | return &EndlessReader{tb: tb, data: b, offset: 0} 20 | } 21 | 22 | // Read implements io.Reader. In practice, it 23 | // always returns (len(p), nil), although it 24 | // fills the supplied slice while the benchmark 25 | // timer is stopped. 26 | func (c *EndlessReader) Read(p []byte) (int, error) { 27 | c.tb.StopTimer() 28 | var n int 29 | l := len(p) 30 | m := len(c.data) 31 | for n < l { 32 | nn := copy(p[n:], c.data[c.offset:]) 33 | n += nn 34 | c.offset += nn 35 | c.offset %= m 36 | } 37 | c.tb.StartTimer() 38 | return n, nil 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/tinylib/msgp/msgp/file.go: -------------------------------------------------------------------------------- 1 | // +build linux,!appengine darwin dragonfly freebsd netbsd openbsd 2 | 3 | package msgp 4 | 5 | import ( 6 | "os" 7 | "syscall" 8 | ) 9 | 10 | // ReadFile reads a file into 'dst' using 11 | // a read-only memory mapping. Consequently, 12 | // the file must be mmap-able, and the 13 | // Unmarshaler should never write to 14 | // the source memory. (Methods generated 15 | // by the msgp tool obey that constraint, but 16 | // user-defined implementations may not.) 17 | // 18 | // Reading and writing through file mappings 19 | // is only efficient for large files; small 20 | // files are best read and written using 21 | // the ordinary streaming interfaces. 22 | // 23 | func ReadFile(dst Unmarshaler, file *os.File) error { 24 | stat, err := file.Stat() 25 | if err != nil { 26 | return err 27 | } 28 | data, err := syscall.Mmap(int(file.Fd()), 0, int(stat.Size()), syscall.PROT_READ, syscall.MAP_SHARED) 29 | if err != nil { 30 | return err 31 | } 32 | adviseRead(data) 33 | _, err = dst.UnmarshalMsg(data) 34 | uerr := syscall.Munmap(data) 35 | if err == nil { 36 | err = uerr 37 | } 38 | return err 39 | } 40 | 41 | // MarshalSizer is the combination 42 | // of the Marshaler and Sizer 43 | // interfaces. 44 | type MarshalSizer interface { 45 | Marshaler 46 | Sizer 47 | } 48 | 49 | // WriteFile writes a file from 'src' using 50 | // memory mapping. It overwrites the entire 51 | // contents of the previous file. 52 | // The mapping size is calculated 53 | // using the `Msgsize()` method 54 | // of 'src', so it must produce a result 55 | // equal to or greater than the actual encoded 56 | // size of the object. Otherwise, 57 | // a fault (SIGBUS) will occur. 58 | // 59 | // Reading and writing through file mappings 60 | // is only efficient for large files; small 61 | // files are best read and written using 62 | // the ordinary streaming interfaces. 63 | // 64 | // NOTE: The performance of this call 65 | // is highly OS- and filesystem-dependent. 66 | // Users should take care to test that this 67 | // performs as expected in a production environment. 68 | // (Linux users should run a kernel and filesystem 69 | // that support fallocate(2) for the best results.) 70 | func WriteFile(src MarshalSizer, file *os.File) error { 71 | sz := src.Msgsize() 72 | err := fallocate(file, int64(sz)) 73 | if err != nil { 74 | return err 75 | } 76 | data, err := syscall.Mmap(int(file.Fd()), 0, sz, syscall.PROT_READ|syscall.PROT_WRITE, syscall.MAP_SHARED) 77 | if err != nil { 78 | return err 79 | } 80 | adviseWrite(data) 81 | chunk := data[:0] 82 | chunk, err = src.MarshalMsg(chunk) 83 | if err != nil { 84 | return err 85 | } 86 | uerr := syscall.Munmap(data) 87 | if uerr != nil { 88 | return uerr 89 | } 90 | return file.Truncate(int64(len(chunk))) 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/tinylib/msgp/msgp/file_port.go: -------------------------------------------------------------------------------- 1 | // +build windows appengine 2 | 3 | package msgp 4 | 5 | import ( 6 | "io/ioutil" 7 | "os" 8 | ) 9 | 10 | // MarshalSizer is the combination 11 | // of the Marshaler and Sizer 12 | // interfaces. 13 | type MarshalSizer interface { 14 | Marshaler 15 | Sizer 16 | } 17 | 18 | func ReadFile(dst Unmarshaler, file *os.File) error { 19 | if u, ok := dst.(Decodable); ok { 20 | return u.DecodeMsg(NewReader(file)) 21 | } 22 | 23 | data, err := ioutil.ReadAll(file) 24 | if err != nil { 25 | return err 26 | } 27 | _, err = dst.UnmarshalMsg(data) 28 | return err 29 | } 30 | 31 | func WriteFile(src MarshalSizer, file *os.File) error { 32 | if e, ok := src.(Encodable); ok { 33 | w := NewWriter(file) 34 | err := e.EncodeMsg(w) 35 | if err == nil { 36 | err = w.Flush() 37 | } 38 | return err 39 | } 40 | 41 | raw, err := src.MarshalMsg(nil) 42 | if err != nil { 43 | return err 44 | } 45 | _, err = file.Write(raw) 46 | return err 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/tinylib/msgp/msgp/size.go: -------------------------------------------------------------------------------- 1 | package msgp 2 | 3 | // The sizes provided 4 | // are the worst-case 5 | // encoded sizes for 6 | // each type. For variable- 7 | // length types ([]byte, string), 8 | // the total encoded size is 9 | // the prefix size plus the 10 | // length of the object. 11 | const ( 12 | Int64Size = 9 13 | IntSize = Int64Size 14 | UintSize = Int64Size 15 | Int8Size = 2 16 | Int16Size = 3 17 | Int32Size = 5 18 | Uint8Size = 2 19 | ByteSize = Uint8Size 20 | Uint16Size = 3 21 | Uint32Size = 5 22 | Uint64Size = Int64Size 23 | Float64Size = 9 24 | Float32Size = 5 25 | Complex64Size = 10 26 | Complex128Size = 18 27 | 28 | TimeSize = 15 29 | BoolSize = 1 30 | NilSize = 1 31 | 32 | MapHeaderSize = 5 33 | ArrayHeaderSize = 5 34 | 35 | BytesPrefixSize = 5 36 | StringPrefixSize = 5 37 | ExtensionPrefixSize = 6 38 | ) 39 | -------------------------------------------------------------------------------- /vendor/github.com/tinylib/msgp/msgp/unsafe.go: -------------------------------------------------------------------------------- 1 | // +build !appengine 2 | 3 | package msgp 4 | 5 | import ( 6 | "reflect" 7 | "unsafe" 8 | ) 9 | 10 | // NOTE: 11 | // all of the definition in this file 12 | // should be repeated in appengine.go, 13 | // but without using unsafe 14 | 15 | const ( 16 | // spec says int and uint are always 17 | // the same size, but that int/uint 18 | // size may not be machine word size 19 | smallint = unsafe.Sizeof(int(0)) == 4 20 | ) 21 | 22 | // UnsafeString returns the byte slice as a volatile string 23 | // THIS SHOULD ONLY BE USED BY THE CODE GENERATOR. 24 | // THIS IS EVIL CODE. 25 | // YOU HAVE BEEN WARNED. 26 | func UnsafeString(b []byte) string { 27 | return *(*string)(unsafe.Pointer(&reflect.StringHeader{Data: uintptr(unsafe.Pointer(&b[0])), Len: len(b)})) 28 | } 29 | 30 | // UnsafeBytes returns the string as a byte slice 31 | // THIS SHOULD ONLY BE USED BY THE CODE GENERATOR. 32 | // THIS IS EVIL CODE. 33 | // YOU HAVE BEEN WARNED. 34 | func UnsafeBytes(s string) []byte { 35 | return *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{ 36 | Len: len(s), 37 | Cap: len(s), 38 | Data: (*(*reflect.StringHeader)(unsafe.Pointer(&s))).Data, 39 | })) 40 | } 41 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/bcrypt/base64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package bcrypt 6 | 7 | import "encoding/base64" 8 | 9 | const alphabet = "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" 10 | 11 | var bcEncoding = base64.NewEncoding(alphabet) 12 | 13 | func base64Encode(src []byte) []byte { 14 | n := bcEncoding.EncodedLen(len(src)) 15 | dst := make([]byte, n) 16 | bcEncoding.Encode(dst, src) 17 | for dst[n-1] == '=' { 18 | n-- 19 | } 20 | return dst[:n] 21 | } 22 | 23 | func base64Decode(src []byte) ([]byte, error) { 24 | numOfEquals := 4 - (len(src) % 4) 25 | for i := 0; i < numOfEquals; i++ { 26 | src = append(src, '=') 27 | } 28 | 29 | dst := make([]byte, bcEncoding.DecodedLen(len(src))) 30 | n, err := bcEncoding.Decode(dst, src) 31 | if err != nil { 32 | return nil, err 33 | } 34 | return dst[:n], nil 35 | } 36 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/LICENSE: -------------------------------------------------------------------------------- 1 | mgo - MongoDB driver for Go 2 | 3 | Copyright (c) 2010-2013 - Gustavo Niemeyer 4 | 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/Makefile: -------------------------------------------------------------------------------- 1 | startdb: 2 | @testdb/setup.sh start 3 | 4 | stopdb: 5 | @testdb/setup.sh stop 6 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/README.md: -------------------------------------------------------------------------------- 1 | The MongoDB driver for Go 2 | ------------------------- 3 | 4 | Please go to [http://labix.org/mgo](http://labix.org/mgo) for all project details. 5 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/bson/LICENSE: -------------------------------------------------------------------------------- 1 | BSON library for Go 2 | 3 | Copyright (c) 2010-2012 - Gustavo Niemeyer 4 | 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/doc.go: -------------------------------------------------------------------------------- 1 | // Package mgo offers a rich MongoDB driver for Go. 2 | // 3 | // Details about the mgo project (pronounced as "mango") are found 4 | // in its web page: 5 | // 6 | // http://labix.org/mgo 7 | // 8 | // Usage of the driver revolves around the concept of sessions. To 9 | // get started, obtain a session using the Dial function: 10 | // 11 | // session, err := mgo.Dial(url) 12 | // 13 | // This will establish one or more connections with the cluster of 14 | // servers defined by the url parameter. From then on, the cluster 15 | // may be queried with multiple consistency rules (see SetMode) and 16 | // documents retrieved with statements such as: 17 | // 18 | // c := session.DB(database).C(collection) 19 | // err := c.Find(query).One(&result) 20 | // 21 | // New sessions are typically created by calling session.Copy on the 22 | // initial session obtained at dial time. These new sessions will share 23 | // the same cluster information and connection pool, and may be easily 24 | // handed into other methods and functions for organizing logic. 25 | // Every session created must have its Close method called at the end 26 | // of its life time, so its resources may be put back in the pool or 27 | // collected, depending on the case. 28 | // 29 | // For more details, see the documentation for the types and methods. 30 | // 31 | package mgo 32 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/internal/sasl/sasl.c: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | static int mgo_sasl_simple(void *context, int id, const char **result, unsigned int *len) 9 | { 10 | if (!result) { 11 | return SASL_BADPARAM; 12 | } 13 | switch (id) { 14 | case SASL_CB_USER: 15 | *result = (char *)context; 16 | break; 17 | case SASL_CB_AUTHNAME: 18 | *result = (char *)context; 19 | break; 20 | case SASL_CB_LANGUAGE: 21 | *result = NULL; 22 | break; 23 | default: 24 | return SASL_BADPARAM; 25 | } 26 | if (len) { 27 | *len = *result ? strlen(*result) : 0; 28 | } 29 | return SASL_OK; 30 | } 31 | 32 | typedef int (*callback)(void); 33 | 34 | static int mgo_sasl_secret(sasl_conn_t *conn, void *context, int id, sasl_secret_t **result) 35 | { 36 | if (!conn || !result || id != SASL_CB_PASS) { 37 | return SASL_BADPARAM; 38 | } 39 | *result = (sasl_secret_t *)context; 40 | return SASL_OK; 41 | } 42 | 43 | sasl_callback_t *mgo_sasl_callbacks(const char *username, const char *password) 44 | { 45 | sasl_callback_t *cb = malloc(4 * sizeof(sasl_callback_t)); 46 | int n = 0; 47 | 48 | size_t len = strlen(password); 49 | sasl_secret_t *secret = (sasl_secret_t*)malloc(sizeof(sasl_secret_t) + len); 50 | if (!secret) { 51 | free(cb); 52 | return NULL; 53 | } 54 | strcpy((char *)secret->data, password); 55 | secret->len = len; 56 | 57 | cb[n].id = SASL_CB_PASS; 58 | cb[n].proc = (callback)&mgo_sasl_secret; 59 | cb[n].context = secret; 60 | n++; 61 | 62 | cb[n].id = SASL_CB_USER; 63 | cb[n].proc = (callback)&mgo_sasl_simple; 64 | cb[n].context = (char*)username; 65 | n++; 66 | 67 | cb[n].id = SASL_CB_AUTHNAME; 68 | cb[n].proc = (callback)&mgo_sasl_simple; 69 | cb[n].context = (char*)username; 70 | n++; 71 | 72 | cb[n].id = SASL_CB_LIST_END; 73 | cb[n].proc = NULL; 74 | cb[n].context = NULL; 75 | 76 | return cb; 77 | } 78 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/internal/sasl/sasl_windows.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "sspi_windows.h" 4 | 5 | SECURITY_STATUS SEC_ENTRY sspi_acquire_credentials_handle(CredHandle* cred_handle, char* username, char* password, char* domain); 6 | int sspi_step(CredHandle* cred_handle, int has_context, CtxtHandle* context, PVOID* buffer, ULONG* buffer_length, char* target); 7 | int sspi_send_client_authz_id(CtxtHandle* context, PVOID* buffer, ULONG* buffer_length, char* user_plus_realm); 8 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/internal/sasl/sspi_windows.h: -------------------------------------------------------------------------------- 1 | // Code adapted from the NodeJS kerberos library: 2 | // 3 | // https://github.com/christkv/kerberos/tree/master/lib/win32/kerberos_sspi.h 4 | // 5 | // Under the terms of the Apache License, Version 2.0: 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | #ifndef SSPI_WINDOWS_H 10 | #define SSPI_WINDOWS_H 11 | 12 | #define SECURITY_WIN32 1 13 | 14 | #include 15 | #include 16 | 17 | int load_secur32_dll(); 18 | 19 | SECURITY_STATUS SEC_ENTRY call_sspi_encrypt_message(PCtxtHandle phContext, unsigned long fQOP, PSecBufferDesc pMessage, unsigned long MessageSeqNo); 20 | 21 | typedef DWORD (WINAPI *encryptMessage_fn)(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo); 22 | 23 | SECURITY_STATUS SEC_ENTRY call_sspi_acquire_credentials_handle( 24 | LPSTR pszPrincipal, // Name of principal 25 | LPSTR pszPackage, // Name of package 26 | unsigned long fCredentialUse, // Flags indicating use 27 | void *pvLogonId, // Pointer to logon ID 28 | void *pAuthData, // Package specific data 29 | SEC_GET_KEY_FN pGetKeyFn, // Pointer to GetKey() func 30 | void *pvGetKeyArgument, // Value to pass to GetKey() 31 | PCredHandle phCredential, // (out) Cred Handle 32 | PTimeStamp ptsExpiry // (out) Lifetime (optional) 33 | ); 34 | 35 | typedef DWORD (WINAPI *acquireCredentialsHandle_fn)( 36 | LPSTR pszPrincipal, LPSTR pszPackage, unsigned long fCredentialUse, 37 | void *pvLogonId, void *pAuthData, SEC_GET_KEY_FN pGetKeyFn, void *pvGetKeyArgument, 38 | PCredHandle phCredential, PTimeStamp ptsExpiry 39 | ); 40 | 41 | SECURITY_STATUS SEC_ENTRY call_sspi_initialize_security_context( 42 | PCredHandle phCredential, // Cred to base context 43 | PCtxtHandle phContext, // Existing context (OPT) 44 | LPSTR pszTargetName, // Name of target 45 | unsigned long fContextReq, // Context Requirements 46 | unsigned long Reserved1, // Reserved, MBZ 47 | unsigned long TargetDataRep, // Data rep of target 48 | PSecBufferDesc pInput, // Input Buffers 49 | unsigned long Reserved2, // Reserved, MBZ 50 | PCtxtHandle phNewContext, // (out) New Context handle 51 | PSecBufferDesc pOutput, // (inout) Output Buffers 52 | unsigned long *pfContextAttr, // (out) Context attrs 53 | PTimeStamp ptsExpiry // (out) Life span (OPT) 54 | ); 55 | 56 | typedef DWORD (WINAPI *initializeSecurityContext_fn)( 57 | PCredHandle phCredential, PCtxtHandle phContext, LPSTR pszTargetName, unsigned long fContextReq, 58 | unsigned long Reserved1, unsigned long TargetDataRep, PSecBufferDesc pInput, unsigned long Reserved2, 59 | PCtxtHandle phNewContext, PSecBufferDesc pOutput, unsigned long *pfContextAttr, PTimeStamp ptsExpiry); 60 | 61 | SECURITY_STATUS SEC_ENTRY call_sspi_query_context_attributes( 62 | PCtxtHandle phContext, // Context to query 63 | unsigned long ulAttribute, // Attribute to query 64 | void *pBuffer // Buffer for attributes 65 | ); 66 | 67 | typedef DWORD (WINAPI *queryContextAttributes_fn)( 68 | PCtxtHandle phContext, unsigned long ulAttribute, void *pBuffer); 69 | 70 | #endif // SSPI_WINDOWS_H 71 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/queue.go: -------------------------------------------------------------------------------- 1 | // mgo - MongoDB driver for Go 2 | // 3 | // Copyright (c) 2010-2012 - Gustavo Niemeyer 4 | // 5 | // All rights reserved. 6 | // 7 | // Redistribution and use in source and binary forms, with or without 8 | // modification, are permitted provided that the following conditions are met: 9 | // 10 | // 1. Redistributions of source code must retain the above copyright notice, this 11 | // list of conditions and the following disclaimer. 12 | // 2. Redistributions in binary form must reproduce the above copyright notice, 13 | // this list of conditions and the following disclaimer in the documentation 14 | // and/or other materials provided with the distribution. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | package mgo 28 | 29 | type queue struct { 30 | elems []interface{} 31 | nelems, popi, pushi int 32 | } 33 | 34 | func (q *queue) Len() int { 35 | return q.nelems 36 | } 37 | 38 | func (q *queue) Push(elem interface{}) { 39 | //debugf("Pushing(pushi=%d popi=%d cap=%d): %#v\n", 40 | // q.pushi, q.popi, len(q.elems), elem) 41 | if q.nelems == len(q.elems) { 42 | q.expand() 43 | } 44 | q.elems[q.pushi] = elem 45 | q.nelems++ 46 | q.pushi = (q.pushi + 1) % len(q.elems) 47 | //debugf(" Pushed(pushi=%d popi=%d cap=%d): %#v\n", 48 | // q.pushi, q.popi, len(q.elems), elem) 49 | } 50 | 51 | func (q *queue) Pop() (elem interface{}) { 52 | //debugf("Popping(pushi=%d popi=%d cap=%d)\n", 53 | // q.pushi, q.popi, len(q.elems)) 54 | if q.nelems == 0 { 55 | return nil 56 | } 57 | elem = q.elems[q.popi] 58 | q.elems[q.popi] = nil // Help GC. 59 | q.nelems-- 60 | q.popi = (q.popi + 1) % len(q.elems) 61 | //debugf(" Popped(pushi=%d popi=%d cap=%d): %#v\n", 62 | // q.pushi, q.popi, len(q.elems), elem) 63 | return elem 64 | } 65 | 66 | func (q *queue) expand() { 67 | curcap := len(q.elems) 68 | var newcap int 69 | if curcap == 0 { 70 | newcap = 8 71 | } else if curcap < 1024 { 72 | newcap = curcap * 2 73 | } else { 74 | newcap = curcap + (curcap / 4) 75 | } 76 | elems := make([]interface{}, newcap) 77 | 78 | if q.popi == 0 { 79 | copy(elems, q.elems) 80 | q.pushi = curcap 81 | } else { 82 | newpopi := newcap - (curcap - q.popi) 83 | copy(elems, q.elems[:q.popi]) 84 | copy(elems[newpopi:], q.elems[q.popi:]) 85 | q.popi = newpopi 86 | } 87 | for i := range q.elems { 88 | q.elems[i] = nil // Help GC. 89 | } 90 | q.elems = elems 91 | } 92 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/raceoff.go: -------------------------------------------------------------------------------- 1 | // +build !race 2 | 3 | package mgo 4 | 5 | const raceDetector = false 6 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/raceon.go: -------------------------------------------------------------------------------- 1 | // +build race 2 | 3 | package mgo 4 | 5 | const raceDetector = true 6 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/saslimpl.go: -------------------------------------------------------------------------------- 1 | //+build sasl 2 | 3 | package mgo 4 | 5 | import ( 6 | "gopkg.in/mgo.v2/internal/sasl" 7 | ) 8 | 9 | func saslNew(cred Credential, host string) (saslStepper, error) { 10 | return sasl.New(cred.Username, cred.Password, cred.Mechanism, cred.Service, host) 11 | } 12 | -------------------------------------------------------------------------------- /vendor/gopkg.in/mgo.v2/saslstub.go: -------------------------------------------------------------------------------- 1 | //+build !sasl 2 | 3 | package mgo 4 | 5 | import ( 6 | "fmt" 7 | ) 8 | 9 | func saslNew(cred Credential, host string) (saslStepper, error) { 10 | return nil, fmt.Errorf("SASL support not enabled during build (-tags sasl)") 11 | } 12 | --------------------------------------------------------------------------------