[
  {
    "path": ".gitignore",
    "content": "glide\nglide.exe\n*.a\n*.sublime-project\n*.sublime-workspace\ndist/\n.DS_Store\n.idea\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: go\n\ngo:\n  - 1.7.x\n  - 1.8.x\n  - 1.9.x\n  - 1.10.x\n  - 1.11.x\n  - 1.12.x\n  - tip\n\n# Setting sudo access to false will let Travis CI use containers rather than\n# VMs to run the tests. For more details see:\n# - http://docs.travis-ci.com/user/workers/container-based-infrastructure/\n# - http://docs.travis-ci.com/user/workers/standard-infrastructure/\nsudo: false\n\n# The default script is go test -v ./... which will test everything\n# in the vendor directory. We don't need to test all dependent packages.\n# Only testing this project.\nscript:\n  - make test integration-test verify-version\n\nnotifications:\n  webhooks:\n    urls:\n      - https://webhooks.gitter.im/e/67e4b42cbf763625d0b4\n    on_success: change\n    on_failure: always\n    on_start: never\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "# Release 0.13.4 (unreleased)\n\n# Release 0.13.3 (2019-07-12)\n\n## Fixed\n\n- #1056: Fixed issue where Glide is not detecting crypto/ed25519, now in the stdlib (thanks @martinkunc)\n- #1033: Fixed segfault with Glide 0.13.2 when stripping Godep workspace (thanks @databus23)\n\n# Release 0.13.2 (2018-09-26)\n\n## Fixed\n\n- #956: Fixed Error handling nested vendor folders (thanks @apynes2)\n- #953: Fixed issue where error was not propagating\n\n# Release 0.13.1 (2017-11-07)\n\n## Fixed\n\n- #935: Fix handling of new core package math/bits (thanks @prateek)\n\n# Release 0.13.0 (2017-09-28)\n\n## Added\n\n- #631: Verify version during build in automation (thanks @breerly)\n- #711: Added a commit hash example to the docs (thanks @mh-cbon)\n- #771: Handling default GOPATH for Go 1.8\n- #814: Adding install instructions for Ubuntu 17.04 (thanks @HaraldNordgren)\n- #870: Added support for s390x architecture (thanks @Nayana-ibm)\n\n## Changed\n\n- #582: Removed verbose flag as it was not being used (thanks @kelcecil)\n- #697: Preserve vendor/.git, if it exists. (thanks @sdboyer)\n- #686: Make ending dots in output more consistent (thanks @stevenroose)\n- #748: Updated tests to work windows and add windows CI testing\n- #717: Cache GOROOT at init time for performance (thanks @heyitsanthony)\n- #797, #821, #908: Updating to the latest version of the dependencies\n- #800: Allow VERSION of glide to be passed in with build script (thanks @BlackYoup)\n- #774: Add docs on using go get to install glide (thanks @philoserf)\n- #907: Updated Travis CI language versions of Go to test against (thanks @dvrkps)\n- #916: Update gox to version managed by Masterminds for builds\n\n## Fixed\n\n- #736: Find home dir without using cgo (thanks @krancour)\n- #603: Fixed where, in some cases not importing dependencies config\n- #620: Fixed grammar usage on projects (thanks @server-monitor)\n- #623: Fixed typos in help and  (thanks @jonboulle)\n- #628: Fixed typos (thanks @philoserf)\n- #733: Fixed documentation issues (thanks @matiasanaya)\n- #747: Fixed issue with glide home directory (thanks @agatan)\n- #759: More spelling fixes (thanks @jbirch)\n- #775: Even more doc typo fixes (thanks @cristiangreco)\n- #811: Fixed issue with windows git submodules\n- #819: Fixed more typos (thanks @zoofood)\n- #829: Fixed preservation of .git files correctly (@RaduBerinde)\n- #778: Fixed removing and moving large sets of files fails on Windows\n- #910: Fixed issue due to go/build.ImportDir change response on not found dir\n- #906: Fixed CustomRemoveAll() to handle spaces in paths, and also file not found (thanks @jpz)\n\n# Release 0.12.3 (2016-10-03)\n\n## Fixed\n- #615: Fixed possible situation where resolver could get stuck in a loop\n\n# Release 0.12.2 (2016-09-13)\n\n## Fixed\n- #599: In some cases was not importing dependencies config\n- #601: Fixed issue where --all-dependencies flag stopped working\n\n# Release 0.12.1 (2016-08-31)\n\n## Fixed\n- #578: Not resolving parent project packages in some cases\n- #580: cross-device error handling failed on Windows in some cases\n- #590: When exit signal received remove global lock\n\nNote, Plan 9 is an experimental OS for Go. Due to some issues we are not going\nto be supporting builds for it at this time.\n\n# Release 0.12.0 (2016-08-23)\n\n## Added\n- Support for distributions in FreeBSD, OpenBSD, NetBSD, and Plan9\n- #528: ARM release support (thanks @franciscocpg)\n- #563: Added initial integration testing\n- #533: Log VCS output with debug (`--debug` switch) when there was a VCS error (thanks @atombender)\n- #39: Added support for mirrors. See the mirror command and subcommands\n\n## Changed\n- #521: Sort subpackages for glide.yaml and glide.lock to avoid spurious diffs\n- #487: Skip lookup of subpackage location when parent repo is already known\n  This skips unnecessary network requests (thanks @hori-ryota)\n- #492 and #547: Dependencies are now resolved in a global cache and exported to\n  vendor/ directories. This allows sharing of VCS data between projects without\n  upseting the GOPATH versions and is faster for projects vendoring dependencies.\n  Some flags including --update-vendored, --cache-gopath, --use-gopath, and some\n  others are deprecated and no longer needed.\n\n## Fixed\n- #287: When file or directory not found provide useful message\n- #559: Fixed error is nil issue (thanks @mfycheng)\n- #553: Export was failing with different physical devices\n- #542: Glide failed to detect some test dependencies (thanks @sdboyer)\n- #517: Fixed failure to install testImport from lock when no imports present\n  or when same dependency on both import and testImport\n- #440: Fixed panic in `glide tree` when walking the filesystem (thanks @abhin4v)\n- #529: --delete flag deleted and re-downloaded transitive dependencies\n- #535: Resolve vendor directory symlinks (thanks @Fugiman)\n\n# Release 0.11.1 (2016-07-21)\n\n## Fixed\n- #505: Ignored dependency showing up in testImport\n\n# Release 0.11.0 (2016-07-05)\n\n## Added\n- #461: Resolve test imports\n- #458: Wizard and version detection are now on `glide get`\n- #444: New config wizard helps you find versions and set ranges. Can be run from\n  `glide init` or as separate command\n- #438: Added ability to read symlink basedirs (thanks @klnusbaum)\n- #436: Added .idea to .gitignore\n- #393 and #401: Added a PPA (https://github.com/Masterminds/glide-ppa) and instructions\n  on using it (thanks @franciscocpg)\n- #390: Added support for custom Go executable name. Needed for environments like\n  appengine. Environment variable GLIDE_GO_EXECUTABLE (thanks @dpmcnevin)\n- #382: `glide info` command takes a format string and returns info (thanks @franciscocpg)\n- #365: glide list: support json output format (thanks @chancez)\n\n## Changed\n- Tags are now in the form v[SemVer]. The change is the initial v on the tag.\n  This is to conform with other Go tools that require this.\n- #501: Updating the plugins documentation and adding listing\n- #500: Log an error if stripping version control data fails (thanks @alexbrand)\n- #496: Updated to github.com/Masterminds/semver 1.1.1\n- #495: Updated to github.com/Masterminds/vcs 1.8.0\n- #494: Glide install skips fetch when it is up to date\n- #489: Make shared funcs for lockfile usage (thanks @heewa)\n- #459: When a conflict occurs output the tag, if one exists, for the commit\n- #443: Updating message indentation to be uniform\n- #431: Updated the docs on subpackages\n- #433: The global shared cache was reworked in prep for future uses\n- #396: Don't update the lock file if nothing has changed\n\n## Fixed\n- #460: Sometimes ignored packages were written to lock file. Fixed.\n- #463: Fixed possible nil pointer issues\n- #453: Fix DeleteUnused flag which was not working (thanks @s-urbaniak)\n- #432: Fixed issue with new net/http/httptrace std lib package\n- #392: Correctly normalize Windows package paths (thanks @jrick)\n- #395: Creating the cache key did not handle SCP properly\n- #386: Fixed help text indentation\n- #383: Failed `glide get` had been updating files. No longer does this\n\nAnd thanks to @derelk, @franciscocpg, @shawnps, @kngu9, @tugberkugurlu, @rhcarvalho,\n@gyuho, and @7imon7ays for documentation updates.\n\n# Release 0.10.2 (2016-04-06)\n\n- Issue #362: Updated docs on how -update-vendored works to help avoid confusion.\n- Fixed #371: Warn when name/location mismatch.\n- Fixed #290: On windows Glide was sometimes pulls in current project (thanks tzneal).\n- Fixed #361: Handle relative imports (thanks tmm1).\n- Fixed #373: Go 1.7 context package import issues.\n\n# Release 0.10.1 (2016-03-25)\n\n- Fixed #354: Fixed a situation where a dependency could be fetched when\n  set to ignore.\n\n# Release 0.10.0 (2016-03-24)\n\n- Issue #293: Added support for importing from Gomfile's (thanks mcuelenaere).\n- Issue #318: Opt-In to strip VCS metadata from vendor directory.\n- Issue #297: Adds exclude property for directories in local codebase to exclude\n  from scanning.\n- Issue #301: Detect version control type from scp style paths (e.g. git@) and\n  from scheme types (e.g., git://).\n- Issue #339: Add ability to remove nested vendor and Godeps workspaces\n  directories. Note, if Godeps rewriting occured it is undone. The Godeps handling\n  is deprecated from day one and will be removed when most Godeps projects have\n  migrated to vendor folder handling.\n- Issue #350: More detailed conflict information (commit metadata displayed).\n- Issue #351: Move to Gitter for chat.\n- Issue #352: Make Glide installable. The dependencies are checked into the\n  `vendor` folder.\n\n# Release 0.9.3 (2016-03-09)\n\n- Fixed #324: Glide tries to update ignored package\n\n# Release 0.9.2 (2016-03-08)\n\n- Fixed issue on #317: Some windows calls had the improper path separator.\n- Issue #315: Track updated packages to avoid duplicated work (in part by\n  thockin, thanks).\n- Fixed #312: Don't double-print SetVersion() failure (thanks thockin).\n- Fixed #311: Don't process deps if 'get' was a non-operation (thanks thockin).\n- Issue #307: Moving 'already set' to a debug message to cleanup output\n  (thanks thockin).\n- Fixed #306: Don't call SetVersion twice. There was a place where it was called\n  twice in a logical row (thanks thockin).\n- Fixed #304: Glide tries to update ignored packages.\n- Fixed #302: Force update can cause a panic.\n\n# Release 0.9.1 (2016-02-24)\n\n- Fixed #272: Handling appengine special package case.\n- Fixed #273: Handle multiple packages in the same directory but handling\n  build tags used in those packages.\n- Added documentation explaining how import resolution works.\n- Fixed #275 and #285: Empty directories as package locations reporting errors.\n  Improved the UX and handle the errors.\n- Fixed #279: Added Go 1.7 support that no longer has GO15VENDOREXPERIMENT.\n- Issue #267: Added `os` and `arch` import properties to the documentation.\n- Fixed #267: Glide was only walking the import tree based on build flags for\n  the current OS and Arch. This is a problem for systems like docker that have\n  variation built in.\n\n# Release 0.9.0 (2016-02-17)\n\n- Fixed #262: Using correct query string merging for go-get queries (thanks gdm85).\n- Fixed #251: Fixed warning message (thanks james-lawrence).\n- Adding support for IBM JazzHub.\n- Fixes #250: When unable to retrieve or set version on a dependency now erroring\n  and exiting with non-0 exit code.\n- Issue #218: Added `glide rm` command.\n- Fixed #215: Under some error conditions the package resolver could get into\n  an infinite loop.\n- Issue #234: Adding more options to the glide.yaml file including license,\n  owners, homepage, etc. See the docs for more detail.\n- Issue #237: Added Read The Docs support and initial docs. http://glide.readthedocs.org\n- Issue #248: Uses go env to get value of GO15VENDOREXPERIMENT due to 1.6 enabling\n  by default.\n- Issue #240: Glide only scans used imports rather than all paths in the tree.\n  The previous behavior is available via a flag.\n- Fixed #235: Glide on windows writing incorrect slashes to files.\n- Fixed #227: Fixed ensure when multiple gopaths.\n- Refactored Glide\n  - Many features broken out into packages. All but `action/` can be\n    used as libraries.\n  - Cookoo is not used anymore\n  - The `action/` package replaces `cmd/`\n\n# Release 0.8.3 (2015-12-30)\n\n- Issue #198: Instead of stopping `glide install` for a hash failures providing\n  a warning. Failed hash check is currently too aggressive.\n- Fixed #199: `glide up` on Windows unable to detect dependencies when GOPATH\n  and GOROOT on a different drive or when GOROOT ends in a path separator.\n- Fixed #194: `glide up` stalling on Windows due to POSIX path separators and\n  path list separators being used.\n- Fixed #185 and #187: Inaccurate hash being generated for lock file with nested\n  version ranges.\n- Fixed #182 and #183: Caching on go-import lookups mishandled some prefixes.\n- Fixed issue in deduping and sub-package names.\n- Fixed #189: nested dependencies that do not contain VCS information were not\n  being updated properly when --updated-vendored was being used.\n- Fixed #186: glide up PACKAGE was failing to generate a proper glide.lock file.\n\n# Release 0.8.2 (2015-12-21)\n\n- Fixed #169: cookoo git url has auth info. Makes glide unbuildable for\n  environments not setup for GitHub.\n- Fixed #180: the hash in the glide.lock file was not being properly calculated.\n- Fixed #174: glide get was causing an error when the flag --updated-vendored\n  was being used.\n- Fixed #175: glide get when the GOPATH isn't setup properly could end up in\n  an infinite loop.\n\n# Release 0.8.1 (2015-12-15)\n\n- Fixed #163: Was detecting std lib packages when the GOROOT was different at\n  runtime than compile time.\n- Fixed #165: glide update panics with --no-recursive option.\n- Added back zip build option to build scripts. This is useful for some\n  environments.\n\n# Release 0.8.0 (2015-12-10)\n\n- Issues #156 and #85: Added lockfile support (glide.lock). This file records\n  commit id pinned versions of the entire dependency tree. The `glide install`\n  command installs the pinned dependencies from the `glide.lock` file while\n  `glide update` updates the tree and lockfile. Most people should use `glide\n  install` unless they want to intentionally updated the pinned dependencies.\n  `glide install` is able to use concurrency to more quickly install update.\n- Issues #33 and #159: Glide notifies if a dependency checkout has uncomitted\n  changes.\n- Issue #146: Glide scans projects not managed by a dependency manager, fetches\n  their dependencies, and pins them in the glide.lock file.\n- Issue #99: Glide `get` pins dependencies by default and allows a version to\n  be passed in. For example, `glide get github.com/Masterminds/convert#^1.0.0`\n  will fetch `github.com/Masterminds/convert` with a version of `^1.0.0`.\n- Issue #155: Copying packages from the `GOPATH` is now opt-in.\n\n# Release 0.7.2 (2015-11-16)\n\n- Fixed #139: glide.yaml file imports being reordered when file written.\n- Fixed #140: packages in glide.yaml were no longer being deduped.\n\n# Release 0.7.1 (2015-11-10)\n\n- Fixed #136: Fixed infinite recursion in list and tree commands.\n- Fixed issue where glide guess listed a null parent.\n- Fixed #135: Hard failure when home directory not found for cache.\n- Fixed #137: Some messages not ending in \"\\n\".\n- Fixed #132 and #133: Build from source directions incorrect (thanks hyPiRion).\n\n# Release 0.7.0 (2015-11-02)\n\n- Fixed #110: Distribution as .tag.gz instead of .zip.\n- Issue #126: Added --no-color option to remove color for systems that do not\n  work well with color codes (thanks albrow).\n- Added caching functionality (some opt-in).\n- Added global debug flag.\n- Moved yaml parsing and writing to gopkg.in/yaml.v2 and separated\n  config handling into separate package.\n- Better godep import handling.\n- Fixed #98: Godep command name fix (thanks jonboulle).\n- #52 and #114: Add semantic version (SemVer) support.\n- #108: Flatten the dependency tree by default.\n- Fixed #107: Allow `glide get` to retrieve insecure packages with `--insecure`\n  flag.\n- #105: Import commands accept a filename with the `-f` flag.\n- Fixed #97: Fixed misspellings (thanks jonboulle).\n- #96: Allow multiple packages in `glide get`.\n- #92: Added support to `glide update` to only update a specific package.\n- #91: `glide list` now displays if a pkg is in vendor, GOPATH, or missing.\n- Issue #89: More robust GOPATH handling (thanks gcmt).\n- Fixed #65: Hg commands were not checking out the codebase on the first update.\n- Fixed #95: Added more detail for errors previously reporting \"Oops! exit\n  status 128\".\n- Fixed #86 and #71: Imported package names including a sub-package were checked\n  out to the wrong location. They are not checked out to the right place and\n  multiple instances of the top level repo are merged with error checking.\n\n# Release 0.6.1 (2015-09-21)\n\n- Fixed #82: C was not recognized as an internal package.\n- Fixed #84: novendor (nv) command returned directories with no Go code.\n\n# Release 0.6.0 (2015-09-16)\n\n- #53: Add support for gb-vendor manifest files.\n- Added `glide tree` command to inspect the code and see the imported packages.\n- Added `glide list` to see an alphabetized list of imported projects.\n- Added flatten feature to flatten the vendor tree (thanks interlock).\n- Fixed #74: Glide guess using the wrong GOROOT locations in some environments\n  (thanks janeczku).\n- Fixed #76: Glide tree doesn't exclude core libraries with the GOROOT is\n  incorrect (thanks janeczku).\n- Fixed #81: rebuild command did not look in vendor/ directory\n- Fixed #77: update failed when a commit id was set for the ref\n\n# Release 0.5.1 (2015-08-31)\n\n- Fixed #58: Guess command not working.\n- Fixed #56: Unable to use glide get on golang.org/x/[name]/[subpackage]\n- Fixed #61: The wrong version of a dependency can be pinned when packages are\n  vendored (no VCS repo associated with them).\n- Fixed #67: Unable to work go-get redirects.\n- Fixed #66: 'glide up' now has an --update-vendored (-u) flag to update\n  vendored directories.\n- Fixed #68: Handling the base where the GOPATH has multiple separated directories.\n\n# Release 0.5.0 (2015-08-19)\n\n**Glide .5 is a major update breaking some backwards compatability with\nprevious releases.**\n\n- Migrated to using the vendor/ directory and the go tools for vendor\n  package management. To leverage this you'll need to set the\n  environment variable GO15VENDOREXPERIMENT=1 and use Go 1.5.\n- `glide up` is now recursive and walks installed packages if there is\n  no vendor directory. Use the --no-recursive flag to skip this.\n- Removed GOPATH management. This was needed for vendor package\n  management that's not built into the go toolchain.\n- Switched to github.com/Masterminds/vcs for VCS integration.\n- When updating packages are now deleted if the --delete flag is set.\n  This feature is now opt-in.\n- Fixed #32: Detects VCS type and endpoint changes along with a --force flag\n  to replace the checkout if desired.\n\n# Release 0.4.1 (2015-07-13)\n\n- Issue #48: When GOPATH not _vendor directory not deleting unused packages.\n\n# Release 0.4.0 (2015-07-07)\n\n- Issue #34: Delete unused packages on update unless flag set.\n- Added 'glide create PACKAGE'\n- Added 'glide exec COMMAND'\n- Added 'glide get PACKAGE'\n- Added 'glide pin FILENAME'\n- Added 'glide guess FILENAME'\n- Updated help text\n\n# Release 0.3.0 (2015-06-17)\n\n- Issue #46: If VCS type is set use that rather than go get.\n- Issue #45: Added git fastpath if configured ref or tag matches current\n  one. (via roblillack)\n- Issue #30: Added support for changed VCS type to a git repo. (thanks roblillack)\n- Issue #42: Fixed update for new dependencies where repo not configured.\n  (thanks roblillack)\n- Issue #25: Added GOOS and GOARCH support.\n- Issue #35: Updated documentation on what update from existing repos means\n- Issue #37: Added support to import from GPM and Godep\n- Issue #36: Added example for shell (bash/zsh) prompt to show the current\n  GOPATH. (thanks eAndrius)\n- Issue #31: The local Go bin should be higher precedence in the\n  system's PATH (via jarod).\n- Issue #28: Use HTTPS instead of HTTP for git and hg. (Thanks chendo)\n- Issue #26: 'glide gopath' is smarter. It now looks for glide.yaml.\n- Issue #24: Trim whitespace off of package names. (Thanks roblillack)\n\n# Release 0.2.0 (2014-10-03)\n\n- Issue #15, #18: `glide guess` can guess dependencies for an existing\n  repo. (HUGE thanks to dz0ny)\n- Issue #14: Glide fails now when YAML is invalid.\n- Issue #13: cli.go added to Makefile (via roblillack)\n- Issue #12: InitGlide takes YAML file now\n- Issue #9: Fixed handling of $SHELL (Thanks roblillack)\n- Issue #10: Symbolic link uses a relative path now (Thanks roblillack)\n- Issue #5: Build step is deferred when 'go get' is used to fetch\n  packages. (Thanks gsalgado)\n- Issue #11: Add GOBIN to glide environment (via dz0ny)\n- Typos fixed (#17 by lamielle, #16 by roblillack)\n- Moved the CLI handling to cli.go (github.com/codegangsta/cli)\n"
  },
  {
    "path": "LICENSE",
    "content": "Glide\nThe Masterminds\nCopyright (C) 2014-2016, Matt Butcher and Matt Farina\nCopyright (C) 2016, Hewlett Packard Enterprise Development LP\nCopyright (C) 2015, Google\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "Makefile",
    "content": "GLIDE_GO_EXECUTABLE ?= go\nDIST_DIRS := find * -type d -exec\nVERSION ?= $(shell git describe --tags)\nVERSION_INCODE = $(shell perl -ne '/^var version.*\"([^\"]+)\".*$$/ && print \"v$$1\\n\"' glide.go)\nVERSION_INCHANGELOG = $(shell perl -ne '/^\\# Release (\\d+(\\.\\d+)+) / && print \"$$1\\n\"' CHANGELOG.md | head -n1)\n\nbuild:\n\t${GLIDE_GO_EXECUTABLE} build -o glide -ldflags \"-X main.version=${VERSION}\" glide.go\n\ninstall: build\n\tinstall -d ${DESTDIR}/usr/local/bin/\n\tinstall -m 755 ./glide ${DESTDIR}/usr/local/bin/glide\n\ntest:\n\t${GLIDE_GO_EXECUTABLE} test . ./gb ./path ./action ./tree ./util ./godep ./godep/strip ./gpm ./cfg ./dependency ./importer ./msg ./repo ./mirrors\n\nintegration-test:\n\t${GLIDE_GO_EXECUTABLE} build\n\t./glide up\n\t./glide install\n\nclean:\n\trm -f ./glide.test\n\trm -f ./glide\n\trm -rf ./dist\n\nbootstrap-dist:\n\t${GLIDE_GO_EXECUTABLE} get -u github.com/Masterminds/gox\n\nbuild-all:\n\tgox -verbose \\\n\t-ldflags \"-X main.version=${VERSION}\" \\\n\t-os=\"linux darwin windows freebsd openbsd netbsd\" \\\n\t-arch=\"amd64 386 armv5 armv6 armv7 arm64 s390x\" \\\n\t-osarch=\"!darwin/arm64\" \\\n\t-output=\"dist/{{.OS}}-{{.Arch}}/{{.Dir}}\" .\n\ndist: build-all\n\tcd dist && \\\n\t$(DIST_DIRS) cp ../LICENSE {} \\; && \\\n\t$(DIST_DIRS) cp ../README.md {} \\; && \\\n\t$(DIST_DIRS) tar -zcf glide-${VERSION}-{}.tar.gz {} \\; && \\\n\t$(DIST_DIRS) zip -r glide-${VERSION}-{}.zip {} \\; && \\\n\tcd ..\n\nverify-version:\n\t@if [ \"$(VERSION_INCODE)\" = \"v$(VERSION_INCHANGELOG)\" ]; then \\\n\t\techo \"glide: $(VERSION_INCHANGELOG)\"; \\\n\telif [ \"$(VERSION_INCODE)\" = \"v$(VERSION_INCHANGELOG)-dev\" ]; then \\\n\t\techo \"glide (development): $(VERSION_INCHANGELOG)\"; \\\n\telse \\\n\t\techo \"Version number in glide.go does not match CHANGELOG.md\"; \\\n\t\techo \"glide.go: $(VERSION_INCODE)\"; \\\n\t\techo \"CHANGELOG : $(VERSION_INCHANGELOG)\"; \\\n\t\texit 1; \\\n\tfi\n\n.PHONY: build test install clean bootstrap-dist build-all dist integration-test verify-version\n"
  },
  {
    "path": "README.md",
    "content": "# Glide: Vendor Package Management for Golang\n\n![glide logo](https://glide.sh/assets/logo-small.png)\n\nAre you used to tools such as Cargo, npm, Composer, Nuget, Pip, Maven, Bundler,\nor other modern package managers? If so, Glide is the comparable Go tool.\n\n*Manage your vendor and vendored packages with ease.* Glide is a tool for\nmanaging the `vendor` directory within a Go package. This feature, first\nintroduced in Go 1.5, allows each package to have a `vendor` directory\ncontaining dependent packages for the project. These vendor packages can be\ninstalled by a tool (e.g. glide), similar to `go get` or they can be vendored and\ndistributed with the package.\n\n[![Build Status](https://travis-ci.org/Masterminds/glide.svg)](https://travis-ci.org/Masterminds/glide)\n[![Build status](https://ci.appveyor.com/api/projects/status/3pl4ytgdlfj852li?svg=true&passingText=windows%20build%20passing&failingText=windows%20build%20failing)](https://ci.appveyor.com/project/mattfarina/glide-a8xtg)\n[![Go Report Card](https://goreportcard.com/badge/github.com/Masterminds/glide)](https://goreportcard.com/report/github.com/Masterminds/glide) [![GoDoc](https://godoc.org/github.com/Masterminds/glide?status.svg)](https://godoc.org/github.com/Masterminds/glide) [![Documentation Status](https://readthedocs.org/projects/glide/badge/?version=stable)](http://glide.readthedocs.org/en/stable/?badge=stable) [![Documentation Status](https://readthedocs.org/projects/glide/badge/?version=latest)](http://glide.readthedocs.org/en/latest/?badge=latest)\n\n### Go Modules\n\nThe Go community is now using Go Modules to handle dependencies. Please consider\nusing that instead of Glide. Glide is now mostly unmaintained.\n\n### Features\n\n* Ease dependency management\n* Support **versioning packages** including [Semantic Versioning\n  2.0.0](http://semver.org/) support. Any constraint the [`github.com/Masterminds/semver`](https://github.com/Masterminds/semver)\n  package can parse can be used.\n* Support **aliasing packages** (e.g. for working with github forks)\n* Remove the need for munging import statements\n* Work with all of the `go` tools\n* Support the VCS tools that Go supports:\n    - git\n    - bzr\n    - hg\n    - svn\n* Support custom local and global plugins (see docs/plugins.md)\n* Repository caching and data caching for improved performance.\n* Flatten dependencies resolving version differences and avoiding the inclusion\n  of a package multiple times.\n* Manage and install dependencies on-demand or vendored in your version control\n  system.\n\n## How It Works\n\nGlide scans the source code of your application or library to determine the needed\ndependencies. To determine the versions and locations (such as aliases for forks)\nGlide reads a `glide.yaml` file with the rules. With this information Glide retrieves\nneeded dependencies.\n\nWhen a dependent package is encountered its imports are scanned to determine\ndependencies of dependencies (transitive dependencies). If the dependent project\ncontains a `glide.yaml` file that information is used to help determine the\ndependency rules when fetching from a location or version to use. Configuration\nfrom Godep, GB, GOM, and GPM is also imported.\n\nThe dependencies are exported to the `vendor/` directory where the `go` tools\ncan find and use them. A `glide.lock` file is generated containing all the\ndependencies, including transitive ones.\n\nThe `glide init` command can be use to setup a new project, `glide update`\nregenerates the dependency versions using scanning and rules, and `glide install`\nwill install the versions listed in the `glide.lock` file, skipping scanning,\nunless the `glide.lock` file is not found in which case it will perform an update.\n\nA project is structured like this:\n\n```\n- $GOPATH/src/myProject (Your project)\n  |\n  |-- glide.yaml\n  |\n  |-- glide.lock\n  |\n  |-- main.go (Your main go code can live here)\n  |\n  |-- mySubpackage (You can create your own subpackages, too)\n  |    |\n  |    |-- foo.go\n  |\n  |-- vendor\n       |-- github.com\n            |\n            |-- Masterminds\n                  |\n                  |-- ... etc.\n```\n\n*Take a look at [the Glide source code](http://github.com/Masterminds/glide)\nto see this philosophy in action.*\n\n## Install\n\nThe easiest way to install the latest release on Mac or Linux is with the following script:\n\n```\ncurl https://glide.sh/get | sh\n```\n\nOn Mac OS X you can also install the latest release via [Homebrew](https://github.com/Homebrew/homebrew):\n\n```\n$ brew install glide\n```\n\nOn Ubuntu Precise (12.04), Trusty (14.04), Wily (15.10) or Xenial (16.04) you can install from our PPA:\n\n```\nsudo add-apt-repository ppa:masterminds/glide && sudo apt-get update\nsudo apt-get install glide\n```\n\nOn Ubuntu Zesty (17.04) the package is called `golang-glide`.\n\n[Binary packages](https://github.com/Masterminds/glide/releases) are available for Mac, Linux and Windows.\n\nFor a development version it is also possible to `go get github.com/Masterminds/glide`.\n\nTo build from source you can:\n\n1. Clone this repository into `$GOPATH/src/github.com/Masterminds/glide` and\n   change directory into it\n2. If you are using Go 1.5 ensure the environment variable GO15VENDOREXPERIMENT is set, for\n   example by running `export GO15VENDOREXPERIMENT=1`. In Go 1.6 it is enabled by default and\n   in Go 1.7 it is always enabled without the ability to turn it off.\n3. Run `make build`\n\nThis will leave you with `./glide`, which you can put in your `$PATH` if\nyou'd like. (You can also take a look at `make install` to install for\nyou.)\n\nThe Glide repo has now been configured to use glide to\nmanage itself, too.\n\n## Usage\n\n```\n$ glide create                            # Start a new workspace\n$ open glide.yaml                         # and edit away!\n$ glide get github.com/Masterminds/cookoo # Get a package and add to glide.yaml\n$ glide install                           # Install packages and dependencies\n# work, work, work\n$ go build                                # Go tools work normally\n$ glide up                                # Update to newest versions of the package\n```\n\nCheck out the `glide.yaml` in this directory, or examples in the `docs/`\ndirectory.\n\n### glide create (aliased to init)\n\nInitialize a new workspace. Among other things, this creates a `glide.yaml` file\nwhile attempting to guess the packages and versions to put in it. For example,\nif your project is using Godep it will use the versions specified there. Glide\nis smart enough to scan your codebase and detect the imports being used whether\nthey are specified with another package manager or not.\n\n```\n$ glide create\n[INFO]\tGenerating a YAML configuration file and guessing the dependencies\n[INFO]\tAttempting to import from other package managers (use --skip-import to skip)\n[INFO]\tScanning code to look for dependencies\n[INFO]\t--> Found reference to github.com/Masterminds/semver\n[INFO]\t--> Found reference to github.com/Masterminds/vcs\n[INFO]\t--> Found reference to github.com/codegangsta/cli\n[INFO]\t--> Found reference to gopkg.in/yaml.v2\n[INFO]\tWriting configuration file (glide.yaml)\n[INFO]\tWould you like Glide to help you find ways to improve your glide.yaml configuration?\n[INFO]\tIf you want to revisit this step you can use the config-wizard command at any time.\n[INFO]\tYes (Y) or No (N)?\nn\n[INFO]\tYou can now edit the glide.yaml file. Consider:\n[INFO]\t--> Using versions and ranges. See https://glide.sh/docs/versions/\n[INFO]\t--> Adding additional metadata. See https://glide.sh/docs/glide.yaml/\n[INFO]\t--> Running the config-wizard command to improve the versions in your configuration\n```\n\nThe `config-wizard`, noted here, can be run here or manually run at a later time.\nThis wizard helps you figure out versions and ranges you can use for your\ndependencies.\n\n### glide config-wizard\n\nThis runs a wizard that scans your dependencies and retrieves information on them\nto offer up suggestions that you can interactively choose. For example, it can\ndiscover if a dependency uses semantic versions and help you choose the version\nranges to use.\n\n### glide get [package name]\n\nYou can download one or more packages to your `vendor` directory and have it added to your\n`glide.yaml` file with `glide get`.\n\n```\n$ glide get github.com/Masterminds/cookoo\n```\n\nWhen `glide get` is used it will introspect the listed package to resolve its\ndependencies including using Godep, GPM, Gom, and GB config files.\n\n### glide update (aliased to up)\n\nDownload or update all of the libraries listed in the `glide.yaml` file and put\nthem in the `vendor` directory. It will also recursively walk through the\ndependency packages to fetch anything that's needed and read in any configuration.\n\n```\n$ glide up\n```\n\nThis will recurse over the packages looking for other projects managed by Glide,\nGodep, gb, gom, and GPM. When one is found those packages will be installed as needed.\n\nA `glide.lock` file will be created or updated with the dependencies pinned to\nspecific versions. For example, if in the `glide.yaml` file a version was\nspecified as a range (e.g., `^1.2.3`) it will be set to a specific commit id in\nthe `glide.lock` file. That allows for reproducible installs (see `glide install`).\n\nTo remove any nested `vendor/` directories from fetched packages see the `-v` flag.\n\n### glide install\n\nWhen you want to install the specific versions from the `glide.lock` file use\n`glide install`.\n\n```\n$ glide install\n```\n\nThis will read the `glide.lock` file and install the commit id specific versions\nthere.\n\nWhen the `glide.lock` file doesn't tie to the `glide.yaml` file, such as there\nbeing a change, it will provide a warning. Running `glide up` will recreate the\n`glide.lock` file when updating the dependency tree.\n\nIf no `glide.lock` file is present `glide install` will perform an `update` and\ngenerate a lock file.\n\nTo remove any nested `vendor/` directories from fetched packages see the `-v` flag.\n\n## glide novendor (aliased to nv)\n\nWhen you run commands like `go test ./...` it will iterate over all the\nsubdirectories including the `vendor` directory. When you are testing your\napplication you may want to test your application files without running all the\ntests of your dependencies and their dependencies. This is where the `novendor`\ncommand comes in. It lists all of the directories except `vendor`.\n\n    $ go test $(glide novendor)\n\nThis will run `go test` over all directories of your project except the\n`vendor` directory.\n\n## glide name\n\nWhen you're scripting with Glide there are occasions where you need to know\nthe name of the package you're working on. `glide name` returns the name of the\npackage listed in the `glide.yaml` file.\n\n### glide tree\n\nGlide includes a few commands that inspect code and give you details\nabout what is imported. `glide tree` is one such command. Running it\ngives data like this:\n\n```\n$ glide tree\ngithub.com/Masterminds/glide\n\tgithub.com/Masterminds/cookoo   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/cookoo)\n\t\tgithub.com/Masterminds/cookoo/io   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/cookoo/io)\n\tgithub.com/Masterminds/glide/cmd   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/cmd)\n\t\tgithub.com/Masterminds/cookoo   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/cookoo)\n\t\t\tgithub.com/Masterminds/cookoo/io   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/cookoo/io)\n\t\tgithub.com/Masterminds/glide/gb   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/gb)\n\t\tgithub.com/Masterminds/glide/util   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/util)\n\t\t\tgithub.com/Masterminds/vcs   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs)\n\t\tgithub.com/Masterminds/glide/yaml   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/yaml)\n\t\t\tgithub.com/Masterminds/glide/util   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/util)\n\t\t\t\tgithub.com/Masterminds/vcs   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs)\n\t\t\tgithub.com/Masterminds/vcs   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs)\n\t\t\tgopkg.in/yaml.v2   (/Users/mfarina/Code/go/src/gopkg.in/yaml.v2)\n\t\tgithub.com/Masterminds/semver   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/semver)\n\t\tgithub.com/Masterminds/vcs   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs)\n\t\tgithub.com/codegangsta/cli   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/codegangsta/cli)\n\tgithub.com/codegangsta/cli   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/codegangsta/cli)\n\tgithub.com/Masterminds/cookoo   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/cookoo)\n\t\tgithub.com/Masterminds/cookoo/io   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/cookoo/io)\n\tgithub.com/Masterminds/glide/gb   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/gb)\n\tgithub.com/Masterminds/glide/util   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/util)\n\t\tgithub.com/Masterminds/vcs   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs)\n\tgithub.com/Masterminds/glide/yaml   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/yaml)\n\t\tgithub.com/Masterminds/glide/util   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/util)\n\t\t\tgithub.com/Masterminds/vcs   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs)\n\t\tgithub.com/Masterminds/vcs   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs)\n\t\tgopkg.in/yaml.v2   (/Users/mfarina/Code/go/src/gopkg.in/yaml.v2)\n\tgithub.com/Masterminds/semver   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/semver)\n\tgithub.com/Masterminds/vcs   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/Masterminds/vcs)\n\tgithub.com/codegangsta/cli   (/Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/codegangsta/cli)\n```\n\nThis shows a tree of imports, excluding core libraries. Because\nvendoring makes it possible for the same package to live in multiple\nplaces, `glide tree` also prints the location of the package being\nimported.\n\n_This command is deprecated and will be removed in the near future._\n\n### glide list\n\nGlide's `list` command shows an alphabetized list of all the packages\nthat a project imports.\n\n```\n$ glide list\nINSTALLED packages:\n\tvendor/github.com/Masterminds/cookoo\n\tvendor/github.com/Masterminds/cookoo/fmt\n\tvendor/github.com/Masterminds/cookoo/io\n\tvendor/github.com/Masterminds/cookoo/web\n\tvendor/github.com/Masterminds/semver\n\tvendor/github.com/Masterminds/vcs\n\tvendor/github.com/codegangsta/cli\n\tvendor/gopkg.in/yaml.v2\n```\n\n### glide help\n\nPrint the glide help.\n\n```\n$ glide help\n```\n\n### glide --version\n\nPrint the version and exit.\n\n```\n$ glide --version\nglide version 0.12.0\n```\n\n### glide.yaml\n\nFor full details on the `glide.yaml` files see [the documentation](https://glide.sh/docs/glide.yaml).\n\nThe `glide.yaml` file does two critical things:\n\n1. It names the current package\n2. It declares external dependencies\n\nA brief `glide.yaml` file looks like this:\n\n```yaml\npackage: github.com/Masterminds/glide\nimport:\n  - package: github.com/Masterminds/semver\n  - package: github.com/Masterminds/cookoo\n    version: ^1.2.0\n    repo: git@github.com:Masterminds/cookoo.git\n```\n\nThe above tells `glide` that...\n\n1. This package is named `github.com/Masterminds/glide`\n2. That this package depends on two libraries.\n\nThe first library exemplifies a minimal package import. It merely gives\nthe fully qualified import path.\n\nWhen Glide reads the definition for the second library, it will get the repo\nfrom the source in `repo`, checkout the latest version between 1.2.0 and 2.0.0,\nand put it in `github.com/Masterminds/cookoo` in the `vendor` directory. (Note\nthat `package` and `repo` can be completely different)\n\n**TIP:** The version is either VCS dependent and can be anything that can be checked\nout or a semantic version constraint that can be parsed by the [`github.com/\nMasterminds/semver`](https://github.com/Masterminds/semver) package.\nFor example, with Git this can be a branch, tag, or hash. This varies and\ndepends on what's supported in the VCS.\n\n**TIP:** In general, you are advised to use the *base package name* for\nimporting a package, not a subpackage name. For example, use\n`github.com/kylelemons/go-gypsy` and not\n`github.com/kylelemons/go-gypsy/yaml`.\n\n## Supported Version Control Systems\n\nThe Git, SVN, Mercurial (Hg), and Bzr source control systems are supported. This\nhappens through the [vcs package](https://github.com/masterminds/vcs).\n\n## Frequently Asked Questions (F.A.Q.)\n\n#### Q: Why does Glide have the concept of sub-packages when Go doesn't?\n\nIn Go every directory is a package. This works well when you have one repo\ncontaining all of your packages. When you have different packages in different\nVCS locations things become a bit more complicated. A project containing a\ncollection of packages should be handled with the same information including\nthe version. By grouping packages this way we are able to manage the related\ninformation.\n\n#### Q: bzr (or hg) is not working the way I expected. Why?\n\nThese are works in progress, and may need some additional tuning. Please\ntake a look at the [vcs package](https://github.com/masterminds/vcs). If you\nsee a better way to handle it please let us know.\n\n#### Q: Should I check `vendor/` into version control?\n\nThat's up to you. It's not necessary, but it may also cause you extra\nwork and lots of extra space in your VCS. There may also be unforeseen errors\n([see an example](https://github.com/mattfarina/golang-broken-vendor)).\n\n#### Q: How do I import settings from GPM, Godep, gom or gb?\n\nThere are two parts to importing.\n\n1. If a package you import has configuration for GPM, Godep, gom or gb Glide will\n   recursively install the dependencies automatically.\n2. If you would like to import configuration from GPM, Godep, gom or gb to Glide see\n   the `glide import` command. For example, you can run `glide import godep` for\n   Glide to detect the projects Godep configuration and generate a `glide.yaml`\n   file for you.\n\nEach of these will merge your existing `glide.yaml` file with the\ndependencies it finds for those managers, and then emit the file as\noutput. **It will not overwrite your glide.yaml file.**\n\nYou can write it to file like this:\n\n```\n$ glide import godep -f glide.yaml\n```\n\n#### Q: Can Glide fetch a package based on OS or Arch?\n\nA: Yes. Using the `os` and `arch` fields on a `package`, you can specify\nwhich OSes and architectures the package should be fetched for. For\nexample, the following package will only be fetched for 64-bit\nDarwin/OSX systems:\n\n```yaml\n- package: some/package\n  os:\n    - darwin\n  arch:\n    - amd64\n```\n\nThe package will not be fetched for other architectures or OSes.\n\n## LICENSE\n\nThis package is made available under an MIT-style license. See\nLICENSE.txt.\n\n## Thanks!\n\nWe owe a huge debt of gratitude to the [GPM and\nGVP](https://github.com/pote/gpm) projects, which\ninspired many of the features of this package. If `glide` isn't the\nright Go project manager for you, check out those.\n\nThe Composer (PHP), npm (JavaScript), and Bundler (Ruby) projects all\ninspired various aspects of this tool, as well.\n\n## The Name\n\nAside from being catchy, \"glide\" is a contraction of \"Go Elide\". The\nidea is to compress the tasks that normally take us lots of time into a\njust a few seconds.\n"
  },
  {
    "path": "action/about.go",
    "content": "package action\n\nimport \"github.com/Masterminds/glide/msg\"\n\nconst aboutMessage = `\nGlide: Vendor Package Management for Go. Manage your vendor and vendored\npackages with ease.\n\nName:\n    Aside from being catchy, \"glide\" is a contraction of \"Go Elide\". The idea is\n    to compress the tasks that normally take us lots of time into a just a few\n    seconds.\n\nTo file issues, obtain the source, or learn more visit:\n    https://github.com/Masterminds/glide\n\nGlide is licensed under the MIT License:\n\n    Copyright (C) 2014-2015, Matt Butcher and Matt Farina\n    Copyright (C) 2015, Google\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy\n    of this software and associated documentation files (the \"Software\"), to deal\n    in the Software without restriction, including without limitation the rights\n    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n    copies of the Software, and to permit persons to whom the Software is\n    furnished to do so, subject to the following conditions:\n\n    The above copyright notice and this permission notice shall be included in\n    all copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n    THE SOFTWARE.`\n\n// About prints information about Glide.\nfunc About() {\n\tmsg.Puts(aboutMessage)\n}\n"
  },
  {
    "path": "action/about_test.go",
    "content": "package action\n\nimport (\n\t\"bytes\"\n\t\"testing\"\n\n\t\"github.com/Masterminds/glide/msg\"\n)\n\nfunc TestAbout(t *testing.T) {\n\tvar buf bytes.Buffer\n\told := msg.Default.Stdout\n\tmsg.Default.Stdout = &buf\n\tAbout()\n\n\tif buf.Len() < len(aboutMessage) {\n\t\tt.Errorf(\"expected this to match aboutMessage: %q\", buf.String())\n\t}\n\n\tmsg.Default.Stdout = old\n}\n"
  },
  {
    "path": "action/cache.go",
    "content": "package action\n\nimport (\n\t\"os\"\n\n\t\"github.com/Masterminds/glide/cache\"\n\t\"github.com/Masterminds/glide/msg\"\n)\n\n// CacheClear clears the Glide cache\nfunc CacheClear() {\n\tl := cache.Location()\n\n\terr := os.RemoveAll(l)\n\tif err != nil {\n\t\tmsg.Die(\"Unable to clear the cache: %s\", err)\n\t}\n\n\tcache.SetupReset()\n\tcache.Setup()\n\n\tmsg.Info(\"Glide cache has been cleared.\")\n}\n"
  },
  {
    "path": "action/config_wizard.go",
    "content": "package action\n\nimport (\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n\t\"regexp\"\n\t\"strings\"\n\n\t\"github.com/Masterminds/glide/cache\"\n\t\"github.com/Masterminds/glide/cfg\"\n\t\"github.com/Masterminds/glide/msg\"\n\tgpath \"github.com/Masterminds/glide/path\"\n\t\"github.com/Masterminds/semver\"\n\t\"github.com/Masterminds/vcs\"\n)\n\n// ConfigWizard reads configuration from a glide.yaml file and attempts to suggest\n// improvements. The wizard is interactive.\nfunc ConfigWizard(base string) {\n\tcache.SystemLock()\n\t_, err := gpath.Glide()\n\tglidefile := gpath.GlideFile\n\tif err != nil {\n\t\tmsg.Info(\"Unable to find a glide.yaml file. Would you like to create one now? Yes (Y) or No (N)\")\n\t\tbres := msg.PromptUntilYorN()\n\t\tif bres {\n\t\t\t// Guess deps\n\t\t\tconf := guessDeps(base, false)\n\t\t\t// Write YAML\n\t\t\tif err := conf.WriteFile(glidefile); err != nil {\n\t\t\t\tmsg.Die(\"Could not save %s: %s\", glidefile, err)\n\t\t\t}\n\t\t} else {\n\t\t\tmsg.Err(\"Unable to find configuration file. Please create configuration information to continue.\")\n\t\t}\n\t}\n\n\tconf := EnsureConfig()\n\n\tcache.Setup()\n\n\tmsg.Info(\"Looking for dependencies to make suggestions on\")\n\tmsg.Info(\"--> Scanning for dependencies not using version ranges\")\n\tmsg.Info(\"--> Scanning for dependencies using commit ids\")\n\tvar deps []*cfg.Dependency\n\tfor _, dep := range conf.Imports {\n\t\tif wizardLookInto(dep) {\n\t\t\tdeps = append(deps, dep)\n\t\t}\n\t}\n\tfor _, dep := range conf.DevImports {\n\t\tif wizardLookInto(dep) {\n\t\t\tdeps = append(deps, dep)\n\t\t}\n\t}\n\n\tmsg.Info(\"Gathering information on each dependency\")\n\tmsg.Info(\"--> This may take a moment. Especially on a codebase with many dependencies\")\n\tmsg.Info(\"--> Gathering release information for dependencies\")\n\tmsg.Info(\"--> Looking for dependency imports where versions are commit ids\")\n\tfor _, dep := range deps {\n\t\twizardFindVersions(dep)\n\t}\n\n\tvar changes int\n\tfor _, dep := range deps {\n\t\tremote := dep.Remote()\n\n\t\t// First check, ask if the tag should be used instead of the commit id for it.\n\t\tcur := cache.MemCurrent(remote)\n\t\tif cur != \"\" && cur != dep.Reference {\n\t\t\twizardSugOnce()\n\t\t\tvar dres bool\n\t\t\tasked, use, val := wizardOnce(\"current\")\n\t\t\tif !use {\n\t\t\t\tdres = wizardAskCurrent(cur, dep)\n\t\t\t}\n\t\t\tif !asked {\n\t\t\t\tas := wizardRemember()\n\t\t\t\twizardSetOnce(\"current\", as, dres)\n\t\t\t}\n\n\t\t\tif asked && use {\n\t\t\t\tdres = val.(bool)\n\t\t\t}\n\n\t\t\tif dres {\n\t\t\t\tmsg.Info(\"Updating %s to use the tag %s instead of commit id %s\", dep.Name, cur, dep.Reference)\n\t\t\t\tdep.Reference = cur\n\t\t\t\tchanges++\n\t\t\t}\n\t\t}\n\n\t\t// Second check, if no version is being used and there's a semver release ask about latest.\n\t\tmemlatest := cache.MemLatest(remote)\n\t\tif dep.Reference == \"\" && memlatest != \"\" {\n\t\t\twizardSugOnce()\n\t\t\tvar dres bool\n\t\t\tasked, use, val := wizardOnce(\"latest\")\n\t\t\tif !use {\n\t\t\t\tdres = wizardAskLatest(memlatest, dep)\n\t\t\t}\n\t\t\tif !asked {\n\t\t\t\tas := wizardRemember()\n\t\t\t\twizardSetOnce(\"latest\", as, dres)\n\t\t\t}\n\n\t\t\tif asked && use {\n\t\t\t\tdres = val.(bool)\n\t\t\t}\n\n\t\t\tif dres {\n\t\t\t\tmsg.Info(\"Updating %s to use the release %s instead of no release\", dep.Name, memlatest)\n\t\t\t\tdep.Reference = memlatest\n\t\t\t\tchanges++\n\t\t\t}\n\t\t}\n\n\t\t// Third check, if the version is semver offer to use a range instead.\n\t\tsv, err := semver.NewVersion(dep.Reference)\n\t\tif err == nil {\n\t\t\twizardSugOnce()\n\t\t\tvar res string\n\t\t\tasked, use, val := wizardOnce(\"range\")\n\t\t\tif !use {\n\t\t\t\tres = wizardAskRange(sv, dep)\n\t\t\t}\n\t\t\tif !asked {\n\t\t\t\tas := wizardRemember()\n\t\t\t\twizardSetOnce(\"range\", as, res)\n\t\t\t}\n\n\t\t\tif asked && use {\n\t\t\t\tres = val.(string)\n\t\t\t}\n\n\t\t\tif res == \"m\" {\n\t\t\t\tr := \"^\" + sv.String()\n\t\t\t\tmsg.Info(\"Updating %s to use the range %s instead of commit id %s\", dep.Name, r, dep.Reference)\n\t\t\t\tdep.Reference = r\n\t\t\t\tchanges++\n\t\t\t} else if res == \"p\" {\n\t\t\t\tr := \"~\" + sv.String()\n\t\t\t\tmsg.Info(\"Updating %s to use the range %s instead of commit id %s\", dep.Name, r, dep.Reference)\n\t\t\t\tdep.Reference = r\n\t\t\t\tchanges++\n\t\t\t}\n\t\t}\n\t}\n\n\tif changes > 0 {\n\t\tmsg.Info(\"Configuration changes have been made. Would you like to write these\")\n\t\tmsg.Info(\"changes to your configuration file? Yes (Y) or No (N)\")\n\t\tdres := msg.PromptUntilYorN()\n\t\tif dres {\n\t\t\tmsg.Info(\"Writing updates to configuration file (%s)\", glidefile)\n\t\t\tif err := conf.WriteFile(glidefile); err != nil {\n\t\t\t\tmsg.Die(\"Could not save %s: %s\", glidefile, err)\n\t\t\t}\n\t\t\tmsg.Info(\"You can now edit the glide.yaml file.:\")\n\t\t\tmsg.Info(\"--> For more information on versions and ranges see https://glide.sh/docs/versions/\")\n\t\t\tmsg.Info(\"--> For details on additional metadata see https://glide.sh/docs/glide.yaml/\")\n\t\t} else {\n\t\t\tmsg.Warn(\"Change not written to configuration file\")\n\t\t}\n\t} else {\n\t\tmsg.Info(\"No proposed changes found. Have a nice day.\")\n\t}\n}\n\nvar wizardOnceVal = make(map[string]interface{})\nvar wizardOnceDo = make(map[string]bool)\nvar wizardOnceAsked = make(map[string]bool)\n\nvar wizardSuggeseOnce bool\n\nfunc wizardSugOnce() {\n\tif !wizardSuggeseOnce {\n\t\tmsg.Info(\"Here are some suggestions...\")\n\t}\n\twizardSuggeseOnce = true\n}\n\n// Returns if it's you should prompt, if not prompt if you should use stored value,\n// and stored value if it has one.\nfunc wizardOnce(name string) (bool, bool, interface{}) {\n\treturn wizardOnceAsked[name], wizardOnceDo[name], wizardOnceVal[name]\n}\n\nfunc wizardSetOnce(name string, prompt bool, val interface{}) {\n\twizardOnceAsked[name] = true\n\twizardOnceDo[name] = prompt\n\twizardOnceVal[name] = val\n}\n\nfunc wizardRemember() bool {\n\tmsg.Info(\"Would you like to remember the previous decision and apply it to future\")\n\tmsg.Info(\"dependencies? Yes (Y) or No (N)\")\n\treturn msg.PromptUntilYorN()\n}\n\nfunc wizardAskRange(ver *semver.Version, d *cfg.Dependency) string {\n\tvstr := ver.String()\n\tmsg.Info(\"The package %s appears to use semantic versions (http://semver.org).\", d.Name)\n\tmsg.Info(\"Would you like to track the latest minor or patch releases (major.minor.patch)?\")\n\tmsg.Info(\"The choices are:\")\n\tmsg.Info(\" - Tracking minor version releases would use '>= %s, < %d.0.0' ('^%s')\", vstr, ver.Major()+1, vstr)\n\tmsg.Info(\" - Tracking patch version releases would use '>= %s, < %d.%d.0' ('~%s')\", vstr, ver.Major(), ver.Minor()+1, vstr)\n\tmsg.Info(\" - Skip using ranges\\n\")\n\tmsg.Info(\"For more information on Glide versions and ranges see https://glide.sh/docs/versions\")\n\tmsg.Info(\"Minor (M), Patch (P), or Skip Ranges (S)?\")\n\n\tres, err := msg.PromptUntil([]string{\"minor\", \"m\", \"patch\", \"p\", \"skip ranges\", \"s\"})\n\tif err != nil {\n\t\tmsg.Die(\"Error processing response: %s\", err)\n\t}\n\tif res == \"m\" || res == \"minor\" {\n\t\treturn \"m\"\n\t} else if res == \"p\" || res == \"patch\" {\n\t\treturn \"p\"\n\t}\n\n\treturn \"s\"\n}\n\nfunc wizardAskCurrent(cur string, d *cfg.Dependency) bool {\n\tmsg.Info(\"The package %s is currently set to use the version %s.\", d.Name, d.Reference)\n\tmsg.Info(\"There is an equivalent semantic version (http://semver.org) release of %s. Would\", cur)\n\tmsg.Info(\"you like to use that instead? Yes (Y) or No (N)\")\n\treturn msg.PromptUntilYorN()\n}\n\nfunc wizardAskLatest(latest string, d *cfg.Dependency) bool {\n\tmsg.Info(\"The package %s appears to have Semantic Version releases (http://semver.org). \", d.Name)\n\tmsg.Info(\"The latest release is %s. You are currently not using a release. Would you like\", latest)\n\tmsg.Info(\"to use this release? Yes (Y) or No (N)\")\n\treturn msg.PromptUntilYorN()\n}\n\nfunc wizardLookInto(d *cfg.Dependency) bool {\n\t_, err := semver.NewConstraint(d.Reference)\n\n\t// The existing version is already a valid semver constraint so we skip suggestions.\n\tif err == nil {\n\t\treturn false\n\t}\n\n\treturn true\n}\n\n// Note, this really needs a simpler name.\nvar createGitParseVersion = regexp.MustCompile(`(?m-s)(?:tags)/(\\S+)$`)\n\nfunc wizardFindVersions(d *cfg.Dependency) {\n\tl := cache.Location()\n\tremote := d.Remote()\n\n\tkey, err := cache.Key(remote)\n\tif err != nil {\n\t\tmsg.Debug(\"Problem generating cache key for %s: %s\", remote, err)\n\t\treturn\n\t}\n\n\tlocal := filepath.Join(l, \"src\", key)\n\trepo, err := vcs.NewRepo(remote, local)\n\tif err != nil {\n\t\tmsg.Debug(\"Problem getting repo instance: %s\", err)\n\t\treturn\n\t}\n\n\tvar useLocal bool\n\tif _, err = os.Stat(local); err == nil {\n\t\tuseLocal = true\n\t}\n\n\t// Git endpoints allow for querying without fetching the codebase locally.\n\t// We try that first to avoid fetching right away. Is this premature\n\t// optimization?\n\tcc := true\n\tif !useLocal && repo.Vcs() == vcs.Git {\n\t\tout, err2 := exec.Command(\"git\", \"ls-remote\", remote).CombinedOutput()\n\t\tif err2 == nil {\n\t\t\tcache.MemTouch(remote)\n\t\t\tcc = false\n\t\t\tlines := strings.Split(string(out), \"\\n\")\n\t\t\tfor _, i := range lines {\n\t\t\t\tti := strings.TrimSpace(i)\n\t\t\t\tif found := createGitParseVersion.FindString(ti); found != \"\" {\n\t\t\t\t\ttg := strings.TrimPrefix(strings.TrimSuffix(found, \"^{}\"), \"tags/\")\n\t\t\t\t\tcache.MemPut(remote, tg)\n\t\t\t\t\tif d.Reference != \"\" && strings.HasPrefix(ti, d.Reference) {\n\t\t\t\t\t\tcache.MemSetCurrent(remote, tg)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif cc {\n\t\tcache.Lock(key)\n\t\tcache.MemTouch(remote)\n\t\tif _, err = os.Stat(local); os.IsNotExist(err) {\n\t\t\trepo.Get()\n\t\t\tbranch := findCurrentBranch(repo)\n\t\t\tc := cache.RepoInfo{DefaultBranch: branch}\n\t\t\terr = cache.SaveRepoData(key, c)\n\t\t\tif err != nil {\n\t\t\t\tmsg.Debug(\"Error saving cache repo details: %s\", err)\n\t\t\t}\n\t\t} else {\n\t\t\trepo.Update()\n\t\t}\n\t\ttgs, err := repo.Tags()\n\t\tif err != nil {\n\t\t\tmsg.Debug(\"Problem getting tags: %s\", err)\n\t\t} else {\n\t\t\tfor _, v := range tgs {\n\t\t\t\tcache.MemPut(remote, v)\n\t\t\t}\n\t\t}\n\t\tif d.Reference != \"\" && repo.IsReference(d.Reference) {\n\t\t\ttgs, err = repo.TagsFromCommit(d.Reference)\n\t\t\tif err != nil {\n\t\t\t\tmsg.Debug(\"Problem getting tags for commit: %s\", err)\n\t\t\t} else {\n\t\t\t\tif len(tgs) > 0 {\n\t\t\t\t\tfor _, v := range tgs {\n\t\t\t\t\t\tif !(repo.Vcs() == vcs.Hg && v == \"tip\") {\n\t\t\t\t\t\t\tcache.MemSetCurrent(remote, v)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcache.Unlock(key)\n\t}\n}\n\nfunc findCurrentBranch(repo vcs.Repo) string {\n\tmsg.Debug(\"Attempting to find current branch for %s\", repo.Remote())\n\t// Svn and Bzr don't have default branches.\n\tif repo.Vcs() == vcs.Svn || repo.Vcs() == vcs.Bzr {\n\t\treturn \"\"\n\t}\n\n\tif repo.Vcs() == vcs.Git || repo.Vcs() == vcs.Hg {\n\t\tver, err := repo.Current()\n\t\tif err != nil {\n\t\t\tmsg.Debug(\"Unable to find current branch for %s, error: %s\", repo.Remote(), err)\n\t\t\treturn \"\"\n\t\t}\n\t\treturn ver\n\t}\n\n\treturn \"\"\n}\n"
  },
  {
    "path": "action/create.go",
    "content": "package action\n\nimport (\n\t\"os\"\n\t\"path/filepath\"\n\t\"sort\"\n\t\"strings\"\n\n\t\"github.com/Masterminds/glide/cfg\"\n\t\"github.com/Masterminds/glide/dependency\"\n\t\"github.com/Masterminds/glide/gb\"\n\t\"github.com/Masterminds/glide/godep\"\n\t\"github.com/Masterminds/glide/gpm\"\n\t\"github.com/Masterminds/glide/msg\"\n\tgpath \"github.com/Masterminds/glide/path\"\n\t\"github.com/Masterminds/glide/util\"\n)\n\n// Create creates/initializes a new Glide repository.\n//\n// This will fail if a glide.yaml already exists.\n//\n// By default, this will scan the present source code directory for dependencies.\n//\n// If skipImport is set to true, this will not attempt to import from an existing\n// GPM, Godep, or GB project if one should exist. However, it will still attempt\n// to read the local source to determine required packages.\nfunc Create(base string, skipImport, nonInteractive bool) {\n\tglidefile := gpath.GlideFile\n\t// Guard against overwrites.\n\tguardYAML(glidefile)\n\n\t// Guess deps\n\tconf := guessDeps(base, skipImport)\n\t// Write YAML\n\tmsg.Info(\"Writing configuration file (%s)\", glidefile)\n\tif err := conf.WriteFile(glidefile); err != nil {\n\t\tmsg.Die(\"Could not save %s: %s\", glidefile, err)\n\t}\n\n\tvar res bool\n\tif !nonInteractive {\n\t\tmsg.Info(\"Would you like Glide to help you find ways to improve your glide.yaml configuration?\")\n\t\tmsg.Info(\"If you want to revisit this step you can use the config-wizard command at any time.\")\n\t\tmsg.Info(\"Yes (Y) or No (N)?\")\n\t\tres = msg.PromptUntilYorN()\n\t\tif res {\n\t\t\tConfigWizard(base)\n\t\t}\n\t}\n\n\tif !res {\n\t\tmsg.Info(\"You can now edit the glide.yaml file. Consider:\")\n\t\tmsg.Info(\"--> Using versions and ranges. See https://glide.sh/docs/versions/\")\n\t\tmsg.Info(\"--> Adding additional metadata. See https://glide.sh/docs/glide.yaml/\")\n\t\tmsg.Info(\"--> Running the config-wizard command to improve the versions in your configuration\")\n\t}\n}\n\n// guardYAML fails if the given file already exists.\n//\n// This prevents an important file from being overwritten.\nfunc guardYAML(filename string) {\n\tif _, err := os.Stat(filename); err == nil {\n\t\tmsg.Die(\"Cowardly refusing to overwrite existing YAML.\")\n\t}\n}\n\n// guessDeps attempts to resolve all of the dependencies for a given project.\n//\n// base is the directory to start with.\n// skipImport will skip running the automatic imports.\n//\n// FIXME: This function is likely a one-off that has a more standard alternative.\n// It's also long and could use a refactor.\nfunc guessDeps(base string, skipImport bool) *cfg.Config {\n\tbuildContext, err := util.GetBuildContext()\n\tif err != nil {\n\t\tmsg.Die(\"Failed to build an import context: %s\", err)\n\t}\n\tname := buildContext.PackageName(base)\n\n\tmsg.Info(\"Generating a YAML configuration file and guessing the dependencies\")\n\n\tconfig := new(cfg.Config)\n\n\t// Get the name of the top level package\n\tconfig.Name = name\n\n\t// Import by looking at other package managers and looking over the\n\t// entire directory structure.\n\n\t// Attempt to import from other package managers.\n\tif !skipImport {\n\t\tguessImportDeps(base, config)\n\t}\n\n\timportLen := len(config.Imports)\n\tif importLen == 0 {\n\t\tmsg.Info(\"Scanning code to look for dependencies\")\n\t} else {\n\t\tmsg.Info(\"Scanning code to look for dependencies not found in import\")\n\t}\n\n\t// Resolve dependencies by looking at the tree.\n\tr, err := dependency.NewResolver(base)\n\tif err != nil {\n\t\tmsg.Die(\"Error creating a dependency resolver: %s\", err)\n\t}\n\n\t// When creating resolve the test dependencies as well as the application ones.\n\tr.ResolveTest = true\n\n\th := &dependency.DefaultMissingPackageHandler{Missing: []string{}, Gopath: []string{}}\n\tr.Handler = h\n\n\tsortable, testSortable, err := r.ResolveLocal(false)\n\tif err != nil {\n\t\tmsg.Die(\"Error resolving local dependencies: %s\", err)\n\t}\n\n\tsort.Strings(sortable)\n\tsort.Strings(testSortable)\n\n\tvpath := r.VendorDir\n\tif !strings.HasSuffix(vpath, \"/\") {\n\t\tvpath = vpath + string(os.PathSeparator)\n\t}\n\n\tfor _, pa := range sortable {\n\t\tn := strings.TrimPrefix(pa, vpath)\n\t\troot, subpkg := util.NormalizeName(n)\n\n\t\tif !config.Imports.Has(root) && root != config.Name {\n\t\t\tmsg.Info(\"--> Found reference to %s\\n\", n)\n\t\t\td := &cfg.Dependency{\n\t\t\t\tName: root,\n\t\t\t}\n\t\t\tif len(subpkg) > 0 {\n\t\t\t\td.Subpackages = []string{subpkg}\n\t\t\t}\n\t\t\tconfig.Imports = append(config.Imports, d)\n\t\t} else if config.Imports.Has(root) {\n\t\t\tif len(subpkg) > 0 {\n\t\t\t\tsubpkg = strings.TrimPrefix(subpkg, \"/\")\n\t\t\t\td := config.Imports.Get(root)\n\t\t\t\tif !d.HasSubpackage(subpkg) {\n\t\t\t\t\tmsg.Info(\"--> Adding sub-package %s to %s\\n\", subpkg, root)\n\t\t\t\t\td.Subpackages = append(d.Subpackages, subpkg)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfor _, pa := range testSortable {\n\t\tn := strings.TrimPrefix(pa, vpath)\n\t\troot, subpkg := util.NormalizeName(n)\n\n\t\tif config.Imports.Has(root) && root != config.Name {\n\t\t\tmsg.Debug(\"--> Found test reference to %s already listed as an import\", n)\n\t\t} else if !config.DevImports.Has(root) && root != config.Name {\n\t\t\tmsg.Info(\"--> Found test reference to %s\", n)\n\t\t\td := &cfg.Dependency{\n\t\t\t\tName: root,\n\t\t\t}\n\t\t\tif len(subpkg) > 0 {\n\t\t\t\td.Subpackages = []string{subpkg}\n\t\t\t}\n\t\t\tconfig.DevImports = append(config.DevImports, d)\n\t\t} else if config.DevImports.Has(root) {\n\t\t\tif len(subpkg) > 0 {\n\t\t\t\tsubpkg = strings.TrimPrefix(subpkg, \"/\")\n\t\t\t\td := config.DevImports.Get(root)\n\t\t\t\tif !d.HasSubpackage(subpkg) {\n\t\t\t\t\tmsg.Info(\"--> Adding test sub-package %s to %s\\n\", subpkg, root)\n\t\t\t\t\td.Subpackages = append(d.Subpackages, subpkg)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(config.Imports) == importLen && importLen != 0 {\n\t\tmsg.Info(\"--> Code scanning found no additional imports\")\n\t}\n\n\treturn config\n}\n\nfunc guessImportDeps(base string, config *cfg.Config) {\n\tmsg.Info(\"Attempting to import from other package managers (use --skip-import to skip)\")\n\tdeps := []*cfg.Dependency{}\n\tabsBase, err := filepath.Abs(base)\n\tif err != nil {\n\t\tmsg.Die(\"Failed to resolve location of %s: %s\", base, err)\n\t}\n\n\tif d, ok := guessImportGodep(absBase); ok {\n\t\tmsg.Info(\"Importing Godep configuration\")\n\t\tmsg.Warn(\"Godep uses commit id versions. Consider using Semantic Versions with Glide\")\n\t\tdeps = d\n\t} else if d, ok := guessImportGPM(absBase); ok {\n\t\tmsg.Info(\"Importing GPM configuration\")\n\t\tdeps = d\n\t} else if d, ok := guessImportGB(absBase); ok {\n\t\tmsg.Info(\"Importing GB configuration\")\n\t\tdeps = d\n\t}\n\n\tfor _, i := range deps {\n\t\tif i.Reference == \"\" {\n\t\t\tmsg.Info(\"--> Found imported reference to %s\", i.Name)\n\t\t} else {\n\t\t\tmsg.Info(\"--> Found imported reference to %s at revision %s\", i.Name, i.Reference)\n\t\t}\n\n\t\tconfig.Imports = append(config.Imports, i)\n\t}\n}\n\nfunc guessImportGodep(dir string) ([]*cfg.Dependency, bool) {\n\td, err := godep.Parse(dir)\n\tif err != nil || len(d) == 0 {\n\t\treturn []*cfg.Dependency{}, false\n\t}\n\n\treturn d, true\n}\n\nfunc guessImportGPM(dir string) ([]*cfg.Dependency, bool) {\n\td, err := gpm.Parse(dir)\n\tif err != nil || len(d) == 0 {\n\t\treturn []*cfg.Dependency{}, false\n\t}\n\n\treturn d, true\n}\n\nfunc guessImportGB(dir string) ([]*cfg.Dependency, bool) {\n\td, err := gb.Parse(dir)\n\tif err != nil || len(d) == 0 {\n\t\treturn []*cfg.Dependency{}, false\n\t}\n\n\treturn d, true\n}\n"
  },
  {
    "path": "action/debug.go",
    "content": "package action\n\nimport (\n\t\"github.com/Masterminds/glide/msg\"\n)\n\n// Debug sets the debugging flags across components.\nfunc Debug(on bool) {\n\tmsg.Default.IsDebugging = on\n}\n\n// Quiet sets the quiet flags across components.\nfunc Quiet(on bool) {\n\tmsg.Default.Quiet = on\n}\n\n// NoColor sets the color flags.\nfunc NoColor(on bool) {\n\tmsg.Default.NoColor = on\n}\n"
  },
  {
    "path": "action/doc.go",
    "content": "// Package action provides implementations for every Glide command.\n//\n// This is not a general-purpose library. It is the main flow controller for Glide.\n//\n// The main glide package acts as a Facade, with this package providing the\n// implementation. This package should know nothing of the command line flags or\n// runtime characteristics. However, this package is allowed to control the flow\n// of the application, including termination. So actions may call `msg.Die()` to\n// immediately stop execution of the program.\n//\n// In general, actions are not required to function as library functions, nor as\n// concurrency-safe functions.\npackage action\n"
  },
  {
    "path": "action/ensure.go",
    "content": "package action\n\nimport (\n\t\"io/ioutil\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/Masterminds/glide/cfg\"\n\t\"github.com/Masterminds/glide/mirrors\"\n\t\"github.com/Masterminds/glide/msg\"\n\tgpath \"github.com/Masterminds/glide/path\"\n\t\"github.com/Masterminds/glide/util\"\n)\n\n// EnsureConfig loads and returns a config file.\n//\n// Any error will cause an immediate exit, with an error printed to Stderr.\nfunc EnsureConfig() *cfg.Config {\n\tyamlpath, err := gpath.Glide()\n\tif err != nil {\n\t\tmsg.ExitCode(2)\n\t\tmsg.Die(\"Failed to find %s file in directory tree: %s\", gpath.GlideFile, err)\n\t}\n\n\tyml, err := ioutil.ReadFile(yamlpath)\n\tif err != nil {\n\t\tmsg.ExitCode(2)\n\t\tmsg.Die(\"Failed to load %s: %s\", yamlpath, err)\n\t}\n\tconf, err := cfg.ConfigFromYaml(yml)\n\tif err != nil {\n\t\tmsg.ExitCode(3)\n\t\tmsg.Die(\"Failed to parse %s: %s\", yamlpath, err)\n\t}\n\n\tb := filepath.Dir(yamlpath)\n\tbuildContext, err := util.GetBuildContext()\n\tif err != nil {\n\t\tmsg.Die(\"Failed to build an import context while ensuring config: %s\", err)\n\t}\n\tcwd, err := os.Getwd()\n\tif err != nil {\n\t\tmsg.Err(\"Unable to get the current working directory\")\n\t} else {\n\t\t// Determining a package name requires a relative path\n\t\tb, err = filepath.Rel(b, cwd)\n\t\tif err == nil {\n\t\t\tname := buildContext.PackageName(b)\n\t\t\tif name != conf.Name {\n\t\t\t\tmsg.Warn(\"The name listed in the config file (%s) does not match the current location (%s)\", conf.Name, name)\n\t\t\t}\n\t\t} else {\n\t\t\tmsg.Warn(\"Problem finding the config file path (%s) relative to the current directory (%s): %s\", b, cwd, err)\n\t\t}\n\t}\n\n\terr = mirrors.Load()\n\tif err != nil {\n\t\tmsg.Err(\"Unable to load mirrors: %s\", err)\n\t}\n\n\treturn conf\n}\n\n// EnsureGoVendor ensures that the Go version is correct.\nfunc EnsureGoVendor() {\n\t// 6l was removed in 1.5, when vendoring was introduced.\n\tcmd := exec.Command(goExecutable(), \"tool\", \"6l\")\n\tif _, err := cmd.CombinedOutput(); err == nil {\n\t\tmsg.Warn(\"You must install the Go 1.5 or greater toolchain to work with Glide.\\n\")\n\t\tos.Exit(1)\n\t}\n\n\t// Check if this is go15, which requires GO15VENDOREXPERIMENT\n\t// Any release after go15 does not require that env var.\n\tcmd = exec.Command(goExecutable(), \"version\")\n\tif out, err := cmd.CombinedOutput(); err != nil {\n\t\tmsg.Err(\"Error getting version: %s.\\n\", err)\n\t\tos.Exit(1)\n\t} else if strings.HasPrefix(string(out), \"go version 1.5\") {\n\t\t// This works with 1.5 and 1.6.\n\t\tcmd = exec.Command(goExecutable(), \"env\", \"GO15VENDOREXPERIMENT\")\n\t\tif out, err := cmd.CombinedOutput(); err != nil {\n\t\t\tmsg.Err(\"Error looking for $GOVENDOREXPERIMENT: %s.\\n\", err)\n\t\t\tos.Exit(1)\n\t\t} else if strings.TrimSpace(string(out)) != \"1\" {\n\t\t\tmsg.Err(\"To use Glide, you must set GO15VENDOREXPERIMENT=1\")\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n\n\t// In the case where vendoring is explicitly disabled, balk.\n\tif os.Getenv(\"GO15VENDOREXPERIMENT\") == \"0\" {\n\t\tmsg.Err(\"To use Glide, you must set GO15VENDOREXPERIMENT=1\")\n\t\tos.Exit(1)\n\t}\n\n\t// Verify the setup isn't for the old version of glide. That is, this is\n\t// no longer assuming the _vendor directory as the GOPATH. Inform of\n\t// the change.\n\tif _, err := os.Stat(\"_vendor/\"); err == nil {\n\t\tmsg.Warn(`Your setup appears to be for the previous version of Glide.\nPreviously, vendor packages were stored in _vendor/src/ and\n_vendor was set as your GOPATH. As of Go 1.5 the go tools\nrecognize the vendor directory as a location for these\nfiles. Glide has embraced this. Please remove the _vendor\ndirectory or move the _vendor/src/ directory to vendor/.` + \"\\n\")\n\t\tos.Exit(1)\n\t}\n}\n\n// EnsureVendorDir ensures that a vendor/ directory is present in the cwd.\nfunc EnsureVendorDir() {\n\tfi, err := os.Stat(gpath.VendorDir)\n\tif err != nil {\n\t\tmsg.Debug(\"Creating %s\", gpath.VendorDir)\n\t\tif err := os.MkdirAll(gpath.VendorDir, os.ModeDir|0755); err != nil {\n\t\t\tmsg.Die(\"Could not create %s: %s\", gpath.VendorDir, err)\n\t\t}\n\t} else if !fi.IsDir() {\n\t\tmsg.Die(\"Vendor is not a directory\")\n\t}\n}\n\n// EnsureGopath fails if GOPATH is not set, or if $GOPATH/src is missing.\n//\n// Otherwise it returns the value of GOPATH.\nfunc EnsureGopath() string {\n\tgps := gpath.Gopaths()\n\tif len(gps) == 0 {\n\t\tmsg.Die(\"$GOPATH is not set.\")\n\t}\n\n\tfor _, gp := range gps {\n\t\t_, err := os.Stat(path.Join(gp, \"src\"))\n\t\tif err != nil {\n\t\t\tmsg.Warn(\"%s\", err)\n\t\t\tcontinue\n\t\t}\n\t\treturn gp\n\t}\n\n\tmsg.Err(\"Could not find any of %s/src.\\n\", strings.Join(gps, \"/src, \"))\n\tmsg.Info(\"As of Glide 0.5/Go 1.5, this is required.\\n\")\n\tmsg.Die(\"Without src, cannot continue.\")\n\treturn \"\"\n}\n\n// goExecutable checks for a set environment variable of GLIDE_GO_EXECUTABLE\n// for the go executable name. The Google App Engine SDK ships with a python\n// wrapper called goapp\n//\n// Example usage: GLIDE_GO_EXECUTABLE=goapp glide install\nfunc goExecutable() string {\n\tgoExecutable := os.Getenv(\"GLIDE_GO_EXECUTABLE\")\n\tif len(goExecutable) <= 0 {\n\t\tgoExecutable = \"go\"\n\t}\n\n\treturn goExecutable\n}\n"
  },
  {
    "path": "action/get.go",
    "content": "package action\n\nimport (\n\t\"fmt\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/Masterminds/glide/cache\"\n\t\"github.com/Masterminds/glide/cfg\"\n\t\"github.com/Masterminds/glide/godep\"\n\t\"github.com/Masterminds/glide/msg\"\n\tgpath \"github.com/Masterminds/glide/path\"\n\t\"github.com/Masterminds/glide/repo\"\n\t\"github.com/Masterminds/glide/util\"\n\t\"github.com/Masterminds/semver\"\n)\n\n// Get fetches one or more dependencies and installs.\n//\n// This includes resolving dependency resolution and re-generating the lock file.\nfunc Get(names []string, installer *repo.Installer, insecure, skipRecursive, stripVendor, nonInteract, testDeps bool) {\n\tcache.SystemLock()\n\n\tbase := gpath.Basepath()\n\tEnsureGopath()\n\tEnsureVendorDir()\n\tconf := EnsureConfig()\n\tglidefile, err := gpath.Glide()\n\tif err != nil {\n\t\tmsg.Die(\"Could not find Glide file: %s\", err)\n\t}\n\n\t// Add the packages to the config.\n\tif count, err2 := addPkgsToConfig(conf, names, insecure, nonInteract, testDeps); err2 != nil {\n\t\tmsg.Die(\"Failed to get new packages: %s\", err2)\n\t} else if count == 0 {\n\t\tmsg.Warn(\"Nothing to do\")\n\t\treturn\n\t}\n\n\t// Fetch the new packages. Can't resolve versions via installer.Update if\n\t// get is called while the vendor/ directory is empty so we checkout\n\t// everything.\n\terr = installer.Checkout(conf)\n\tif err != nil {\n\t\tmsg.Die(\"Failed to checkout packages: %s\", err)\n\t}\n\n\t// Prior to resolving dependencies we need to start working with a clone\n\t// of the conf because we'll be making real changes to it.\n\tconfcopy := conf.Clone()\n\n\tif !skipRecursive {\n\t\t// Get all repos and update them.\n\t\t// TODO: Can we streamline this in any way? The reason that we update all\n\t\t// of the dependencies is that we need to re-negotiate versions. For example,\n\t\t// if an existing dependency has the constraint >1.0 and this new package\n\t\t// adds the constraint <2.0, then this may re-resolve the existing dependency\n\t\t// to be between 1.0 and 2.0. But changing that dependency may then result\n\t\t// in that dependency's dependencies changing... so we sorta do the whole\n\t\t// thing to be safe.\n\t\terr = installer.Update(confcopy)\n\t\tif err != nil {\n\t\t\tmsg.Die(\"Could not update packages: %s\", err)\n\t\t}\n\t}\n\n\t// Set Reference\n\tif err := repo.SetReference(confcopy, installer.ResolveTest); err != nil {\n\t\tmsg.Err(\"Failed to set references: %s\", err)\n\t}\n\n\terr = installer.Export(confcopy)\n\tif err != nil {\n\t\tmsg.Die(\"Unable to export dependencies to vendor directory: %s\", err)\n\t}\n\n\t// Write YAML\n\tif err := conf.WriteFile(glidefile); err != nil {\n\t\tmsg.Die(\"Failed to write glide YAML file: %s\", err)\n\t}\n\tif !skipRecursive {\n\t\t// Write lock\n\t\tif stripVendor {\n\t\t\tconfcopy = godep.RemoveGodepSubpackages(confcopy)\n\t\t}\n\t\twriteLock(conf, confcopy, base)\n\t} else {\n\t\tmsg.Warn(\"Skipping lockfile generation because full dependency tree is not being calculated\")\n\t}\n\n\tif stripVendor {\n\t\tmsg.Info(\"Removing nested vendor and Godeps/_workspace directories...\")\n\t\terr := gpath.StripVendor()\n\t\tif err != nil {\n\t\t\tmsg.Err(\"Unable to strip vendor directories: %s\", err)\n\t\t}\n\t}\n}\n\nfunc writeLock(conf, confcopy *cfg.Config, base string) {\n\thash, err := conf.Hash()\n\tif err != nil {\n\t\tmsg.Die(\"Failed to generate config hash. Unable to generate lock file.\")\n\t}\n\tlock, err := cfg.NewLockfile(confcopy.Imports, confcopy.DevImports, hash)\n\tif err != nil {\n\t\tmsg.Die(\"Failed to generate lock file: %s\", err)\n\t}\n\tif err := lock.WriteFile(filepath.Join(base, gpath.LockFile)); err != nil {\n\t\tmsg.Die(\"Failed to write glide lock file: %s\", err)\n\t}\n}\n\n// addPkgsToConfig adds the given packages to the config file.\n//\n// Along the way it:\n// - ensures that this package is not in the ignore list\n// - checks to see if this is already in the dependency list.\n// - splits version of of package name and adds the version attribute\n// - separates repo from packages\n// - sets up insecure repo URLs where necessary\n// - generates a list of subpackages\nfunc addPkgsToConfig(conf *cfg.Config, names []string, insecure, nonInteract, testDeps bool) (int, error) {\n\n\tif len(names) == 1 {\n\t\tmsg.Info(\"Preparing to install %d package.\", len(names))\n\t} else {\n\t\tmsg.Info(\"Preparing to install %d packages.\", len(names))\n\t}\n\tnumAdded := 0\n\tfor _, name := range names {\n\t\tvar version string\n\t\tparts := strings.Split(name, \"#\")\n\t\tif len(parts) > 1 {\n\t\t\tname = parts[0]\n\t\t\tversion = parts[1]\n\t\t}\n\n\t\tmsg.Info(\"Attempting to get package %s\", name)\n\n\t\troot, subpkg := util.NormalizeName(name)\n\t\tif len(root) == 0 {\n\t\t\treturn 0, fmt.Errorf(\"Package name is required for %q.\", name)\n\t\t}\n\n\t\tif conf.HasDependency(root) {\n\n\t\t\tvar moved bool\n\t\t\tvar dep *cfg.Dependency\n\t\t\t// Move from DevImports to Imports\n\t\t\tif !testDeps && !conf.Imports.Has(root) && conf.DevImports.Has(root) {\n\t\t\t\tdep = conf.DevImports.Get(root)\n\t\t\t\tconf.Imports = append(conf.Imports, dep)\n\t\t\t\tconf.DevImports = conf.DevImports.Remove(root)\n\t\t\t\tmoved = true\n\t\t\t\tnumAdded++\n\t\t\t\tmsg.Info(\"--> Moving %s from testImport to import\", root)\n\t\t\t} else if testDeps && conf.Imports.Has(root) {\n\t\t\t\tmsg.Warn(\"--> Test dependency %s already listed as import\", root)\n\t\t\t}\n\n\t\t\t// Check if the subpackage is present.\n\t\t\tif subpkg != \"\" {\n\t\t\t\tif dep == nil {\n\t\t\t\t\tdep = conf.Imports.Get(root)\n\t\t\t\t\tif dep == nil && testDeps {\n\t\t\t\t\t\tdep = conf.DevImports.Get(root)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif dep.HasSubpackage(subpkg) {\n\t\t\t\t\tif !moved {\n\t\t\t\t\t\tmsg.Warn(\"--> Package %q is already in glide.yaml. Skipping\", name)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tdep.Subpackages = append(dep.Subpackages, subpkg)\n\t\t\t\t\tmsg.Info(\"--> Adding sub-package %s to existing import %s\", subpkg, root)\n\t\t\t\t\tnumAdded++\n\t\t\t\t}\n\t\t\t} else if !moved {\n\t\t\t\tmsg.Warn(\"--> Package %q is already in glide.yaml. Skipping\", root)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tif conf.HasIgnore(root) {\n\t\t\tmsg.Warn(\"--> Package %q is set to be ignored in glide.yaml. Skipping\", root)\n\t\t\tcontinue\n\t\t}\n\n\t\tdep := &cfg.Dependency{\n\t\t\tName: root,\n\t\t}\n\n\t\t// When retriving from an insecure location set the repo to the\n\t\t// insecure location.\n\t\tif insecure {\n\t\t\tdep.Repository = \"http://\" + root\n\t\t}\n\n\t\tif version != \"\" {\n\t\t\tdep.Reference = version\n\t\t} else if !nonInteract {\n\t\t\tgetWizard(dep)\n\t\t}\n\n\t\tif len(subpkg) > 0 {\n\t\t\tdep.Subpackages = []string{subpkg}\n\t\t}\n\n\t\tif dep.Reference != \"\" {\n\t\t\tmsg.Info(\"--> Adding %s to your configuration with the version %s\", dep.Name, dep.Reference)\n\t\t} else {\n\t\t\tmsg.Info(\"--> Adding %s to your configuration\", dep.Name)\n\t\t}\n\n\t\tif testDeps {\n\t\t\tconf.DevImports = append(conf.DevImports, dep)\n\t\t} else {\n\t\t\tconf.Imports = append(conf.Imports, dep)\n\t\t}\n\t\tnumAdded++\n\t}\n\treturn numAdded, nil\n}\n\nfunc getWizard(dep *cfg.Dependency) {\n\tremote := dep.Remote()\n\n\t// Lookup dependency info and store in cache.\n\tmsg.Info(\"--> Gathering release information for %s\", dep.Name)\n\twizardFindVersions(dep)\n\n\tmemlatest := cache.MemLatest(remote)\n\tif memlatest != \"\" {\n\t\tdres := wizardAskLatest(memlatest, dep)\n\t\tif dres {\n\t\t\tdep.Reference = memlatest\n\n\t\t\tsv, err := semver.NewVersion(dep.Reference)\n\t\t\tif err == nil {\n\t\t\t\tres := wizardAskRange(sv, dep)\n\t\t\t\tif res == \"m\" {\n\t\t\t\t\tdep.Reference = \"^\" + sv.String()\n\t\t\t\t} else if res == \"p\" {\n\t\t\t\t\tdep.Reference = \"~\" + sv.String()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "action/get_test.go",
    "content": "package action\n\nimport (\n\t\"io/ioutil\"\n\t\"testing\"\n\n\t\"github.com/Masterminds/glide/cfg\"\n\t\"github.com/Masterminds/glide/msg\"\n)\n\nfunc TestAddPkgsToConfig(t *testing.T) {\n\t// Route output to discard so it's not displayed with the test output.\n\to := msg.Default.Stderr\n\tmsg.Default.Stderr = ioutil.Discard\n\n\tconf := new(cfg.Config)\n\tdep := new(cfg.Dependency)\n\tdep.Name = \"github.com/Masterminds/cookoo\"\n\tdep.Subpackages = append(dep.Subpackages, \"convert\")\n\tconf.Imports = append(conf.Imports, dep)\n\n\tnames := []string{\n\t\t\"github.com/Masterminds/cookoo/fmt\",\n\t\t\"github.com/Masterminds/semver\",\n\t}\n\n\taddPkgsToConfig(conf, names, false, true, false)\n\n\tif !conf.HasDependency(\"github.com/Masterminds/semver\") {\n\t\tt.Error(\"addPkgsToConfig failed to add github.com/Masterminds/semver\")\n\t}\n\n\td := conf.Imports.Get(\"github.com/Masterminds/cookoo\")\n\tfound := false\n\tfor _, s := range d.Subpackages {\n\t\tif s == \"fmt\" {\n\t\t\tfound = true\n\t\t}\n\t}\n\tif !found {\n\t\tt.Error(\"addPkgsToConfig failed to add subpackage to existing import\")\n\t}\n\n\t// Restore messaging to original location\n\tmsg.Default.Stderr = o\n}\n"
  },
  {
    "path": "action/import_gb.go",
    "content": "package action\n\nimport (\n\t\"github.com/Masterminds/glide/cfg\"\n\t\"github.com/Masterminds/glide/gb\"\n\t\"github.com/Masterminds/glide/msg\"\n\tgpath \"github.com/Masterminds/glide/path\"\n)\n\n// ImportGB imports GB dependencies into the present glide config.\nfunc ImportGB(dest string) {\n\tbase := \".\"\n\tconfig := EnsureConfig()\n\tif !gb.Has(base) {\n\t\tmsg.Die(\"There is no GB manifest to import.\")\n\t}\n\tdeps, err := gb.Parse(base)\n\tif err != nil {\n\t\tmsg.Die(\"Failed to extract GB manifest: %s\", err)\n\t}\n\tappendImports(deps, config)\n\twriteConfigToFileOrStdout(config, dest)\n}\n\nfunc appendImports(deps []*cfg.Dependency, config *cfg.Config) {\n\tif len(deps) == 0 {\n\t\tmsg.Info(\"No dependencies added.\")\n\t\treturn\n\t}\n\n\t//Append deps to existing dependencies.\n\tif err := config.AddImport(deps...); err != nil {\n\t\tmsg.Die(\"Failed to add imports: %s\", err)\n\t}\n}\n\n// writeConfigToFileOrStdout is a convenience function for import utils.\nfunc writeConfigToFileOrStdout(config *cfg.Config, dest string) {\n\tif dest != \"\" {\n\t\tif err := config.WriteFile(dest); err != nil {\n\t\t\tmsg.Die(\"Failed to write %s: %s\", gpath.GlideFile, err)\n\t\t}\n\t} else {\n\t\to, err := config.Marshal()\n\t\tif err != nil {\n\t\t\tmsg.Die(\"Error encoding config: %s\", err)\n\t\t}\n\t\tmsg.Default.Stdout.Write(o)\n\t}\n}\n"
  },
  {
    "path": "action/import_godep.go",
    "content": "package action\n\nimport (\n\t\"github.com/Masterminds/glide/godep\"\n\t\"github.com/Masterminds/glide/msg\"\n)\n\n// ImportGodep imports a Godep file.\nfunc ImportGodep(dest string) {\n\tbase := \".\"\n\tconfig := EnsureConfig()\n\tif !godep.Has(base) {\n\t\tmsg.Die(\"No Godep data found.\")\n\t}\n\tdeps, err := godep.Parse(base)\n\tif err != nil {\n\t\tmsg.Die(\"Failed to extract Godeps file: %s\", err)\n\t}\n\tappendImports(deps, config)\n\twriteConfigToFileOrStdout(config, dest)\n}\n"
  },
  {
    "path": "action/import_gom.go",
    "content": "package action\n\nimport (\n\t\"github.com/Masterminds/glide/gom\"\n\t\"github.com/Masterminds/glide/msg\"\n)\n\n// ImportGom imports a Gomfile.\nfunc ImportGom(dest string) {\n\tbase := \".\"\n\tconfig := EnsureConfig()\n\tif !gom.Has(base) {\n\t\tmsg.Die(\"No gom data found.\")\n\t}\n\tdeps, err := gom.Parse(base)\n\tif err != nil {\n\t\tmsg.Die(\"Failed to extract Gomfile: %s\", err)\n\t}\n\tappendImports(deps, config)\n\twriteConfigToFileOrStdout(config, dest)\n}\n"
  },
  {
    "path": "action/import_gpm.go",
    "content": "package action\n\nimport (\n\t\"github.com/Masterminds/glide/gpm\"\n\t\"github.com/Masterminds/glide/msg\"\n)\n\n// ImportGPM imports a GPM file.\nfunc ImportGPM(dest string) {\n\tbase := \".\"\n\tconfig := EnsureConfig()\n\tif !gpm.Has(base) {\n\t\tmsg.Die(\"No GPM Godeps file found.\")\n\t}\n\tdeps, err := gpm.Parse(base)\n\tif err != nil {\n\t\tmsg.Die(\"Failed to extract GPM Godeps file: %s\", err)\n\t}\n\tappendImports(deps, config)\n\twriteConfigToFileOrStdout(config, dest)\n}\n"
  },
  {
    "path": "action/init.go",
    "content": "package action\n\nimport (\n\tgpath \"github.com/Masterminds/glide/path\"\n)\n\n// Init initializes the action subsystem for handling one or more subesequent actions.\nfunc Init(yaml, home string) {\n\tgpath.GlideFile = yaml\n\tgpath.SetHome(home)\n}\n"
  },
  {
    "path": "action/install.go",
    "content": "package action\n\nimport (\n\t\"path/filepath\"\n\n\t\"github.com/Masterminds/glide/cache\"\n\t\"github.com/Masterminds/glide/cfg\"\n\t\"github.com/Masterminds/glide/msg\"\n\tgpath \"github.com/Masterminds/glide/path\"\n\t\"github.com/Masterminds/glide/repo\"\n)\n\n// Install installs a vendor directory based on an existing Glide configuration.\nfunc Install(installer *repo.Installer, stripVendor bool) {\n\tcache.SystemLock()\n\n\tbase := \".\"\n\t// Ensure GOPATH\n\tEnsureGopath()\n\tEnsureVendorDir()\n\tconf := EnsureConfig()\n\n\t// Lockfile exists\n\tif !gpath.HasLock(base) {\n\t\tmsg.Info(\"Lock file (glide.lock) does not exist. Performing update.\")\n\t\tUpdate(installer, false, stripVendor)\n\t\treturn\n\t}\n\t// Load lockfile\n\tlock, err := cfg.ReadLockFile(filepath.Join(base, gpath.LockFile))\n\tif err != nil {\n\t\tmsg.Die(\"Could not load lockfile.\")\n\t}\n\t// Verify lockfile hasn't changed\n\thash, err := conf.Hash()\n\tif err != nil {\n\t\tmsg.Die(\"Could not load lockfile.\")\n\t} else if hash != lock.Hash {\n\t\tmsg.Warn(\"Lock file may be out of date. Hash check of YAML failed. You may need to run 'update'\")\n\t}\n\n\t// Install\n\tnewConf, err := installer.Install(lock, conf)\n\tif err != nil {\n\t\tmsg.Die(\"Failed to install: %s\", err)\n\t}\n\n\tmsg.Info(\"Setting references.\")\n\n\t// Set reference\n\tif err := repo.SetReference(newConf, installer.ResolveTest); err != nil {\n\t\tmsg.Die(\"Failed to set references: %s (Skip to cleanup)\", err)\n\t}\n\n\terr = installer.Export(newConf)\n\tif err != nil {\n\t\tmsg.Die(\"Unable to export dependencies to vendor directory: %s\", err)\n\t}\n\n\tif stripVendor {\n\t\tmsg.Info(\"Removing nested vendor and Godeps/_workspace directories...\")\n\t\terr := gpath.StripVendor()\n\t\tif err != nil {\n\t\t\tmsg.Err(\"Unable to strip vendor directories: %s\", err)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "action/list.go",
    "content": "package action\n\nimport (\n\t\"encoding/json\"\n\t\"path/filepath\"\n\t\"sort\"\n\n\t\"github.com/Masterminds/glide/dependency\"\n\t\"github.com/Masterminds/glide/msg\"\n)\n\n// List lists all of the dependencies of the current project.\n//\n// Params:\n//  - dir (string): basedir\n//  - deep (bool): whether to do a deep scan or a shallow scan\n//  - format (string): The format to output (text, json, json-pretty)\nfunc List(basedir string, deep bool, format string) {\n\tbasedir, err := filepath.Abs(basedir)\n\tif err != nil {\n\t\tmsg.Die(\"Could not read directory: %s\", err)\n\t}\n\n\tr, err := dependency.NewResolver(basedir)\n\tif err != nil {\n\t\tmsg.Die(\"Could not create a resolver: %s\", err)\n\t}\n\th := &dependency.DefaultMissingPackageHandler{Missing: []string{}, Gopath: []string{}, Prefix: \"vendor\"}\n\tr.Handler = h\n\n\tlocalPkgs, _, err := r.ResolveLocal(deep)\n\tif err != nil {\n\t\tmsg.Die(\"Error listing dependencies: %s\", err)\n\t}\n\tsort.Strings(localPkgs)\n\tinstalled := make([]string, len(localPkgs))\n\tfor i, pkg := range localPkgs {\n\t\trelPkg, err := filepath.Rel(basedir, pkg)\n\t\tif err != nil {\n\t\t\t// msg.Warn(\"Failed to Rel path: %s\", err)\n\t\t\trelPkg = pkg\n\t\t}\n\t\tinstalled[i] = relPkg\n\t}\n\tl := PackageList{\n\t\tInstalled: installed,\n\t\tMissing:   h.Missing,\n\t\tGopath:    h.Gopath,\n\t}\n\n\toutputList(l, format)\n}\n\n// PackageList contains the packages being used by their location\ntype PackageList struct {\n\tInstalled []string `json:\"installed\"`\n\tMissing   []string `json:\"missing\"`\n\tGopath    []string `json:\"gopath\"`\n}\n\nconst (\n\ttextFormat       = \"text\"\n\tjsonFormat       = \"json\"\n\tjsonPrettyFormat = \"json-pretty\"\n)\n\nfunc outputList(l PackageList, format string) {\n\tswitch format {\n\tcase textFormat:\n\t\tmsg.Puts(\"INSTALLED packages:\")\n\t\tfor _, pkg := range l.Installed {\n\t\t\tmsg.Puts(\"\\t%s\", pkg)\n\t\t}\n\n\t\tif len(l.Missing) > 0 {\n\t\t\tmsg.Puts(\"\\nMISSING packages:\")\n\t\t\tfor _, pkg := range l.Missing {\n\t\t\t\tmsg.Puts(\"\\t%s\", pkg)\n\t\t\t}\n\t\t}\n\t\tif len(l.Gopath) > 0 {\n\t\t\tmsg.Puts(\"\\nGOPATH packages:\")\n\t\t\tfor _, pkg := range l.Gopath {\n\t\t\t\tmsg.Puts(\"\\t%s\", pkg)\n\t\t\t}\n\t\t}\n\tcase jsonFormat:\n\t\tjson.NewEncoder(msg.Default.Stdout).Encode(l)\n\tcase jsonPrettyFormat:\n\t\tb, err := json.MarshalIndent(l, \"\", \"  \")\n\t\tif err != nil {\n\t\t\tmsg.Die(\"could not unmarshal package list: %s\", err)\n\t\t}\n\t\tmsg.Puts(string(b))\n\tdefault:\n\t\tmsg.Die(\"invalid output format: must be one of: json|json-pretty|text\")\n\t}\n}\n"
  },
  {
    "path": "action/list_test.go",
    "content": "package action\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"testing\"\n\n\t\"github.com/Masterminds/glide/msg\"\n)\n\nfunc TestList(t *testing.T) {\n\tmsg.Default.PanicOnDie = true\n\told := msg.Default.Stdout\n\tdefer func() {\n\t\tmsg.Default.Stdout = old\n\t}()\n\n\tvar buf bytes.Buffer\n\tmsg.Default.Stdout = &buf\n\tList(\"../\", false, \"text\")\n\tif buf.Len() < 5 {\n\t\tt.Error(\"Expected some data to be found.\")\n\t}\n\n\tvar buf2 bytes.Buffer\n\tmsg.Default.Stdout = &buf2\n\tList(\"../\", false, \"json\")\n\tj := buf2.Bytes()\n\tvar o PackageList\n\terr := json.Unmarshal(j, &o)\n\tif err != nil {\n\t\tt.Errorf(\"Error unmarshaling json list: %s\", err)\n\t}\n\tif len(o.Installed) == 0 {\n\t\tt.Error(\"No packages found on json list\")\n\t}\n\n\tvar buf3 bytes.Buffer\n\tmsg.Default.Stdout = &buf3\n\tList(\"../\", false, \"json-pretty\")\n\tj = buf3.Bytes()\n\tvar o2 PackageList\n\terr = json.Unmarshal(j, &o2)\n\tif err != nil {\n\t\tt.Errorf(\"Error unmarshaling json-pretty list: %s\", err)\n\t}\n\tif len(o2.Installed) == 0 {\n\t\tt.Error(\"No packages found on json-pretty list\")\n\t}\n}\n"
  },
  {
    "path": "action/mirrors.go",
    "content": "package action\n\nimport (\n\t\"os\"\n\t\"path/filepath\"\n\n\t\"github.com/Masterminds/glide/mirrors\"\n\t\"github.com/Masterminds/glide/msg\"\n\tgpath \"github.com/Masterminds/glide/path\"\n)\n\n// MirrorsList displays a list of currently setup mirrors.\nfunc MirrorsList() error {\n\thome := gpath.Home()\n\n\top := filepath.Join(home, \"mirrors.yaml\")\n\n\tif _, err := os.Stat(op); os.IsNotExist(err) {\n\t\tmsg.Info(\"No mirrors exist. No mirrors.yaml file not found\")\n\t\treturn nil\n\t}\n\n\tov, err := mirrors.ReadMirrorsFile(op)\n\tif err != nil {\n\t\tmsg.Die(\"Unable to read mirrors.yaml file: %s\", err)\n\t}\n\n\tif len(ov.Repos) == 0 {\n\t\tmsg.Info(\"No mirrors found\")\n\t\treturn nil\n\t}\n\n\tmsg.Info(\"Mirrors...\")\n\tfor _, r := range ov.Repos {\n\t\tif r.Vcs == \"\" {\n\t\t\tmsg.Info(\"--> %s replaced by %s\", r.Original, r.Repo)\n\t\t} else {\n\t\t\tmsg.Info(\"--> %s replaced by %s (%s)\", r.Original, r.Repo, r.Vcs)\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// MirrorsSet sets a mirror to use\nfunc MirrorsSet(o, r, v string) error {\n\tif o == \"\" || r == \"\" {\n\t\tmsg.Err(\"Both the original and mirror values are required\")\n\t\treturn nil\n\t}\n\n\thome := gpath.Home()\n\n\top := filepath.Join(home, \"mirrors.yaml\")\n\n\tvar ov *mirrors.Mirrors\n\tif _, err := os.Stat(op); os.IsNotExist(err) {\n\t\tmsg.Info(\"No mirrors.yaml file exists. Creating new one\")\n\t\tov = &mirrors.Mirrors{\n\t\t\tRepos: make(mirrors.MirrorRepos, 0),\n\t\t}\n\t} else {\n\t\tov, err = mirrors.ReadMirrorsFile(op)\n\t\tif err != nil {\n\t\t\tmsg.Die(\"Error reading existing mirrors.yaml file: %s\", err)\n\t\t}\n\t}\n\n\tfound := false\n\tfor i, re := range ov.Repos {\n\t\tif re.Original == o {\n\t\t\tfound = true\n\t\t\tmsg.Info(\"%s found in mirrors. Replacing with new settings\", o)\n\t\t\tov.Repos[i].Repo = r\n\t\t\tov.Repos[i].Vcs = v\n\t\t}\n\t}\n\n\tif !found {\n\t\tnr := &mirrors.MirrorRepo{\n\t\t\tOriginal: o,\n\t\t\tRepo:     r,\n\t\t\tVcs:      v,\n\t\t}\n\t\tov.Repos = append(ov.Repos, nr)\n\t}\n\n\tmsg.Info(\"%s being set to %s\", o, r)\n\n\terr := ov.WriteFile(op)\n\tif err != nil {\n\t\tmsg.Err(\"Error writing mirrors.yaml file: %s\", err)\n\t} else {\n\t\tmsg.Info(\"mirrors.yaml written with changes\")\n\t}\n\n\treturn nil\n}\n\n// MirrorsRemove removes a mirrors setting\nfunc MirrorsRemove(k string) error {\n\tif k == \"\" {\n\t\tmsg.Err(\"The mirror to remove is required\")\n\t\treturn nil\n\t}\n\n\thome := gpath.Home()\n\n\top := filepath.Join(home, \"mirrors.yaml\")\n\n\tif _, err := os.Stat(op); os.IsNotExist(err) {\n\t\tmsg.Err(\"mirrors.yaml file not found\")\n\t\treturn nil\n\t}\n\n\tov, err := mirrors.ReadMirrorsFile(op)\n\tif err != nil {\n\t\tmsg.Die(\"Unable to read mirrors.yaml file: %s\", err)\n\t}\n\n\tvar nre mirrors.MirrorRepos\n\tvar found bool\n\tfor _, re := range ov.Repos {\n\t\tif re.Original != k {\n\t\t\tnre = append(nre, re)\n\t\t} else {\n\t\t\tfound = true\n\t\t}\n\t}\n\n\tif !found {\n\t\tmsg.Warn(\"%s was not found in mirrors\", k)\n\t} else {\n\t\tmsg.Info(\"%s was removed from mirrors\", k)\n\t\tov.Repos = nre\n\n\t\terr = ov.WriteFile(op)\n\t\tif err != nil {\n\t\t\tmsg.Err(\"Error writing mirrors.yaml file: %s\", err)\n\t\t} else {\n\t\t\tmsg.Info(\"mirrors.yaml written with changes\")\n\t\t}\n\t}\n\n\treturn nil\n}\n"
  },
  {
    "path": "action/name.go",
    "content": "package action\n\nimport (\n\t\"github.com/Masterminds/glide/msg\"\n)\n\n// Name prints the name of the package, according to the glide.yaml file.\nfunc Name() {\n\tconf := EnsureConfig()\n\tmsg.Puts(conf.Name)\n}\n"
  },
  {
    "path": "action/name_test.go",
    "content": "package action\n\nimport (\n\t\"bytes\"\n\t\"os\"\n\t\"testing\"\n\n\t\"github.com/Masterminds/glide/msg\"\n)\n\nfunc TestName(t *testing.T) {\n\tvar buf bytes.Buffer\n\tmsg.Default.PanicOnDie = true\n\tostdout := msg.Default.Stdout\n\tmsg.Default.Stdout = &buf\n\twd, _ := os.Getwd()\n\tif err := os.Chdir(\"../testdata/name\"); err != nil {\n\t\tt.Errorf(\"Failed to change directory: %s\", err)\n\t}\n\tName()\n\tif buf.String() != \"technosophos.com/x/foo\\n\" {\n\t\tt.Errorf(\"Unexpectedly got name %q\", buf.String())\n\t}\n\tmsg.Default.Stdout = ostdout\n\tos.Chdir(wd)\n}\n"
  },
  {
    "path": "action/no_vendor.go",
    "content": "package action\n\nimport (\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/Masterminds/glide/msg\"\n)\n\n// NoVendor generates a list of source code directories, excepting `vendor/`.\n//\n// If \"onlyGo\" is true, only folders that have Go code in them will be returned.\n//\n// If suffix is true, this will append `/...` to every directory.\nfunc NoVendor(path string, onlyGo, suffix bool) {\n\t// This is responsible for printing the results of noVend.\n\tpaths, err := noVend(path, onlyGo, suffix)\n\tif err != nil {\n\t\tmsg.Err(\"Failed to walk file tree: %s\", err)\n\t\tmsg.Warn(\"FIXME: NoVendor should exit with non-zero exit code.\")\n\t\treturn\n\t}\n\n\tfor _, p := range paths {\n\t\tmsg.Puts(p)\n\t}\n}\n\n// noVend takes a directory and returns a list of Go-like files or directories,\n// provided the directory is not a vendor directory.\n//\n// If onlyGo is true, this will filter out all directories that do not contain\n// \".go\" files.\n//\n// TODO: Should we move this to its own package?\nfunc noVend(path string, onlyGo, suffix bool) ([]string, error) {\n\n\tinfo, err := os.Stat(path)\n\tif err != nil {\n\t\treturn []string{}, err\n\t}\n\n\tif !info.IsDir() {\n\t\treturn []string{path}, nil\n\t}\n\n\tres := []string{}\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\treturn res, err\n\t}\n\n\tfis, err := f.Readdir(0)\n\tif err != nil {\n\t\treturn res, err\n\t}\n\n\tcur := false\n\n\tfor _, fi := range fis {\n\t\tif exclude(fi) {\n\t\t\tcontinue\n\t\t}\n\n\t\tfull := filepath.Join(path, fi.Name())\n\t\tif fi.IsDir() && !isVend(fi) {\n\t\t\tp := \"./\" + full + \"/...\"\n\t\t\tres = append(res, p)\n\t\t} else if !fi.IsDir() && isGoish(fi) {\n\t\t\t//res = append(res, full)\n\t\t\tcur = true\n\t\t}\n\t}\n\n\t// Filter out directories that do not contain Go code\n\tif onlyGo {\n\t\tres = hasGoSource(res, suffix)\n\t}\n\n\tif cur {\n\t\tres = append(res, \".\")\n\t}\n\n\treturn res, nil\n}\n\n// hasGoSource returns a list of directories that contain Go source.\nfunc hasGoSource(dirs []string, suffix bool) []string {\n\tsuf := \"/\"\n\tif suffix {\n\t\tsuf = \"/...\"\n\t}\n\tbuf := []string{}\n\tfor _, d := range dirs {\n\t\td := filepath.Dir(d)\n\t\tfound := false\n\t\twalker := func(p string, fi os.FileInfo, err error) error {\n\t\t\t// Dumb optimization\n\t\t\tif found {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\t// If the file ends with .go, report a match.\n\t\t\tif strings.ToLower(filepath.Ext(p)) == \".go\" {\n\t\t\t\tfound = true\n\t\t\t}\n\n\t\t\treturn nil\n\t\t}\n\t\tfilepath.Walk(d, walker)\n\n\t\tif found {\n\t\t\tbuf = append(buf, \"./\"+d+suf)\n\t\t}\n\t}\n\treturn buf\n}\n\n// isVend returns true of this directory is a vendor directory.\n//\n// TODO: Should we return true for Godeps directory?\nfunc isVend(fi os.FileInfo) bool {\n\treturn fi.Name() == \"vendor\"\n}\n\n// exclude returns true if the directory should be excluded by Go toolchain tools.\n//\n// Examples: directories prefixed with '.' or '_'.\nfunc exclude(fi os.FileInfo) bool {\n\tif strings.HasPrefix(fi.Name(), \"_\") {\n\t\treturn true\n\t}\n\tif strings.HasPrefix(fi.Name(), \".\") {\n\t\treturn true\n\t}\n\treturn false\n}\n\n// isGoish returns true if the file appears to be Go source.\nfunc isGoish(fi os.FileInfo) bool {\n\treturn filepath.Ext(fi.Name()) == \".go\"\n}\n"
  },
  {
    "path": "action/no_vendor_test.go",
    "content": "package action\n\nimport (\n\t\"testing\"\n\n\t\"github.com/Masterminds/glide/msg\"\n)\n\nfunc TestNoVendor(t *testing.T) {\n\tmsg.Default.PanicOnDie = true\n\tNoVendor(\"../testdata/nv\", false, false)\n}\n"
  },
  {
    "path": "action/plugin.go",
    "content": "package action\n\nimport (\n\t\"os\"\n\t\"os/exec\"\n\n\t\"github.com/Masterminds/glide/msg\"\n)\n\n// Plugin attempts to find and execute a plugin based on a command.\n//\n// Exit code 99 means the plugin was never executed. Code 1 means the program\n// exited badly.\nfunc Plugin(command string, args []string) {\n\n\tcwd, err := os.Getwd()\n\tif err != nil {\n\t\tmsg.ExitCode(99)\n\t\tmsg.Die(\"Could not get working directory: %s\", err)\n\t}\n\n\tcmd := \"glide-\" + command\n\tvar fullcmd string\n\tif fullcmd, err = exec.LookPath(cmd); err != nil {\n\t\tfullcmd = cwd + \"/\" + cmd\n\t\tif _, err := os.Stat(fullcmd); err != nil {\n\t\t\tmsg.ExitCode(99)\n\t\t\tmsg.Die(\"Command %s does not exist.\", cmd)\n\t\t}\n\t}\n\n\t// Turning os.Args first argument from `glide` to `glide-command`\n\targs[0] = cmd\n\t// Removing the first argument (command)\n\tremoved := false\n\tfor i, v := range args {\n\t\tif removed == false && v == command {\n\t\t\targs = append(args[:i], args[i+1:]...)\n\t\t\tremoved = true\n\t\t}\n\t}\n\tpa := os.ProcAttr{\n\t\tFiles: []*os.File{os.Stdin, os.Stdout, os.Stderr},\n\t\tDir:   cwd,\n\t}\n\n\tmsg.Debug(\"Delegating to plugin %s (%v)\\n\", fullcmd, args)\n\n\tproc, err := os.StartProcess(fullcmd, args, &pa)\n\tif err != nil {\n\t\tmsg.Err(\"Failed to execute %s: %s\", cmd, err)\n\t\tos.Exit(98)\n\t}\n\n\tif _, err := proc.Wait(); err != nil {\n\t\tmsg.Err(err.Error())\n\t\tos.Exit(1)\n\t}\n}\n"
  },
  {
    "path": "action/plugin_test.go",
    "content": "package action\n\nimport (\n\t\"os\"\n\t\"runtime\"\n\t\"testing\"\n\n\t\"github.com/Masterminds/glide/msg\"\n)\n\nfunc TestPlugin(t *testing.T) {\n\twd, _ := os.Getwd()\n\tos.Chdir(\"../testdata/plugin\")\n\tmsg.Default.PanicOnDie = true\n\tvar cmd string\n\n\t// Windows scripts for testing (batch) are different from shells scripts.\n\t// Making sure the plugin works in both bases.\n\tif runtime.GOOS == \"windows\" {\n\t\tcmd = \"hello-win\"\n\t} else {\n\t\tcmd = \"hello\"\n\t}\n\targs := []string{\"a\", \"b\"}\n\t// FIXME: Trapping the panic is the nice thing to do.\n\tPlugin(cmd, args)\n\tos.Chdir(wd)\n}\n"
  },
  {
    "path": "action/project_info.go",
    "content": "package action\n\nimport (\n\t\"bytes\"\n\n\t\"github.com/Masterminds/glide/msg\"\n)\n\n// Info prints information about a project based on a passed in format.\nfunc Info(format string) {\n\tconf := EnsureConfig()\n\tvar buffer bytes.Buffer\n\tvarInit := false\n\tfor _, varfmt := range format {\n\t\tif varInit {\n\t\t\tswitch varfmt {\n\t\t\tcase 'n':\n\t\t\t\tbuffer.WriteString(conf.Name)\n\t\t\tcase 'd':\n\t\t\t\tbuffer.WriteString(conf.Description)\n\t\t\tcase 'h':\n\t\t\t\tbuffer.WriteString(conf.Home)\n\t\t\tcase 'l':\n\t\t\t\tbuffer.WriteString(conf.License)\n\t\t\tdefault:\n\t\t\t\tmsg.Die(\"Invalid format %s\", string(varfmt))\n\t\t\t}\n\t\t} else {\n\t\t\tswitch varfmt {\n\t\t\tcase '%':\n\t\t\t\tvarInit = true\n\t\t\t\tcontinue\n\t\t\tdefault:\n\t\t\t\tbuffer.WriteString(string(varfmt))\n\t\t\t}\n\t\t}\n\t\tvarInit = false\n\t}\n\tmsg.Puts(buffer.String())\n}\n"
  },
  {
    "path": "action/rebuild.go",
    "content": "package action\n\nimport (\n\t\"os\"\n\t\"os/exec\"\n\t\"path\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/Masterminds/glide/cfg\"\n\t\"github.com/Masterminds/glide/msg\"\n\tgpath \"github.com/Masterminds/glide/path\"\n)\n\n// Rebuild rebuilds '.a' files for a project.\n//\n// Prior to Go 1.4, this could substantially reduce time on incremental compiles.\n// It remains to be seen whether this is tremendously beneficial to modern Go\n// programs.\nfunc Rebuild() {\n\tmsg.Warn(\"The rebuild command is deprecated and will be removed in a future version\")\n\tmsg.Warn(\"Use the go install command instead\")\n\tconf := EnsureConfig()\n\tvpath, err := gpath.Vendor()\n\tif err != nil {\n\t\tmsg.Die(\"Could not get vendor path: %s\", err)\n\t}\n\n\tmsg.Info(\"Building dependencies.\\n\")\n\n\tif len(conf.Imports) == 0 {\n\t\tmsg.Info(\"No dependencies found. Nothing built.\\n\")\n\t\treturn\n\t}\n\n\tfor _, dep := range conf.Imports {\n\t\tif err := buildDep(dep, vpath); err != nil {\n\t\t\tmsg.Warn(\"Failed to build %s: %s\\n\", dep.Name, err)\n\t\t}\n\t}\n}\n\nfunc buildDep(dep *cfg.Dependency, vpath string) error {\n\tif len(dep.Subpackages) == 0 {\n\t\tbuildPath(dep.Name)\n\t}\n\n\tfor _, pkg := range dep.Subpackages {\n\t\tif pkg == \"**\" || pkg == \"...\" {\n\t\t\t//Info(\"Building all packages in %s\\n\", dep.Name)\n\t\t\tbuildPath(path.Join(dep.Name, \"...\"))\n\t\t} else {\n\t\t\tpaths, err := resolvePackages(vpath, dep.Name, pkg)\n\t\t\tif err != nil {\n\t\t\t\tmsg.Warn(\"Error resolving packages: %s\", err)\n\t\t\t}\n\t\t\tbuildPaths(paths)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc resolvePackages(vpath, pkg, subpkg string) ([]string, error) {\n\tsdir, _ := os.Getwd()\n\tif err := os.Chdir(filepath.Join(vpath, pkg, subpkg)); err != nil {\n\t\treturn []string{}, err\n\t}\n\tdefer os.Chdir(sdir)\n\tp, err := filepath.Glob(path.Join(vpath, pkg, subpkg))\n\tif err != nil {\n\t\treturn []string{}, err\n\t}\n\tfor k, v := range p {\n\t\tnv := strings.TrimPrefix(v, vpath)\n\t\tp[k] = strings.TrimPrefix(nv, string(filepath.Separator))\n\t}\n\treturn p, nil\n}\n\nfunc buildPaths(paths []string) error {\n\tfor _, path := range paths {\n\t\tif err := buildPath(path); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc buildPath(path string) error {\n\tmsg.Info(\"Running go build %s\\n\", path)\n\t// . in a filepath.Join is removed so it needs to be prepended separately.\n\tp := \".\" + string(filepath.Separator) + filepath.Join(\"vendor\", path)\n\tout, err := exec.Command(goExecutable(), \"install\", p).CombinedOutput()\n\tif err != nil {\n\t\tmsg.Warn(\"Failed to run 'go install' for %s: %s\", path, string(out))\n\t}\n\treturn err\n}\n"
  },
  {
    "path": "action/rebuild_test.go",
    "content": "package action\n\nimport (\n\t\"os\"\n\t\"testing\"\n\n\t\"github.com/Masterminds/glide/msg\"\n)\n\nfunc TestRebuild(t *testing.T) {\n\tmsg.Default.PanicOnDie = true\n\twd, _ := os.Getwd()\n\tif err := os.Chdir(\"../testdata/rebuild\"); err != nil {\n\t\tt.Errorf(\"Could not change dir: %s (%s)\", err, wd)\n\t}\n\tRebuild()\n\tos.Chdir(wd)\n}\n"
  },
  {
    "path": "action/remove.go",
    "content": "package action\n\nimport (\n\t\"github.com/Masterminds/glide/cache\"\n\t\"github.com/Masterminds/glide/cfg\"\n\t\"github.com/Masterminds/glide/msg\"\n\tgpath \"github.com/Masterminds/glide/path\"\n\t\"github.com/Masterminds/glide/repo\"\n)\n\n// Remove removes a dependncy from the configuration.\nfunc Remove(packages []string, inst *repo.Installer) {\n\tcache.SystemLock()\n\tbase := gpath.Basepath()\n\tEnsureGopath()\n\tEnsureVendorDir()\n\tconf := EnsureConfig()\n\tglidefile, err := gpath.Glide()\n\tif err != nil {\n\t\tmsg.Die(\"Could not find Glide file: %s\", err)\n\t}\n\n\tmsg.Info(\"Preparing to remove %d packages.\", len(packages))\n\tconf.Imports = rmDeps(packages, conf.Imports)\n\tconf.DevImports = rmDeps(packages, conf.DevImports)\n\n\t// Copy used to generate locks.\n\tconfcopy := conf.Clone()\n\n\t//confcopy.Imports = inst.List(confcopy)\n\n\tif err := repo.SetReference(confcopy, inst.ResolveTest); err != nil {\n\t\tmsg.Err(\"Failed to set references: %s\", err)\n\t}\n\n\terr = inst.Export(confcopy)\n\tif err != nil {\n\t\tmsg.Die(\"Unable to export dependencies to vendor directory: %s\", err)\n\t}\n\n\t// Write glide.yaml\n\tif err := conf.WriteFile(glidefile); err != nil {\n\t\tmsg.Die(\"Failed to write glide YAML file: %s\", err)\n\t}\n\n\t// Write glide lock\n\twriteLock(conf, confcopy, base)\n}\n\n// rmDeps returns a list of dependencies that do not contain the given pkgs.\n//\n// It generates neither an error nor a warning for a pkg that does not exist\n// in the list of deps.\nfunc rmDeps(pkgs []string, deps []*cfg.Dependency) []*cfg.Dependency {\n\tres := []*cfg.Dependency{}\n\tfor _, d := range deps {\n\t\trem := false\n\t\tfor _, p := range pkgs {\n\t\t\tif p == d.Name {\n\t\t\t\trem = true\n\t\t\t}\n\t\t}\n\t\tif !rem {\n\t\t\tres = append(res, d)\n\t\t}\n\t}\n\treturn res\n}\n"
  },
  {
    "path": "action/tree.go",
    "content": "package action\n\nimport (\n\t\"container/list\"\n\t\"os\"\n\n\t\"github.com/Masterminds/glide/msg\"\n\t\"github.com/Masterminds/glide/tree\"\n\t\"github.com/Masterminds/glide/util\"\n)\n\n// Tree prints a tree representing dependencies.\nfunc Tree(basedir string, showcore bool) {\n\tmsg.Warn(\"The tree command is deprecated and will be removed in a future version\")\n\tbuildContext, err := util.GetBuildContext()\n\tif err != nil {\n\t\tmsg.Die(\"Failed to get a build context: %s\", err)\n\t}\n\tmyName := buildContext.PackageName(basedir)\n\n\tif basedir == \".\" {\n\t\tvar err error\n\t\tbasedir, err = os.Getwd()\n\t\tif err != nil {\n\t\t\tmsg.Die(\"Could not get working directory\")\n\t\t}\n\t}\n\n\tmsg.Puts(myName)\n\tl := list.New()\n\tl.PushBack(myName)\n\ttree.Display(buildContext, basedir, myName, 1, showcore, l)\n}\n"
  },
  {
    "path": "action/update.go",
    "content": "package action\n\nimport (\n\t\"io/ioutil\"\n\t\"path/filepath\"\n\n\t\"github.com/Masterminds/glide/cache\"\n\t\"github.com/Masterminds/glide/cfg\"\n\t\"github.com/Masterminds/glide/msg\"\n\tgpath \"github.com/Masterminds/glide/path\"\n\t\"github.com/Masterminds/glide/repo\"\n)\n\n// Update updates repos and the lock file from the main glide yaml.\nfunc Update(installer *repo.Installer, skipRecursive, stripVendor bool) {\n\tcache.SystemLock()\n\n\tbase := \".\"\n\tEnsureGopath()\n\tEnsureVendorDir()\n\tconf := EnsureConfig()\n\n\t// Try to check out the initial dependencies.\n\tif err := installer.Checkout(conf); err != nil {\n\t\tmsg.Die(\"Failed to do initial checkout of config: %s\", err)\n\t}\n\n\t// Set the versions for the initial dependencies so that resolved dependencies\n\t// are rooted in the correct version of the base.\n\tif err := repo.SetReference(conf, installer.ResolveTest); err != nil {\n\t\tmsg.Die(\"Failed to set initial config references: %s\", err)\n\t}\n\n\t// Prior to resolving dependencies we need to start working with a clone\n\t// of the conf because we'll be making real changes to it.\n\tconfcopy := conf.Clone()\n\n\tif !skipRecursive {\n\t\t// Get all repos and update them.\n\t\terr := installer.Update(confcopy)\n\t\tif err != nil {\n\t\t\tmsg.Die(\"Could not update packages: %s\", err)\n\t\t}\n\n\t\t// Set references. There may be no remaining references to set since the\n\t\t// installer set them as it went to make sure it parsed the right imports\n\t\t// from the right version of the package.\n\t\tmsg.Info(\"Setting references for remaining imports\")\n\t\tif err := repo.SetReference(confcopy, installer.ResolveTest); err != nil {\n\t\t\tmsg.Err(\"Failed to set references: %s (Skip to cleanup)\", err)\n\t\t}\n\t}\n\n\terr := installer.Export(confcopy)\n\tif err != nil {\n\t\tmsg.Die(\"Unable to export dependencies to vendor directory: %s\", err)\n\t}\n\n\t// Write glide.yaml (Why? Godeps/GPM/GB?)\n\t// I think we don't need to write a new Glide file because update should not\n\t// change anything important. It will just generate information about\n\t// transative dependencies, all of which belongs exclusively in the lock\n\t// file, not the glide.yaml file.\n\t// TODO(mattfarina): Detect when a new dependency has been added or removed\n\t// from the project. A removed dependency should warn and an added dependency\n\t// should be added to the glide.yaml file. See issue #193.\n\n\tif !skipRecursive {\n\t\t// Write lock\n\t\thash, err := conf.Hash()\n\t\tif err != nil {\n\t\t\tmsg.Die(\"Failed to generate config hash. Unable to generate lock file.\")\n\t\t}\n\t\tlock, err := cfg.NewLockfile(confcopy.Imports, confcopy.DevImports, hash)\n\t\tif err != nil {\n\t\t\tmsg.Die(\"Failed to generate lock file: %s\", err)\n\t\t}\n\t\twl := true\n\t\tif gpath.HasLock(base) {\n\t\t\tyml, err := ioutil.ReadFile(filepath.Join(base, gpath.LockFile))\n\t\t\tif err == nil {\n\t\t\t\tl2, err := cfg.LockfileFromYaml(yml)\n\t\t\t\tif err == nil {\n\t\t\t\t\tf1, err := l2.Fingerprint()\n\t\t\t\t\tf2, err2 := lock.Fingerprint()\n\t\t\t\t\tif err == nil && err2 == nil && f1 == f2 {\n\t\t\t\t\t\twl = false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif wl {\n\t\t\tif err := lock.WriteFile(filepath.Join(base, gpath.LockFile)); err != nil {\n\t\t\t\tmsg.Err(\"Could not write lock file to %s: %s\", base, err)\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\tmsg.Info(\"Versions did not change. Skipping glide.lock update.\")\n\t\t}\n\n\t\tmsg.Info(\"Project relies on %d dependencies.\", len(confcopy.Imports))\n\t} else {\n\t\tmsg.Warn(\"Skipping lockfile generation because full dependency tree is not being calculated\")\n\t}\n\n\tif stripVendor {\n\t\tmsg.Info(\"Removing nested vendor and Godeps/_workspace directories...\")\n\t\terr := gpath.StripVendor()\n\t\tif err != nil {\n\t\t\tmsg.Err(\"Unable to strip vendor directories: %s\", err)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "appveyor.yml",
    "content": "\nversion: build-{build}.{branch}\n\nclone_folder: C:\\gopath\\src\\github.com\\Masterminds\\glide\nshallow_clone: true\n\nenvironment:\n  GOPATH: C:\\gopath\n\nplatform:\n  - x64\n\nbuild: off\n\ninstall:\n  - go version\n  - go env\n\ntest_script:\n  - go test -v . ./gb ./path ./action ./tree ./util ./godep ./godep/strip ./gpm ./cfg ./dependency ./importer ./msg ./repo ./mirrors\n\ndeploy: off\n"
  },
  {
    "path": "cache/cache.go",
    "content": "// Package cache provides an interface for interfacing with the Glide local cache\n//\n// Glide has a local cache of metadata and repositories similar to the GOPATH.\n// To store the cache Glide creates a .glide directory with a cache subdirectory.\n// This is usually in the users home directory unless there is no accessible\n// home directory in which case the .glide directory is in the root of the\n// repository.\n//\n// To get the cache location use the `cache.Location()` function. This will\n// return the proper base location in your environment.\n//\n// Within the cache directory there are two subdirectories. They are the src\n// and info directories. The src directory contains version control checkouts\n// of the packages. The info direcory contains metadata. The metadata maps to\n// the RepoInfo struct. Both stores are happed to keys.\n//\n// Using the `cache.Key()` function you can get a key for a repo. Pass in a\n// location such as `https://github.com/foo/bar` or `git@example.com:foo.git`\n// and a key will be returned that can be used for caching operations.\n//\n// Note, the caching is based on repo rather than package. This is important\n// for a couple reasons.\n//\n// 1. Forks or package replacements are supported in Glide. Where a different\n//    repo maps to a package.\n// 2. Permissions enable different access. For example `https://example.com/foo.git`\n//    and `git@example.com:foo.git` may have access to different branches or tags.\npackage cache\n\nimport (\n\t\"encoding/json\"\n\t\"errors\"\n\t\"io/ioutil\"\n\t\"net/url\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"regexp\"\n\t\"strings\"\n\t\"sync\"\n\t\"time\"\n\n\t\"github.com/Masterminds/glide/msg\"\n\tgpath \"github.com/Masterminds/glide/path\"\n)\n\n// Enabled sets if the cache is globally enabled. Defaults to true.\nvar Enabled = true\n\n// ErrCacheDisabled is returned with the cache is disabled.\nvar ErrCacheDisabled = errors.New(\"Cache disabled\")\n\nvar isSetup bool\n\nvar setupMutex sync.Mutex\n\n// Setup creates the cache location.\nfunc Setup() {\n\tsetupMutex.Lock()\n\tdefer setupMutex.Unlock()\n\n\tif isSetup {\n\t\treturn\n\t}\n\tmsg.Debug(\"Setting up the cache directory\")\n\tpths := []string{\n\t\t\"cache\",\n\t\tfilepath.Join(\"cache\", \"src\"),\n\t\tfilepath.Join(\"cache\", \"info\"),\n\t}\n\n\tfor _, l := range pths {\n\t\terr := os.MkdirAll(filepath.Join(gpath.Home(), l), 0755)\n\t\tif err != nil {\n\t\t\tmsg.Die(\"Cache directory unavailable: %s\", err)\n\t\t}\n\t}\n\n\tisSetup = true\n}\n\n// SetupReset resets if setup has been completed. The next time setup is run\n// it will attempt a full setup.\nfunc SetupReset() {\n\tisSetup = false\n}\n\n// Location returns the location of the cache.\nfunc Location() string {\n\tp := filepath.Join(gpath.Home(), \"cache\")\n\tSetup()\n\n\treturn p\n}\n\n// scpSyntaxRe matches the SCP-like addresses used to access repos over SSH.\nvar scpSyntaxRe = regexp.MustCompile(`^([a-zA-Z0-9_]+)@([a-zA-Z0-9._-]+):(.*)$`)\n\n// Key generates a cache key based on a url or scp string. The key is file\n// system safe.\nfunc Key(repo string) (string, error) {\n\n\tvar u *url.URL\n\tvar err error\n\tvar strip bool\n\tif m := scpSyntaxRe.FindStringSubmatch(repo); m != nil {\n\t\t// Match SCP-like syntax and convert it to a URL.\n\t\t// Eg, \"git@github.com:user/repo\" becomes\n\t\t// \"ssh://git@github.com/user/repo\".\n\t\tu = &url.URL{\n\t\t\tScheme: \"ssh\",\n\t\t\tUser:   url.User(m[1]),\n\t\t\tHost:   m[2],\n\t\t\tPath:   \"/\" + m[3],\n\t\t}\n\t\tstrip = true\n\t} else {\n\t\tu, err = url.Parse(repo)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\n\tif strip {\n\t\tu.Scheme = \"\"\n\t}\n\n\tvar key string\n\tif u.Scheme != \"\" {\n\t\tkey = u.Scheme + \"-\"\n\t}\n\tif u.User != nil && u.User.Username() != \"\" {\n\t\tkey = key + u.User.Username() + \"-\"\n\t}\n\tkey = key + u.Host\n\tif u.Path != \"\" {\n\t\tkey = key + strings.Replace(u.Path, \"/\", \"-\", -1)\n\t}\n\n\tkey = strings.Replace(key, \":\", \"-\", -1)\n\n\treturn key, nil\n}\n\n// RepoInfo holds information about a repo.\ntype RepoInfo struct {\n\tDefaultBranch string `json:\"default-branch\"`\n\tLastUpdate    string `json:\"last-update\"`\n}\n\n// SaveRepoData stores data about a repo in the Glide cache\nfunc SaveRepoData(key string, data RepoInfo) error {\n\tif !Enabled {\n\t\treturn ErrCacheDisabled\n\t}\n\tlocation := Location()\n\tdata.LastUpdate = time.Now().String()\n\td, err := json.Marshal(data)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tpp := filepath.Join(location, \"info\")\n\terr = os.MkdirAll(pp, 0755)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tp := filepath.Join(pp, key+\".json\")\n\tf, err := os.Create(p)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\n\t_, err = f.Write(d)\n\treturn err\n}\n\n// RepoData retrieves cached information about a repo.\nfunc RepoData(key string) (*RepoInfo, error) {\n\tif !Enabled {\n\t\treturn &RepoInfo{}, ErrCacheDisabled\n\t}\n\tlocation := Location()\n\tc := &RepoInfo{}\n\tp := filepath.Join(location, \"info\", key+\".json\")\n\tf, err := ioutil.ReadFile(p)\n\tif err != nil {\n\t\treturn &RepoInfo{}, err\n\t}\n\terr = json.Unmarshal(f, c)\n\tif err != nil {\n\t\treturn &RepoInfo{}, err\n\t}\n\treturn c, nil\n}\n\nvar lockSync sync.Mutex\n\nvar lockData = make(map[string]*sync.Mutex)\n\n// Lock locks a particular key name\nfunc Lock(name string) {\n\tlockSync.Lock()\n\tm, ok := lockData[name]\n\tif !ok {\n\t\tm = &sync.Mutex{}\n\t\tlockData[name] = m\n\t}\n\tlockSync.Unlock()\n\tmsg.Debug(\"Locking %s\", name)\n\tm.Lock()\n}\n\n// Unlock unlocks a particular key name\nfunc Unlock(name string) {\n\tmsg.Debug(\"Unlocking %s\", name)\n\tlockSync.Lock()\n\tif m, ok := lockData[name]; ok {\n\t\tm.Unlock()\n\t}\n\n\tlockSync.Unlock()\n}\n"
  },
  {
    "path": "cache/cache_test.go",
    "content": "package cache\n\nimport \"testing\"\n\nfunc TestKey(t *testing.T) {\n\ttests := map[string]string{\n\t\t\"https://github.com/foo/bar\":     \"https-github.com-foo-bar\",\n\t\t\"git@github.com:foo/bar\":         \"git-github.com-foo-bar\",\n\t\t\"https://github.com:123/foo/bar\": \"https-github.com-123-foo-bar\",\n\t}\n\n\tfor k, v := range tests {\n\t\tkey, err := Key(k)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Cache key generation err: %s\", err)\n\t\t\tcontinue\n\t\t}\n\t\tif key != v {\n\t\t\tt.Errorf(\"Expected cache key %s for %s but got %s\", v, k, key)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "cache/global_lock.go",
    "content": "package cache\n\nimport (\n\t\"encoding/json\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"os/signal\"\n\t\"path/filepath\"\n\t\"time\"\n\n\t\"github.com/Masterminds/glide/msg\"\n\tgpath \"github.com/Masterminds/glide/path\"\n)\n\nvar isStarted bool\n\n// If the global cache lock file should be written\nvar shouldWriteLock = true\n\n// SystemLock starts a system rather than application lock. This way multiple\n// app instances don't cause race conditions when working in the cache.\nfunc SystemLock() error {\n\tif isStarted {\n\t\treturn nil\n\t}\n\terr := waitOnLock()\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = startLock()\n\tisStarted = true\n\treturn err\n}\n\n// SystemUnlock removes the system wide Glide cache lock.\nfunc SystemUnlock() {\n\tlockdone <- struct{}{}\n\tos.Remove(lockFileName)\n}\n\nvar lockdone = make(chan struct{}, 1)\n\ntype lockdata struct {\n\tComment string `json:\"comment\"`\n\tPid     int    `json:\"pid\"`\n\tTime    string `json:\"time\"`\n}\n\nvar lockFileName = filepath.Join(gpath.Home(), \"lock.json\")\n\n// Write a lock for now.\nfunc writeLock() error {\n\n\t// If the lock should not be written exit immediately. This happens in cases\n\t// where shutdown/clean is happening.\n\tif !shouldWriteLock {\n\t\treturn nil\n\t}\n\n\tld := &lockdata{\n\t\tComment: \"File managed by Glide (https://glide.sh)\",\n\t\tPid:     os.Getpid(),\n\t\tTime:    time.Now().Format(time.RFC3339Nano),\n\t}\n\n\tout, err := json.Marshal(ld)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = ioutil.WriteFile(lockFileName, out, 0755)\n\treturn err\n}\n\nfunc startLock() error {\n\terr := writeLock()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-lockdone:\n\t\t\t\treturn\n\t\t\tdefault:\n\t\t\t\ttime.Sleep(10 * time.Second)\n\t\t\t\terr := writeLock()\n\t\t\t\tif err != nil {\n\t\t\t\t\tmsg.Die(\"Error using Glide lock: %s\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\n\t// Capture ctrl-c or other interruptions then clean up the global lock.\n\tch := make(chan os.Signal)\n\tsignal.Notify(ch, os.Interrupt, os.Kill)\n\tgo func(cc <-chan os.Signal) {\n\t\ts := <-cc\n\t\tshouldWriteLock = false\n\t\tSystemUnlock()\n\n\t\t// Exiting with the expected exit codes when we can.\n\t\tif s == os.Interrupt {\n\t\t\tos.Exit(130)\n\t\t} else if s == os.Kill {\n\t\t\tos.Exit(137)\n\t\t} else {\n\t\t\tos.Exit(1)\n\t\t}\n\t}(ch)\n\n\treturn nil\n}\n\nfunc waitOnLock() error {\n\tvar announced bool\n\tfor {\n\t\tfi, err := os.Stat(lockFileName)\n\t\tif err != nil && os.IsNotExist(err) {\n\t\t\treturn nil\n\t\t} else if err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tdiff := time.Now().Sub(fi.ModTime())\n\t\tif diff.Seconds() > 15 {\n\t\t\treturn nil\n\t\t}\n\n\t\tif !announced {\n\t\t\tannounced = true\n\t\t\tmsg.Info(\"Waiting on Glide global cache access\")\n\t\t}\n\n\t\t// Check on the lock file every second.\n\t\ttime.Sleep(time.Second)\n\t}\n}\n"
  },
  {
    "path": "cache/memory.go",
    "content": "package cache\n\nimport (\n\t\"sync\"\n\n\t\"github.com/Masterminds/glide/msg\"\n\t\"github.com/Masterminds/semver\"\n)\n\n// Provide an in memory cache of imported project information.\n\nvar defaultMemCache = newMemCache()\n\n// MemPut put a version into the in memory cache for a name.\n// This will silently ignore non-semver and make sure the latest\n// is stored.\nfunc MemPut(name, version string) {\n\tdefaultMemCache.put(name, version)\n}\n\n// MemTouched returns true if the cache was touched for a name.\nfunc MemTouched(name string) bool {\n\treturn defaultMemCache.touched(name)\n}\n\n// MemTouch notes if a name has been looked at.\nfunc MemTouch(name string) {\n\tdefaultMemCache.touch(name)\n}\n\n// MemLatest returns the latest, that is most recent, semver release. This\n// may be a blank string if no put value\nfunc MemLatest(name string) string {\n\treturn defaultMemCache.getLatest(name)\n}\n\n// MemSetCurrent is used to set the current version in use.\nfunc MemSetCurrent(name, version string) {\n\tdefaultMemCache.setCurrent(name, version)\n}\n\n// MemCurrent is used to get the current version in use.\nfunc MemCurrent(name string) string {\n\treturn defaultMemCache.current(name)\n}\n\n// An in memory cache.\ntype memCache struct {\n\tsync.RWMutex\n\tlatest   map[string]string\n\tt        map[string]bool\n\tversions map[string][]string\n\tc        map[string]string\n}\n\nfunc newMemCache() *memCache {\n\treturn &memCache{\n\t\tlatest:   make(map[string]string),\n\t\tt:        make(map[string]bool),\n\t\tversions: make(map[string][]string),\n\t\tc:        make(map[string]string),\n\t}\n}\n\nfunc (m *memCache) setCurrent(name, version string) {\n\tm.Lock()\n\tdefer m.Unlock()\n\n\tif m.c[name] == \"\" {\n\t\tm.c[name] = version\n\t} else {\n\t\t// If we already have a version try to see if the new or old one is\n\t\t// semver and use that one.\n\t\t_, err := semver.NewVersion(m.c[name])\n\t\tif err != nil {\n\t\t\t_, err2 := semver.NewVersion(version)\n\t\t\tif err2 == nil {\n\t\t\t\tm.c[name] = version\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc (m *memCache) current(name string) string {\n\tm.RLock()\n\tdefer m.RUnlock()\n\treturn m.c[name]\n}\n\nfunc (m *memCache) put(name, version string) {\n\tm.Lock()\n\tdefer m.Unlock()\n\tm.t[name] = true\n\tsv, err := semver.NewVersion(version)\n\tif err != nil {\n\t\tmsg.Debug(\"Ignoring %s version %s: %s\", name, version, err)\n\t\treturn\n\t}\n\n\tlatest, found := m.latest[name]\n\tif found {\n\t\tlv, err := semver.NewVersion(latest)\n\t\tif err == nil {\n\t\t\tif sv.GreaterThan(lv) {\n\t\t\t\tm.latest[name] = version\n\t\t\t}\n\t\t}\n\t} else {\n\t\tm.latest[name] = version\n\t}\n\n\tfound = false\n\tfor _, v := range m.versions[name] {\n\t\tif v == version {\n\t\t\tfound = true\n\t\t}\n\t}\n\tif !found {\n\t\tm.versions[name] = append(m.versions[name], version)\n\t}\n}\n\nfunc (m *memCache) touch(name string) {\n\tm.Lock()\n\tdefer m.Unlock()\n\tm.t[name] = true\n}\n\nfunc (m *memCache) touched(name string) bool {\n\tm.RLock()\n\tdefer m.RUnlock()\n\treturn m.t[name]\n}\n\nfunc (m *memCache) getLatest(name string) string {\n\tm.RLock()\n\tdefer m.RUnlock()\n\treturn m.latest[name]\n}\n"
  },
  {
    "path": "cfg/cfg.go",
    "content": "// Package cfg handles working with the Glide configuration files.\n//\n// The cfg package contains the ability to parse (unmarshal) and write (marshal)\n// glide.yaml and glide.lock files. These files contains the details about\n// projects managed by Glide.\n//\n// To convert yaml into a cfg.Config instance use the cfg.ConfigFromYaml function.\n// The yaml, typically in a glide.yaml file, has the following structure.\n//\n//     package: github.com/Masterminds/glide\n//     homepage: https://masterminds.github.io/glide\n//     license: MIT\n//     owners:\n//     - name: Matt Butcher\n//       email: technosophos@gmail.com\n//       homepage: http://technosophos.com\n//     - name: Matt Farina\n//       email: matt@mattfarina.com\n//       homepage: https://www.mattfarina.com\n//     ignore:\n//     - appengine\n//     excludeDirs:\n//     - node_modules\n//     import:\n//     - package: gopkg.in/yaml.v2\n//     - package: github.com/Masterminds/vcs\n//       version: ^1.2.0\n//       repo:    git@github.com:Masterminds/vcs\n//       vcs:     git\n//     - package: github.com/codegangsta/cli\n//     - package: github.com/Masterminds/semver\n//       version: ^1.0.0\n//\n// These elements are:\n//\n//    - package: The top level package is the location in the GOPATH. This is used\n//      for things such as making sure an import isn't also importing the top level\n//      package.\n//    - homepage: To find the place where you can find details about the package or\n//      applications. For example, http://k8s.io\n//    - license: The license is either an SPDX license string or the filepath to the\n//      license. This allows automation and consumers to easily identify the license.\n//    - owners: The owners is a list of one or more owners for the project. This\n//      can be a person or organization and is useful for things like notifying the\n//      owners of a security issue without filing a public bug.\n//    - ignore: A list of packages for Glide to ignore importing. These are package\n//      names to ignore rather than directories.\n//    - excludeDirs: A list of directories in the local codebase to exclude from\n//      scanning for dependencies.\n//    - import: A list of packages to import. Each package can include:\n//        - package: The name of the package to import and the only non-optional item.\n//        - version: A semantic version, semantic version range, branch, tag, or\n//          commit id to use.\n//        - repo: If the package name isn't the repo location or this is a private\n//          repository it can go here. The package will be checked out from the\n//          repo and put where the package name specifies. This allows using forks.\n//        - vcs: A VCS to use such as git, hg, bzr, or svn. This is only needed\n//          when the type cannot be detected from the name. For example, a repo\n//          ending in .git or on GitHub can be detected to be Git. For a repo on\n//          Bitbucket we can contact the API to discover the type.\n//    - testImport: A list of development packages not already listed under import.\n//      Each package has the same details as those listed under import.\npackage cfg\n"
  },
  {
    "path": "cfg/config.go",
    "content": "package cfg\n\nimport (\n\t\"crypto/sha256\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"reflect\"\n\t\"sort\"\n\t\"strings\"\n\n\t\"github.com/Masterminds/glide/mirrors\"\n\t\"github.com/Masterminds/glide/util\"\n\t\"github.com/Masterminds/vcs\"\n\t\"gopkg.in/yaml.v2\"\n)\n\n// Config is the top-level configuration object.\ntype Config struct {\n\n\t// Name is the name of the package or application.\n\tName string `yaml:\"package\"`\n\n\t// Description is a short description for a package, application, or library.\n\t// This description is similar but different to a Go package description as\n\t// it is for marketing and presentation purposes rather than technical ones.\n\tDescription string `json:\"description,omitempty\"`\n\n\t// Home is a url to a website for the package.\n\tHome string `yaml:\"homepage,omitempty\"`\n\n\t// License provides either a SPDX license or a path to a file containing\n\t// the license. For more information on SPDX see http://spdx.org/licenses/.\n\t// When more than one license an SPDX expression can be used.\n\tLicense string `yaml:\"license,omitempty\"`\n\n\t// Owners is an array of owners for a project. See the Owner type for\n\t// more detail. These can be one or more people, companies, or other\n\t// organizations.\n\tOwners Owners `yaml:\"owners,omitempty\"`\n\n\t// Ignore contains a list of packages to ignore fetching. This is useful\n\t// when walking the package tree (including packages of packages) to list\n\t// those to skip.\n\tIgnore []string `yaml:\"ignore,omitempty\"`\n\n\t// Exclude contains a list of directories in the local application to\n\t// exclude from scanning for dependencies.\n\tExclude []string `yaml:\"excludeDirs,omitempty\"`\n\n\t// Imports contains a list of all non-development imports for a project. For\n\t// more detail on how these are captured see the Dependency type.\n\tImports Dependencies `yaml:\"import\"`\n\n\t// DevImports contains the test or other development imports for a project.\n\t// See the Dependency type for more details on how this is recorded.\n\tDevImports Dependencies `yaml:\"testImport,omitempty\"`\n}\n\n// A transitive representation of a dependency for importing and exporting to yaml.\ntype cf struct {\n\tName        string       `yaml:\"package\"`\n\tDescription string       `yaml:\"description,omitempty\"`\n\tHome        string       `yaml:\"homepage,omitempty\"`\n\tLicense     string       `yaml:\"license,omitempty\"`\n\tOwners      Owners       `yaml:\"owners,omitempty\"`\n\tIgnore      []string     `yaml:\"ignore,omitempty\"`\n\tExclude     []string     `yaml:\"excludeDirs,omitempty\"`\n\tImports     Dependencies `yaml:\"import\"`\n\tDevImports  Dependencies `yaml:\"testImport,omitempty\"`\n}\n\n// ConfigFromYaml returns an instance of Config from YAML\nfunc ConfigFromYaml(yml []byte) (*Config, error) {\n\tcfg := &Config{}\n\terr := yaml.Unmarshal([]byte(yml), &cfg)\n\treturn cfg, err\n}\n\n// Marshal converts a Config instance to YAML\nfunc (c *Config) Marshal() ([]byte, error) {\n\tyml, err := yaml.Marshal(&c)\n\tif err != nil {\n\t\treturn []byte{}, err\n\t}\n\treturn yml, nil\n}\n\n// UnmarshalYAML is a hook for gopkg.in/yaml.v2 in the unmarshalling process\nfunc (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {\n\tnewConfig := &cf{}\n\tif err := unmarshal(&newConfig); err != nil {\n\t\treturn err\n\t}\n\tc.Name = newConfig.Name\n\tc.Description = newConfig.Description\n\tc.Home = newConfig.Home\n\tc.License = newConfig.License\n\tc.Owners = newConfig.Owners\n\tc.Ignore = newConfig.Ignore\n\tc.Exclude = newConfig.Exclude\n\tc.Imports = newConfig.Imports\n\tc.DevImports = newConfig.DevImports\n\n\t// Cleanup the Config object now that we have it.\n\terr := c.DeDupe()\n\n\treturn err\n}\n\n// MarshalYAML is a hook for gopkg.in/yaml.v2 in the marshaling process\nfunc (c *Config) MarshalYAML() (interface{}, error) {\n\tnewConfig := &cf{\n\t\tName:        c.Name,\n\t\tDescription: c.Description,\n\t\tHome:        c.Home,\n\t\tLicense:     c.License,\n\t\tOwners:      c.Owners,\n\t\tIgnore:      c.Ignore,\n\t\tExclude:     c.Exclude,\n\t}\n\ti, err := c.Imports.Clone().DeDupe()\n\tif err != nil {\n\t\treturn newConfig, err\n\t}\n\n\tdi, err := c.DevImports.Clone().DeDupe()\n\tif err != nil {\n\t\treturn newConfig, err\n\t}\n\n\tnewConfig.Imports = i\n\tnewConfig.DevImports = di\n\n\treturn newConfig, nil\n}\n\n// HasDependency returns true if the given name is listed as an import or dev import.\nfunc (c *Config) HasDependency(name string) bool {\n\tfor _, d := range c.Imports {\n\t\tif d.Name == name {\n\t\t\treturn true\n\t\t}\n\t}\n\tfor _, d := range c.DevImports {\n\t\tif d.Name == name {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\n// HasIgnore returns true if the given name is listed on the ignore list.\nfunc (c *Config) HasIgnore(name string) bool {\n\tfor _, v := range c.Ignore {\n\n\t\t// Check for both a name and to make sure sub-packages are ignored as\n\t\t// well.\n\t\tif v == name || strings.HasPrefix(name, v+\"/\") {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n// HasExclude returns true if the given name is listed on the exclude list.\nfunc (c *Config) HasExclude(ex string) bool {\n\tep := normalizeSlash(ex)\n\tfor _, v := range c.Exclude {\n\t\tif vp := normalizeSlash(v); vp == ep {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n// Clone performs a deep clone of the Config instance\nfunc (c *Config) Clone() *Config {\n\tn := &Config{}\n\tn.Name = c.Name\n\tn.Description = c.Description\n\tn.Home = c.Home\n\tn.License = c.License\n\tn.Owners = c.Owners.Clone()\n\tn.Ignore = c.Ignore\n\tn.Exclude = c.Exclude\n\tn.Imports = c.Imports.Clone()\n\tn.DevImports = c.DevImports.Clone()\n\treturn n\n}\n\n// WriteFile writes a Glide YAML file.\n//\n// This is a convenience function that marshals the YAML and then writes it to\n// the given file. If the file exists, it will be clobbered.\nfunc (c *Config) WriteFile(glidepath string) error {\n\to, err := c.Marshal()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ioutil.WriteFile(glidepath, o, 0666)\n}\n\n// DeDupe consolidates duplicate dependencies on a Config instance\nfunc (c *Config) DeDupe() error {\n\n\t// Remove duplicates in the imports\n\tvar err error\n\tc.Imports, err = c.Imports.DeDupe()\n\tif err != nil {\n\t\treturn err\n\t}\n\tc.DevImports, err = c.DevImports.DeDupe()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// If the name on the config object is part of the imports remove it.\n\tfound := -1\n\tfor i, dep := range c.Imports {\n\t\tif dep.Name == c.Name {\n\t\t\tfound = i\n\t\t}\n\t}\n\tif found >= 0 {\n\t\tc.Imports = append(c.Imports[:found], c.Imports[found+1:]...)\n\t}\n\n\tfound = -1\n\tfor i, dep := range c.DevImports {\n\t\tif dep.Name == c.Name {\n\t\t\tfound = i\n\t\t}\n\t}\n\tif found >= 0 {\n\t\tc.DevImports = append(c.DevImports[:found], c.DevImports[found+1:]...)\n\t}\n\n\t// If something is on the ignore list remove it from the imports.\n\tfor _, v := range c.Ignore {\n\t\tfound = -1\n\t\tfor k, d := range c.Imports {\n\t\t\tif v == d.Name {\n\t\t\t\tfound = k\n\t\t\t}\n\t\t}\n\t\tif found >= 0 {\n\t\t\tc.Imports = append(c.Imports[:found], c.Imports[found+1:]...)\n\t\t}\n\n\t\tfound = -1\n\t\tfor k, d := range c.DevImports {\n\t\t\tif v == d.Name {\n\t\t\t\tfound = k\n\t\t\t}\n\t\t}\n\t\tif found >= 0 {\n\t\t\tc.DevImports = append(c.DevImports[:found], c.DevImports[found+1:]...)\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// AddImport appends dependencies to the import list, deduplicating as we go.\nfunc (c *Config) AddImport(deps ...*Dependency) error {\n\tt := c.Imports\n\tt = append(t, deps...)\n\tt, err := t.DeDupe()\n\tif err != nil {\n\t\treturn err\n\t}\n\tc.Imports = t\n\treturn nil\n}\n\n// Hash generates a sha256 hash for a given Config\nfunc (c *Config) Hash() (string, error) {\n\tyml, err := c.Marshal()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\thash := sha256.New()\n\thash.Write(yml)\n\treturn fmt.Sprintf(\"%x\", hash.Sum(nil)), nil\n}\n\n// Dependencies is a collection of Dependency\ntype Dependencies []*Dependency\n\n// Get a dependency by name\nfunc (d Dependencies) Get(name string) *Dependency {\n\tfor _, dep := range d {\n\t\tif dep.Name == name {\n\t\t\treturn dep\n\t\t}\n\t}\n\treturn nil\n}\n\n// Has checks if a dependency is on a list of dependencies such as import or testImport\nfunc (d Dependencies) Has(name string) bool {\n\tfor _, dep := range d {\n\t\tif dep.Name == name {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\n// Remove removes a dependency from a list of dependencies\nfunc (d Dependencies) Remove(name string) Dependencies {\n\tfound := -1\n\tfor i, dep := range d {\n\t\tif dep.Name == name {\n\t\t\tfound = i\n\t\t}\n\t}\n\n\tif found >= 0 {\n\t\tcopy(d[found:], d[found+1:])\n\t\td[len(d)-1] = nil\n\t\treturn d[:len(d)-1]\n\t}\n\treturn d\n}\n\n// Clone performs a deep clone of Dependencies\nfunc (d Dependencies) Clone() Dependencies {\n\tn := make(Dependencies, 0, len(d))\n\tfor _, v := range d {\n\t\tn = append(n, v.Clone())\n\t}\n\treturn n\n}\n\n// DeDupe cleans up duplicates on a list of dependencies.\nfunc (d Dependencies) DeDupe() (Dependencies, error) {\n\tchecked := map[string]int{}\n\timports := make(Dependencies, 0, 1)\n\ti := 0\n\tfor _, dep := range d {\n\t\t// The first time we encounter a dependency add it to the list\n\t\tif val, ok := checked[dep.Name]; !ok {\n\t\t\tchecked[dep.Name] = i\n\t\t\timports = append(imports, dep)\n\t\t\ti++\n\t\t} else {\n\t\t\t// In here we've encountered a dependency for the second time.\n\t\t\t// Make sure the details are the same or return an error.\n\t\t\tv := imports[val]\n\t\t\tif dep.Reference != v.Reference {\n\t\t\t\treturn d, fmt.Errorf(\"Import %s repeated with different versions '%s' and '%s'\", dep.Name, dep.Reference, v.Reference)\n\t\t\t}\n\t\t\tif dep.Repository != v.Repository || dep.VcsType != v.VcsType {\n\t\t\t\treturn d, fmt.Errorf(\"Import %s repeated with different Repository details\", dep.Name)\n\t\t\t}\n\t\t\tif !reflect.DeepEqual(dep.Os, v.Os) || !reflect.DeepEqual(dep.Arch, v.Arch) {\n\t\t\t\treturn d, fmt.Errorf(\"Import %s repeated with different OS or Architecture filtering\", dep.Name)\n\t\t\t}\n\t\t\timports[checked[dep.Name]].Subpackages = stringArrayDeDupe(v.Subpackages, dep.Subpackages...)\n\t\t}\n\t}\n\n\treturn imports, nil\n}\n\n// Dependency describes a package that the present package depends upon.\ntype Dependency struct {\n\tName        string   `yaml:\"package\"`\n\tReference   string   `yaml:\"version,omitempty\"`\n\tPin         string   `yaml:\"-\"`\n\tRepository  string   `yaml:\"repo,omitempty\"`\n\tVcsType     string   `yaml:\"vcs,omitempty\"`\n\tSubpackages []string `yaml:\"subpackages,omitempty\"`\n\tArch        []string `yaml:\"arch,omitempty\"`\n\tOs          []string `yaml:\"os,omitempty\"`\n}\n\n// A transitive representation of a dependency for importing and exploting to yaml.\ntype dep struct {\n\tName        string   `yaml:\"package\"`\n\tReference   string   `yaml:\"version,omitempty\"`\n\tRef         string   `yaml:\"ref,omitempty\"`\n\tRepository  string   `yaml:\"repo,omitempty\"`\n\tVcsType     string   `yaml:\"vcs,omitempty\"`\n\tSubpackages []string `yaml:\"subpackages,omitempty\"`\n\tArch        []string `yaml:\"arch,omitempty\"`\n\tOs          []string `yaml:\"os,omitempty\"`\n}\n\n// DependencyFromLock converts a Lock to a Dependency\nfunc DependencyFromLock(lock *Lock) *Dependency {\n\treturn &Dependency{\n\t\tName:        lock.Name,\n\t\tReference:   lock.Version,\n\t\tRepository:  lock.Repository,\n\t\tVcsType:     lock.VcsType,\n\t\tSubpackages: lock.Subpackages,\n\t\tArch:        lock.Arch,\n\t\tOs:          lock.Os,\n\t}\n}\n\n// UnmarshalYAML is a hook for gopkg.in/yaml.v2 in the unmarshaling process\nfunc (d *Dependency) UnmarshalYAML(unmarshal func(interface{}) error) error {\n\tnewDep := &dep{}\n\terr := unmarshal(&newDep)\n\tif err != nil {\n\t\treturn err\n\t}\n\td.Name = newDep.Name\n\td.Reference = newDep.Reference\n\td.Repository = newDep.Repository\n\td.VcsType = newDep.VcsType\n\td.Subpackages = newDep.Subpackages\n\td.Arch = newDep.Arch\n\td.Os = newDep.Os\n\n\tif d.Reference == \"\" && newDep.Ref != \"\" {\n\t\td.Reference = newDep.Ref\n\t}\n\n\t// Make sure only legitimate VCS are listed.\n\td.VcsType = filterVcsType(d.VcsType)\n\n\t// Get the root name for the package\n\ttn, subpkg := util.NormalizeName(d.Name)\n\td.Name = tn\n\tif subpkg != \"\" {\n\t\td.Subpackages = append(d.Subpackages, subpkg)\n\t}\n\n\t// Older versions of Glide had a / prefix on subpackages in some cases.\n\t// Here that's cleaned up. Someday we should be able to remove this.\n\tfor k, v := range d.Subpackages {\n\t\td.Subpackages[k] = strings.TrimPrefix(v, \"/\")\n\t}\n\n\treturn nil\n}\n\n// MarshalYAML is a hook for gopkg.in/yaml.v2 in the marshaling process\nfunc (d *Dependency) MarshalYAML() (interface{}, error) {\n\n\t// Make sure we only write the correct vcs type to file\n\tt := filterVcsType(d.VcsType)\n\tnewDep := &dep{\n\t\tName:        d.Name,\n\t\tReference:   d.Reference,\n\t\tRepository:  d.Repository,\n\t\tVcsType:     t,\n\t\tSubpackages: d.Subpackages,\n\t\tArch:        d.Arch,\n\t\tOs:          d.Os,\n\t}\n\n\treturn newDep, nil\n}\n\n// Remote returns the remote location to fetch source from. This location is\n// the central place where mirrors can alter the location.\nfunc (d *Dependency) Remote() string {\n\tvar r string\n\n\tif d.Repository != \"\" {\n\t\tr = d.Repository\n\t} else {\n\t\tr = \"https://\" + d.Name\n\t}\n\n\tf, nr, _ := mirrors.Get(r)\n\tif f {\n\t\treturn nr\n\t}\n\n\treturn r\n}\n\n// Vcs returns the VCS type to fetch source from.\nfunc (d *Dependency) Vcs() string {\n\tvar r string\n\n\tif d.Repository != \"\" {\n\t\tr = d.Repository\n\t} else {\n\t\tr = \"https://\" + d.Name\n\t}\n\n\tf, _, nv := mirrors.Get(r)\n\tif f {\n\t\treturn nv\n\t}\n\n\treturn d.VcsType\n}\n\n// GetRepo retrieves a Masterminds/vcs repo object configured for the root\n// of the package being retrieved.\nfunc (d *Dependency) GetRepo(dest string) (vcs.Repo, error) {\n\n\t// The remote location is either the configured repo or the package\n\t// name as an https url.\n\tremote := d.Remote()\n\n\tVcsType := d.Vcs()\n\n\t// If the VCS type has a value we try that first.\n\tif len(VcsType) > 0 && VcsType != \"None\" {\n\t\tswitch vcs.Type(VcsType) {\n\t\tcase vcs.Git:\n\t\t\treturn vcs.NewGitRepo(remote, dest)\n\t\tcase vcs.Svn:\n\t\t\treturn vcs.NewSvnRepo(remote, dest)\n\t\tcase vcs.Hg:\n\t\t\treturn vcs.NewHgRepo(remote, dest)\n\t\tcase vcs.Bzr:\n\t\t\treturn vcs.NewBzrRepo(remote, dest)\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"Unknown VCS type %s set for %s\", VcsType, d.Name)\n\t\t}\n\t}\n\n\t// When no type set we try to autodetect.\n\treturn vcs.NewRepo(remote, dest)\n}\n\n// Clone creates a clone of a Dependency\nfunc (d *Dependency) Clone() *Dependency {\n\treturn &Dependency{\n\t\tName:        d.Name,\n\t\tReference:   d.Reference,\n\t\tPin:         d.Pin,\n\t\tRepository:  d.Repository,\n\t\tVcsType:     d.VcsType,\n\t\tSubpackages: d.Subpackages,\n\t\tArch:        d.Arch,\n\t\tOs:          d.Os,\n\t}\n}\n\n// HasSubpackage returns if the subpackage is present on the dependency\nfunc (d *Dependency) HasSubpackage(sub string) bool {\n\n\tfor _, v := range d.Subpackages {\n\t\tif sub == v {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n// Owners is a list of owners for a project.\ntype Owners []*Owner\n\n// Clone performs a deep clone of Owners\nfunc (o Owners) Clone() Owners {\n\tn := make(Owners, 0, 1)\n\tfor _, v := range o {\n\t\tn = append(n, v.Clone())\n\t}\n\treturn n\n}\n\n// Owner describes an owner of a package. This can be a person, company, or\n// other organization. This is useful if someone needs to contact the\n// owner of a package to address things like a security issue.\ntype Owner struct {\n\n\t// Name describes the name of an organization.\n\tName string `yaml:\"name,omitempty\"`\n\n\t// Email is an email address to reach the owner at.\n\tEmail string `yaml:\"email,omitempty\"`\n\n\t// Home is a url to a website for the owner.\n\tHome string `yaml:\"homepage,omitempty\"`\n}\n\n// Clone creates a clone of a Dependency\nfunc (o *Owner) Clone() *Owner {\n\treturn &Owner{\n\t\tName:  o.Name,\n\t\tEmail: o.Email,\n\t\tHome:  o.Home,\n\t}\n}\n\nfunc stringArrayDeDupe(s []string, items ...string) []string {\n\tfor _, item := range items {\n\t\texists := false\n\t\tfor _, v := range s {\n\t\t\tif v == item {\n\t\t\t\texists = true\n\t\t\t}\n\t\t}\n\t\tif !exists {\n\t\t\ts = append(s, item)\n\t\t}\n\t}\n\tsort.Strings(s)\n\treturn s\n}\n\nfunc filterVcsType(vcs string) string {\n\tswitch vcs {\n\tcase \"git\", \"hg\", \"bzr\", \"svn\":\n\t\treturn vcs\n\tcase \"mercurial\":\n\t\treturn \"hg\"\n\tcase \"bazaar\":\n\t\treturn \"bzr\"\n\tcase \"subversion\":\n\t\treturn \"svn\"\n\tdefault:\n\t\treturn \"\"\n\t}\n}\n\nfunc normalizeSlash(k string) string {\n\treturn strings.Replace(k, \"\\\\\", \"/\", -1)\n}\n"
  },
  {
    "path": "cfg/config_test.go",
    "content": "package cfg\n\nimport (\n\t\"testing\"\n\n\t\"gopkg.in/yaml.v2\"\n)\n\nvar yml = `\npackage: fake/testing\ndescription: foo bar baz\nhomepage: https://example.com\nlicense: MIT\nowners:\n- name: foo\n  email: bar@example.com\n  homepage: https://example.com\nimport:\n  - package: github.com/kylelemons/go-gypsy\n    subpackages:\n      - yaml\n  # Intentionally left spaces at end of next line.\n  - package: github.com/Masterminds/convert\n    repo: git@github.com:Masterminds/convert.git\n    vcs: git\n    ref: a9949121a2e2192ca92fa6dddfeaaa4a4412d955\n    subpackages:\n      - color\n      - nautical\n      - radial\n    os:\n      - linux\n    arch:\n      - i386\n      - arm\n  - package: github.com/Masterminds/structable\n  - package: github.com/Masterminds/cookoo/color\n  - package: github.com/Masterminds/cookoo/convert\n\ntestImport:\n  - package: github.com/kylelemons/go-gypsy\n`\n\nfunc TestManualConfigFromYaml(t *testing.T) {\n\tcfg := &Config{}\n\terr := yaml.Unmarshal([]byte(yml), &cfg)\n\tif err != nil {\n\t\tt.Errorf(\"Unable to Unmarshal config yaml\")\n\t}\n\n\tif cfg.Name != \"fake/testing\" {\n\t\tt.Errorf(\"Inaccurate name found %s\", cfg.Name)\n\t}\n\n\tif cfg.Description != \"foo bar baz\" {\n\t\tt.Errorf(\"Inaccurate description found %s\", cfg.Description)\n\t}\n\n\tif cfg.Home != \"https://example.com\" {\n\t\tt.Errorf(\"Inaccurate homepage found %s\", cfg.Home)\n\t}\n\n\tif cfg.License != \"MIT\" {\n\t\tt.Errorf(\"Inaccurate license found %s\", cfg.License)\n\t}\n\n\tfound := false\n\tfound2 := false\n\tfor _, i := range cfg.Imports {\n\t\tif i.Name == \"github.com/Masterminds/convert\" {\n\t\t\tfound = true\n\t\t\tref := \"a9949121a2e2192ca92fa6dddfeaaa4a4412d955\"\n\t\t\tif i.Reference != ref {\n\t\t\t\tt.Errorf(\"Config reference for cookoo is inaccurate. Expected '%s' found '%s'\", ref, i.Reference)\n\t\t\t}\n\t\t}\n\n\t\tif i.Name == \"github.com/Masterminds/cookoo\" {\n\t\t\tfound2 = true\n\t\t\tif i.Subpackages[0] != \"color\" {\n\t\t\t\tt.Error(\"Dependency separating package and subpackage not working\")\n\t\t\t}\n\t\t}\n\t}\n\tif !found {\n\t\tt.Error(\"Unable to find github.com/Masterminds/convert\")\n\t}\n\tif !found2 {\n\t\tt.Error(\"Unable to find github.com/Masterminds/cookoo\")\n\t}\n}\n\nfunc TestClone(t *testing.T) {\n\tcfg := &Config{}\n\terr := yaml.Unmarshal([]byte(yml), &cfg)\n\tif err != nil {\n\t\tt.Errorf(\"Unable to Unmarshal config yaml\")\n\t}\n\n\tcfg2 := cfg.Clone()\n\tif cfg2.Name != \"fake/testing\" {\n\t\tt.Error(\"Config cloning failed\")\n\t}\n\tif cfg2.License != \"MIT\" {\n\t\tt.Error(\"Config cloning failed to copy License\")\n\t}\n\tcfg.Name = \"foo\"\n\n\tif cfg.Name == cfg2.Name {\n\t\tt.Error(\"Cloning Config name failed\")\n\t}\n}\n\nfunc TestConfigFromYaml(t *testing.T) {\n\tc, err := ConfigFromYaml([]byte(yml))\n\tif err != nil {\n\t\tt.Error(\"ConfigFromYaml failed to parse yaml\")\n\t}\n\n\tif c.Name != \"fake/testing\" {\n\t\tt.Error(\"ConfigFromYaml failed to properly parse yaml\")\n\t}\n}\n\nfunc TestHasDependency(t *testing.T) {\n\tc, err := ConfigFromYaml([]byte(yml))\n\tif err != nil {\n\t\tt.Error(\"ConfigFromYaml failed to parse yaml for HasDependency\")\n\t}\n\n\tif c.HasDependency(\"github.com/Masterminds/convert\") != true {\n\t\tt.Error(\"HasDependency failing to pickup depenency\")\n\t}\n\n\tif c.HasDependency(\"foo/bar/bar\") != false {\n\t\tt.Error(\"HasDependency picking up dependency it shouldn't\")\n\t}\n}\n\nfunc TestOwners(t *testing.T) {\n\to := new(Owner)\n\to.Name = \"foo\"\n\to.Email = \"foo@example.com\"\n\to.Home = \"https://foo.example.com\"\n\n\to2 := o.Clone()\n\tif o2.Name != o.Name || o2.Email != o.Email || o2.Home != o.Home {\n\t\tt.Error(\"Unable to clone Owner\")\n\t}\n\n\to.Name = \"Bar\"\n\tif o.Name == o2.Name {\n\t\tt.Error(\"Owner clone is a pointer instead of a clone\")\n\t}\n\n\ts := make(Owners, 0, 1)\n\ts = append(s, o)\n\ts2 := s.Clone()\n\to3 := s2[0]\n\n\to3.Name = \"Qux\"\n\n\tif o3.Name == o.Name {\n\t\tt.Error(\"Owners cloning isn't deep\")\n\t}\n\n\tcfg := &Config{}\n\terr := yaml.Unmarshal([]byte(yml), &cfg)\n\tif err != nil {\n\t\tt.Errorf(\"Unable to Unmarshal config yaml\")\n\t}\n\n\tif cfg.Owners[0].Name != \"foo\" ||\n\t\tcfg.Owners[0].Email != \"bar@example.com\" ||\n\t\tcfg.Owners[0].Home != \"https://example.com\" {\n\t\tt.Error(\"Unable to parse owners from yaml\")\n\t}\n}\n"
  },
  {
    "path": "cfg/lock.go",
    "content": "package cfg\n\nimport (\n\t\"crypto/sha256\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"sort\"\n\t\"strings\"\n\t\"time\"\n\n\t\"gopkg.in/yaml.v2\"\n)\n\n// Lockfile represents a glide.lock file.\ntype Lockfile struct {\n\tHash       string    `yaml:\"hash\"`\n\tUpdated    time.Time `yaml:\"updated\"`\n\tImports    Locks     `yaml:\"imports\"`\n\tDevImports Locks     `yaml:\"testImports\"`\n}\n\n// LockfileFromYaml returns an instance of Lockfile from YAML\nfunc LockfileFromYaml(yml []byte) (*Lockfile, error) {\n\tlock := &Lockfile{}\n\terr := yaml.Unmarshal([]byte(yml), &lock)\n\treturn lock, err\n}\n\n// Marshal converts a Config instance to YAML\nfunc (lf *Lockfile) Marshal() ([]byte, error) {\n\tyml, err := yaml.Marshal(&lf)\n\tif err != nil {\n\t\treturn []byte{}, err\n\t}\n\treturn yml, nil\n}\n\n// MarshalYAML is a hook for gopkg.in/yaml.v2.\n// It sorts import subpackages lexicographically for reproducibility.\nfunc (lf *Lockfile) MarshalYAML() (interface{}, error) {\n\tfor _, imp := range lf.Imports {\n\t\tsort.Strings(imp.Subpackages)\n\t}\n\n\t// Ensure elements on testImport don't already exist on import.\n\tvar newDI Locks\n\tvar found bool\n\tfor _, imp := range lf.DevImports {\n\t\tfound = false\n\t\tfor i := 0; i < len(lf.Imports); i++ {\n\t\t\tif lf.Imports[i].Name == imp.Name {\n\t\t\t\tfound = true\n\t\t\t\tif lf.Imports[i].Version != imp.Version {\n\t\t\t\t\treturn lf, fmt.Errorf(\"Generating lock YAML produced conflicting versions of %s. import (%s), testImport (%s)\", imp.Name, lf.Imports[i].Version, imp.Version)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif !found {\n\t\t\tnewDI = append(newDI, imp)\n\t\t}\n\t}\n\tlf.DevImports = newDI\n\n\tfor _, imp := range lf.DevImports {\n\t\tsort.Strings(imp.Subpackages)\n\t}\n\treturn lf, nil\n}\n\n// WriteFile writes a Glide lock file.\n//\n// This is a convenience function that marshals the YAML and then writes it to\n// the given file. If the file exists, it will be clobbered.\nfunc (lf *Lockfile) WriteFile(lockpath string) error {\n\to, err := lf.Marshal()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ioutil.WriteFile(lockpath, o, 0666)\n}\n\n// Clone returns a clone of Lockfile\nfunc (lf *Lockfile) Clone() *Lockfile {\n\tn := &Lockfile{}\n\tn.Hash = lf.Hash\n\tn.Updated = lf.Updated\n\tn.Imports = lf.Imports.Clone()\n\tn.DevImports = lf.DevImports.Clone()\n\n\treturn n\n}\n\n// Fingerprint returns a hash of the contents minus the date. This allows for\n// two lockfiles to be compared irrespective of their updated times.\nfunc (lf *Lockfile) Fingerprint() ([32]byte, error) {\n\tc := lf.Clone()\n\tc.Updated = time.Time{} // Set the time to be the nil equivalent\n\tsort.Sort(c.Imports)\n\tsort.Sort(c.DevImports)\n\tyml, err := c.Marshal()\n\tif err != nil {\n\t\treturn [32]byte{}, err\n\t}\n\n\treturn sha256.Sum256(yml), nil\n}\n\n// ReadLockFile loads the contents of a glide.lock file.\nfunc ReadLockFile(lockpath string) (*Lockfile, error) {\n\tyml, err := ioutil.ReadFile(lockpath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlock, err := LockfileFromYaml(yml)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn lock, nil\n}\n\n// Locks is a slice of locked dependencies.\ntype Locks []*Lock\n\n// Clone returns a Clone of Locks.\nfunc (l Locks) Clone() Locks {\n\tn := make(Locks, 0, len(l))\n\tfor _, v := range l {\n\t\tn = append(n, v.Clone())\n\t}\n\treturn n\n}\n\n// Len returns the length of the Locks. This is needed for sorting with\n// the sort package.\nfunc (l Locks) Len() int {\n\treturn len(l)\n}\n\n// Less is needed for the sort interface. It compares two locks based on\n// their name.\nfunc (l Locks) Less(i, j int) bool {\n\n\t// Names are normalized to lowercase because case affects sorting order. For\n\t// example, Masterminds comes before kylelemons. Making them lowercase\n\t// causes kylelemons to come first which is what is expected.\n\treturn strings.ToLower(l[i].Name) < strings.ToLower(l[j].Name)\n}\n\n// Swap is needed for the sort interface. It swaps the position of two\n// locks.\nfunc (l Locks) Swap(i, j int) {\n\tl[i], l[j] = l[j], l[i]\n}\n\n// Lock represents an individual locked dependency.\ntype Lock struct {\n\tName        string   `yaml:\"name\"`\n\tVersion     string   `yaml:\"version\"`\n\tRepository  string   `yaml:\"repo,omitempty\"`\n\tVcsType     string   `yaml:\"vcs,omitempty\"`\n\tSubpackages []string `yaml:\"subpackages,omitempty\"`\n\tArch        []string `yaml:\"arch,omitempty\"`\n\tOs          []string `yaml:\"os,omitempty\"`\n}\n\n// Clone creates a clone of a Lock.\nfunc (l *Lock) Clone() *Lock {\n\treturn &Lock{\n\t\tName:        l.Name,\n\t\tVersion:     l.Version,\n\t\tRepository:  l.Repository,\n\t\tVcsType:     l.VcsType,\n\t\tSubpackages: l.Subpackages,\n\t\tArch:        l.Arch,\n\t\tOs:          l.Os,\n\t}\n}\n\n// LockFromDependency converts a Dependency to a Lock\nfunc LockFromDependency(dep *Dependency) *Lock {\n\treturn &Lock{\n\t\tName:        dep.Name,\n\t\tVersion:     dep.Pin,\n\t\tRepository:  dep.Repository,\n\t\tVcsType:     dep.VcsType,\n\t\tSubpackages: dep.Subpackages,\n\t\tArch:        dep.Arch,\n\t\tOs:          dep.Os,\n\t}\n}\n\n// NewLockfile is used to create an instance of Lockfile.\nfunc NewLockfile(ds, tds Dependencies, hash string) (*Lockfile, error) {\n\tlf := &Lockfile{\n\t\tHash:       hash,\n\t\tUpdated:    time.Now(),\n\t\tImports:    make([]*Lock, len(ds)),\n\t\tDevImports: make([]*Lock, 0),\n\t}\n\n\tfor i := 0; i < len(ds); i++ {\n\t\tlf.Imports[i] = LockFromDependency(ds[i])\n\t}\n\n\tsort.Sort(lf.Imports)\n\n\tvar found bool\n\tfor i := 0; i < len(tds); i++ {\n\t\tfound = false\n\t\tfor ii := 0; ii < len(ds); ii++ {\n\t\t\tif ds[ii].Name == tds[i].Name {\n\t\t\t\tfound = true\n\t\t\t\tif ds[ii].Reference != tds[i].Reference {\n\t\t\t\t\treturn &Lockfile{}, fmt.Errorf(\"Generating lock produced conflicting versions of %s. import (%s), testImport (%s)\", tds[i].Name, ds[ii].Reference, tds[i].Reference)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\tlf.DevImports = append(lf.DevImports, LockFromDependency(tds[i]))\n\t\t}\n\t}\n\n\tsort.Sort(lf.DevImports)\n\n\treturn lf, nil\n}\n\n// LockfileFromMap takes a map of dependencies and generates a lock Lockfile instance.\nfunc LockfileFromMap(ds map[string]*Dependency, hash string) *Lockfile {\n\tlf := &Lockfile{\n\t\tHash:    hash,\n\t\tUpdated: time.Now(),\n\t\tImports: make([]*Lock, len(ds)),\n\t}\n\n\ti := 0\n\tfor name, dep := range ds {\n\t\tlf.Imports[i] = LockFromDependency(dep)\n\t\tlf.Imports[i].Name = name\n\t\ti++\n\t}\n\n\tsort.Sort(lf.Imports)\n\n\treturn lf\n}\n"
  },
  {
    "path": "cfg/lock_test.go",
    "content": "package cfg\n\nimport (\n\t\"sort\"\n\t\"strings\"\n\t\"testing\"\n)\n\nfunc TestSortLocks(t *testing.T) {\n\tc, err := ConfigFromYaml([]byte(yml))\n\tif err != nil {\n\t\tt.Error(\"ConfigFromYaml failed to parse yaml for TestSortDependencies\")\n\t}\n\n\tls := make(Locks, len(c.Imports))\n\tfor i := 0; i < len(c.Imports); i++ {\n\t\tls[i] = &Lock{\n\t\t\tName:    c.Imports[i].Name,\n\t\t\tVersion: c.Imports[i].Reference,\n\t\t}\n\t}\n\n\tif ls[2].Name != \"github.com/Masterminds/structable\" {\n\t\tt.Error(\"Initial dependencies are out of order prior to sort\")\n\t}\n\n\tsort.Sort(ls)\n\n\tif ls[0].Name != \"github.com/kylelemons/go-gypsy\" ||\n\t\tls[1].Name != \"github.com/Masterminds/convert\" ||\n\t\tls[2].Name != \"github.com/Masterminds/cookoo\" ||\n\t\tls[3].Name != \"github.com/Masterminds/structable\" {\n\t\tt.Error(\"Sorting of dependencies failed\")\n\t}\n}\n\nconst inputSubpkgYaml = `\nimports:\n- name: github.com/gogo/protobuf\n  version: 82d16f734d6d871204a3feb1a73cb220cc92574c\n  subpackages:\n  - plugin/equal\n  - sortkeys\n  - plugin/face\n  - plugin/gostring\n  - vanity\n  - plugin/grpc\n  - plugin/marshalto\n  - plugin/populate\n  - plugin/oneofcheck\n  - plugin/size\n  - plugin/stringer\n  - plugin/defaultcheck\n  - plugin/embedcheck\n  - plugin/description\n  - plugin/enumstringer\n  - gogoproto\n  - plugin/testgen\n  - plugin/union\n  - plugin/unmarshal\n  - protoc-gen-gogo/generator\n  - protoc-gen-gogo/plugin\n  - vanity/command\n  - protoc-gen-gogo/descriptor\n  - proto\n`\nconst expectSubpkgYaml = `\nimports:\n- name: github.com/gogo/protobuf\n  version: 82d16f734d6d871204a3feb1a73cb220cc92574c\n  subpackages:\n  - gogoproto\n  - plugin/defaultcheck\n  - plugin/description\n  - plugin/embedcheck\n  - plugin/enumstringer\n  - plugin/equal\n  - plugin/face\n  - plugin/gostring\n  - plugin/grpc\n  - plugin/marshalto\n  - plugin/oneofcheck\n  - plugin/populate\n  - plugin/size\n  - plugin/stringer\n  - plugin/testgen\n  - plugin/union\n  - plugin/unmarshal\n  - proto\n  - protoc-gen-gogo/descriptor\n  - protoc-gen-gogo/generator\n  - protoc-gen-gogo/plugin\n  - sortkeys\n  - vanity\n  - vanity/command\n`\n\nfunc TestSortSubpackages(t *testing.T) {\n\tlf, err := LockfileFromYaml([]byte(inputSubpkgYaml))\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tout, err := lf.Marshal()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif !strings.Contains(string(out), expectSubpkgYaml) {\n\t\tt.Errorf(\"Expected %q\\n to contain\\n%q\", string(out), expectSubpkgYaml)\n\t}\n}\n"
  },
  {
    "path": "dependency/resolver.go",
    "content": "package dependency\n\nimport (\n\t\"container/list\"\n\t\"errors\"\n\t\"runtime\"\n\t\"sort\"\n\n\t//\"go/build\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/Masterminds/glide/cfg\"\n\t\"github.com/Masterminds/glide/msg\"\n\tgpath \"github.com/Masterminds/glide/path\"\n\t\"github.com/Masterminds/glide/util\"\n)\n\n// MissingPackageHandler handles the case where a package is missing during scanning.\n//\n// It returns true if the package can be passed to the resolver, false otherwise.\n// False may be returned even if error is nil.\ntype MissingPackageHandler interface {\n\t// NotFound is called when the Resolver fails to find a package with the given name.\n\t//\n\t// NotFound returns true when the resolver should attempt to re-resole the\n\t// dependency (e.g. when NotFound has gone and fetched the missing package).\n\t//\n\t// When NotFound returns false, the Resolver does not try to do any additional\n\t// work on the missing package.\n\t//\n\t// NotFound only returns errors when it fails to perform its internal goals.\n\t// When it returns false with no error, this indicates that the handler did\n\t// its job, but the resolver should not do any additional work on the\n\t// package.\n\tNotFound(pkg string, addTest bool) (bool, error)\n\n\t// OnGopath is called when the Resolver finds a dependency, but it's only on GOPATH.\n\t//\n\t// OnGopath provides an opportunity to copy, move, warn, or ignore cases like this.\n\t//\n\t// OnGopath returns true when the resolver should attempt to re-resolve the\n\t// dependency (e.g. when the dependency is copied to a new location).\n\t//\n\t// When OnGopath returns false, the Resolver does not try to do any additional\n\t// work on the package.\n\t//\n\t// An error indicates that OnGopath cannot complete its intended operation.\n\t// Not all false results are errors.\n\tOnGopath(pkg string, addTest bool) (bool, error)\n\n\t// InVendor is called when the Resolver finds a dependency in the vendor/ directory.\n\t//\n\t// This can be used update a project found in the vendor/ folder.\n\tInVendor(pkg string, addTest bool) error\n\n\t// PkgPath is called to find the location locally to scan. This gives the\n\t// handler to do things such as use a cached location.\n\tPkgPath(pkg string) string\n}\n\n// DefaultMissingPackageHandler is the default handler for missing packages.\n//\n// When asked to handle a missing package, it will report the miss as a warning,\n// and then store the package in the Missing slice for later access.\ntype DefaultMissingPackageHandler struct {\n\tMissing []string\n\tGopath  []string\n\tPrefix  string\n}\n\n// NotFound prints a warning and then stores the package name in Missing.\n//\n// It never returns an error, and it always returns false.\nfunc (d *DefaultMissingPackageHandler) NotFound(pkg string, addTest bool) (bool, error) {\n\tmsg.Warn(\"Package %s is not installed\", pkg)\n\td.Missing = append(d.Missing, pkg)\n\treturn false, nil\n}\n\n// OnGopath is run when a package is missing from vendor/ but found in the GOPATH\nfunc (d *DefaultMissingPackageHandler) OnGopath(pkg string, addTest bool) (bool, error) {\n\tmsg.Warn(\"Package %s is only on GOPATH.\", pkg)\n\td.Gopath = append(d.Gopath, pkg)\n\treturn false, nil\n}\n\n// InVendor is run when a package is found in the vendor/ folder\nfunc (d *DefaultMissingPackageHandler) InVendor(pkg string, addTest bool) error {\n\tmsg.Info(\"Package %s found in vendor/ folder\", pkg)\n\treturn nil\n}\n\n// PkgPath returns the path to the package\nfunc (d *DefaultMissingPackageHandler) PkgPath(pkg string) string {\n\tif d.Prefix != \"\" {\n\t\treturn filepath.Join(d.Prefix, pkg)\n\t}\n\treturn pkg\n}\n\n// VersionHandler sets the version for a package when found while scanning.\n//\n// When a package if found it needs to be on the correct version before\n// scanning its contents to be sure to pick up the right elements for that\n// version.\ntype VersionHandler interface {\n\n\t// Process provides an opportunity to process the codebase for version setting.\n\tProcess(pkg string) error\n\n\t// SetVersion sets the version for a package. An error is returned if there\n\t// was a problem setting the version.\n\tSetVersion(pkg string, testDep bool) error\n}\n\n// DefaultVersionHandler is the default handler for setting the version.\n//\n// The default handler leaves the current version and skips setting a version.\n// For a handler that alters the version see the handler included in the repo\n// package as part of the installer.\ntype DefaultVersionHandler struct{}\n\n// Process a package to aide in version setting.\nfunc (d *DefaultVersionHandler) Process(pkg string) error {\n\treturn nil\n}\n\n// SetVersion here sends a message when a package is found noting that it\n// did not set the version.\nfunc (d *DefaultVersionHandler) SetVersion(pkg string, testDep bool) error {\n\tmsg.Warn(\"Version not set for package %s\", pkg)\n\treturn nil\n}\n\n// Resolver resolves a dependency tree.\n//\n// It operates in two modes:\n// - local resolution (ResolveLocal) determines the dependencies of the local project.\n// - vendor resolving (Resolve, ResolveAll) determines the dependencies of vendored\n//   projects.\n//\n// Local resolution is for guessing initial dependencies. Vendor resolution is\n// for determining vendored dependencies.\ntype Resolver struct {\n\tHandler        MissingPackageHandler\n\tVersionHandler VersionHandler\n\tVendorDir      string\n\tBuildContext   *util.BuildCtxt\n\tConfig         *cfg.Config\n\n\t// ResolveAllFiles toggles deep scanning.\n\t// If this is true, resolve by scanning all files, not by walking the\n\t// import tree.\n\tResolveAllFiles bool\n\n\t// ResolveTest sets if test dependencies should be resolved.\n\tResolveTest bool\n\n\t// Items already in the queue.\n\talreadyQ map[string]bool\n\n\t// Attempts to scan that had unrecoverable error.\n\thadError map[string]bool\n\n\tbasedir string\n\tseen    map[string]bool\n\n\t// findCache caches hits from Find. This reduces the number of filesystem\n\t// touches that have to be done for dependency resolution.\n\tfindCache map[string]*PkgInfo\n}\n\n// NewResolver returns a new Resolver initialized with the DefaultMissingPackageHandler.\n//\n// This will return an error if the given path does not meet the basic criteria\n// for a Go source project. For example, basedir must have a vendor subdirectory.\n//\n// The BuildContext uses the \"go/build\".Default to resolve dependencies.\nfunc NewResolver(basedir string) (*Resolver, error) {\n\n\tvar err error\n\tbasedir, err = filepath.Abs(basedir)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbasedir, err = checkForBasedirSymlink(basedir)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvdir := filepath.Join(basedir, \"vendor\")\n\n\tbuildContext, err := util.GetBuildContext()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tr := &Resolver{\n\t\tHandler:        &DefaultMissingPackageHandler{Missing: []string{}, Gopath: []string{}},\n\t\tVersionHandler: &DefaultVersionHandler{},\n\t\tbasedir:        basedir,\n\t\tVendorDir:      vdir,\n\t\tBuildContext:   buildContext,\n\t\tseen:           map[string]bool{},\n\t\talreadyQ:       map[string]bool{},\n\t\thadError:       map[string]bool{},\n\t\tfindCache:      map[string]*PkgInfo{},\n\n\t\t// The config instance here should really be replaced with a real one.\n\t\tConfig: &cfg.Config{},\n\t}\n\n\t// TODO: Make sure the build context is correctly set up. Especially in\n\t// regards to GOROOT, which is not always set.\n\n\treturn r, nil\n}\n\n// Resolve takes a package name and returns all of the imported package names.\n//\n// If a package is not found, this calls the Fetcher. If the Fetcher returns\n// true, it will re-try traversing that package for dependencies. Otherwise it\n// will add that package to the deps array and continue on without trying it.\n// And if the Fetcher returns an error, this will stop resolution and return\n// the error.\n//\n// If basepath is set to $GOPATH, this will start from that package's root there.\n// If basepath is set to a project's vendor path, the scanning will begin from\n// there.\nfunc (r *Resolver) Resolve(pkg, basepath string) ([]string, error) {\n\ttarget := filepath.Join(basepath, filepath.FromSlash(pkg))\n\t//msg.Debug(\"Scanning %s\", target)\n\tl := list.New()\n\tl.PushBack(target)\n\n\t// In this mode, walk the entire tree.\n\tif r.ResolveAllFiles {\n\t\treturn r.resolveList(l, false, false)\n\t}\n\treturn r.resolveImports(l, false, false)\n}\n\n// dirHasPrefix tests whether the directory dir begins with prefix.\nfunc dirHasPrefix(dir, prefix string) bool {\n\tif runtime.GOOS != \"windows\" {\n\t\treturn strings.HasPrefix(dir, prefix)\n\t}\n\treturn len(dir) >= len(prefix) && strings.EqualFold(dir[:len(prefix)], prefix)\n}\n\n// ResolveLocal resolves dependencies for the current project.\n//\n// This begins with the project, builds up a list of external dependencies.\n//\n// If the deep flag is set to true, this will then resolve all of the dependencies\n// of the dependencies it has found. If not, it will return just the packages that\n// the base project relies upon.\nfunc (r *Resolver) ResolveLocal(deep bool) ([]string, []string, error) {\n\t// We build a list of local source to walk, then send this list\n\t// to resolveList.\n\tmsg.Debug(\"Resolving local dependencies\")\n\tl := list.New()\n\ttl := list.New()\n\talreadySeen := map[string]bool{}\n\ttalreadySeen := map[string]bool{}\n\terr := filepath.Walk(r.basedir, func(path string, fi os.FileInfo, err error) error {\n\t\tif err != nil && err != filepath.SkipDir {\n\t\t\treturn err\n\t\t}\n\t\tpt := strings.TrimPrefix(path, r.basedir+string(os.PathSeparator))\n\t\tpt = strings.TrimSuffix(pt, string(os.PathSeparator))\n\t\tif r.Config.HasExclude(pt) {\n\t\t\tmsg.Debug(\"Excluding %s\", pt)\n\t\t\treturn filepath.SkipDir\n\t\t}\n\t\tif !fi.IsDir() {\n\t\t\treturn nil\n\t\t}\n\t\tif !srcDir(fi) {\n\t\t\treturn filepath.SkipDir\n\t\t}\n\n\t\t// Scan for dependencies, and anything that's not part of the local\n\t\t// package gets added to the scan list.\n\t\tvar imps []string\n\t\tvar testImps []string\n\t\tp, err := r.BuildContext.ImportDir(path, 0)\n\t\tif err != nil {\n\t\t\tif strings.HasPrefix(err.Error(), \"no buildable Go source\") {\n\t\t\t\treturn nil\n\t\t\t} else if strings.HasPrefix(err.Error(), \"found packages \") {\n\t\t\t\t// If we got here it's because a package and multiple packages\n\t\t\t\t// declared. This is often because of an example with a package\n\t\t\t\t// or main but +build ignore as a build tag. In that case we\n\t\t\t\t// try to brute force the packages with a slower scan.\n\t\t\t\timps, testImps, err = IterativeScan(path)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\timps = p.Imports\n\t\t\ttestImps = dedupeStrings(p.TestImports, p.XTestImports)\n\t\t}\n\n\t\t// We are only looking for dependencies in vendor. No root, cgo, etc.\n\t\tfor _, imp := range imps {\n\t\t\tif r.Config.HasIgnore(imp) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif alreadySeen[imp] {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\talreadySeen[imp] = true\n\t\t\tinfo := r.FindPkg(imp)\n\t\t\tswitch info.Loc {\n\t\t\tcase LocUnknown, LocVendor:\n\t\t\t\tl.PushBack(filepath.Join(r.VendorDir, filepath.FromSlash(imp))) // Do we need a path on this?\n\t\t\tcase LocGopath:\n\t\t\t\tif !dirHasPrefix(info.Path, r.basedir) {\n\t\t\t\t\t// FIXME: This is a package outside of the project we're\n\t\t\t\t\t// scanning. It should really be on vendor. But we don't\n\t\t\t\t\t// want it to reference GOPATH. We want it to be detected\n\t\t\t\t\t// and moved.\n\t\t\t\t\tl.PushBack(filepath.Join(r.VendorDir, filepath.FromSlash(imp)))\n\t\t\t\t}\n\t\t\tcase LocRelative:\n\t\t\t\tif strings.HasPrefix(imp, \"./\"+gpath.VendorDir) {\n\t\t\t\t\tmsg.Warn(\"Go package resolving will resolve %s without the ./%s/ prefix\", imp, gpath.VendorDir)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif r.ResolveTest {\n\t\t\tfor _, imp := range testImps {\n\t\t\t\tif talreadySeen[imp] {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\ttalreadySeen[imp] = true\n\t\t\t\tinfo := r.FindPkg(imp)\n\t\t\t\tswitch info.Loc {\n\t\t\t\tcase LocUnknown, LocVendor:\n\t\t\t\t\ttl.PushBack(filepath.Join(r.VendorDir, filepath.FromSlash(imp))) // Do we need a path on this?\n\t\t\t\tcase LocGopath:\n\t\t\t\t\tif !dirHasPrefix(info.Path, r.basedir) {\n\t\t\t\t\t\t// FIXME: This is a package outside of the project we're\n\t\t\t\t\t\t// scanning. It should really be on vendor. But we don't\n\t\t\t\t\t\t// want it to reference GOPATH. We want it to be detected\n\t\t\t\t\t\t// and moved.\n\t\t\t\t\t\ttl.PushBack(filepath.Join(r.VendorDir, filepath.FromSlash(imp)))\n\t\t\t\t\t}\n\t\t\t\tcase LocRelative:\n\t\t\t\t\tif strings.HasPrefix(imp, \"./\"+gpath.VendorDir) {\n\t\t\t\t\t\tmsg.Warn(\"Go package resolving will resolve %s without the ./%s/ prefix\", imp, gpath.VendorDir)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\tmsg.Err(\"Failed to build an initial list of packages to scan: %s\", err)\n\t\treturn []string{}, []string{}, err\n\t}\n\n\tif deep {\n\t\tif r.ResolveAllFiles {\n\t\t\tre, err := r.resolveList(l, false, false)\n\t\t\tif err != nil {\n\t\t\t\treturn []string{}, []string{}, err\n\t\t\t}\n\t\t\ttre, err := r.resolveList(l, false, true)\n\t\t\treturn re, tre, err\n\t\t}\n\t\tre, err := r.resolveImports(l, false, false)\n\t\tif err != nil {\n\t\t\treturn []string{}, []string{}, err\n\t\t}\n\t\ttre, err := r.resolveImports(tl, true, true)\n\t\treturn re, tre, err\n\t}\n\n\t// If we're not doing a deep scan, we just convert the list into an\n\t// array and return.\n\tres := make([]string, 0, l.Len())\n\tfor e := l.Front(); e != nil; e = e.Next() {\n\t\tres = append(res, e.Value.(string))\n\t}\n\ttres := make([]string, 0, l.Len())\n\tif r.ResolveTest {\n\t\tfor e := tl.Front(); e != nil; e = e.Next() {\n\t\t\ttres = append(tres, e.Value.(string))\n\t\t}\n\t}\n\n\treturn res, tres, nil\n}\n\n// ResolveAll takes a list of packages and returns an inclusive list of all\n// vendored dependencies.\n//\n// While this will scan all of the source code it can find, it will only return\n// packages that were either explicitly passed in as deps, or were explicitly\n// imported by the code.\n//\n// Packages that are either CGO or on GOROOT are ignored. Packages that are\n// on GOPATH, but not vendored currently generate a warning.\n//\n// If one of the passed in packages does not exist in the vendor directory,\n// an error is returned.\nfunc (r *Resolver) ResolveAll(deps []*cfg.Dependency, addTest bool) ([]string, error) {\n\n\tqueue := sliceToQueue(deps, r.VendorDir)\n\n\tif r.ResolveAllFiles {\n\t\treturn r.resolveList(queue, false, addTest)\n\t}\n\treturn r.resolveImports(queue, false, addTest)\n}\n\n// Stripv strips the vendor/ prefix from vendored packages.\nfunc (r *Resolver) Stripv(str string) string {\n\treturn strings.TrimPrefix(str, r.VendorDir+string(os.PathSeparator))\n}\n\n// vpath adds an absolute vendor path.\nfunc (r *Resolver) vpath(str string) string {\n\treturn filepath.Join(r.basedir, \"vendor\", str)\n}\n\n// resolveImports takes a list of existing packages and resolves their imports.\n//\n// It returns a list of all of the packages that it can determine are required\n// for the given code to function.\n//\n// The expectation is that each item in the queue is an absolute path to a\n// vendored package. This attempts to read that package, and then find\n// its referenced packages. Those packages are then added to the list\n// to be scanned next.\n//\n// The resolver's handler is used in the cases where a package cannot be\n// located.\n//\n// testDeps specifies if the test dependencies should be resolved and addTest\n// specifies if the dependencies should be added to the Config.DevImports. This\n// is important because we may resolve normal dependencies of test deps and add\n// them to the DevImports list.\nfunc (r *Resolver) resolveImports(queue *list.List, testDeps, addTest bool) ([]string, error) {\n\tmsg.Debug(\"Resolving import path\")\n\n\t// When test deps passed in but not resolving return empty.\n\tif (testDeps || addTest) && !r.ResolveTest {\n\t\treturn []string{}, nil\n\t}\n\n\talreadySeen := make(map[string]bool, queue.Len())\n\n\tfor e := queue.Front(); e != nil; e = e.Next() {\n\t\tvdep := e.Value.(string)\n\t\tdep := r.Stripv(vdep)\n\t\t// Check if marked in the Q and then explicitly mark it. We want to know\n\t\t// if it had previously been marked and ensure it for the future.\n\n\t\tif alreadySeen[dep] {\n\t\t\tcontinue\n\t\t}\n\t\talreadySeen[dep] = true\n\n\t\t_, foundQ := r.alreadyQ[dep]\n\t\tr.alreadyQ[dep] = true\n\n\t\t// If we've already encountered an error processing this dependency\n\t\t// skip it.\n\t\t_, foundErr := r.hadError[dep]\n\t\tif foundErr {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Skip ignored packages\n\t\tif r.Config.HasIgnore(dep) {\n\t\t\tmsg.Debug(\"Ignoring: %s\", dep)\n\t\t\tcontinue\n\t\t}\n\t\tr.VersionHandler.Process(dep)\n\t\t// Here, we want to import the package and see what imports it has.\n\t\tmsg.Debug(\"Trying to open %s (%s)\", dep, r.Handler.PkgPath(dep))\n\t\tvar imps []string\n\t\tpkg, err := r.BuildContext.ImportDir(r.Handler.PkgPath(dep), 0)\n\t\tif err != nil && strings.HasPrefix(err.Error(), \"found packages \") {\n\t\t\t// If we got here it's because a package and multiple packages\n\t\t\t// declared. This is often because of an example with a package\n\t\t\t// or main but +build ignore as a build tag. In that case we\n\t\t\t// try to brute force the packages with a slower scan.\n\t\t\tmsg.Debug(\"Using Iterative Scanning for %s\", dep)\n\t\t\tif testDeps {\n\t\t\t\t_, imps, err = IterativeScan(r.Handler.PkgPath(dep))\n\t\t\t} else {\n\t\t\t\timps, _, err = IterativeScan(r.Handler.PkgPath(dep))\n\t\t\t}\n\n\t\t\tif err != nil {\n\t\t\t\tmsg.Err(\"Iterative scanning error %s: %s\", dep, err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t} else if err != nil {\n\t\t\terrStr := err.Error()\n\t\t\tmsg.Debug(\"ImportDir error on %s: %s\", r.Handler.PkgPath(dep), err)\n\t\t\tif strings.HasPrefix(errStr, \"no buildable Go source\") {\n\t\t\t\tmsg.Debug(\"No subpackages declared. Skipping %s.\", dep)\n\t\t\t\tcontinue\n\t\t\t} else if osDirNotFound(err, r.Handler.PkgPath(dep)) && !foundErr && !foundQ {\n\t\t\t\t// If the location doesn't exist, there hasn't already been an\n\t\t\t\t// error, it's not already been in the Q then try to fetch it.\n\t\t\t\t// When there's an error or it's already in the Q (it should be\n\t\t\t\t// fetched if it's marked in r.alreadyQ) we skip to make sure\n\t\t\t\t// not to get stuck in a recursion.\n\n\t\t\t\t// If the location doesn't exist try to fetch it.\n\t\t\t\tif ok, err2 := r.Handler.NotFound(dep, addTest); ok {\n\t\t\t\t\tr.alreadyQ[dep] = true\n\t\t\t\t\talreadySeen[dep] = false\n\n\t\t\t\t\t// By adding to the queue it will get reprocessed now that\n\t\t\t\t\t// it exists.\n\t\t\t\t\tqueue.PushBack(r.vpath(dep))\n\t\t\t\t\tr.VersionHandler.SetVersion(dep, addTest)\n\t\t\t\t} else if err2 != nil {\n\t\t\t\t\tr.hadError[dep] = true\n\t\t\t\t\tmsg.Err(\"Error looking for %s: %s\", dep, err2)\n\t\t\t\t} else {\n\t\t\t\t\tr.hadError[dep] = true\n\t\t\t\t\t// TODO (mpb): Should we toss this into a Handler to\n\t\t\t\t\t// see if this is on GOPATH and copy it?\n\t\t\t\t\tmsg.Info(\"Not found in vendor/: %s (1)\", dep)\n\t\t\t\t}\n\t\t\t} else if strings.Contains(errStr, \"no such file or directory\") {\n\t\t\t\tr.hadError[dep] = true\n\t\t\t\tmsg.Err(\"Error scanning %s: %s\", dep, err)\n\t\t\t\tmsg.Err(\"This error means the referenced package was not found.\")\n\t\t\t\tmsg.Err(\"Missing file or directory errors usually occur when multiple packages\")\n\t\t\t\tmsg.Err(\"share a common dependency and the first reference encountered by the scanner\")\n\t\t\t\tmsg.Err(\"sets the version to one that does not contain a subpackage needed required\")\n\t\t\t\tmsg.Err(\"by another package that uses the shared dependency. Try setting a\")\n\t\t\t\tmsg.Err(\"version in your glide.yaml that works for all packages that share this\")\n\t\t\t\tmsg.Err(\"dependency.\")\n\t\t\t} else {\n\t\t\t\tr.hadError[dep] = true\n\t\t\t\tmsg.Err(\"Error scanning %s: %s\", dep, err)\n\t\t\t}\n\t\t\tcontinue\n\t\t} else {\n\t\t\tif testDeps {\n\t\t\t\timps = dedupeStrings(pkg.TestImports, pkg.XTestImports)\n\t\t\t} else {\n\t\t\t\timps = pkg.Imports\n\t\t\t}\n\n\t\t}\n\n\t\t// Range over all of the identified imports and see which ones we\n\t\t// can locate.\n\t\tfor _, imp := range imps {\n\t\t\tif r.Config.HasIgnore(imp) {\n\t\t\t\tmsg.Debug(\"Ignoring: %s\", imp)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tpi := r.FindPkg(imp)\n\t\t\tif pi.Loc != LocCgo && pi.Loc != LocGoroot && pi.Loc != LocAppengine {\n\t\t\t\tmsg.Debug(\"Package %s imports %s\", dep, imp)\n\t\t\t}\n\t\t\tswitch pi.Loc {\n\t\t\tcase LocVendor:\n\t\t\t\tmsg.Debug(\"In vendor: %s\", imp)\n\t\t\t\tif _, ok := r.alreadyQ[imp]; !ok {\n\t\t\t\t\tmsg.Debug(\"Marking %s to be scanned.\", imp)\n\t\t\t\t\tr.alreadyQ[imp] = true\n\t\t\t\t\tqueue.PushBack(r.vpath(imp))\n\t\t\t\t\tif err := r.Handler.InVendor(imp, addTest); err == nil {\n\t\t\t\t\t\tr.VersionHandler.SetVersion(imp, addTest)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmsg.Warn(\"Error updating %s: %s\", imp, err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase LocUnknown:\n\t\t\t\tmsg.Debug(\"Missing %s. Trying to resolve.\", imp)\n\t\t\t\tif ok, err := r.Handler.NotFound(imp, addTest); ok {\n\t\t\t\t\tr.alreadyQ[imp] = true\n\t\t\t\t\tqueue.PushBack(r.vpath(imp))\n\t\t\t\t\tr.VersionHandler.SetVersion(imp, addTest)\n\t\t\t\t} else if err != nil {\n\t\t\t\t\tr.hadError[imp] = true\n\t\t\t\t\tmsg.Err(\"Error looking for %s: %s\", imp, err)\n\t\t\t\t} else {\n\t\t\t\t\tr.hadError[imp] = true\n\t\t\t\t\tmsg.Err(\"Not found: %s (2)\", imp)\n\t\t\t\t}\n\t\t\tcase LocGopath:\n\t\t\t\tmsg.Debug(\"Found on GOPATH, not vendor: %s\", imp)\n\t\t\t\tif _, ok := r.alreadyQ[imp]; !ok {\n\t\t\t\t\t// Only scan it if it gets moved into vendor/\n\t\t\t\t\tif ok, _ := r.Handler.OnGopath(imp, addTest); ok {\n\t\t\t\t\t\tr.alreadyQ[imp] = true\n\t\t\t\t\t\tqueue.PushBack(r.vpath(imp))\n\t\t\t\t\t\tr.VersionHandler.SetVersion(imp, addTest)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(r.hadError) > 0 {\n\t\t// Errors occurred so we return.\n\t\treturn []string{}, errors.New(\"Error resolving imports\")\n\t}\n\n\t// FIXME: From here to the end is a straight copy of the resolveList() func.\n\tres := make([]string, 0, queue.Len())\n\n\t// In addition to generating a list\n\tfor e := queue.Front(); e != nil; e = e.Next() {\n\t\tt := r.Stripv(e.Value.(string))\n\t\troot, sp := util.NormalizeName(t)\n\n\t\tif root == r.Config.Name {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Skip ignored packages\n\t\tif r.Config.HasIgnore(e.Value.(string)) {\n\t\t\tmsg.Debug(\"Ignoring: %s\", e.Value.(string))\n\t\t\tcontinue\n\t\t}\n\n\t\t// TODO(mattfarina): Need to eventually support devImport\n\t\texisting := r.Config.Imports.Get(root)\n\t\tif existing == nil && addTest {\n\t\t\texisting = r.Config.DevImports.Get(root)\n\t\t}\n\t\tif existing != nil {\n\t\t\tif sp != \"\" && !existing.HasSubpackage(sp) {\n\t\t\t\texisting.Subpackages = append(existing.Subpackages, sp)\n\t\t\t}\n\t\t} else {\n\t\t\tnewDep := &cfg.Dependency{\n\t\t\t\tName: root,\n\t\t\t}\n\t\t\tif sp != \"\" {\n\t\t\t\tnewDep.Subpackages = []string{sp}\n\t\t\t}\n\n\t\t\tif addTest {\n\t\t\t\tr.Config.DevImports = append(r.Config.DevImports, newDep)\n\t\t\t} else {\n\t\t\t\tr.Config.Imports = append(r.Config.Imports, newDep)\n\t\t\t}\n\t\t}\n\t\tres = append(res, t)\n\t}\n\n\treturn res, nil\n}\n\n// resolveList takes a list and resolves it.\n//\n// This walks the entire file tree for the given dependencies, not just the\n// parts that are imported directly. Using this will discover dependencies\n// regardless of OS, and arch.\nfunc (r *Resolver) resolveList(queue *list.List, testDeps, addTest bool) ([]string, error) {\n\t// When test deps passed in but not resolving return empty.\n\tif testDeps && !r.ResolveTest {\n\t\treturn []string{}, nil\n\t}\n\n\tvar failedDep string\n\tvar failedDepPath string\n\tvar pkgPath string\n\tfor e := queue.Front(); e != nil; e = e.Next() {\n\t\tdep := e.Value.(string)\n\t\tt := strings.TrimPrefix(dep, r.VendorDir+string(os.PathSeparator))\n\t\tif r.Config.HasIgnore(t) {\n\t\t\tmsg.Debug(\"Ignoring: %s\", t)\n\t\t\tcontinue\n\t\t}\n\t\tr.VersionHandler.Process(t)\n\t\t//msg.Warn(\"#### %s ####\", dep)\n\t\t//msg.Info(\"Seen Count: %d\", len(r.seen))\n\t\t// Catch the outtermost dependency.\n\t\tpkgPath = r.Handler.PkgPath(t)\n\t\tfailedDep = t\n\t\tfailedDepPath = pkgPath\n\t\terr := filepath.Walk(pkgPath, func(path string, fi os.FileInfo, err error) error {\n\t\t\tif err != nil && err != filepath.SkipDir {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\t// Skip files.\n\t\t\tif !fi.IsDir() {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\t// Skip dirs that are not source.\n\t\t\tif !srcDir(fi) {\n\t\t\t\t//msg.Debug(\"Skip resource %s\", fi.Name())\n\t\t\t\treturn filepath.SkipDir\n\t\t\t}\n\n\t\t\t// Anything that comes through here has already been through\n\t\t\t// the queue.\n\t\t\tr.alreadyQ[path] = true\n\t\t\te := r.queueUnseen(path, queue, testDeps, addTest)\n\t\t\tif e != nil {\n\t\t\t\tfailedDepPath = path\n\t\t\t\t//msg.Err(\"Failed to fetch dependency %s: %s\", path, err)\n\t\t\t}\n\t\t\treturn e\n\t\t})\n\t\tif err != nil && err != filepath.SkipDir {\n\t\t\tmsg.Err(\"Dependency %s (%s) failed to resolve: %s.\", failedDep, failedDepPath, err)\n\t\t\treturn []string{}, err\n\t\t}\n\t}\n\n\tres := make([]string, 0, queue.Len())\n\n\t// In addition to generating a list\n\tfor e := queue.Front(); e != nil; e = e.Next() {\n\t\tt := strings.TrimPrefix(e.Value.(string), r.VendorDir+string(os.PathSeparator))\n\t\troot, sp := util.NormalizeName(t)\n\n\t\tif root == r.Config.Name {\n\t\t\tcontinue\n\t\t}\n\n\t\texisting := r.Config.Imports.Get(root)\n\t\tif existing == nil && addTest {\n\t\t\texisting = r.Config.DevImports.Get(root)\n\t\t}\n\n\t\tif existing != nil {\n\t\t\tif sp != \"\" && !existing.HasSubpackage(sp) {\n\t\t\t\texisting.Subpackages = append(existing.Subpackages, sp)\n\t\t\t}\n\t\t} else {\n\t\t\tnewDep := &cfg.Dependency{\n\t\t\t\tName: root,\n\t\t\t}\n\t\t\tif sp != \"\" {\n\t\t\t\tnewDep.Subpackages = []string{sp}\n\t\t\t}\n\n\t\t\tif addTest {\n\t\t\t\tr.Config.DevImports = append(r.Config.DevImports, newDep)\n\t\t\t} else {\n\t\t\t\tr.Config.Imports = append(r.Config.Imports, newDep)\n\t\t\t}\n\t\t}\n\t\tres = append(res, e.Value.(string))\n\t}\n\n\treturn res, nil\n}\n\n// queueUnseenImports scans a package's imports and adds any new ones to the\n// processing queue.\nfunc (r *Resolver) queueUnseen(pkg string, queue *list.List, testDeps, addTest bool) error {\n\t// A pkg is marked \"seen\" as soon as we have inspected it the first time.\n\t// Seen means that we have added all of its imports to the list.\n\n\t// Already queued indicates that we've either already put it into the queue\n\t// or intentionally not put it in the queue for fatal reasons (e.g. no\n\t// buildable source).\n\n\tdeps, err := r.imports(pkg, testDeps, addTest)\n\tif err != nil && !strings.HasPrefix(err.Error(), \"no buildable Go source\") {\n\t\tmsg.Err(\"Could not find %s: %s\", pkg, err)\n\t\treturn err\n\t\t// NOTE: If we uncomment this, we get lots of \"no buildable Go source\" errors,\n\t\t// which don't ever seem to be helpful. They don't actually indicate an error\n\t\t// condition, and it's perfectly okay to run into that condition.\n\t\t//} else if err != nil {\n\t\t//\tmsg.Warn(err.Error())\n\t}\n\n\tfor _, d := range deps {\n\t\tif _, ok := r.alreadyQ[d]; !ok {\n\t\t\tr.alreadyQ[d] = true\n\t\t\tqueue.PushBack(d)\n\t\t}\n\t}\n\treturn nil\n}\n\n// imports gets all of the imports for a given package.\n//\n// If the package is in GOROOT, this will return an empty list (but not\n// an error).\n// If it cannot resolve the pkg, it will return an error.\nfunc (r *Resolver) imports(pkg string, testDeps, addTest bool) ([]string, error) {\n\n\tif r.Config.HasIgnore(pkg) {\n\t\tmsg.Debug(\"Ignoring %s\", pkg)\n\t\treturn []string{}, nil\n\t}\n\n\t// If this pkg is marked seen, we don't scan it again.\n\tif _, ok := r.seen[pkg]; ok {\n\t\tmsg.Debug(\"Already saw %s\", pkg)\n\t\treturn []string{}, nil\n\t}\n\n\t// FIXME: On error this should try to NotFound to the dependency, and then import\n\t// it again.\n\tvar imps []string\n\tp, err := r.BuildContext.ImportDir(pkg, 0)\n\tif err != nil && strings.HasPrefix(err.Error(), \"found packages \") {\n\t\t// If we got here it's because a package and multiple packages\n\t\t// declared. This is often because of an example with a package\n\t\t// or main but +build ignore as a build tag. In that case we\n\t\t// try to brute force the packages with a slower scan.\n\t\tif testDeps {\n\t\t\t_, imps, err = IterativeScan(r.Handler.PkgPath(pkg))\n\t\t} else {\n\t\t\timps, _, err = IterativeScan(r.Handler.PkgPath(pkg))\n\t\t}\n\n\t\tif err != nil {\n\t\t\treturn []string{}, err\n\t\t}\n\t} else if err != nil {\n\t\treturn []string{}, err\n\t} else {\n\t\tif testDeps {\n\t\t\timps = dedupeStrings(p.TestImports, p.XTestImports)\n\t\t} else {\n\t\t\timps = p.Imports\n\t\t}\n\t}\n\n\t// It is okay to scan a package more than once. In some cases, this is\n\t// desirable because the package can change between scans (e.g. as a result\n\t// of a failed scan resolving the situation).\n\tmsg.Debug(\"=> Scanning %s (%s)\", p.ImportPath, pkg)\n\tr.seen[pkg] = true\n\n\t// Optimization: If it's in GOROOT, it has no imports worth scanning.\n\tif p.Goroot {\n\t\treturn []string{}, nil\n\t}\n\n\t// We are only looking for dependencies in vendor. No root, cgo, etc.\n\tbuf := []string{}\n\tfor _, imp := range imps {\n\t\tif r.Config.HasIgnore(imp) {\n\t\t\tmsg.Debug(\"Ignoring %s\", imp)\n\t\t\tcontinue\n\t\t}\n\t\tinfo := r.FindPkg(imp)\n\t\tswitch info.Loc {\n\t\tcase LocUnknown:\n\t\t\t// Do we resolve here?\n\t\t\tfound, err := r.Handler.NotFound(imp, addTest)\n\t\t\tif err != nil {\n\t\t\t\tmsg.Err(\"Failed to fetch %s: %s\", imp, err)\n\t\t\t}\n\t\t\tif found {\n\t\t\t\tbuf = append(buf, filepath.Join(r.VendorDir, filepath.FromSlash(imp)))\n\t\t\t\tr.VersionHandler.SetVersion(imp, addTest)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tr.seen[info.Path] = true\n\t\tcase LocVendor:\n\t\t\t//msg.Debug(\"Vendored: %s\", imp)\n\t\t\tbuf = append(buf, info.Path)\n\t\t\tif err := r.Handler.InVendor(imp, addTest); err == nil {\n\t\t\t\tr.VersionHandler.SetVersion(imp, addTest)\n\t\t\t} else {\n\t\t\t\tmsg.Warn(\"Error updating %s: %s\", imp, err)\n\t\t\t}\n\t\tcase LocGopath:\n\t\t\tfound, err := r.Handler.OnGopath(imp, addTest)\n\t\t\tif err != nil {\n\t\t\t\tmsg.Err(\"Failed to fetch %s: %s\", imp, err)\n\t\t\t}\n\t\t\t// If the Handler marks this as found, we drop it into the buffer\n\t\t\t// for subsequent processing. Otherwise, we assume that we're\n\t\t\t// in a less-than-perfect, but functional, situation.\n\t\t\tif found {\n\t\t\t\tbuf = append(buf, filepath.Join(r.VendorDir, filepath.FromSlash(imp)))\n\t\t\t\tr.VersionHandler.SetVersion(imp, addTest)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tmsg.Warn(\"Package %s is on GOPATH, but not vendored. Ignoring.\", imp)\n\t\t\tr.seen[info.Path] = true\n\t\tdefault:\n\t\t\t// Local packages are an odd case. CGO cannot be scanned.\n\t\t\tmsg.Debug(\"===> Skipping %s\", imp)\n\t\t}\n\t}\n\n\treturn buf, nil\n}\n\n// sliceToQueue is a special-purpose function for unwrapping a slice of\n// dependencies into a queue of fully qualified paths.\nfunc sliceToQueue(deps []*cfg.Dependency, basepath string) *list.List {\n\tl := list.New()\n\tfor _, e := range deps {\n\t\tif len(e.Subpackages) > 0 {\n\t\t\tfor _, v := range e.Subpackages {\n\t\t\t\tip := e.Name\n\t\t\t\tif v != \".\" && v != \"\" {\n\t\t\t\t\tip = ip + \"/\" + v\n\t\t\t\t}\n\t\t\t\tmsg.Debug(\"Adding local Import %s to queue\", ip)\n\t\t\t\tl.PushBack(filepath.Join(basepath, filepath.FromSlash(ip)))\n\t\t\t}\n\t\t} else {\n\t\t\tmsg.Debug(\"Adding local Import %s to queue\", e.Name)\n\t\t\tl.PushBack(filepath.Join(basepath, filepath.FromSlash(e.Name)))\n\t\t}\n\n\t}\n\treturn l\n}\n\n// PkgLoc describes the location of the package.\ntype PkgLoc uint8\n\nconst (\n\t// LocUnknown indicates the package location is unknown (probably not present)\n\tLocUnknown PkgLoc = iota\n\t// LocLocal inidcates that the package is in a local dir, not GOPATH or GOROOT.\n\tLocLocal\n\t// LocVendor indicates that the package is in a vendor/ dir\n\tLocVendor\n\t// LocGopath inidcates that the package is in GOPATH\n\tLocGopath\n\t// LocGoroot indicates that the package is in GOROOT\n\tLocGoroot\n\t// LocCgo indicates that the package is a a CGO package\n\tLocCgo\n\t// LocAppengine indicates the package is part of the appengine SDK. It's a\n\t// special build mode. https://blog.golang.org/the-app-engine-sdk-and-workspaces-gopath\n\t// Why does a Google product get a special case build mode with a local\n\t// package?\n\tLocAppengine\n\t// LocRelative indicates the package is a relative directory\n\tLocRelative\n)\n\n// PkgInfo represents metadata about a package found by the resolver.\ntype PkgInfo struct {\n\tName, Path string\n\tVendored   bool\n\tLoc        PkgLoc\n}\n\n// PackagesAddedToStdlib is the list of packages added to the go standard lib\n// at various points.\nvar PackagesAddedToStdlib = map[string]struct{}{\n\t// context and net/http/httptrace are packages being added to\n\t// the Go 1.7 standard library. Some packages, such as golang.org/x/net\n\t// are importing it with build flags in files for go1.7.\n\t\"context\":            struct{}{},\n\t\"net/http/httptrace\": struct{}{},\n\n\t// math.bits are packages being added to the Go 1.9 standard library.\n\t// Some packages, such as github.com/RoaringBitmap/roaring are importing\n\t// it with build flags in files for go1.9.\n\t\"math/bits\": struct{}{},\n\n\t// crypto/ed25519 is a package being added to the Go 1.13 standard library.\n\t// It is importing itself  with build flags in files for go1.13.\n\t\"crypto/ed25519\": struct{}{},\n}\n\n// FindPkg takes a package name and attempts to find it on the filesystem\n//\n// The resulting PkgInfo will indicate where it was found.\nfunc (r *Resolver) FindPkg(name string) *PkgInfo {\n\t// We cachae results for FindPkg to reduce the number of filesystem ops\n\t// that we have to do. This is a little risky because certain directories,\n\t// like GOPATH, can be modified while we're running an operation, and\n\t// render the cache inaccurate.\n\t//\n\t// Unfound items (LocUnknown) are never cached because we assume that as\n\t// part of the response, the Resolver may fetch that dependency.\n\tif i, ok := r.findCache[name]; ok {\n\t\t//msg.Info(\"Cache hit on %s\", name)\n\t\treturn i\n\t}\n\n\t// 502 individual packages scanned.\n\t// No cache:\n\t// glide -y etcd.yaml list  0.27s user 0.19s system 85% cpu 0.534 total\n\t// With cache:\n\t// glide -y etcd.yaml list  0.22s user 0.15s system 85% cpu 0.438 total\n\n\tvar p string\n\tinfo := &PkgInfo{\n\t\tName: name,\n\t}\n\n\tif strings.HasPrefix(name, \"./\") || strings.HasPrefix(name, \"../\") {\n\t\tinfo.Loc = LocRelative\n\t\tr.findCache[name] = info\n\t\treturn info\n\t}\n\n\t// Check _only_ if this dep is in the current vendor directory.\n\tp = filepath.Join(r.VendorDir, filepath.FromSlash(name))\n\tif pkgExists(p) {\n\t\tinfo.Path = p\n\t\tinfo.Loc = LocVendor\n\t\tinfo.Vendored = true\n\t\tr.findCache[name] = info\n\t\treturn info\n\t}\n\n\t// TODO: Do we need this if we always flatten?\n\t// Recurse backward to scan other vendor/ directories\n\t//for wd := cwd; wd != \"/\"; wd = filepath.Dir(wd) {\n\t//p = filepath.Join(wd, \"vendor\", filepath.FromSlash(name))\n\t//if fi, err = os.Stat(p); err == nil && (fi.IsDir() || isLink(fi)) {\n\t//info.Path = p\n\t//info.PType = ptypeVendor\n\t//info.Vendored = true\n\t//return info\n\t//}\n\t//}\n\n\t// Check $GOPATH\n\tfor _, rr := range filepath.SplitList(r.BuildContext.GOPATH) {\n\t\tp = filepath.Join(rr, \"src\", filepath.FromSlash(name))\n\t\tif pkgExists(p) {\n\t\t\tinfo.Path = p\n\t\t\tinfo.Loc = LocGopath\n\t\t\tr.findCache[name] = info\n\t\t\treturn info\n\t\t}\n\t}\n\n\t// Check $GOROOT\n\tfor _, rr := range filepath.SplitList(r.BuildContext.GOROOT) {\n\t\tp = filepath.Join(rr, \"src\", filepath.FromSlash(name))\n\t\tif pkgExists(p) {\n\t\t\tinfo.Path = p\n\t\t\tinfo.Loc = LocGoroot\n\t\t\tr.findCache[name] = info\n\t\t\treturn info\n\t\t}\n\t}\n\n\t// If this is \"C\", we're dealing with cgo\n\tif name == \"C\" {\n\t\tinfo.Loc = LocCgo\n\t\tr.findCache[name] = info\n\t} else if name == \"appengine\" || name == \"appengine_internal\" ||\n\t\tstrings.HasPrefix(name, \"appengine/\") ||\n\t\tstrings.HasPrefix(name, \"appengine_internal/\") {\n\t\t// Appengine is a special case when it comes to Go builds. It is a local\n\t\t// looking package only available within appengine. It's a special case\n\t\t// where Google products are playing with each other.\n\t\t// https://blog.golang.org/the-app-engine-sdk-and-workspaces-gopath\n\t\tinfo.Loc = LocAppengine\n\t\tr.findCache[name] = info\n\t} else if _, ok := PackagesAddedToStdlib[name]; ok {\n\t\t// Various packages are being added to the Go standard library, and being imported\n\t\t// with build flags. Need to detect this and handle it.\n\t\tinfo.Loc = LocGoroot\n\t\tr.findCache[name] = info\n\t}\n\n\treturn info\n}\n\nfunc pkgExists(path string) bool {\n\tfi, err := os.Stat(path)\n\treturn err == nil && (fi.IsDir() || isLink(fi))\n}\n\n// isLink returns true if the given FileInfo is a symbolic link.\nfunc isLink(fi os.FileInfo) bool {\n\treturn fi.Mode()&os.ModeSymlink == os.ModeSymlink\n}\n\n// IsSrcDir returns true if this is a directory that could have source code,\n// false otherwise.\n//\n// Directories with _ or . prefixes are skipped, as are testdata and vendor.\nfunc IsSrcDir(fi os.FileInfo) bool {\n\treturn srcDir(fi)\n}\n\nfunc srcDir(fi os.FileInfo) bool {\n\tif !fi.IsDir() {\n\t\treturn false\n\t}\n\n\t// Ignore _foo and .foo\n\tif strings.HasPrefix(fi.Name(), \"_\") || strings.HasPrefix(fi.Name(), \".\") {\n\t\treturn false\n\t}\n\n\t// Ignore testdata. For now, ignore vendor.\n\tif fi.Name() == \"testdata\" || fi.Name() == \"vendor\" {\n\t\treturn false\n\t}\n\n\treturn true\n}\n\n// checkForBasedirSymlink checks to see if the given basedir is actually a\n// symlink. In the case that it is a symlink, the symlink is read and returned.\n// If the basedir is not a symlink, the provided basedir argument is simply\n// returned back to the caller.\nfunc checkForBasedirSymlink(basedir string) (string, error) {\n\tfi, err := os.Lstat(basedir)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif fi.Mode()&os.ModeSymlink != 0 {\n\t\treturn os.Readlink(basedir)\n\t}\n\n\treturn basedir, nil\n}\n\n// helper func to merge, dedupe, and sort strings\nfunc dedupeStrings(s1, s2 []string) (r []string) {\n\tdedupe := make(map[string]bool)\n\n\tif len(s1) > 0 && len(s2) > 0 {\n\t\tfor _, i := range s1 {\n\t\t\tdedupe[i] = true\n\t\t}\n\t\tfor _, i := range s2 {\n\t\t\tdedupe[i] = true\n\t\t}\n\n\t\tfor i := range dedupe {\n\t\t\tr = append(r, i)\n\t\t}\n\t\t// And then re-sort them\n\t\tsort.Strings(r)\n\t} else if len(s1) > 0 {\n\t\tr = s1\n\t} else if len(s2) > 0 {\n\t\tr = s2\n\t}\n\n\treturn\n}\n\n// In Go 1.9 go/build.ImportDir changed so that a missing dir\n// no longer responses with os.IsNotExist. Instead the error changed\n// one in the form of fmt.Errorf(\"cannot find package %q in:\\n\\t%s\", path, p.Dir)\n// which is similar to other go/build.ImportDir errors. This function\n// attempts to detect when ImportDir thinks something is not found\nfunc osDirNotFound(err error, p string) bool {\n\n\tif os.IsNotExist(err) {\n\t\treturn true\n\t}\n\n\t// Since there are multiple errors that start like this we need to make\n\t// sure the directory is not present\n\tif strings.HasPrefix(err.Error(), \"cannot find package \") {\n\t\t_, nferr := os.Stat(p)\n\t\tif os.IsNotExist(nferr) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n"
  },
  {
    "path": "dependency/resolver_test.go",
    "content": "package dependency\n\nimport (\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/Masterminds/glide/cfg\"\n)\n\nfunc TestResolveLocalShallow(t *testing.T) {\n\tr, err := NewResolver(\"../\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tl, _, err := r.ResolveLocal(false)\n\tif err != nil {\n\t\tt.Fatalf(\"Failed to resolve: %s\", err)\n\t}\n\n\texpect := []string{\n\t\tfilepath.FromSlash(\"github.com/Masterminds/semver\"),\n\t\tfilepath.FromSlash(\"github.com/Masterminds/vcs\"),\n\t\tfilepath.FromSlash(\"gopkg.in/yaml.v2\"),\n\t\tfilepath.FromSlash(\"github.com/codegangsta/cli\"),\n\t}\n\n\tfor _, p := range expect {\n\t\tfound := false\n\t\tfor _, li := range l {\n\t\t\tif strings.HasSuffix(li, p) {\n\t\t\t\tfound = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\tt.Errorf(\"Could not find %s in resolved list.\", p)\n\t\t}\n\t}\n}\n\nfunc TestResolveLocalDeep(t *testing.T) {\n\tr, err := NewResolver(\"../\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\th := &DefaultMissingPackageHandler{Missing: []string{}, Gopath: []string{}, Prefix: \"../vendor\"}\n\tr.Handler = h\n\n\tl, _, err := r.ResolveLocal(true)\n\tif err != nil {\n\t\tt.Fatalf(\"Failed to resolve: %s\", err)\n\t}\n\n\tif len(l) < 4 {\n\t\tt.Errorf(\"Expected at least 4 deps, got %d\", len(l))\n\t}\n}\n\nfunc TestResolve(t *testing.T) {\n\tr, err := NewResolver(\"../\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\th := &DefaultMissingPackageHandler{Missing: []string{}, Gopath: []string{}, Prefix: \"../vendor\"}\n\tr.Handler = h\n\n\tbase := filepath.Join(os.Getenv(\"GOPATH\"), \"src/github.com/Masterminds/glide/vendor\")\n\tl, err := r.Resolve(\"github.com/codegangsta/cli\", base)\n\tif err != nil {\n\t\tt.Fatalf(\"Failed to resolve: %s\", err)\n\t}\n\n\tif len(l) != 1 {\n\t\tt.Errorf(\"Expected 1 dep, got %d: %s\", len(l), l[0])\n\t}\n\n\tif !strings.HasSuffix(filepath.FromSlash(\"github.com/codegangsta/cli\"), l[0]) {\n\t\tt.Errorf(\"Unexpected package name: %s\", l[0])\n\t}\n}\n\nfunc TestResolveAll(t *testing.T) {\n\t// These are build dependencies of Glide, so we know they are here.\n\tdeps := []*cfg.Dependency{\n\t\t{Name: \"github.com/codegangsta/cli\"},\n\t\t{Name: \"github.com/Masterminds/semver\"},\n\t\t{Name: \"github.com/Masterminds/vcs\"},\n\t\t{Name: \"gopkg.in/yaml.v2\"},\n\t}\n\n\tr, err := NewResolver(\"../\")\n\tif err != nil {\n\t\tt.Fatalf(\"No new resolver: %s\", err)\n\t}\n\th := &DefaultMissingPackageHandler{Missing: []string{}, Gopath: []string{}, Prefix: \"../vendor\"}\n\tr.Handler = h\n\tl, err := r.ResolveAll(deps, false)\n\tif err != nil {\n\t\tt.Fatalf(\"Failed to resolve: %s\", err)\n\t}\n\n\tif len(l) < len(deps) {\n\t\tt.Errorf(\"Expected at least %d deps, got %d\", len(deps), len(l))\n\t}\n}\n"
  },
  {
    "path": "dependency/scan.go",
    "content": "package dependency\n\nimport (\n\t\"bytes\"\n\t\"io\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\t\"text/scanner\"\n\n\t\"github.com/Masterminds/glide/msg\"\n\t\"github.com/Masterminds/glide/util\"\n)\n\nvar osList []string\nvar archList []string\n\nfunc init() {\n\t// The supported systems are listed in\n\t// https://github.com/golang/go/blob/master/src/go/build/syslist.go\n\t// The lists are not exported so we need to duplicate them here.\n\tosListString := \"android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows\"\n\tosList = strings.Split(osListString, \" \")\n\n\tarchListString := \"386 amd64 amd64p32 arm armbe arm64 arm64be ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32le ppc s390 s390x sparc sparc64\"\n\tarchList = strings.Split(archListString, \" \")\n}\n\n// IterativeScan attempts to obtain a list of imported dependencies from a\n// package. This scanning is different from ImportDir as part of the go/build\n// package. It looks over different permutations of the supported OS/Arch to\n// try and find all imports. This is different from setting UseAllFiles to\n// true on the build Context. It scopes down to just the supported OS/Arch.\n//\n// Note, there are cases where multiple packages are in the same directory. This\n// usually happens with an example that has a main package and a +build tag\n// of ignore. This is a bit of a hack. It causes UseAllFiles to have errors.\nfunc IterativeScan(path string) ([]string, []string, error) {\n\n\t// TODO(mattfarina): Add support for release tags.\n\n\ttgs, _ := readBuildTags(path)\n\t// Handle the case of scanning with no tags\n\ttgs = append(tgs, \"\")\n\n\tvar pkgs []string\n\tvar testPkgs []string\n\tfor _, tt := range tgs {\n\n\t\t// split the tag combination to look at permutations.\n\t\tts := strings.Split(tt, \",\")\n\t\tvar ttgs []string\n\t\tvar arch string\n\t\tvar ops string\n\t\tfor _, ttt := range ts {\n\t\t\tdirty := false\n\t\t\tif strings.HasPrefix(ttt, \"!\") {\n\t\t\t\tdirty = true\n\t\t\t\tttt = strings.TrimPrefix(ttt, \"!\")\n\t\t\t}\n\t\t\tif isSupportedOs(ttt) {\n\t\t\t\tif dirty {\n\t\t\t\t\tops = getOsValue(ttt)\n\t\t\t\t} else {\n\t\t\t\t\tops = ttt\n\t\t\t\t}\n\t\t\t} else if isSupportedArch(ttt) {\n\t\t\t\tif dirty {\n\t\t\t\t\tarch = getArchValue(ttt)\n\t\t\t\t} else {\n\t\t\t\t\tarch = ttt\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif !dirty {\n\t\t\t\t\tttgs = append(ttgs, ttt)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Handle the case where there are no tags but we need to iterate\n\t\t// on something.\n\t\tif len(ttgs) == 0 {\n\t\t\tttgs = append(ttgs, \"\")\n\t\t}\n\n\t\tb, err := util.GetBuildContext()\n\t\tif err != nil {\n\t\t\treturn []string{}, []string{}, err\n\t\t}\n\n\t\t// Make sure use all files is off\n\t\tb.UseAllFiles = false\n\n\t\t// Set the OS and Arch for this pass\n\t\tb.GOARCH = arch\n\t\tb.GOOS = ops\n\t\tb.BuildTags = ttgs\n\t\tmsg.Debug(\"Scanning with Arch(%s), OS(%s), and Build Tags(%v)\", arch, ops, ttgs)\n\n\t\tpk, err := b.ImportDir(path, 0)\n\n\t\t// If there are no buildable souce with this permutation we skip it.\n\t\tif err != nil && strings.HasPrefix(err.Error(), \"no buildable Go source files in\") {\n\t\t\tcontinue\n\t\t} else if err != nil && strings.HasPrefix(err.Error(), \"found packages \") {\n\t\t\t// A permutation may cause multiple packages to appear. For example,\n\t\t\t// an example file with an ignore build tag. If this happens we\n\t\t\t// ignore it.\n\t\t\t// TODO(mattfarina): Find a better way.\n\t\t\tmsg.Debug(\"Found multiple packages while scanning %s: %s\", path, err)\n\t\t\tcontinue\n\t\t} else if err != nil {\n\t\t\tmsg.Debug(\"Problem parsing package at %s for %s %s\", path, ops, arch)\n\t\t\treturn []string{}, []string{}, err\n\t\t}\n\n\t\tfor _, dep := range pk.Imports {\n\t\t\tfound := false\n\t\t\tfor _, p := range pkgs {\n\t\t\t\tif p == dep {\n\t\t\t\t\tfound = true\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !found {\n\t\t\t\tpkgs = append(pkgs, dep)\n\t\t\t}\n\t\t}\n\n\t\tfor _, dep := range pk.TestImports {\n\t\t\tfound := false\n\t\t\tfor _, p := range pkgs {\n\t\t\t\tif p == dep {\n\t\t\t\t\tfound = true\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !found {\n\t\t\t\ttestPkgs = append(testPkgs, dep)\n\t\t\t}\n\t\t}\n\n\t\tfor _, dep := range pk.XTestImports {\n\t\t\tfound := false\n\t\t\tfor _, p := range pkgs {\n\t\t\t\tif p == dep {\n\t\t\t\t\tfound = true\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !found {\n\t\t\t\ttestPkgs = append(testPkgs, dep)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn pkgs, testPkgs, nil\n}\n\nfunc readBuildTags(p string) ([]string, error) {\n\t_, err := os.Stat(p)\n\tif err != nil {\n\t\treturn []string{}, err\n\t}\n\n\td, err := os.Open(p)\n\tif err != nil {\n\t\treturn []string{}, err\n\t}\n\n\tobjects, err := d.Readdir(-1)\n\tif err != nil {\n\t\treturn []string{}, err\n\t}\n\n\tvar tags []string\n\tfor _, obj := range objects {\n\n\t\t// only process Go files\n\t\tif strings.HasSuffix(obj.Name(), \".go\") {\n\t\t\tfp := filepath.Join(p, obj.Name())\n\n\t\t\tco, err := readGoContents(fp)\n\t\t\tif err != nil {\n\t\t\t\treturn []string{}, err\n\t\t\t}\n\n\t\t\t// Only look at places where we had a code comment.\n\t\t\tif len(co) > 0 {\n\t\t\t\tt := findTags(co)\n\t\t\t\tfor _, tg := range t {\n\t\t\t\t\tfound := false\n\t\t\t\t\tfor _, tt := range tags {\n\t\t\t\t\t\tif tt == tg {\n\t\t\t\t\t\t\tfound = true\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif !found {\n\t\t\t\t\t\ttags = append(tags, tg)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn tags, nil\n}\n\n// Read contents of a Go file up to the package declaration. This can be used\n// to find the the build tags.\nfunc readGoContents(fp string) ([]byte, error) {\n\tf, err := os.Open(fp)\n\tdefer f.Close()\n\tif err != nil {\n\t\treturn []byte{}, err\n\t}\n\n\tvar s scanner.Scanner\n\ts.Init(f)\n\tvar tok rune\n\tvar pos scanner.Position\n\tfor tok != scanner.EOF {\n\t\ttok = s.Scan()\n\n\t\t// Getting the token text will skip comments by default.\n\t\ttt := s.TokenText()\n\t\t// build tags will not be after the package declaration.\n\t\tif tt == \"package\" {\n\t\t\tpos = s.Position\n\t\t\tbreak\n\t\t}\n\t}\n\n\tbuf := bytes.NewBufferString(\"\")\n\tf.Seek(0, 0)\n\t_, err = io.CopyN(buf, f, int64(pos.Offset))\n\tif err != nil {\n\t\treturn []byte{}, err\n\t}\n\n\treturn buf.Bytes(), nil\n}\n\n// From a byte slice of a Go file find the tags.\nfunc findTags(co []byte) []string {\n\tp := co\n\tvar tgs []string\n\tfor len(p) > 0 {\n\t\tline := p\n\t\tif i := bytes.IndexByte(line, '\\n'); i >= 0 {\n\t\t\tline, p = line[:i], p[i+1:]\n\t\t} else {\n\t\t\tp = p[len(p):]\n\t\t}\n\t\tline = bytes.TrimSpace(line)\n\t\t// Only look at comment lines that are well formed in the Go style\n\t\tif bytes.HasPrefix(line, []byte(\"//\")) {\n\t\t\tline = bytes.TrimSpace(line[len([]byte(\"//\")):])\n\t\t\tif len(line) > 0 && line[0] == '+' {\n\t\t\t\tf := strings.Fields(string(line))\n\n\t\t\t\t// We've found a +build tag line.\n\t\t\t\tif f[0] == \"+build\" {\n\t\t\t\t\tfor _, tg := range f[1:] {\n\t\t\t\t\t\ttgs = append(tgs, tg)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn tgs\n}\n\n// Get an OS value that's not the one passed in.\nfunc getOsValue(n string) string {\n\tfor _, o := range osList {\n\t\tif o != n {\n\t\t\treturn o\n\t\t}\n\t}\n\n\treturn n\n}\n\nfunc isSupportedOs(n string) bool {\n\tfor _, o := range osList {\n\t\tif o == n {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n// Get an Arch value that's not the one passed in.\nfunc getArchValue(n string) string {\n\tfor _, o := range archList {\n\t\tif o != n {\n\t\t\treturn o\n\t\t}\n\t}\n\n\treturn n\n}\n\nfunc isSupportedArch(n string) bool {\n\tfor _, o := range archList {\n\t\tif o == n {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n"
  },
  {
    "path": "docs/commands.md",
    "content": "# Commands\n\nThe following are the Glide commands, most of which are to help you manage your workspace.\n\n## glide create (aliased to init)\n\nInitialize a new workspace. Among other things, this creates a `glide.yaml` file\nwhile attempting to guess the packages and versions to put in it. For example,\nif your project is using Godep it will use the versions specified there. Glide\nis smart enough to scan your codebase and detect the imports being used whether\nthey are specified with another package manager or not.\n\n    $ glide create\n    [INFO]\tGenerating a YAML configuration file and guessing the dependencies\n    [INFO]\tAttempting to import from other package managers (use --skip-import to skip)\n    [INFO]\tScanning code to look for dependencies\n    [INFO]\t--> Found reference to github.com/Masterminds/semver\n    [INFO]\t--> Found reference to github.com/Masterminds/vcs\n    [INFO]\t--> Found reference to github.com/codegangsta/cli\n    [INFO]\t--> Found reference to gopkg.in/yaml.v2\n    [INFO]\tWriting configuration file (glide.yaml)\n    [INFO]\tWould you like Glide to help you find ways to improve your glide.yaml configuration?\n    [INFO]\tIf you want to revisit this step you can use the config-wizard command at any time.\n    [INFO]\tYes (Y) or No (N)?\n    n\n    [INFO]\tYou can now edit the glide.yaml file. Consider:\n    [INFO]\t--> Using versions and ranges. See https://glide.sh/docs/versions/\n    [INFO]\t--> Adding additional metadata. See https://glide.sh/docs/glide.yaml/\n    [INFO]\t--> Running the config-wizard command to improve the versions in your configuration\n\nThe `config-wizard`, noted here, can be run here or manually run at a later time.\nThis wizard helps you figure out versions and ranges you can use for your\ndependencies.\n\n### glide config-wizard\n\nThis runs a wizard that scans your dependencies and retrieves information on them\nto offer up suggestions that you can interactively choose. For example, it can\ndiscover if a dependency uses semantic versions and help you choose the version\nranges to use.\n\n## glide get [package name]\n\nYou can download one or more packages to your `vendor` directory and have it added to your\n`glide.yaml` file with `glide get`.\n\n    $ glide get github.com/Masterminds/cookoo\n\nWhen `glide get` is used it will introspect the listed package to resolve its dependencies including using Godep, GPM, Gom, and GB config files.\n\nThe `glide get` command can have a [version or range](versions.md) passed in with the package name. For example,\n\n    $ glide get github.com/Masterminds/cookoo#^1.2.3\n\nThe version is separated from the package name by an anchor (`#`). If no version or range is specified and the dependency uses Semantic Versions Glide will prompt you to ask if you want to use them.\n\n## glide update (aliased to up)\n\nDownload or update all of the libraries listed in the `glide.yaml` file and put\nthem in the `vendor` directory. It will also recursively walk through the\ndependency packages to fetch anything that's needed and read in any configuration.\n\n    $ glide up\n\nThis will recurse over the packages looking for other projects managed by Glide,\nGodep, gb, gom, and GPM. When one is found those packages will be installed as needed.\n\nA `glide.lock` file will be created or updated with the dependencies pinned to\nspecific versions. For example, if in the `glide.yaml` file a version was\nspecified as a range (e.g., `^1.2.3`) it will be set to a specific commit id in\nthe `glide.lock` file. That allows for reproducible installs (see `glide install`).\n\nTo remove any nested `vendor/` directories from fetched packages see the `-v` flag.\n\n## glide install\n\nWhen you want to install the specific versions from the `glide.lock` file use `glide install`.\n\n    $ glide install\n\nThis will read the `glide.lock` file, warning you if it's not tied to the `glide.yaml` file, and install the commit id specific versions there.\n\nWhen the `glide.lock` file doesn't tie to the `glide.yaml` file, such as there being a change, it will provide an warning. Running `glide up` will recreate the `glide.lock` file when updating the dependency tree.\n\nIf no `glide.lock` file is present `glide install` will perform an `update` and generates a lock file.\n\nTo remove any nested `vendor/` directories from fetched packages see the `-v` flag.\n\n## glide novendor (aliased to nv)\n\nWhen you run commands like `go test ./...` it will iterate over all the subdirectories including the `vendor` directory. When you are testing your application you may want to test your application files without running all the tests of your dependencies and their dependencies. This is where the `novendor` command comes in. It lists all of the directories except `vendor`.\n\n    $ go test $(glide novendor)\n\nThis will run `go test` over all directories of your project except the `vendor` directory.\n\n## glide name\n\nWhen you're scripting with Glide there are occasions where you need to know the name of the package you're working on. `glide name` returns the name of the package listed in the `glide.yaml` file.\n\n## glide list\n\nGlide's `list` command shows an alphabetized list of all the packages that a project imports.\n\n    $ glide list\n    INSTALLED packages:\n    \tvendor/github.com/Masterminds/cookoo\n    \tvendor/github.com/Masterminds/cookoo/fmt\n    \tvendor/github.com/Masterminds/cookoo/io\n    \tvendor/github.com/Masterminds/cookoo/web\n    \tvendor/github.com/Masterminds/semver\n    \tvendor/github.com/Masterminds/vcs\n    \tvendor/github.com/codegangsta/cli\n    \tvendor/gopkg.in/yaml.v2\n\n## glide help\n\nPrint the glide help.\n\n    $ glide help\n\n## glide --version\n\nPrint the version and exit.\n\n    $ glide --version\n    glide version 0.12.0\n\n## glide mirror\n\nMirrors provide the ability to replace a repo location with\nanother location that's a mirror of the original. This is useful when you want\nto have a cache for your continuous integration (CI) system or if you want to\nwork on a dependency in a local location.\n\nThe mirrors are stored in an `mirrors.yaml` file in your `GLIDE_HOME`.\n\nThe three commands to manage mirrors are `list`, `set`, and `remove`.\n\nUse `set` in the form:\n\n    glide mirror set [original] [replacement]\n\nor\n\n    glide mirror set [original] [replacement] --vcs [type]\n\nfor example,\n\n    glide mirror set https://github.com/example/foo https://git.example.com/example/foo.git\n\nor\n\n    glide mirror set https://github.com/example/foo file:///path/to/local/repo --vcs git\n\nUse `remove` in the form:\n\n    glide mirror remove [original]\n\nfor example,\n\n    glide mirror remove https://github.com/example/foo\n"
  },
  {
    "path": "docs/example-glide.yaml",
    "content": "# The name of this package.\npackage: github.com/Masterminds/glide\n\n# External dependencies.\nimport:\n  # Minimal definition\n  # This will use \"go get [-u]\" to fetch and update the package, and it will\n  # attempt to keep the release at the tip of master. It does this by looking\n  # for telltale signs that this is a git, bzr, or hg repo, and then acting\n  # accordingly.\n  - package: github.com/kylelemons/go-gypsy\n\n  # Full definition\n  # This will check out the given Git repo, set the version to master,\n  # use \"git\" (not \"go get\") to manage it, and alias the package to the\n  # import path github.com/Masterminds/cookoo\n  - package: github.com/Masterminds/cookoo\n    vcs: git\n    version: master\n    repo: git@github.com:Masterminds/cookoo.git\n\n  # Here's an example with a commit hash for a version. Since repo is not\n  # specified, this will use git to to try to clone\n  # 'http://github.com/aokoli/goutils' and then set the revision to the given\n  # hash.\n  - package: github.com/aokoli/goutils\n    vcs: git\n    version: 9c37978a95bd5c709a15883b6242714ea6709e64\n\n  # MASKING: This takes my fork of goamz (technosophos/goamz) and clones it\n  # as if it were the crowdmob/goamz package. This is incredibly useful for\n  # masking packages and/or working with forks or clones.\n  #\n  # Note that absolutely no namespace munging happens on the code. If you want\n  # that, you'll have to do it on your own. The intent of this masking was to\n  # make it so you don't have to vendor imports.\n  - package: github.com/crowdmob/goamz\n    vcs: git\n    repo: git@github.com:technosophos/goamz.git\n\n  - package: bzr.example.com/foo/bar/trunk\n    vcs: bzr\n    repo: bzr://bzr.example.com/foo/bar/trunk\n    # The version can be a branch, tag, commit id, or a semantic version\n    # constraint parsable by https://github.com/Masterminds/semver\n    version: 1.0.0\n\n  - package: hg.example.com/foo/bar\n    vcs: hg\n    repo: http://hg.example.com/foo/bar\n    version: ae081cd1d6cc\n\n  # For SVN, the only valid version is a commit number. Tags and branches go in\n  # the repo URL.\n  - package: svn.example.com/foo/bar/trunk\n    vcs: svn\n    repo: http://svn.example.com/foo/bar/trunk\n\n\n  # If a package is dependent on OS, you can tell Glide to only\n  # fetch for certain OS or architectures.\n  #\n  # os can be any valid GOOS.\n  # arch can be any valid GOARCH.\n  - package: github.com/unixy/package\n    os:\n      - linux\n      - darwin\n    arch:\n      - amd64\n"
  },
  {
    "path": "docs/faq.md",
    "content": "# Frequently Asked Questions (F.A.Q.)\n\n## Q: Why does Glide have the concept of sub-packages when Go doesn't?\n\nIn Go every directory is a package. This works well when you have one repo containing all of your packages. When you have different packages in different VCS locations things become a bit more complicated. A project containing a collection of packages should be handled with the same information including the version. By grouping packages this way we are able to manage the related information.\n\n## Q: bzr (or hg) is not working the way I expected. Why?\n\nThese are works in progress, and may need some additional tuning. Please take a look at the [vcs package](https://github.com/masterminds/vcs). If you see a better way to handle it please let us know.\n\n## Q: Should I check `vendor/` into version control?\n\nThat's up to you. It's a personal or organizational decision. Glide will help you install the outside dependencies on demand or help you manage the dependencies as they are checked into your version control system.\n\nBy default, commands such as `glide update` and `glide install` install on-demand. To manage a vendor folder that's checked into version control use the flags:\n\n* `--update-vendored` (aliased to `-u`) to update the vendored dependencies.\n* `--strip-vcs` (aliased to `-s`) to strip VCS metadata (e.g., `.git` directories) from the `vendor` folder.\n* `--strip-vendor` (aliased to `-v`) to strip nested `vendor/` directories.\n\n## Q: How do I import settings from GPM, Godep, Gom, or GB?\n\nThere are two parts to importing.\n\n1. If a package you import has configuration for GPM, Godep, Gom, or GB Glide will recursively install the dependencies automatically.\n2. If you would like to import configuration from GPM, Godep, Gom, or GB to Glide see the `glide import` command. For example, you can run `glide import godep` for Glide to detect the projects Godep configuration and generate a `glide.yaml` file for you.\n\nEach of these will merge your existing `glide.yaml` file with the\ndependencies it finds for those managers, and then emit the file as\noutput. **It will not overwrite your glide.yaml file.**\n\nYou can write it to file like this:\n\n    $ glide import godep -f glide.yaml\n\n\n## Q: Can Glide fetch a package based on OS or Arch?\n\nYes. Using the `os` and `arch` fields on a `package`, you can specify\nwhich OSes and architectures the package should be fetched for. For\nexample, the following package will only be fetched for 64-bit\nDarwin/OSX systems:\n\n    - package: some/package\n      os:\n        - darwin\n      arch:\n        - amd64\n\nThe package will not be fetched for other architectures or OSes.\n\n## Q: How did Glide get its name?\n\nAside from being catchy, \"glide\" is a contraction of \"Go Elide\". The\nidea is to compress the tasks that normally take us lots of time into a\njust a few seconds.\n"
  },
  {
    "path": "docs/getting-started.md",
    "content": "# Getting Started With Glide\n\nThis is a quick start guide to using Glide once you have it installed.\n\n## Initially Detecting Project Dependencies\n\nGlide can detect the dependencies in use on a project and create an initial `glide.yaml` file for you. This detection can import the configuration from Godep, GPM, Gom, and GB. To do this change into the top level directory for the project and run:\n\n    $ glide init\n\nWhen this is complete you'll have a `glide.yaml` file populated with the projects being used. You can open up this file and even edit it to add information such as versions.\n\nRunning `glide init` will also ask if you would like to use a wizard to discover information about your dependencies versions and use versions or ranges. Each decision is interactive and your choice.\n\n## Updating Dependencies\n\nTo fetch the dependencies and set them to any versions specified in the `glide.yaml` file use the following command:\n\n    $ glide up\n\nThe `up` is short for `update`. This will fetch any dependencies specified in the `glide.yaml` file, walk the dependency tree to make sure any dependencies of the dependencies are fetched, and set them to the proper version. While walking the tree it will make sure versions are set and configuration from Godep, GPM, Gom, and GB is imported.\n\nThe fetched dependencies are all placed in the `vendor/` folder at the root of the project. The `go` toolchain will use the dependencies here prior to looking in the `GOPATH` or `GOROOT` if you are using Go 1.6+ or Go 1.5 with the Go 1.5 Vendor Experiment enabled.\n\nGlide will then create a `glide.lock` file. This file contains the entire dependency tree pinned to specific commit ids. This file, as we'll see in a moment, can be used to recreate the exact dependency tree and versions used.\n\nIf you want to remove nested `vendor/` directories from within dependencies use the `--strip-vendor` or `-v` flag.\n\n### Dependency Flattening\n\nAll of the dependencies Glide fetches are into the top level `vendor/` folder for a project. Go provides the ability for each package to have a `vendor/` folder. Glide only uses a top level folder for two reasons:\n\n1. Each import location will be compiled into the binary. If the same dependency is imported into three `vendor/` folders it will be in the compiled binary three times. This can quickly lead to binary bloat.\n2. Instances of types created in a dependency in one `vendor/` folder are not compatible with the same dependency in other locations. Even if they are the same version. Go sees them as different packages because they are in different locations. This is a problem for database drivers, loggers, and many other things. If you [try to pass an instance created from one location of a package to another you'll encounter errors](https://github.com/mattfarina/golang-broken-vendor).\n\nIf a dependency has a `vendor/` directory of its own Glide does not remove it by default. The resolution in the `go` toolchain will use these nested versions if they are present. To remove them use the `--strip-vendor` or `-v` flag on the `up` or `install` commands.\n\n## Installing Dependencies\n\nIf you want to install the dependencies needed by a project use the `install` command like so:\n\n    $ glide install\n\nThis command does one of two things:\n\n* If a `glide.lock` file is present it retrieves, if missing from the `vendor/` folder, the dependency and sets it to the exact version in the `glide.lock` file. The dependencies are fetched and versions set concurrently so this operation is fairly quick.\n* If there is no `glide.lock` file then an `update` will be performed.\n\nIf you're not managing the dependency versions for a project but need to install the dependencies you should use the `install` command.\n\n## Adding More Dependencies\n\nGlide can help you add more dependencies to the `glide.yaml` file with the `get` command.\n\n    $ glide get github.com/Masterminds/semver\n\nThe `get` command is similar to `go get` but instead fetches dependencies into the `vendor/` folder and adds them to the `glide.yaml` file. This command can take one or more dependencies to fetch.\n\nThe `get` command can also work with versions.\n\n    $ glide get github.com/Masterminds/semver#~1.2.0\n\nThe `#` is used as a separator between the dependency name and a version to use. The version can be a semantic version, version range, branch, tag, or commit id.\n\nIf no version or range is specified and the dependency uses Semantic Versions Glide will prompt you to ask if you want to use them.\n"
  },
  {
    "path": "docs/glide-plugin-example",
    "content": "#!/bin/bash\n\n# You can execute me through Glide by doing the following:\n# - Copy me to a directory on $PATH. _vendor/bin/ will work just fine.\n# - Execute `glide plugin-example`\n# - ???\n# - Profit\n\necho \"I received arguments '$@'\"\n\n# This should match the directory from which you executed glide.\necho \"My current working directory is $(pwd)\"\n\n# This is the GOPATH for the current glide session.\necho \"My GOPATH is $GOPATH\"\n\n# This is the base directory of your project.\necho \"The project directory is $GLIDE_PROJECT\"\n\n# This is the location of the glide.yaml file.\necho \"The Glide YAML is in $GLIDE_YAML\"\n\n# This is the PATH that the plugin inherited.\necho \"My PATH is $PATH\"\n\n"
  },
  {
    "path": "docs/glide.lock.md",
    "content": "# The glide.lock File\n\nWhere a [`glide.yaml`](glide.yaml.md) file contains the dependencies, versions (including ranges), and other configuration for the local codebase, the related `glide.lock` file contains the complete dependency tree and the revision (commit id) in use.\n\nKnowing the complete dependency tree is useful for Glide. For example, when the complete tree is known the `glide install` command can install and set the proper revision for multiple dependencies concurrently. This is a fast operation to reproducibly install the dependencies.\n\nThe lock file also provides a record of the complete tree, beyond the needs of your codebase, and the revisions used. This is useful for things like audits or detecting what changed in a dependency tree when troubleshooting a problem.\n\nThe details of this file are not included here as this file should not be edited by hand. If you know how to read the [`glide.yaml`](glide.yaml.md) file you'll be able to generally understand the `glide.lock` file.\n"
  },
  {
    "path": "docs/glide.yaml.md",
    "content": "# The glide.yaml File\n\nThe `glide.yaml` file contains information about the project and the dependent packages. Here the elements of the `glide.yaml` file are outlined.\n\n    package: github.com/Masterminds/glide\n    homepage: https://masterminds.github.io/glide\n    license: MIT\n    owners:\n    - name: Matt Butcher\n      email: technosophos@gmail.com\n      homepage: http://technosophos.com\n    - name: Matt Farina\n      email: matt@mattfarina.com\n      homepage: https://www.mattfarina.com\n    ignore:\n    - appengine\n    excludeDirs:\n    - node_modules\n    import:\n    - package: gopkg.in/yaml.v2\n    - package: github.com/Masterminds/vcs\n      version: ^1.2.0\n      repo:    git@github.com:Masterminds/vcs\n      vcs:     git\n    - package: github.com/codegangsta/cli\n      version: f89effe81c1ece9c5b0fda359ebd9cf65f169a51\n    - package: github.com/Masterminds/semver\n      version: ^1.0.0\n    testImport:\n    - package: github.com/arschles/assert\n\nThese elements are:\n\n- `package`: The top level package is the location in the `GOPATH`. This is used for things such as making sure an import isn't also importing the top level package.\n- `homepage`: To find the place where you can find details about the package or applications. For example, http://k8s.io\n- license: The license is either an [SPDX license](http://spdx.org/licenses/) string or the filepath to the license. This allows automation and consumers to easily identify the license.\n- `owners`: The owners is a list of one or more owners for the project. This can be a person or organization and is useful for things like notifying the owners of a security issue without filing a public bug.\n- `ignore`: A list of packages for Glide to ignore importing. These are package names to ignore rather than directories.\n- `excludeDirs`: A list of directories in the local codebase to exclude from scanning for dependencies.\n- `import`: A list of packages to import. Each package can include:\n    - `package`: The name of the package to import and the only non-optional item. Package names follow the same patterns the `go` tool does. That means:\n        - Package names that map to a VCS remote location end in .git, .bzr, .hg, or .svn. For example, `example.com/foo/pkg.git/subpkg`.\n        - GitHub, BitBucket, Launchpad, IBM Bluemix Services, and Go on Google Source are special cases that don't need the VCS extension.\n    - `version`: A semantic version, semantic version range, branch, tag, or commit id to use. For more information see the [versioning documentation](versions.md).\n    - `repo`: If the package name isn't the repo location or this is a private repository it can go here. The package will be checked out from the repo and put where the package name specifies. This allows using forks.\n    - `vcs`: A VCS to use such as git, hg, bzr, or svn. This is only needed when the type cannot be detected from the name. For example, a repo ending in .git or on GitHub can be detected to be Git. For a repo on Bitbucket we can contact the API to discover the type.\n    - `subpackages`: A record of packages being used within a repository. This does not include all packages within a repository but rather those being used.\n    - `os`: A list of operating systems used for filtering. If set it will compare the current runtime OS to the one specified and only fetch the dependency if there is a match. If not set filtering is skipped. The names are the same used in build flags and `GOOS` environment variable.\n    - `arch`: A list of architectures used for filtering. If set it will compare the current runtime architecture to the one specified and only fetch the dependency if there is a match. If not set filtering is skipped. The names are the same used in build flags and `GOARCH` environment variable.\n- `testImport`: A list of packages used in tests that are not already listed in `import`. Each package has the same details as those listed under import.\n"
  },
  {
    "path": "docs/importing.md",
    "content": "# Importing\n\nGlide has limited support for importing from other formats.\n\n**Note:** If you'd like to help build importers, we'd love some pull\nrequests. Just take a look at `cmd/godeps.git`.\n\n## Godeps and Godeps-Git\n\nTo import from Godeps or Godeps-Git format, run `glide godeps`. This\nwill read the `glide.yaml`, then look for `Godeps` or `Godeps-Git` files\nto also read. It will then attempt to merge the packages in those files\ninto the current YAML, printing the resulting YAML to standard out.\n\nThe preferred procedure for merging:\n\n```\n$ glide godeps # look at the output and see if it's okay\n$ glide -q godeps > glide.yaml # Write the merged file\n```\n"
  },
  {
    "path": "docs/index.md",
    "content": "# Glide: Vendor Package Management for Go\n\n[Glide](https://glide.sh) is a package manager for [Go](https://golang.org) that is conceptually similar to package managers for other languages such as Cargo for Rust, NPM for Node.js, Pip for Python, Bundler for Ruby, and so forth.\n\nGlide provides the following functionality:\n\n* Records dependency information in a `glide.yaml` file. This includes a name, version or version range, version control information for private repos or when the type cannot be detected, and more.\n* Tracks the specific revision each package is locked to in a `glide.lock` file. This enables reproducibly fetching the dependency tree.\n* Works with Semantic Versions and Semantic Version ranges.\n* Supports Git, Bzr, HG, and SVN. These are the same version control systems supported by `go get`.\n* Utilizes `vendor/` directories, known as the Vendor Experiment, so that different projects can have differing versions of the same dependencies.\n* Allows for aliasing packages which is useful for working with forks.\n* Import configuration from Godep, GPM, Gom, and GB.\n\n## Installing Glide\n\nThere are a few ways to install Glide.\n\n1. Use the shell script to try an automatically install it. `curl https://glide.sh/get | sh`\n2. Download a [versioned release](https://github.com/Masterminds/glide/releases). Glide releases are semantically versioned.\n3. Use a system package manager to install Glide. For example, using `brew install glide` can be used if you're using [Homebrew](http://brew.sh) on Mac.\n4. The latest development snapshot can be installed with `go get`. For example, `go get -u github.com/Masterminds/glide`. This is not a release version.\n"
  },
  {
    "path": "docs/plugins.md",
    "content": "# Glide Plugins\n\nGlide supports a simple plugin system similar to Git.\n\n## Existing Plugins\n\nSome plugins exist today for Glide including:\n\n* [glide-vc](https://github.com/sgotti/glide-vc) - The vendor cleaner allows you to strip files not needed for building your application from the `vendor/` directory.\n* [glide-brew](https://github.com/heewa/glide-brew) - Convert Go deps managed by glide to Homebrew resources to help you make brew formulas for you Go programs.\n* [glide-hash](https://github.com/mattfarina/glide-hash) - Generates a hash of the `glide.yaml` file compatible with Glides internal hash.\n* [glide-cleanup](https://github.com/ngdinhtoan/glide-cleanup) - Removing unused packages from the `glide.yaml` file.\n* [glide-pin](https://github.com/multiplay/glide-pin) - Take all dependencies from the `glide.lock` and pin them explicitly in the `glide.yaml` file.\n\n_Note, to add plugins to this list please create a pull request._\n\n## How Plugins Work\n\nWhen Glide encounters a subcommand that it does not know, it will try to delegate it to another executable according to the following rules.\n\nExample:\n\n```\n$ glide install # We know this command, so we execute it\n$ glide foo     # We don't know this command, so we look for a suitable\n                # plugin.\n```\n\nIn the example above, when glide receives the command `foo`, which it does not know, it will do the following:\n\n1. Transform the name from `foo` to `glide-foo`\n2. Look on the system `$PATH` for `glide-foo`. If it finds a program by that name, execute it...\n3. Or else, look at the current project's root for `glide-foo`. (That is, look in the same directory as `glide.yaml`). If found, execute it.\n4. If no suitable command is found, exit with an error.\n\n## Writing a Glide Plugin\n\nA Glide plugin can be written in any language you wish, provided that it can be executed from the command line as a subprocess of Glide. The example included with Glide is a simple Bash script. We could just as easily write Go, Python, Perl, or even Java code (with a wrapper) to\nexecute.\n\nA Glide plugin must be in one of two locations:\n\n1. Somewhere on the PATH\n2. In the same directory as `glide.yaml`\n\nIt is recommended that system-wide Glide plugins go in `/usr/local/bin` or `$GOPATH/bin` while project-specific plugins go in the same directory as `glide.yaml`.\n\n### Arguments and Flags\n\nSay Glide is executed like this:\n\n```\n$ glide foo -name=Matt myfile.txt\n```\n\nGlide will interpret this as a request to execute `glide-foo` with the arguments `-name=Matt myfile.txt`. It will not attempt to interpret those arguments or modify them in any way.\n\nHypothetically, if Glide had a `-x` flag of its own, you could call this:\n\n```\n$ glide -x foo -name=Matt myfile.txt\n```\n\nIn this case, glide would interpret and swollow the -x and pass the rest on to `glide-foo` as in the example above.\n\n## Example Plugin\n\nFile: glide-foo\n\n```bash\n#!/bin/bash\n\necho \"Hello\"\n```\n"
  },
  {
    "path": "docs/resolving-imports.md",
    "content": "# Resolving Imports\n\nGlide scans an applications codebase to discover the projects to manage in the `vendor/` directory. This happens in a few different ways. Knowing how this works can help you understand what Glide is doing.\n\n## At Initialization\n\nWhen you run `glide create` or `glide init` to create a `glide.yaml` file for a codebase Glide will scan your codebase to identify the imports. It does this by walking the filesystem to identify packages. In each package it reads the imports within the Go files.\n\nFrom this it will attempt to figure out the external packages. External packages are grouped by the root version control system repo with their sub-packages listed underneath. Figuring out the root version control repo compared with the packages underneath it follows the same rules for the `go` tool.\n\n1. GitHub, Bitbucket, Launchpad, IBM Jazz, and go.googlesource.com are evaluated with special rules. We know or can talk to an API to learn about these repos.\n2. If the package associated with the repo ends in `.git`, `.hg`, `.bzr`, or `.svn` this is used to determine the root and the type of version control system.\n3. If the rules don't provide an answer a `go get` request occurs to try and lookup the information.\n\nAgain, this is the same way `go` tries to determine an external location when you use `go get`.\n\nIf the project has dependency configuration stored in a Godep, GPM, Gom, or GB file that information will be used to populate the version within the `glide.yaml` file.\n\n## At Update\n\nWhen `glide update`, `glide up`, `glide get`, or `glide install` (when no `glide.lock` is present) Glide will attempt to discover the complete dependency tree. That is all dependencies including dependencies of dependencies of dependencies.\n\n### The Default Option\n\nThe default method is to walk the referenced import tree. The resolver starts by scanning the local application to get a list of imports. Then it looks at the specific package imports, scans the imported package for imports, and repeats the lookup cycle until the complete tree has been fetched.\n\nThat means that only imports referenced in the source are fetched.\n\nWhen a version control repo is fetched it does fetch the complete repo. But, it doesn't scan all the packages in the repo for dependencies. Instead, only the packages referenced in the tree are scanned with the imports being followed.\n\nAlong the way configuration stored in Glide, Godep, GPM, Gom, and GB files are used to work out the version to set and fetched repos to. The first version found while walking the import tree wins.\n\n### All Possible Dependencies\n\nUsing the `--all-dependencies` flag on `glide update` will change the behavior of the scan. Instead of walking the import tree it walks the filesystem and fetches all possible packages referenced everywhere. This downloads all packages in the tree. Even those not referenced in an applications source or in support of the applications imports.\n\nAs in other cases, Glide, Godep, GPM, Gom, and GB files are used to set the version of the fetched repo.\n"
  },
  {
    "path": "docs/vendor.md",
    "content": "# Vendor Directories\n\nWith the release of Go 1.5 the `vendor/` directory was added to the resolution locations for a dependent package in addition to the `GOPATH` and `GOROOT`. Prior to Go 1.6 you needed to opt-in before Go would look there by setting the environment variable `GO15VENDOREXPERIMENT=1`. In Go 1.6 this is an opt-out feature.\n\n_Note, even if you use the `vendor/` directories your codebase needs to be inside the `GOPATH`. With the `go` toolchain there is no escaping the `GOPATH`._\n\nThe resolution locations for a dependent package are:\n\n* The `vendor/` directory within the current package.\n* Walk up the directory tree looking for the package in a parents `vendor/` directory.\n* Look for the package in the `GOPATH`.\n* Use the package in the `GOROOT` (where the standard library package reside) if present.\n\n## Recommendations\n\nHaving worked with the `vendor/` directories since they were first released we've come to some conclusions and recommendations. Glide tries to help you with these.\n\n1. Libraries (codebases without a `main` package) should not store outside packages in a `vendor/` folder in their VCS unless they have a specific reason and understand why they're doing it.\n2. In applications (codebases with a `main` package) there should only be one `vendor/` directory at the top level of the codebase.\n\nThere are some important reasons for these recommendations.\n\n* Each instance of a package, even the same package at the same version, in the directory structure will be in the resulting binaries. If everyone stores their own dependencies separately this will quickly lead to **binary bloat**.\n* Instances of a type created from a package in one location are **not compatible** with the same package, even at the exact same version, in another location. [You can see for yourself](https://github.com/mattfarina/golang-broken-vendor). That means loggers, database connections, and other shared instances won't work.\n\nBecause of this Glide flattens the dependency tree into a single top level `vendor/` directory. If a package happens to have some dependencies in their own `vendor/` folder the `go` tool will properly resolve that version.\n\n## Why Use A `vendor` Directory?\n\nIf we already have the `GOPATH` to store packages why is there a need for a `vendor/` directory? This is a perfectly valid question.\n\nWhat if multiple applications in the `GOPATH` use different versions of the same package? This is a valid problem that's both been encountered in Go applications and widely seen in languages that have been around for a lot longer.\n\nThe `vendor/` directory allows differing codebases to have their own version available without having to be concerned with another codebase that needs a different version interfering with the version it needs. It provides a level of separation for each project.\n"
  },
  {
    "path": "docs/versions.md",
    "content": "# Versions and Ranges\n\nGlide supports [Semantic Versions](http://semver.org), SemVer ranges, branches, tags, and commit ids as versions.\n\n## Basic Ranges\nA simple range is in the form `> 1.2.3`. This tells Glide to use the latest versions that's after `1.2.3`. Glide has support for the following operators:\n\n* `=`: equal (aliased to no operator)\n* `!=`: not equal\n* `>`: greater than\n* `<`: less than\n* `>=`: greater than or equal to\n* `<=`: less than or equal to\n\nThese can be combined. A `,` is an and operator and a `||` is an or operator. The or operators cause groups of and operators to be checked. For example, `\">= 1.2, < 3.0.0 || >= 4.2.3\"`.\n\n## Hyphen Ranges\n\nThere are multiple shortcuts to handle ranges and the first is hyphens ranges. These look like:\n\n* `1.2 - 1.4.5` which is equivalent to `>= 1.2, <= 1.4.5`\n* `2.3.4 - 4.5` which is equivalent to `>= 2.3.4, <= 4.5`\n\n## Wildcards In Comparisons\n\nThe `x`, `X`, and `*` characters can be used as a wildcard character. This works for all comparison operators. When used on the `=` operator it falls back to the patch level comparison (see tilde below). For example,\n\n* `1.2.x` is equivalent to `>= 1.2.0, < 1.3.0`\n* `>= 1.2.x` is equivalent to `>= 1.2.0`\n* `<= 2.x` is equivalent to `< 3`\n* `*` is equivalent to `>= 0.0.0`\n\n## Tilde Range Comparisons (Patch)\n\nThe tilde (`~`) comparison operator is for patch level ranges when a minor version is specified and major level changes when the minor number is missing. For example,\n\n* `~1.2.3` is equivalent to `>= 1.2.3, < 1.3.0`\n* `~1` is equivalent to `>= 1, < 2`\n* `~2.3` is equivalent to `>= 2.3, < 2.4`\n* `~1.2.x` is equivalent to `>= 1.2.0, < 1.3.0`\n* `~1.x` is equivalent to `>= 1, < 2`\n\n## Caret Range Comparisons (Major)\n\nThe caret (`^`) comparison operator is for major level changes. This is useful when comparisons of API versions as a major change is API breaking. For example,\n\n* `^1.2.3` is equivalent to `>= 1.2.3, < 2.0.0`\n* `^1.2.x` is equivalent to `>= 1.2.0, < 2.0.0`\n* `^2.3` is equivalent to `>= 2.3, < 3`\n* `^2.x` is equivalent to `>= 2.0.0, < 3`\n"
  },
  {
    "path": "gb/gb.go",
    "content": "package gb\n\nimport (\n\t\"encoding/json\"\n\t\"os\"\n\t\"path/filepath\"\n\n\t\"github.com/Masterminds/glide/cfg\"\n\t\"github.com/Masterminds/glide/msg\"\n\tgpath \"github.com/Masterminds/glide/path\"\n\t\"github.com/Masterminds/glide/util\"\n)\n\n// Has returns true if this dir has a GB-flavored manifest file.\nfunc Has(dir string) bool {\n\tpath := filepath.Join(dir, \"vendor/manifest\")\n\t_, err := os.Stat(path)\n\treturn err == nil\n}\n\n// Parse parses a GB-flavored manifest file.\nfunc Parse(dir string) ([]*cfg.Dependency, error) {\n\tpath := filepath.Join(dir, \"vendor/manifest\")\n\tif fi, err := os.Stat(path); err != nil || fi.IsDir() {\n\t\treturn []*cfg.Dependency{}, nil\n\t}\n\n\tmsg.Info(\"Found GB manifest file in %s\", gpath.StripBasepath(dir))\n\tmsg.Info(\"--> Parsing GB metadata...\")\n\tbuf := []*cfg.Dependency{}\n\tfile, err := os.Open(path)\n\tif err != nil {\n\t\treturn buf, err\n\t}\n\tdefer file.Close()\n\n\tman := Manifest{}\n\n\tdec := json.NewDecoder(file)\n\tif err := dec.Decode(&man); err != nil {\n\t\treturn buf, err\n\t}\n\n\tseen := map[string]bool{}\n\n\tfor _, d := range man.Dependencies {\n\t\tpkg, sub := util.NormalizeName(d.Importpath)\n\t\tif _, ok := seen[pkg]; ok {\n\t\t\tif len(sub) == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor _, dep := range buf {\n\t\t\t\tif dep.Name == pkg {\n\t\t\t\t\tdep.Subpackages = append(dep.Subpackages, sub)\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tseen[pkg] = true\n\t\t\tdep := &cfg.Dependency{\n\t\t\t\tName:       pkg,\n\t\t\t\tReference:  d.Revision,\n\t\t\t\tRepository: d.Repository,\n\t\t\t}\n\t\t\tif len(sub) > 0 {\n\t\t\t\tdep.Subpackages = []string{sub}\n\t\t\t}\n\t\t\tbuf = append(buf, dep)\n\t\t}\n\t}\n\treturn buf, nil\n}\n"
  },
  {
    "path": "gb/manifest.go",
    "content": "// Package gb provides compatibility with GB manifests.\npackage gb\n\n// This is lifted wholesale from GB's `vendor/manifest.go` file.\n//\n// gb's license is MIT-style.\n\n// Manifest represents the GB manifest file\ntype Manifest struct {\n\tVersion      int          `json:\"version\"`\n\tDependencies []Dependency `json:\"dependencies\"`\n}\n\n// Dependency represents an individual dependency in the GB manifest file\ntype Dependency struct {\n\tImportpath string `json:\"importpath\"`\n\tRepository string `json:\"repository\"`\n\tRevision   string `json:\"revision\"`\n\tBranch     string `json:\"branch\"`\n\tPath       string `json:\"path,omitempty\"`\n}\n"
  },
  {
    "path": "glide.go",
    "content": "// Glide is a command line utility that manages Go project dependencies.\n//\n// Configuration of where to start is managed via a glide.yaml in the root of a\n// project. The yaml\n//\n// A glide.yaml file looks like:\n//\n//\t\tpackage: github.com/Masterminds/glide\n//\t\timports:\n//\t\t- package: github.com/Masterminds/cookoo\n//\t\t- package: github.com/kylelemons/go-gypsy\n//\t\t  subpackages:\n//\t\t  - yaml\n//\n// Glide puts dependencies in a vendor directory. Go utilities require this to\n// be in your GOPATH. Glide makes this easy.\n//\n// For more information use the `glide help` command or see https://glide.sh\npackage main\n\nimport (\n\t\"path/filepath\"\n\n\t\"github.com/Masterminds/glide/action\"\n\t\"github.com/Masterminds/glide/cache\"\n\t\"github.com/Masterminds/glide/msg\"\n\tgpath \"github.com/Masterminds/glide/path\"\n\t\"github.com/Masterminds/glide/repo\"\n\t\"github.com/Masterminds/glide/util\"\n\n\t\"github.com/codegangsta/cli\"\n\n\t\"fmt\"\n\t\"os\"\n)\n\nvar version = \"0.13.4-dev\"\n\nconst usage = `Vendor Package Management for your Go projects.\n\n   Each project should have a 'glide.yaml' file in the project directory. Files\n   look something like this:\n\n       package: github.com/Masterminds/glide\n       imports:\n       - package: github.com/Masterminds/cookoo\n         version: 1.1.0\n       - package: github.com/kylelemons/go-gypsy\n         subpackages:\n         - yaml\n\n   For more details on the 'glide.yaml' files see the documentation at\n   https://glide.sh/docs/glide.yaml\n`\n\n// VendorDir default vendor directory name\nvar VendorDir = \"vendor\"\n\nfunc main() {\n\tapp := cli.NewApp()\n\tapp.Name = \"glide\"\n\tapp.Usage = usage\n\tapp.Version = version\n\tapp.Flags = []cli.Flag{\n\t\tcli.StringFlag{\n\t\t\tName:  \"yaml, y\",\n\t\t\tValue: \"glide.yaml\",\n\t\t\tUsage: \"Set a YAML configuration file.\",\n\t\t},\n\t\tcli.BoolFlag{\n\t\t\tName:  \"quiet, q\",\n\t\t\tUsage: \"Quiet (no info or debug messages)\",\n\t\t},\n\t\tcli.BoolFlag{\n\t\t\tName:  \"debug\",\n\t\t\tUsage: \"Print debug verbose informational messages\",\n\t\t},\n\t\tcli.StringFlag{\n\t\t\tName:   \"home\",\n\t\t\tValue:  gpath.Home(),\n\t\t\tUsage:  \"The location of Glide files\",\n\t\t\tEnvVar: \"GLIDE_HOME\",\n\t\t},\n\t\tcli.StringFlag{\n\t\t\tName:   \"tmp\",\n\t\t\tValue:  \"\",\n\t\t\tUsage:  \"The temp directory to use. Defaults to systems temp\",\n\t\t\tEnvVar: \"GLIDE_TMP\",\n\t\t},\n\t\tcli.BoolFlag{\n\t\t\tName:  \"no-color\",\n\t\t\tUsage: \"Turn off colored output for log messages\",\n\t\t},\n\t}\n\tapp.CommandNotFound = func(c *cli.Context, command string) {\n\t\t// TODO: Set some useful env vars.\n\t\taction.Plugin(command, os.Args)\n\t}\n\tapp.Before = startup\n\tapp.After = shutdown\n\tapp.Commands = commands()\n\n\t// Detect errors from the Before and After calls and exit on them.\n\tif err := app.Run(os.Args); err != nil {\n\t\tmsg.Err(err.Error())\n\t\tos.Exit(1)\n\t}\n\n\t// If there was an Error message exit non-zero.\n\tif msg.HasErrored() {\n\t\tm := msg.Color(msg.Red, \"An Error has occurred\")\n\t\tmsg.Msg(m)\n\t\tos.Exit(2)\n\t}\n}\n\nfunc commands() []cli.Command {\n\treturn []cli.Command{\n\t\t{\n\t\t\tName:      \"create\",\n\t\t\tShortName: \"init\",\n\t\t\tUsage:     \"Initialize a new project, creating a glide.yaml file\",\n\t\t\tDescription: `This command starts from a project without Glide and\n   sets it up. It generates a glide.yaml file, parsing your codebase to guess\n   the dependencies to include. Once this step is done you may edit the\n   glide.yaml file to update imported dependency properties such as the version\n   or version range to include.\n\n   To fetch the dependencies you may run 'glide install'.`,\n\t\t\tFlags: []cli.Flag{\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:  \"skip-import\",\n\t\t\t\t\tUsage: \"When initializing skip importing from other package managers.\",\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:  \"non-interactive\",\n\t\t\t\t\tUsage: \"Disable interactive prompts.\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\taction.Create(\".\", c.Bool(\"skip-import\"), c.Bool(\"non-interactive\"))\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName:      \"config-wizard\",\n\t\t\tShortName: \"cw\",\n\t\t\tUsage:     \"Wizard that makes optional suggestions to improve config in a glide.yaml file.\",\n\t\t\tDescription: `Glide will analyze a projects glide.yaml file and the imported\n\t\tprojects to find ways the glide.yaml file can potentially be improved. It\n\t\twill then interactively make suggestions that you can skip or accept.`,\n\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\taction.ConfigWizard(\".\")\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName:  \"get\",\n\t\t\tUsage: \"Install one or more packages into `vendor/` and add dependency to glide.yaml.\",\n\t\t\tDescription: `Gets one or more package (like 'go get') and then adds that file\n   to the glide.yaml file. Multiple package names can be specified on one line.\n\n       $ glide get github.com/Masterminds/cookoo/web\n\n   The above will install the project github.com/Masterminds/cookoo and add\n   the subpackage 'web'.\n\n   If a fetched dependency has a glide.yaml file, configuration from Godep,\n   GPM, GOM, or GB Glide that configuration will be used to find the dependencies\n   and versions to fetch. If those are not available the dependent packages will\n   be fetched as either a version specified elsewhere or the latest version.\n\n   When adding a new dependency Glide will perform an update to work out\n   the versions for the dependencies of this dependency (transitive ones). This\n   will generate an updated glide.lock file with specific locked versions to use.\n\n   The '--strip-vendor' flag will remove any nested 'vendor' folders and\n   'Godeps/_workspace' folders after an update (along with undoing any Godep\n   import rewriting). Note, The Godeps specific functionality is deprecated and\n   will be removed when most Godeps users have migrated to using the vendor\n   folder.`,\n\t\t\tFlags: []cli.Flag{\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:  \"test\",\n\t\t\t\t\tUsage: \"Add test dependencies.\",\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:  \"insecure\",\n\t\t\t\t\tUsage: \"Use http:// rather than https:// to retrieve packages.\",\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:  \"no-recursive, quick\",\n\t\t\t\t\tUsage: \"Disable updating dependencies' dependencies.\",\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:  \"force\",\n\t\t\t\t\tUsage: \"If there was a change in the repo or VCS switch to new one. Warning, changes will be lost.\",\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:  \"all-dependencies\",\n\t\t\t\t\tUsage: \"This will resolve all dependencies for all packages, not just those directly used.\",\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:   \"update-vendored, u\",\n\t\t\t\t\tUsage:  \"Update vendored packages (without local VCS repo). Warning, changes will be lost.\",\n\t\t\t\t\tHidden: true,\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:   \"cache\",\n\t\t\t\t\tUsage:  \"When downloading dependencies attempt to cache them.\",\n\t\t\t\t\tHidden: true,\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:   \"cache-gopath\",\n\t\t\t\t\tUsage:  \"When downloading dependencies attempt to put them in the GOPATH, too.\",\n\t\t\t\t\tHidden: true,\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:   \"use-gopath\",\n\t\t\t\t\tUsage:  \"Copy dependencies from the GOPATH if they exist there.\",\n\t\t\t\t\tHidden: true,\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:  \"resolve-current\",\n\t\t\t\t\tUsage: \"Resolve dependencies for only the current system rather than all build modes.\",\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:   \"strip-vcs, s\",\n\t\t\t\t\tUsage:  \"Removes version control metadata (e.g, .git directory) from the vendor folder.\",\n\t\t\t\t\tHidden: true,\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:  \"strip-vendor, v\",\n\t\t\t\t\tUsage: \"Removes nested vendor and Godeps/_workspace directories.\",\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:  \"non-interactive\",\n\t\t\t\t\tUsage: \"Disable interactive prompts.\",\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:  \"skip-test\",\n\t\t\t\t\tUsage: \"Resolve dependencies in test files.\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\tif c.Bool(\"delete\") {\n\t\t\t\t\tmsg.Warn(\"The --delete flag is deprecated. This now works by default.\")\n\t\t\t\t}\n\t\t\t\tif c.Bool(\"update-vendored\") {\n\t\t\t\t\tmsg.Warn(\"The --update-vendored flag is deprecated. This now works by default.\")\n\t\t\t\t}\n\t\t\t\tif c.String(\"file\") != \"\" {\n\t\t\t\t\tmsg.Warn(\"The --file flag is deprecated.\")\n\t\t\t\t}\n\t\t\t\tif c.Bool(\"cache\") {\n\t\t\t\t\tmsg.Warn(\"The --cache flag is deprecated. This now works by default.\")\n\t\t\t\t}\n\t\t\t\tif c.Bool(\"cache-gopath\") {\n\t\t\t\t\tmsg.Warn(\"The --cache-gopath flag is deprecated.\")\n\t\t\t\t}\n\t\t\t\tif c.Bool(\"use-gopath\") {\n\t\t\t\t\tmsg.Warn(\"The --use-gopath flag is deprecated. Please see overrides.\")\n\t\t\t\t}\n\t\t\t\tif c.Bool(\"strip-vcs\") {\n\t\t\t\t\tmsg.Warn(\"The --strip-vcs flag is deprecated. This now works by default.\")\n\t\t\t\t}\n\n\t\t\t\tif len(c.Args()) < 1 {\n\t\t\t\t\tfmt.Println(\"Oops! Package name is required.\")\n\t\t\t\t\tos.Exit(1)\n\t\t\t\t}\n\n\t\t\t\tif c.Bool(\"resolve-current\") {\n\t\t\t\t\tutil.ResolveCurrent = true\n\t\t\t\t\tmsg.Warn(\"Only resolving dependencies for the current OS/Arch.\")\n\t\t\t\t}\n\n\t\t\t\tinst := repo.NewInstaller()\n\t\t\t\tinst.Force = c.Bool(\"force\")\n\t\t\t\tinst.ResolveAllFiles = c.Bool(\"all-dependencies\")\n\t\t\t\tinst.ResolveTest = !c.Bool(\"skip-test\")\n\t\t\t\tpackages := []string(c.Args())\n\t\t\t\tinsecure := c.Bool(\"insecure\")\n\t\t\t\taction.Get(packages, inst, insecure, c.Bool(\"no-recursive\"), c.Bool(\"strip-vendor\"), c.Bool(\"non-interactive\"), c.Bool(\"test\"))\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName:      \"remove\",\n\t\t\tShortName: \"rm\",\n\t\t\tUsage:     \"Remove a package from the glide.yaml file, and regenerate the lock file.\",\n\t\t\tDescription: `This takes one or more package names, and removes references from the glide.yaml file.\n   This will rebuild the glide lock file re-resolving the depencies.`,\n\t\t\tFlags: []cli.Flag{\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:  \"delete,d\",\n\t\t\t\t\tUsage: \"Also delete from vendor/ any packages that are no longer used.\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\tif len(c.Args()) < 1 {\n\t\t\t\t\tfmt.Println(\"Oops! At least one package name is required.\")\n\t\t\t\t\tos.Exit(1)\n\t\t\t\t}\n\n\t\t\t\tif c.Bool(\"delete\") {\n\t\t\t\t\t// FIXME: Implement this in the installer.\n\t\t\t\t\tfmt.Println(\"Delete is not currently implemented.\")\n\t\t\t\t}\n\t\t\t\tinst := repo.NewInstaller()\n\t\t\t\tinst.Force = c.Bool(\"force\")\n\t\t\t\tpackages := []string(c.Args())\n\t\t\t\taction.Remove(packages, inst)\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName:  \"import\",\n\t\t\tUsage: \"Import files from other dependency management systems.\",\n\t\t\tSubcommands: []cli.Command{\n\t\t\t\t{\n\t\t\t\t\tName:  \"godep\",\n\t\t\t\t\tUsage: \"Import Godep's Godeps.json files and display the would-be yaml file\",\n\t\t\t\t\tFlags: []cli.Flag{\n\t\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\t\tName:  \"file, f\",\n\t\t\t\t\t\t\tUsage: \"Save all of the discovered dependencies to a Glide YAML file.\",\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\t\t\taction.ImportGodep(c.String(\"file\"))\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tName:  \"gpm\",\n\t\t\t\t\tUsage: \"Import GPM's Godeps and Godeps-Git files and display the would-be yaml file\",\n\t\t\t\t\tFlags: []cli.Flag{\n\t\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\t\tName:  \"file, f\",\n\t\t\t\t\t\t\tUsage: \"Save all of the discovered dependencies to a Glide YAML file.\",\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\t\t\taction.ImportGPM(c.String(\"file\"))\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tName:  \"gb\",\n\t\t\t\t\tUsage: \"Import gb's manifest file and display the would-be yaml file\",\n\t\t\t\t\tFlags: []cli.Flag{\n\t\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\t\tName:  \"file, f\",\n\t\t\t\t\t\t\tUsage: \"Save all of the discovered dependencies to a Glide YAML file.\",\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\t\t\taction.ImportGB(c.String(\"file\"))\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tName:  \"gom\",\n\t\t\t\t\tUsage: \"Import Gomfile and display the would-be yaml file\",\n\t\t\t\t\tFlags: []cli.Flag{\n\t\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\t\tName:  \"file, f\",\n\t\t\t\t\t\t\tUsage: \"Save all of the discovered dependencies to a Glide YAML file.\",\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\t\t\taction.ImportGom(c.String(\"file\"))\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName:        \"name\",\n\t\t\tUsage:       \"Print the name of this project.\",\n\t\t\tDescription: `Read the glide.yaml file and print the name given on the 'package' line.`,\n\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\taction.Name()\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName:      \"novendor\",\n\t\t\tShortName: \"nv\",\n\t\t\tUsage:     \"List all non-vendor paths in a directory.\",\n\t\t\tDescription: `Given a directory, list all the relevant Go paths that are not vendored.\n\nExample:\n   $ go test $(glide novendor)`,\n\t\t\tFlags: []cli.Flag{\n\t\t\t\tcli.StringFlag{\n\t\t\t\t\tName:  \"dir,d\",\n\t\t\t\t\tUsage: \"Specify a directory to run novendor against.\",\n\t\t\t\t\tValue: \".\",\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:  \"no-subdir,x\",\n\t\t\t\t\tUsage: \"Specify this to prevent nv from append '/...' to all directories.\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\taction.NoVendor(c.String(\"dir\"), true, !c.Bool(\"no-subdir\"))\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName:  \"rebuild\",\n\t\t\tUsage: \"Rebuild ('go build') the dependencies\",\n\t\t\tDescription: `(Deprecated) This rebuilds the packages' '.a' files. On some systems\n\tthis can improve performance on subsequent 'go run' and 'go build' calls.`,\n\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\taction.Rebuild()\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName:      \"install\",\n\t\t\tShortName: \"i\",\n\t\t\tUsage:     \"Install a project's dependencies\",\n\t\t\tDescription: `This uses the native VCS of each package to install\n   the appropriate version. There are two ways a project's dependencies can\n   be installed. When there is a glide.yaml file defining the dependencies but\n   no lock file (glide.lock) the dependencies are installed using the \"update\"\n   command and a glide.lock file is generated pinning all dependencies. If a\n   glide.lock file is already present the dependencies are installed or updated\n   from the lock file.`,\n\t\t\tFlags: []cli.Flag{\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:   \"delete\",\n\t\t\t\t\tUsage:  \"Delete vendor packages not specified in config.\",\n\t\t\t\t\tHidden: true,\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:  \"force\",\n\t\t\t\t\tUsage: \"If there was a change in the repo or VCS switch to new one. Warning: changes will be lost.\",\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:   \"update-vendored, u\",\n\t\t\t\t\tUsage:  \"Update vendored packages (without local VCS repo). Warning: this may destroy local modifications to vendor/.\",\n\t\t\t\t\tHidden: true,\n\t\t\t\t},\n\t\t\t\tcli.StringFlag{\n\t\t\t\t\tName:   \"file, f\",\n\t\t\t\t\tUsage:  \"Save all of the discovered dependencies to a Glide YAML file. (DEPRECATED: This has no impact.)\",\n\t\t\t\t\tHidden: true,\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:   \"cache\",\n\t\t\t\t\tUsage:  \"When downloading dependencies attempt to cache them.\",\n\t\t\t\t\tHidden: true,\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:   \"cache-gopath\",\n\t\t\t\t\tUsage:  \"When downloading dependencies attempt to put them in the GOPATH, too.\",\n\t\t\t\t\tHidden: true,\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:   \"use-gopath\",\n\t\t\t\t\tUsage:  \"Copy dependencies from the GOPATH if they exist there.\",\n\t\t\t\t\tHidden: true,\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:   \"strip-vcs, s\",\n\t\t\t\t\tUsage:  \"Removes version control metadata (e.g, .git directory) from the vendor folder.\",\n\t\t\t\t\tHidden: true,\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:  \"strip-vendor, v\",\n\t\t\t\t\tUsage: \"Removes nested vendor and Godeps/_workspace directories.\",\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:  \"skip-test\",\n\t\t\t\t\tUsage: \"Resolve dependencies in test files.\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\tif c.Bool(\"delete\") {\n\t\t\t\t\tmsg.Warn(\"The --delete flag is deprecated. This now works by default.\")\n\t\t\t\t}\n\t\t\t\tif c.Bool(\"update-vendored\") {\n\t\t\t\t\tmsg.Warn(\"The --update-vendored flag is deprecated. This now works by default.\")\n\t\t\t\t}\n\t\t\t\tif c.String(\"file\") != \"\" {\n\t\t\t\t\tmsg.Warn(\"The --flag flag is deprecated.\")\n\t\t\t\t}\n\t\t\t\tif c.Bool(\"cache\") {\n\t\t\t\t\tmsg.Warn(\"The --cache flag is deprecated. This now works by default.\")\n\t\t\t\t}\n\t\t\t\tif c.Bool(\"cache-gopath\") {\n\t\t\t\t\tmsg.Warn(\"The --cache-gopath flag is deprecated.\")\n\t\t\t\t}\n\t\t\t\tif c.Bool(\"use-gopath\") {\n\t\t\t\t\tmsg.Warn(\"The --use-gopath flag is deprecated. Please see overrides.\")\n\t\t\t\t}\n\t\t\t\tif c.Bool(\"strip-vcs\") {\n\t\t\t\t\tmsg.Warn(\"The --strip-vcs flag is deprecated. This now works by default.\")\n\t\t\t\t}\n\n\t\t\t\tinstaller := repo.NewInstaller()\n\t\t\t\tinstaller.Force = c.Bool(\"force\")\n\t\t\t\tinstaller.Home = c.GlobalString(\"home\")\n\t\t\t\tinstaller.ResolveTest = !c.Bool(\"skip-test\")\n\n\t\t\t\taction.Install(installer, c.Bool(\"strip-vendor\"))\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName:      \"update\",\n\t\t\tShortName: \"up\",\n\t\t\tUsage:     \"Update a project's dependencies\",\n\t\t\tDescription: `This updates the dependencies by scanning the codebase\n   to determine the needed dependencies and fetching them following the rules\n   in the glide.yaml file. When no rules exist the tip of the default branch\n   is used. For more details see https://glide.sh/docs/glide.yaml\n\n   If a dependency has a glide.yaml file, update will read that file and\n   use the information contained there. Those dependencies are maintained in\n   the top level 'vendor/' directory. 'vendor/foo/bar' will have its\n   dependencies stored in 'vendor/'. This behavior can be disabled with\n   '--no-recursive'. When this behavior is skipped a glide.lock file is not\n   generated because the full dependency tree cannot be known.\n\n   Glide will also import Godep, GB, GOM, and GPM files as it finds them in dependencies.\n   It will create a glide.yaml file from the Godeps data, and then update. This\n   has no effect if '--no-recursive' is set.\n\n   The '--strip-vendor' flag will remove any nested 'vendor' folders and\n   'Godeps/_workspace' folders after an update (along with undoing any Godep\n   import rewriting). Note, the Godeps specific functionality is deprecated and\n   will be removed when most Godeps users have migrated to using the vendor\n   folder.`,\n\t\t\tFlags: []cli.Flag{\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:   \"delete\",\n\t\t\t\t\tUsage:  \"Delete vendor packages not specified in config.\",\n\t\t\t\t\tHidden: true,\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:  \"no-recursive, quick\",\n\t\t\t\t\tUsage: \"Disable updating dependencies' dependencies. Only update things in glide.yaml.\",\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:  \"force\",\n\t\t\t\t\tUsage: \"If there was a change in the repo or VCS switch to new one. Warning, changes will be lost.\",\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:  \"all-dependencies\",\n\t\t\t\t\tUsage: \"This will resolve all dependencies for all packages, not just those directly used.\",\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:   \"update-vendored, u\",\n\t\t\t\t\tUsage:  \"Update vendored packages (without local VCS repo). Warning, changes will be lost.\",\n\t\t\t\t\tHidden: true,\n\t\t\t\t},\n\t\t\t\tcli.StringFlag{\n\t\t\t\t\tName:   \"file, f\",\n\t\t\t\t\tUsage:  \"Save all of the discovered dependencies to a Glide YAML file.\",\n\t\t\t\t\tHidden: true,\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:   \"cache\",\n\t\t\t\t\tUsage:  \"When downloading dependencies attempt to cache them.\",\n\t\t\t\t\tHidden: true,\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:   \"cache-gopath\",\n\t\t\t\t\tUsage:  \"When downloading dependencies attempt to put them in the GOPATH, too.\",\n\t\t\t\t\tHidden: true,\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:   \"use-gopath\",\n\t\t\t\t\tUsage:  \"Copy dependencies from the GOPATH if they exist there.\",\n\t\t\t\t\tHidden: true,\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:  \"resolve-current\",\n\t\t\t\t\tUsage: \"Resolve dependencies for only the current system rather than all build modes.\",\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:   \"strip-vcs, s\",\n\t\t\t\t\tUsage:  \"Removes version control metadata (e.g, .git directory) from the vendor folder.\",\n\t\t\t\t\tHidden: true,\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:  \"strip-vendor, v\",\n\t\t\t\t\tUsage: \"Removes nested vendor and Godeps/_workspace directories.\",\n\t\t\t\t},\n\t\t\t\tcli.BoolFlag{\n\t\t\t\t\tName:  \"skip-test\",\n\t\t\t\t\tUsage: \"Resolve dependencies in test files.\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\tif c.Bool(\"delete\") {\n\t\t\t\t\tmsg.Warn(\"The --delete flag is deprecated. This now works by default.\")\n\t\t\t\t}\n\t\t\t\tif c.Bool(\"update-vendored\") {\n\t\t\t\t\tmsg.Warn(\"The --update-vendored flag is deprecated. This now works by default.\")\n\t\t\t\t}\n\t\t\t\tif c.String(\"file\") != \"\" {\n\t\t\t\t\tmsg.Warn(\"The --flag flag is deprecated.\")\n\t\t\t\t}\n\t\t\t\tif c.Bool(\"cache\") {\n\t\t\t\t\tmsg.Warn(\"The --cache flag is deprecated. This now works by default.\")\n\t\t\t\t}\n\t\t\t\tif c.Bool(\"cache-gopath\") {\n\t\t\t\t\tmsg.Warn(\"The --cache-gopath flag is deprecated.\")\n\t\t\t\t}\n\t\t\t\tif c.Bool(\"use-gopath\") {\n\t\t\t\t\tmsg.Warn(\"The --use-gopath flag is deprecated. Please see overrides.\")\n\t\t\t\t}\n\t\t\t\tif c.Bool(\"strip-vcs\") {\n\t\t\t\t\tmsg.Warn(\"The --strip-vcs flag is deprecated. This now works by default.\")\n\t\t\t\t}\n\n\t\t\t\tif c.Bool(\"resolve-current\") {\n\t\t\t\t\tutil.ResolveCurrent = true\n\t\t\t\t\tmsg.Warn(\"Only resolving dependencies for the current OS/Arch\")\n\t\t\t\t}\n\n\t\t\t\tinstaller := repo.NewInstaller()\n\t\t\t\tinstaller.Force = c.Bool(\"force\")\n\t\t\t\tinstaller.ResolveAllFiles = c.Bool(\"all-dependencies\")\n\t\t\t\tinstaller.Home = c.GlobalString(\"home\")\n\t\t\t\tinstaller.ResolveTest = !c.Bool(\"skip-test\")\n\n\t\t\t\taction.Update(installer, c.Bool(\"no-recursive\"), c.Bool(\"strip-vendor\"))\n\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName:  \"tree\",\n\t\t\tUsage: \"(Deprecated) Tree prints the dependencies of this project as a tree.\",\n\t\t\tDescription: `This scans a project's source files and builds a tree\n   representation of the import graph.\n\n   It ignores testdata/ and directories that begin with . or _. Packages in\n   vendor/ are only included if they are referenced by the main project or\n   one of its dependencies.\n\n   Note, for large projects this can display a large list tens of thousands of\n   lines long.`,\n\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\taction.Tree(\".\", false)\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName:  \"list\",\n\t\t\tUsage: \"List prints all dependencies that the present code references.\",\n\t\t\tDescription: `List scans your code and lists all of the packages that are used.\n\n   It does not use the glide.yaml. Instead, it inspects the code to determine what packages are\n   imported.\n\n   Directories that begin with . or _ are ignored, as are testdata directories. Packages in\n   vendor are only included if they are used by the project.`,\n\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\taction.List(\".\", true, c.String(\"output\"))\n\t\t\t\treturn nil\n\t\t\t},\n\t\t\tFlags: []cli.Flag{\n\t\t\t\tcli.StringFlag{\n\t\t\t\t\tName:  \"output, o\",\n\t\t\t\t\tUsage: \"Output format. One of: json|json-pretty|text\",\n\t\t\t\t\tValue: \"text\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName:  \"info\",\n\t\t\tUsage: \"Info prints information about this project\",\n\t\t\tFlags: []cli.Flag{\n\t\t\t\tcli.StringFlag{\n\t\t\t\t\tName:  \"format, f\",\n\t\t\t\t\tUsage: `Format of the information wanted (required).`,\n\t\t\t\t},\n\t\t\t},\n\t\t\tDescription: `A format containing the text with replacement variables\n   has to be passed in. Those variables are:\n\n       %n - name\n       %d - description\n       %h - homepage\n       %l - license\n\n   For example, given a project with the following glide.yaml:\n\n       package: foo\n       homepage: https://example.com\n       license: MIT\n       description: Some example description\n\n   Then running the following commands:\n\n       glide info -f %n\n          prints 'foo'\n\n       glide info -f \"License: %l\"\n          prints 'License: MIT'\n\n       glide info -f \"%n - %d - %h - %l\"\n          prints 'foo - Some example description - https://example.com - MIT'`,\n\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\tif c.IsSet(\"format\") {\n\t\t\t\t\taction.Info(c.String(\"format\"))\n\t\t\t\t} else {\n\t\t\t\t\tcli.ShowCommandHelp(c, c.Command.Name)\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName:      \"cache-clear\",\n\t\t\tShortName: \"cc\",\n\t\t\tUsage:     \"Clears the Glide cache.\",\n\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\taction.CacheClear()\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName:  \"about\",\n\t\t\tUsage: \"Learn about Glide\",\n\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\taction.About()\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName:  \"mirror\",\n\t\t\tUsage: \"Manage mirrors\",\n\t\t\tDescription: `Mirrors provide the ability to replace a repo location with\n   another location that's a mirror of the original. This is useful when you want\n   to have a cache for your continuous integration (CI) system or if you want to\n   work on a dependency in a local location.\n\n   The mirrors are stored in a mirrors.yaml file in your GLIDE_HOME.\n\n   The three commands to manage mirrors are 'list', 'set', and 'remove'.\n\n   Use 'set' in the form:\n\n       glide mirror set [original] [replacement]\n\n   or\n\n       glide mirror set [original] [replacement] --vcs [type]\n\n   for example,\n\n       glide mirror set https://github.com/example/foo https://git.example.com/example/foo.git\n\n       glide mirror set https://github.com/example/foo file:///path/to/local/repo --vcs git\n\n   Use 'remove' in the form:\n\n       glide mirror remove [original]\n\n   for example,\n\n       glide mirror remove https://github.com/example/foo`,\n\t\t\tSubcommands: []cli.Command{\n\t\t\t\t{\n\t\t\t\t\tName:  \"list\",\n\t\t\t\t\tUsage: \"List the current mirrors\",\n\t\t\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\t\t\treturn action.MirrorsList()\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tName:  \"set\",\n\t\t\t\t\tUsage: \"Set a mirror. This overwrites an existing entry if one exists\",\n\t\t\t\t\tDescription: `Use 'set' in the form:\n\n       glide mirror set [original] [replacement]\n\n   or\n\n       glide mirror set [original] [replacement] --vcs [type]\n\n   for example,\n\n       glide mirror set https://github.com/example/foo https://git.example.com/example/foo.git\n\n       glide mirror set https://github.com/example/foo file:///path/to/local/repo --vcs git`,\n\t\t\t\t\tFlags: []cli.Flag{\n\t\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\t\tName:  \"vcs\",\n\t\t\t\t\t\t\tUsage: \"The VCS type to use. Autodiscovery is attempted when not supplied. Can be one of git, svn, bzr, or hg\",\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\t\t\treturn action.MirrorsSet(c.Args().Get(0), c.Args().Get(1), c.String(\"vcs\"))\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tName:      \"remove\",\n\t\t\t\t\tShortName: \"rm\",\n\t\t\t\t\tUsage:     \"Remove a mirror\",\n\t\t\t\t\tDescription: `Use 'remove' in the form:\n\n       glide mirror remove [original]\n\n   for example,\n\n       glide mirror remove https://github.com/example/foo`,\n\t\t\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\t\t\treturn action.MirrorsRemove(c.Args().Get(0))\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n}\n\n// startup sets up the base environment.\n//\n// It does not assume the presence of a Glide.yaml file or vendor/ directory,\n// so it can be used by any Glide command.\nfunc startup(c *cli.Context) error {\n\taction.Debug(c.Bool(\"debug\"))\n\taction.NoColor(c.Bool(\"no-color\"))\n\taction.Quiet(c.Bool(\"quiet\"))\n\taction.Init(c.String(\"yaml\"), c.String(\"home\"))\n\taction.EnsureGoVendor()\n\tgpath.Tmp = c.String(\"tmp\")\n\treturn nil\n}\n\nfunc shutdown(c *cli.Context) error {\n\tcache.SystemUnlock()\n\treturn nil\n}\n\n// Get the path to the glide.yaml file.\n//\n// This returns the name of the path, even if the file does not exist. The value\n// may be set by the user, or it may be the default.\nfunc glidefile(c *cli.Context) string {\n\tpath := c.String(\"file\")\n\tif path == \"\" {\n\t\t// For now, we construct a basic assumption. In the future, we could\n\t\t// traverse backward to see if a glide.yaml exists in a parent.\n\t\tpath = \"./glide.yaml\"\n\t}\n\ta, err := filepath.Abs(path)\n\tif err != nil {\n\t\t// Underlying fs didn't provide working dir.\n\t\treturn path\n\t}\n\treturn a\n}\n"
  },
  {
    "path": "glide.yaml",
    "content": "package: github.com/Masterminds/glide\nhomepage: https://glide.sh\nlicense: MIT\nowners:\n- name: Matt Butcher\n  email: technosophos@gmail.com\n  homepage: http://technosophos.com/\n- name: Matt Farina\n  email: matt@mattfarina.com\n  homepage: https://www.mattfarina.com/\nimport:\n- package: gopkg.in/yaml.v2\n- package: github.com/Masterminds/vcs\n  version: ^1.13.1\n- package: github.com/codegangsta/cli\n  version: ^1.16.0\n- package: github.com/Masterminds/semver\n  version: ^1.4.0\n- package: github.com/mitchellh/go-homedir\n"
  },
  {
    "path": "glide_test.go",
    "content": "package main\n\nimport (\n\t\"testing\"\n)\n\nfunc TestCommandsNonEmpty(t *testing.T) {\n\tcommands := commands()\n\tif len(commands) == 0 {\n\t\tt.Fail()\n\t}\n}\n"
  },
  {
    "path": "godep/godep.go",
    "content": "// Package godep provides basic importing of Godep dependencies.\n//\n// This is not a complete implementation of Godep.\npackage godep\n\nimport (\n\t\"encoding/json\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/Masterminds/glide/cfg\"\n\t\"github.com/Masterminds/glide/msg\"\n\tgpath \"github.com/Masterminds/glide/path\"\n\t\"github.com/Masterminds/glide/util\"\n)\n\n// This file contains commands for working with Godep.\n\n// The Godeps struct from Godep.\n//\n// https://raw.githubusercontent.com/tools/godep/master/dep.go\n//\n// We had to copy this because it's in the package main for Godep.\ntype Godeps struct {\n\tImportPath string\n\tGoVersion  string\n\tPackages   []string `json:\",omitempty\"` // Arguments to save, if any.\n\tDeps       []Dependency\n\n\touterRoot string\n}\n\n// Dependency is a modified version of Godep's Dependency struct.\n// It drops all of the unexported fields.\ntype Dependency struct {\n\tImportPath string\n\tComment    string `json:\",omitempty\"` // Description of commit, if present.\n\tRev        string // VCS-specific commit ID.\n}\n\n// Has is a command to detect if a package contains a Godeps.json file.\nfunc Has(dir string) bool {\n\tpath := filepath.Join(dir, \"Godeps/Godeps.json\")\n\t_, err := os.Stat(path)\n\treturn err == nil\n}\n\n// Parse parses a Godep's Godeps file.\n//\n// It returns the contents as a dependency array.\nfunc Parse(dir string) ([]*cfg.Dependency, error) {\n\tpath := filepath.Join(dir, \"Godeps/Godeps.json\")\n\tif _, err := os.Stat(path); err != nil {\n\t\treturn []*cfg.Dependency{}, nil\n\t}\n\tmsg.Info(\"Found Godeps.json file in %s\", gpath.StripBasepath(dir))\n\tmsg.Info(\"--> Parsing Godeps metadata...\")\n\n\tbuf := []*cfg.Dependency{}\n\n\tgodeps := &Godeps{}\n\n\t// Get a handle to the file.\n\tfile, err := os.Open(path)\n\tif err != nil {\n\t\treturn buf, err\n\t}\n\tdefer file.Close()\n\n\tdec := json.NewDecoder(file)\n\tif err := dec.Decode(godeps); err != nil {\n\t\treturn buf, err\n\t}\n\n\tseen := map[string]bool{}\n\tfor _, d := range godeps.Deps {\n\t\tpkg, sub := util.NormalizeName(d.ImportPath)\n\t\tif _, ok := seen[pkg]; ok {\n\t\t\tif len(sub) == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Modify existing dep with additional subpackages.\n\t\t\tfor _, dep := range buf {\n\t\t\t\tif dep.Name == pkg {\n\t\t\t\t\tdep.Subpackages = append(dep.Subpackages, sub)\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tseen[pkg] = true\n\t\t\tdep := &cfg.Dependency{Name: pkg, Reference: d.Rev}\n\t\t\tif sub != \"\" {\n\t\t\t\tdep.Subpackages = []string{sub}\n\t\t\t}\n\t\t\tbuf = append(buf, dep)\n\t\t}\n\t}\n\n\treturn buf, nil\n}\n\n// RemoveGodepSubpackages strips subpackages from a cfg.Config dependencies that\n// contain \"Godeps/_workspace/src\" as part of the path.\nfunc RemoveGodepSubpackages(c *cfg.Config) *cfg.Config {\n\tfor _, d := range c.Imports {\n\t\tn := []string{}\n\t\tfor _, v := range d.Subpackages {\n\t\t\tif !strings.HasPrefix(v, \"Godeps/_workspace/src\") {\n\t\t\t\tn = append(n, v)\n\t\t\t}\n\t\t}\n\t\td.Subpackages = n\n\t}\n\n\tfor _, d := range c.DevImports {\n\t\tn := []string{}\n\t\tfor _, v := range d.Subpackages {\n\t\t\tif !strings.HasPrefix(v, \"Godeps/_workspace/src\") {\n\t\t\t\tn = append(n, v)\n\t\t\t}\n\t\t}\n\t\td.Subpackages = n\n\t}\n\n\treturn c\n}\n"
  },
  {
    "path": "godep/strip/strip.go",
    "content": "// Package strip removes Godeps/_workspace and undoes the Godep rewrites. This\n// essentially removes the old style (pre-vendor) Godep vendoring.\n//\n// Note, this functionality is deprecated. Once more projects use the Godep\n// support for the core vendoring this will no longer be needed.\npackage strip\n\nimport (\n\t\"bytes\"\n\t\"go/ast\"\n\t\"go/parser\"\n\t\"go/printer\"\n\t\"go/token\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strconv\"\n\t\"strings\"\n\n\t\"github.com/Masterminds/glide/msg\"\n)\n\nvar godepMark = map[string]bool{}\n\nvar vPath = \"vendor\"\n\n// GodepWorkspace removes any Godeps/_workspace directories and makes sure\n// any rewrites are undone.\n// Note, this is not concuccency safe.\nfunc GodepWorkspace(v string) error {\n\tvPath = v\n\tif _, err := os.Stat(vPath); err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\tmsg.Debug(\"Vendor directory does not exist.\")\n\t\t}\n\n\t\treturn err\n\t}\n\n\terr := filepath.Walk(vPath, stripGodepWorkspaceHandler)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Walk the marked projects to make sure rewrites are undone.\n\tfor k := range godepMark {\n\t\tmsg.Info(\"Removing Godep rewrites for %s\", k)\n\t\terr := filepath.Walk(k, rewriteGodepfilesHandler)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc stripGodepWorkspaceHandler(path string, info os.FileInfo, err error) error {\n\t// Skip the base vendor directory\n\tif path == vPath {\n\t\treturn nil\n\t}\n\n\tname := info.Name()\n\tp := filepath.Dir(path)\n\tpn := filepath.Base(p)\n\tif name == \"_workspace\" && pn == \"Godeps\" {\n\t\tif _, err := os.Stat(path); err == nil {\n\t\t\tif info.IsDir() {\n\t\t\t\t// Marking this location to make sure rewrites are undone.\n\t\t\t\tpp := filepath.Dir(p)\n\t\t\t\tgodepMark[pp] = true\n\n\t\t\t\tmsg.Info(\"Removing: %s\", path)\n\t\t\t\tif err := os.RemoveAll(path); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\treturn filepath.SkipDir\n\t\t\t}\n\n\t\t\tmsg.Debug(\"%s is not a directory. Skipping removal\", path)\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc rewriteGodepfilesHandler(path string, info os.FileInfo, err error) error {\n\tname := info.Name()\n\n\tif info.IsDir() {\n\t\tif name == \"testdata\" || name == \"vendor\" {\n\t\t\treturn filepath.SkipDir\n\t\t}\n\t\treturn nil\n\t}\n\n\tif e := filepath.Ext(path); e != \".go\" {\n\t\treturn nil\n\t}\n\n\tfset := token.NewFileSet()\n\tf, err := parser.ParseFile(fset, path, nil, parser.ParseComments)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar changed bool\n\tfor _, s := range f.Imports {\n\t\tn, err := strconv.Unquote(s.Path.Value)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tq := rewriteGodepImport(n)\n\t\tif q != name {\n\t\t\ts.Path.Value = strconv.Quote(q)\n\t\t\tchanged = true\n\t\t}\n\t}\n\tif !changed {\n\t\treturn nil\n\t}\n\n\tprinterConfig := &printer.Config{Mode: printer.TabIndent | printer.UseSpaces, Tabwidth: 8}\n\tvar buffer bytes.Buffer\n\tif err = printerConfig.Fprint(&buffer, fset, f); err != nil {\n\t\treturn err\n\t}\n\tfset = token.NewFileSet()\n\tf, err = parser.ParseFile(fset, name, &buffer, parser.ParseComments)\n\tast.SortImports(fset, f)\n\ttpath := path + \".temp\"\n\tt, err := os.Create(tpath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err = printerConfig.Fprint(t, fset, f); err != nil {\n\t\treturn err\n\t}\n\tif err = t.Close(); err != nil {\n\t\treturn err\n\t}\n\n\tmsg.Debug(\"Rewriting Godep imports for %s\", path)\n\n\t// This is required before the rename on windows.\n\tif err = os.Remove(path); err != nil {\n\t\treturn err\n\t}\n\treturn os.Rename(tpath, path)\n}\n\nfunc rewriteGodepImport(n string) string {\n\tif !strings.Contains(n, \"Godeps/_workspace/src\") {\n\t\treturn n\n\t}\n\n\ti := strings.LastIndex(n, \"Godeps/_workspace/src\")\n\n\treturn strings.TrimPrefix(n[i:], \"Godeps/_workspace/src/\")\n}\n"
  },
  {
    "path": "godep/strip/strip_test.go",
    "content": "package strip\n\nimport \"testing\"\n\nfunc TestRewriteGodepImport(t *testing.T) {\n\ttests := map[string]string{\n\t\t\"github.com/Masterminds/glide/action\":                           \"github.com/Masterminds/glide/action\",\n\t\t\"github.com/tools/godep/Godeps/_workspace/src/github.com/kr/fs\": \"github.com/kr/fs\",\n\t}\n\n\tfor k, v := range tests {\n\t\to := rewriteGodepImport(k)\n\t\tif o != v {\n\t\t\tt.Errorf(\"Incorrect Godep import path rewritten %s: %s\", v, o)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "gom/gom.go",
    "content": "package gom\n\nimport (\n\t\"errors\"\n\t\"os\"\n\t\"path/filepath\"\n\n\t\"github.com/Masterminds/glide/cfg\"\n\t\"github.com/Masterminds/glide/msg\"\n\tgpath \"github.com/Masterminds/glide/path\"\n\t\"github.com/Masterminds/glide/util\"\n)\n\n// Has returns true if this dir has a Gomfile.\nfunc Has(dir string) bool {\n\tpath := filepath.Join(dir, \"Gomfile\")\n\tfi, err := os.Stat(path)\n\treturn err == nil && !fi.IsDir()\n}\n\n// Parse parses a Gomfile.\nfunc Parse(dir string) ([]*cfg.Dependency, error) {\n\tpath := filepath.Join(dir, \"Gomfile\")\n\tif fi, err := os.Stat(path); err != nil || fi.IsDir() {\n\t\treturn []*cfg.Dependency{}, nil\n\t}\n\n\tmsg.Info(\"Found Gomfile in %s\", gpath.StripBasepath(dir))\n\tmsg.Info(\"--> Parsing Gomfile metadata...\")\n\tbuf := []*cfg.Dependency{}\n\n\tgoms, err := parseGomfile(path)\n\tif err != nil {\n\t\treturn []*cfg.Dependency{}, err\n\t}\n\n\tfor _, gom := range goms {\n\t\t// Do we need to skip this dependency?\n\t\tif val, ok := gom.options[\"skipdep\"]; ok && val.(string) == \"true\" {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Check for custom cloning command\n\t\tif _, ok := gom.options[\"command\"]; ok {\n\t\t\treturn []*cfg.Dependency{}, errors.New(\"Glide does not support custom Gomfile commands\")\n\t\t}\n\n\t\t// Check for groups/environments\n\t\tif val, ok := gom.options[\"group\"]; ok {\n\t\t\tgroups := toStringSlice(val)\n\t\t\tif !stringsContain(groups, \"development\") && !stringsContain(groups, \"production\") {\n\t\t\t\t// right now we only support development and production\n\t\t\t\tmsg.Info(\"Skipping dependency '%s' because it isn't in the development or production group\", gom.name)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tpkg, sub := util.NormalizeName(gom.name)\n\n\t\tdep := &cfg.Dependency{\n\t\t\tName: pkg,\n\t\t}\n\n\t\tif len(sub) > 0 {\n\t\t\tdep.Subpackages = []string{sub}\n\t\t}\n\n\t\t// Check for a specific revision\n\t\tif val, ok := gom.options[\"commit\"]; ok {\n\t\t\tdep.Reference = val.(string)\n\t\t}\n\t\tif val, ok := gom.options[\"tag\"]; ok {\n\t\t\tdep.Reference = val.(string)\n\t\t}\n\t\tif val, ok := gom.options[\"branch\"]; ok {\n\t\t\tdep.Reference = val.(string)\n\t\t}\n\n\t\t// Parse goos and goarch\n\t\tif val, ok := gom.options[\"goos\"]; ok {\n\t\t\tdep.Os = toStringSlice(val)\n\t\t}\n\t\tif val, ok := gom.options[\"goarch\"]; ok {\n\t\t\tdep.Arch = toStringSlice(val)\n\t\t}\n\n\t\tbuf = append(buf, dep)\n\t}\n\n\treturn buf, nil\n}\n\nfunc stringsContain(v []string, key string) bool {\n\tfor _, s := range v {\n\t\tif s == key {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc toStringSlice(v interface{}) []string {\n\tif v, ok := v.(string); ok {\n\t\treturn []string{v}\n\t}\n\n\tif v, ok := v.([]string); ok {\n\t\treturn v\n\t}\n\n\treturn []string{}\n}\n"
  },
  {
    "path": "gom/parser.go",
    "content": "package gom\n\n// This is copied + slightly adapted from gom's `gomfile.go` file.\n//\n// gom's license is MIT-style.\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"regexp\"\n\t\"strings\"\n)\n\nvar qx = `'[^']*'|\"[^\"]*\"`\nvar kx = `:[a-z][a-z0-9_]*`\nvar ax = `(?:\\s*` + kx + `\\s*|,\\s*` + kx + `\\s*)`\nvar reGroup = regexp.MustCompile(`\\s*group\\s+((?:` + kx + `\\s*|,\\s*` + kx + `\\s*)*)\\s*do\\s*$`)\nvar reEnd = regexp.MustCompile(`\\s*end\\s*$`)\nvar reGom = regexp.MustCompile(`^\\s*gom\\s+(` + qx + `)\\s*((?:,\\s*` + kx + `\\s*=>\\s*(?:` + qx + `|\\s*\\[\\s*` + ax + `*\\s*\\]\\s*))*)$`)\nvar reOptions = regexp.MustCompile(`(,\\s*` + kx + `\\s*=>\\s*(?:` + qx + `|\\s*\\[\\s*` + ax + `*\\s*\\]\\s*)\\s*)`)\n\nfunc unquote(name string) string {\n\tname = strings.TrimSpace(name)\n\tif len(name) > 2 {\n\t\tif (name[0] == '\\'' && name[len(name)-1] == '\\'') || (name[0] == '\"' && name[len(name)-1] == '\"') {\n\t\t\treturn name[1 : len(name)-1]\n\t\t}\n\t}\n\treturn name\n}\n\nfunc parseOptions(line string, options map[string]interface{}) {\n\tss := reOptions.FindAllStringSubmatch(line, -1)\n\treA := regexp.MustCompile(ax)\n\tfor _, s := range ss {\n\t\tkvs := strings.SplitN(strings.TrimSpace(s[0])[1:], \"=>\", 2)\n\t\tkvs[0], kvs[1] = strings.TrimSpace(kvs[0]), strings.TrimSpace(kvs[1])\n\t\tif kvs[1][0] == '[' {\n\t\t\tas := reA.FindAllStringSubmatch(kvs[1][1:len(kvs[1])-1], -1)\n\t\t\ta := []string{}\n\t\t\tfor i := range as {\n\t\t\t\tit := strings.TrimSpace(as[i][0])\n\t\t\t\tif strings.HasPrefix(it, \",\") {\n\t\t\t\t\tit = strings.TrimSpace(it[1:])\n\t\t\t\t}\n\t\t\t\tif strings.HasPrefix(it, \":\") {\n\t\t\t\t\tit = strings.TrimSpace(it[1:])\n\t\t\t\t}\n\t\t\t\ta = append(a, it)\n\t\t\t}\n\t\t\toptions[kvs[0][1:]] = a\n\t\t} else {\n\t\t\toptions[kvs[0][1:]] = unquote(kvs[1])\n\t\t}\n\t}\n}\n\n// Gom represents configuration from Gom.\ntype Gom struct {\n\tname    string\n\toptions map[string]interface{}\n}\n\nfunc parseGomfile(filename string) ([]Gom, error) {\n\tf, err := os.Open(filename + \".lock\")\n\tif err != nil {\n\t\tf, err = os.Open(filename)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tbr := bufio.NewReader(f)\n\n\tgoms := make([]Gom, 0)\n\n\tn := 0\n\tskip := 0\n\tvalid := true\n\tvar envs []string\n\tfor {\n\t\tn++\n\t\tlb, _, err := br.ReadLine()\n\t\tif err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\treturn goms, nil\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\t\tline := strings.TrimSpace(string(lb))\n\t\tif line == \"\" || strings.HasPrefix(line, \"#\") {\n\t\t\tcontinue\n\t\t}\n\n\t\tname := \"\"\n\t\toptions := make(map[string]interface{})\n\t\tvar items []string\n\t\tif reGroup.MatchString(line) {\n\t\t\tenvs = strings.Split(reGroup.FindStringSubmatch(line)[1], \",\")\n\t\t\tfor i := range envs {\n\t\t\t\tenvs[i] = strings.TrimSpace(envs[i])[1:]\n\t\t\t}\n\t\t\tvalid = true\n\t\t\tcontinue\n\t\t} else if reEnd.MatchString(line) {\n\t\t\tif !valid {\n\t\t\t\tskip--\n\t\t\t\tif skip < 0 {\n\t\t\t\t\treturn nil, fmt.Errorf(\"Syntax Error at line %d\", n)\n\t\t\t\t}\n\t\t\t}\n\t\t\tvalid = false\n\t\t\tenvs = nil\n\t\t\tcontinue\n\t\t} else if skip > 0 {\n\t\t\tcontinue\n\t\t} else if reGom.MatchString(line) {\n\t\t\titems = reGom.FindStringSubmatch(line)[1:]\n\t\t\tname = unquote(items[0])\n\t\t\tparseOptions(items[1], options)\n\t\t} else {\n\t\t\treturn nil, fmt.Errorf(\"Syntax Error at line %d\", n)\n\t\t}\n\t\tif envs != nil {\n\t\t\toptions[\"group\"] = envs\n\t\t}\n\t\tgoms = append(goms, Gom{name, options})\n\t}\n}\n"
  },
  {
    "path": "gpm/gpm.go",
    "content": "// Package gpm reads GPM's Godeps files.\n//\n// It is not a complete implementaton of GPM.\npackage gpm\n\nimport (\n\t\"bufio\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/Masterminds/glide/cfg\"\n\t\"github.com/Masterminds/glide/msg\"\n\tgpath \"github.com/Masterminds/glide/path\"\n)\n\n// Has indicates whether a Godeps file exists.\nfunc Has(dir string) bool {\n\tpath := filepath.Join(dir, \"Godeps\")\n\t_, err := os.Stat(path)\n\treturn err == nil\n}\n\n// Parse parses a GPM-flavored Godeps file.\nfunc Parse(dir string) ([]*cfg.Dependency, error) {\n\tpath := filepath.Join(dir, \"Godeps\")\n\tif i, err := os.Stat(path); err != nil {\n\t\treturn []*cfg.Dependency{}, nil\n\t} else if i.IsDir() {\n\t\tmsg.Info(\"Godeps is a directory. This is probably a Godep project.\\n\")\n\t\treturn []*cfg.Dependency{}, nil\n\t}\n\tmsg.Info(\"Found Godeps file in %s\", gpath.StripBasepath(dir))\n\tmsg.Info(\"--> Parsing GPM metadata...\")\n\n\tbuf := []*cfg.Dependency{}\n\n\tfile, err := os.Open(path)\n\tif err != nil {\n\t\treturn buf, err\n\t}\n\tscanner := bufio.NewScanner(file)\n\tfor scanner.Scan() {\n\t\tparts, ok := parseGodepsLine(scanner.Text())\n\t\tif ok {\n\t\t\tdep := &cfg.Dependency{Name: parts[0]}\n\t\t\tif len(parts) > 1 {\n\t\t\t\tdep.Reference = parts[1]\n\t\t\t}\n\t\t\tbuf = append(buf, dep)\n\t\t}\n\t}\n\tif err := scanner.Err(); err != nil {\n\t\tmsg.Warn(\"Scan failed: %s\\n\", err)\n\t\treturn buf, err\n\t}\n\n\treturn buf, nil\n}\n\nfunc parseGodepsLine(line string) ([]string, bool) {\n\tline = strings.TrimSpace(line)\n\n\tif len(line) == 0 || strings.HasPrefix(line, \"#\") {\n\t\treturn []string{}, false\n\t}\n\n\treturn strings.Fields(line), true\n}\n"
  },
  {
    "path": "importer/importer.go",
    "content": "// Package importer imports dependency configuration from Glide, Godep, GPM, GB and gom\npackage importer\n\nimport (\n\t\"io/ioutil\"\n\t\"os\"\n\t\"path/filepath\"\n\n\t\"github.com/Masterminds/glide/cfg\"\n\t\"github.com/Masterminds/glide/gb\"\n\t\"github.com/Masterminds/glide/godep\"\n\t\"github.com/Masterminds/glide/gom\"\n\t\"github.com/Masterminds/glide/gpm\"\n)\n\nvar i = &DefaultImporter{}\n\n// Import uses the DefaultImporter to import from Glide, Godep, GPM, GB and gom.\nfunc Import(path string) (bool, []*cfg.Dependency, error) {\n\treturn i.Import(path)\n}\n\n// Importer enables importing depenency configuration.\ntype Importer interface {\n\n\t// Import imports dependency configuration. It returns:\n\t// - A bool if any configuration was found.\n\t// - []*cfg.Dependency containing dependency configuration if any is found.\n\t// - An error if one was reported.\n\tImport(path string) (bool, []*cfg.Dependency, error)\n}\n\n// DefaultImporter imports from Glide, Godep, GPM, GB and gom.\ntype DefaultImporter struct{}\n\n// Import tries to import configuration from Glide, Godep, GPM, GB and gom.\nfunc (d *DefaultImporter) Import(path string) (bool, []*cfg.Dependency, error) {\n\n\t// Try importing from Glide first.\n\tp := filepath.Join(path, \"glide.yaml\")\n\tif _, err := os.Stat(p); err == nil {\n\t\t// We found glide configuration.\n\t\tyml, err := ioutil.ReadFile(p)\n\t\tif err != nil {\n\t\t\treturn false, []*cfg.Dependency{}, err\n\t\t}\n\t\tconf, err := cfg.ConfigFromYaml(yml)\n\t\tif err != nil {\n\t\t\treturn false, []*cfg.Dependency{}, err\n\t\t}\n\t\treturn true, conf.Imports, nil\n\t}\n\n\t// Try importing from Godep\n\tif godep.Has(path) {\n\t\tdeps, err := godep.Parse(path)\n\t\tif err != nil {\n\t\t\treturn false, []*cfg.Dependency{}, err\n\t\t}\n\t\treturn true, deps, nil\n\t}\n\n\t// Try importing from GPM\n\tif gpm.Has(path) {\n\t\tdeps, err := gpm.Parse(path)\n\t\tif err != nil {\n\t\t\treturn false, []*cfg.Dependency{}, err\n\t\t}\n\t\treturn true, deps, nil\n\t}\n\n\t// Try importin from GB\n\tif gb.Has(path) {\n\t\tdeps, err := gb.Parse(path)\n\t\tif err != nil {\n\t\t\treturn false, []*cfg.Dependency{}, err\n\t\t}\n\t\treturn true, deps, nil\n\t}\n\n\t// Try importing from gom\n\tif gom.Has(path) {\n\t\tdeps, err := gom.Parse(path)\n\t\tif err != nil {\n\t\t\treturn false, []*cfg.Dependency{}, err\n\t\t}\n\t\treturn true, deps, nil\n\t}\n\n\t// When none are found.\n\treturn false, []*cfg.Dependency{}, nil\n}\n"
  },
  {
    "path": "mirrors/cfg.go",
    "content": "package mirrors\n\nimport (\n\t\"io/ioutil\"\n\t\"sort\"\n\t\"strings\"\n\n\t\"gopkg.in/yaml.v2\"\n)\n\n// Mirrors contains global mirrors to local configuration\ntype Mirrors struct {\n\n\t// Repos contains repo mirror configuration\n\tRepos MirrorRepos `yaml:\"repos\"`\n}\n\n// Marshal converts a Mirror instance to YAML\nfunc (ov *Mirrors) Marshal() ([]byte, error) {\n\tyml, err := yaml.Marshal(&ov)\n\tif err != nil {\n\t\treturn []byte{}, err\n\t}\n\treturn yml, nil\n}\n\n// WriteFile writes an mirrors.yaml file\n//\n// This is a convenience function that marshals the YAML and then writes it to\n// the given file. If the file exists, it will be clobbered.\nfunc (ov *Mirrors) WriteFile(opath string) error {\n\to, err := ov.Marshal()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ioutil.WriteFile(opath, o, 0666)\n}\n\n// ReadMirrorsFile loads the contents of an mirrors.yaml file.\nfunc ReadMirrorsFile(opath string) (*Mirrors, error) {\n\tyml, err := ioutil.ReadFile(opath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tov, err := FromYaml(yml)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ov, nil\n}\n\n// FromYaml returns an instance of Mirrors from YAML\nfunc FromYaml(yml []byte) (*Mirrors, error) {\n\tov := &Mirrors{}\n\terr := yaml.Unmarshal([]byte(yml), &ov)\n\treturn ov, err\n}\n\n// MarshalYAML is a hook for gopkg.in/yaml.v2.\n// It sorts mirror repos lexicographically for reproducibility.\nfunc (ov *Mirrors) MarshalYAML() (interface{}, error) {\n\n\tsort.Sort(ov.Repos)\n\n\treturn ov, nil\n}\n\n// MirrorRepos is a slice of Mirror pointers\ntype MirrorRepos []*MirrorRepo\n\n// Len returns the length of the MirrorRepos. This is needed for sorting with\n// the sort package.\nfunc (o MirrorRepos) Len() int {\n\treturn len(o)\n}\n\n// Less is needed for the sort interface. It compares two MirrorRepos based on\n// their original value.\nfunc (o MirrorRepos) Less(i, j int) bool {\n\n\t// Names are normalized to lowercase because case affects sorting order. For\n\t// example, Masterminds comes before kylelemons. Making them lowercase\n\t// causes kylelemons to come first which is what is expected.\n\treturn strings.ToLower(o[i].Original) < strings.ToLower(o[j].Original)\n}\n\n// Swap is needed for the sort interface. It swaps the position of two\n// MirrorRepos.\nfunc (o MirrorRepos) Swap(i, j int) {\n\to[i], o[j] = o[j], o[i]\n}\n\n// MirrorRepo represents a single repo mirror\ntype MirrorRepo struct {\n\tOriginal string `yaml:\"original\"`\n\tRepo     string `yaml:\"repo\"`\n\tVcs      string `yaml:\"vcs,omitempty\"`\n}\n"
  },
  {
    "path": "mirrors/mirrors.go",
    "content": "// Package mirrors handles managing mirrors in the running application\npackage mirrors\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n\n\t\"github.com/Masterminds/glide/msg\"\n\tgpath \"github.com/Masterminds/glide/path\"\n)\n\nvar mirrors map[string]*mirror\n\nfunc init() {\n\tmirrors = make(map[string]*mirror)\n}\n\ntype mirror struct {\n\tRepo, Vcs string\n}\n\n// Get retrieves information about an mirror. It returns.\n// - bool if found\n// - new repo location\n// - vcs type\nfunc Get(k string) (bool, string, string) {\n\to, f := mirrors[k]\n\tif !f {\n\t\treturn false, \"\", \"\"\n\t}\n\n\treturn true, o.Repo, o.Vcs\n}\n\n// Load pulls the mirrors into memory\nfunc Load() error {\n\thome := gpath.Home()\n\n\top := filepath.Join(home, \"mirrors.yaml\")\n\n\tvar ov *Mirrors\n\tif _, err := os.Stat(op); os.IsNotExist(err) {\n\t\tmsg.Debug(\"No mirrors.yaml file exists\")\n\t\tov = &Mirrors{\n\t\t\tRepos: make(MirrorRepos, 0),\n\t\t}\n\t\treturn nil\n\t} else if err != nil {\n\t\tov = &Mirrors{\n\t\t\tRepos: make(MirrorRepos, 0),\n\t\t}\n\t\treturn err\n\t}\n\n\tvar err error\n\tov, err = ReadMirrorsFile(op)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error reading existing mirrors.yaml file: %s\", err)\n\t}\n\n\tmsg.Info(\"Loading mirrors from mirrors.yaml file\")\n\tfor _, o := range ov.Repos {\n\t\tmsg.Debug(\"Found mirror: %s to %s (%s)\", o.Original, o.Repo, o.Vcs)\n\t\tno := &mirror{\n\t\t\tRepo: o.Repo,\n\t\t\tVcs:  o.Vcs,\n\t\t}\n\t\tmirrors[o.Original] = no\n\t}\n\n\treturn nil\n}\n"
  },
  {
    "path": "mirrors/mirrors_test.go",
    "content": "package mirrors\n\nimport \"testing\"\n\nvar oyml = `\nrepos:\n- original: github.com/Masterminds/semver\n  repo: file:///path/to/local/repo\n  vcs: git\n- original: github.com/Masterminds/atest\n  repo: github.com/example/atest\n`\n\nvar ooutyml = `repos:\n- original: github.com/Masterminds/atest\n  repo: github.com/example/atest\n- original: github.com/Masterminds/semver\n  repo: file:///path/to/local/repo\n  vcs: git\n`\n\nfunc TestSortMirrors(t *testing.T) {\n\tov, err := FromYaml([]byte(oyml))\n\tif err != nil {\n\t\tt.Error(\"Unable to read mirrors yaml\")\n\t}\n\n\tout, err := ov.Marshal()\n\tif err != nil {\n\t\tt.Error(\"Unable to marshal mirrors yaml\")\n\t}\n\n\tif string(out) != ooutyml {\n\t\tt.Error(\"Output mirrors sorting failed\")\n\t}\n}\n"
  },
  {
    "path": "mkdocs.yml",
    "content": "site_name: Glide Documentation\npages:\n- Home: index.md\n- Getting Started: getting-started.md\n- The glide.yaml File: glide.yaml.md\n- Versions and Ranges: versions.md\n- Lock file: glide.lock.md\n- Commands: commands.md\n- Resolving Imports: resolving-imports.md\n- Vendor Directories: vendor.md\n- Plugins: plugins.md\n- F.A.Q.: faq.md\ntheme: readthedocs\n"
  },
  {
    "path": "msg/msg.go",
    "content": "package msg\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strings\"\n\t\"sync\"\n\n\t\"github.com/Masterminds/vcs\"\n)\n\n// Messenger provides the underlying implementation that displays output to\n// users.\ntype Messenger struct {\n\tsync.Mutex\n\n\t// Quiet, if true, suppresses chatty levels, like Info.\n\tQuiet bool\n\n\t// IsDebugging, if true, shows Debug.\n\tIsDebugging bool\n\n\t// NoColor, if true, will not use color in the output.\n\tNoColor bool\n\n\t// Stdout is the location where this prints output.\n\tStdout io.Writer\n\n\t// Stderr is the location where this prints logs.\n\tStderr io.Writer\n\n\t// Stdin is the location where input is read.\n\tStdin io.Reader\n\n\t// PanicOnDie if true Die() will panic instead of exiting.\n\tPanicOnDie bool\n\n\t// The default exit code to use when dyping\n\tecode int\n\n\t// If an error was been sent.\n\thasErrored bool\n}\n\n// NewMessenger creates a default Messenger to display output.\nfunc NewMessenger() *Messenger {\n\tm := &Messenger{\n\t\tQuiet:       false,\n\t\tIsDebugging: false,\n\t\tNoColor:     false,\n\t\tStdout:      os.Stdout,\n\t\tStderr:      os.Stderr,\n\t\tStdin:       os.Stdin,\n\t\tPanicOnDie:  false,\n\t\tecode:       1,\n\t}\n\n\treturn m\n}\n\n// Default contains a default Messenger used by package level functions\nvar Default = NewMessenger()\n\n// Info logs information\nfunc (m *Messenger) Info(msg string, args ...interface{}) {\n\tif m.Quiet {\n\t\treturn\n\t}\n\tprefix := m.Color(Green, \"[INFO]\\t\")\n\tm.Msg(prefix+msg, args...)\n}\n\n// Info logs information using the Default Messenger\nfunc Info(msg string, args ...interface{}) {\n\tDefault.Info(msg, args...)\n}\n\n// Debug logs debug information\nfunc (m *Messenger) Debug(msg string, args ...interface{}) {\n\tif m.Quiet || !m.IsDebugging {\n\t\treturn\n\t}\n\tprefix := \"[DEBUG]\\t\"\n\tm.Msg(prefix+msg, args...)\n}\n\n// Debug logs debug information using the Default Messenger\nfunc Debug(msg string, args ...interface{}) {\n\tDefault.Debug(msg, args...)\n}\n\n// Warn logs a warning\nfunc (m *Messenger) Warn(msg string, args ...interface{}) {\n\tprefix := m.Color(Yellow, \"[WARN]\\t\")\n\tm.Msg(prefix+msg, args...)\n}\n\n// Warn logs a warning using the Default Messenger\nfunc Warn(msg string, args ...interface{}) {\n\tDefault.Warn(msg, args...)\n}\n\n// Err logs an error.\nfunc (m *Messenger) Err(msg string, args ...interface{}) {\n\tprefix := m.Color(Red, \"[ERROR]\\t\")\n\tm.Msg(prefix+msg, args...)\n\tm.hasErrored = true\n}\n\n// Err logs anderror using the Default Messenger\nfunc Err(msg string, args ...interface{}) {\n\tDefault.Err(msg, args...)\n}\n\n// Die prints an error message and immediately exits the application.\n// If PanicOnDie is set to true a panic will occur instead of os.Exit being\n// called.\nfunc (m *Messenger) Die(msg string, args ...interface{}) {\n\tm.Err(msg, args...)\n\tif m.PanicOnDie {\n\t\tpanic(\"trapped a Die() call\")\n\t}\n\tos.Exit(m.ecode)\n}\n\n// Die prints an error message and immediately exits the application using the\n// Default Messenger. If PanicOnDie is set to true a panic will occur instead of\n// os.Exit being called.\nfunc Die(msg string, args ...interface{}) {\n\tDefault.Die(msg, args...)\n}\n\n// ExitCode sets the exit code used by Die.\n//\n// The default is 1.\n//\n// Returns the old error code.\nfunc (m *Messenger) ExitCode(e int) int {\n\tm.Lock()\n\told := m.ecode\n\tm.ecode = e\n\tm.Unlock()\n\treturn old\n}\n\n// ExitCode sets the exit code used by Die using the Default Messenger.\n//\n// The default is 1.\n//\n// Returns the old error code.\nfunc ExitCode(e int) int {\n\treturn Default.ExitCode(e)\n}\n\n// Msg prints a message with optional arguments, that can be printed, of\n// varying types.\nfunc (m *Messenger) Msg(msg string, args ...interface{}) {\n\t// When operations in Glide are happening concurrently messaging needs to be\n\t// locked to avoid displaying one message in the middle of another one.\n\tm.Lock()\n\tdefer m.Unlock()\n\t// Get rid of the annoying fact that messages need \\n at the end, but do\n\t// it in a backward compatible way.\n\tif !strings.HasSuffix(msg, \"\\n\") {\n\t\tmsg += \"\\n\"\n\t}\n\n\tif len(args) == 0 {\n\t\tfmt.Fprint(m.Stderr, msg)\n\t} else {\n\t\tfmt.Fprintf(m.Stderr, msg, args...)\n\t}\n\n\t// If an arg is a vcs error print the output if in debug mode. This is\n\t// capured here rather than calling Debug because concurrent operations\n\t// could cause other messages to appear between the initial error and the\n\t// debug output by unlocking and calling Debug.\n\tif len(args) != 0 && !m.Quiet && m.IsDebugging {\n\t\tif err, ok := args[len(args)-1].(error); ok {\n\t\t\tswitch t := err.(type) {\n\t\t\tcase *vcs.LocalError:\n\t\t\t\tfmt.Fprintf(m.Stderr, \"[DEBUG]\\tOutput was: %s\", strings.TrimSpace(t.Out()))\n\t\t\tcase *vcs.RemoteError:\n\t\t\t\tfmt.Fprintf(m.Stderr, \"[DEBUG]\\tOutput was: %s\", strings.TrimSpace(t.Out()))\n\t\t\t}\n\t\t}\n\t}\n}\n\n// Msg prints a message with optional arguments, that can be printed, of\n// varying types using the Default Messenger.\nfunc Msg(msg string, args ...interface{}) {\n\tDefault.Msg(msg, args...)\n}\n\n// Puts formats a message and then prints to Stdout.\n//\n// It does not prefix the message, does not color it, or otherwise decorate it.\n//\n// It does add a line feed.\nfunc (m *Messenger) Puts(msg string, args ...interface{}) {\n\t// When operations in Glide are happening concurrently messaging needs to be\n\t// locked to avoid displaying one message in the middle of another one.\n\tm.Lock()\n\tdefer m.Unlock()\n\n\tfmt.Fprintf(m.Stdout, msg, args...)\n\tfmt.Fprintln(m.Stdout)\n}\n\n// Puts formats a message and then prints to Stdout using the Default Messenger.\n//\n// It does not prefix the message, does not color it, or otherwise decorate it.\n//\n// It does add a line feed.\nfunc Puts(msg string, args ...interface{}) {\n\tDefault.Puts(msg, args...)\n}\n\n// Print prints exactly the string given.\n//\n// It prints to Stdout.\nfunc (m *Messenger) Print(msg string) {\n\t// When operations in Glide are happening concurrently messaging needs to be\n\t// locked to avoid displaying one message in the middle of another one.\n\tm.Lock()\n\tdefer m.Unlock()\n\n\tfmt.Fprint(m.Stdout, msg)\n}\n\n// Print prints exactly the string given using the Default Messenger.\n//\n// It prints to Stdout.\nfunc Print(msg string) {\n\tDefault.Print(msg)\n}\n\n// HasErrored returns if Error has been called.\n//\n// This is useful if you want to known if Error was called to exit with a\n// non-zero exit code.\nfunc (m *Messenger) HasErrored() bool {\n\treturn m.hasErrored\n}\n\n// HasErrored returns if Error has been called on the Default Messenger.\n//\n// This is useful if you want to known if Error was called to exit with a\n// non-zero exit code.\nfunc HasErrored() bool {\n\treturn Default.HasErrored()\n}\n\n// Color returns a string in a certain color if colors are enabled and\n// available on that platform.\nfunc Color(code, msg string) string {\n\treturn Default.Color(code, msg)\n}\n\n// PromptUntil provides a prompt until one of the passed in strings has been\n// entered and return is hit. Note, the comparisons are case insensitive meaning\n// Y == y. The returned value is the one from the passed in options (same case).\nfunc (m *Messenger) PromptUntil(opts []string) (string, error) {\n\treader := bufio.NewReader(os.Stdin)\n\tfor {\n\t\ttext, err := reader.ReadString('\\n')\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\n\t\tfor _, c := range opts {\n\t\t\tif strings.EqualFold(c, strings.TrimSpace(text)) {\n\t\t\t\treturn c, nil\n\t\t\t}\n\t\t}\n\t}\n}\n\n// PromptUntil provides a prompt until one of the passed in strings has been\n// entered and return is hit. Note, the comparisons are case insensitive meaning\n// Y == y. The returned value is the one from the passed in options (same case).\n// Uses the default setup.\nfunc PromptUntil(opts []string) (string, error) {\n\treturn Default.PromptUntil(opts)\n}\n\n// PromptUntilYorN provides a prompt until the user chooses yes or no. This is\n// not case sensitive and they can input other options such as Y or N.\n// In the response Yes is bool true and No is bool false.\nfunc (m *Messenger) PromptUntilYorN() bool {\n\tres, err := m.PromptUntil([]string{\"y\", \"yes\", \"n\", \"no\"})\n\tif err != nil {\n\t\tm.Die(\"Error processing response: %s\", err)\n\t}\n\n\tif res == \"y\" || res == \"yes\" {\n\t\treturn true\n\t}\n\n\treturn false\n}\n\n// PromptUntilYorN provides a prompt until the user chooses yes or no. This is\n// not case sensitive and they can input other options such as Y or N.\n// In the response Yes is bool true and No is bool false.\n// Uses the default setup.\nfunc PromptUntilYorN() bool {\n\treturn Default.PromptUntilYorN()\n}\n"
  },
  {
    "path": "msg/out.go",
    "content": "// +build !windows\n\npackage msg\n\nimport \"fmt\"\n\n// These contanstants map to color codes for shell scripts making them\n// human readable.\nconst (\n\tBlue   = \"0;34\"\n\tRed    = \"0;31\"\n\tGreen  = \"0;32\"\n\tYellow = \"0;33\"\n\tCyan   = \"0;36\"\n\tPink   = \"1;35\"\n)\n\n// Color returns a string in a certain color. The first argument is a string\n// containing the color code or a constant from the table above mapped to a code.\n//\n// The following will print the string \"Foo\" in yellow:\n//     fmt.Print(Color(Yellow, \"Foo\"))\nfunc (m *Messenger) Color(code, msg string) string {\n\tif m.NoColor {\n\t\treturn msg\n\t}\n\treturn fmt.Sprintf(\"\\033[%sm%s\\033[m\", code, msg)\n}\n"
  },
  {
    "path": "msg/out_windows.go",
    "content": "// +build windows\n\npackage msg\n\n// The color codes here are for compatibility with how Colors are used. Windows\n// colors have not been implemented yet. See https://github.com/Masterminds/glide/issues/158\n// for more detail.\nconst (\n\tBlue   = \"\"\n\tRed    = \"\"\n\tGreen  = \"\"\n\tYellow = \"\"\n\tCyan   = \"\"\n\tPink   = \"\"\n)\n\n// Color on windows returns no color. See\n// https://github.com/Masterminds/glide/issues/158 if you want to help.\nfunc (m *Messenger) Color(code, msg string) string {\n\treturn msg\n}\n"
  },
  {
    "path": "path/path.go",
    "content": "// Package path contains path and environment utilities for Glide.\n//\n// This includes tools to find and manipulate Go path variables, as well as\n// tools for copying from one path to another.\npackage path\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/mitchellh/go-homedir\"\n)\n\n// DefaultGlideFile is the default name for the glide.yaml file.\nconst DefaultGlideFile = \"glide.yaml\"\n\n// VendorDir is the name of the directory that holds vendored dependencies.\n//\n// As of Go 1.5, this is always vendor.\nvar VendorDir = \"vendor\"\n\n// Tmp is the temporary directory Glide should use. Defaults to \"\" which\n// signals using the system default.\nvar Tmp = \"\"\n\n// Cache the location of the homedirectory.\nvar homeDir = \"\"\n\n// GlideFile is the name of the Glide file.\n//\n// Setting this is not concurrency safe. For consistency, it should really\n// only be set once, at startup, or not at all.\nvar GlideFile = DefaultGlideFile\n\n// LockFile is the default name for the lock file.\nconst LockFile = \"glide.lock\"\n\nfunc init() {\n\n\t// As of Go 1.8 the GOPATH is no longer required to be set. Instead there\n\t// is a default value. If there is no GOPATH check for the default value.\n\t// Note, checking the GOPATH first to avoid invoking the go toolchain if\n\t// possible.\n\tif gopaths = os.Getenv(\"GOPATH\"); len(gopaths) == 0 {\n\t\tgoExecutable := os.Getenv(\"GLIDE_GO_EXECUTABLE\")\n\t\tif len(goExecutable) <= 0 {\n\t\t\tgoExecutable = \"go\"\n\t\t}\n\t\tout, err := exec.Command(goExecutable, \"env\", \"GOPATH\").Output()\n\t\tif err == nil {\n\t\t\tgopaths = strings.TrimSpace(string(out))\n\t\t}\n\t}\n}\n\n// Home returns the Glide home directory ($GLIDE_HOME or ~/.glide, typically).\n//\n// This normalizes to an absolute path, and passes through os.ExpandEnv.\nfunc Home() string {\n\tif homeDir != \"\" {\n\t\treturn homeDir\n\t}\n\n\tif h, err := homedir.Dir(); err == nil {\n\t\thomeDir = filepath.Join(h, \".glide\")\n\t} else {\n\t\tcwd, err := os.Getwd()\n\t\tif err == nil {\n\t\t\thomeDir = filepath.Join(cwd, \".glide\")\n\t\t} else {\n\t\t\thomeDir = \".glide\"\n\t\t}\n\t}\n\n\treturn homeDir\n}\n\n// SetHome sets the home directory for Glide.\nfunc SetHome(h string) {\n\thomeDir = h\n}\n\n// Vendor calculates the path to the vendor directory.\n//\n// Based on working directory, VendorDir and GlideFile, this attempts to\n// guess the location of the vendor directory.\nfunc Vendor() (string, error) {\n\tcwd, err := os.Getwd()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// Find the directory that contains glide.yaml\n\tyamldir, err := GlideWD(cwd)\n\tif err != nil {\n\t\treturn cwd, err\n\t}\n\n\tgopath := filepath.Join(yamldir, VendorDir)\n\n\t// Resolve symlinks\n\tinfo, err := os.Lstat(gopath)\n\tif err != nil {\n\t\treturn gopath, nil\n\t}\n\tfor i := 0; IsLink(info) && i < 255; i++ {\n\t\tp, err := os.Readlink(gopath)\n\t\tif err != nil {\n\t\t\treturn gopath, nil\n\t\t}\n\n\t\tif filepath.IsAbs(p) {\n\t\t\tgopath = p\n\t\t} else {\n\t\t\tgopath = filepath.Join(filepath.Dir(gopath), p)\n\t\t}\n\n\t\tinfo, err = os.Lstat(gopath)\n\t\tif err != nil {\n\t\t\treturn gopath, nil\n\t\t}\n\t}\n\n\treturn gopath, nil\n}\n\n// Glide gets the path to the closest glide file.\nfunc Glide() (string, error) {\n\tcwd, err := os.Getwd()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// Find the directory that contains glide.yaml\n\tyamldir, err := GlideWD(cwd)\n\tif err != nil {\n\t\treturn cwd, err\n\t}\n\n\tgf := filepath.Join(yamldir, GlideFile)\n\treturn gf, nil\n}\n\n// GlideWD finds the working directory of the glide.yaml file, starting at dir.\n//\n// If the glide file is not found in the current directory, it recurses up\n// a directory.\nfunc GlideWD(dir string) (string, error) {\n\tfullpath := filepath.Join(dir, GlideFile)\n\n\tif _, err := os.Stat(fullpath); err == nil {\n\t\treturn dir, nil\n\t}\n\n\tbase := filepath.Dir(dir)\n\tif base == dir {\n\t\treturn \"\", fmt.Errorf(\"Cannot resolve parent of %s\", base)\n\t}\n\n\treturn GlideWD(base)\n}\n\n// Stores the gopaths so they do not get repeatedly looked up. This is especially\n// true when the default value needs to be retrieved from `go env GOPATH`.\n// TODO(mattfarina): Instead of a singleton an application context would be a\n// better place to store things like this.\nvar gopaths string\n\n// Gopath gets GOPATH from environment and return the most relevant path.\n//\n// A GOPATH can contain a colon-separated list of paths. This retrieves the\n// GOPATH and returns only the FIRST (\"most relevant\") path.\n//\n// This should be used carefully. If, for example, you are looking for a package,\n// you may be better off using Gopaths.\nfunc Gopath() string {\n\tgopaths := Gopaths()\n\tif len(gopaths) == 0 {\n\t\treturn \"\"\n\t}\n\treturn gopaths[0]\n}\n\n// Gopaths retrieves the Gopath as a list when there is more than one path\n// listed in the Gopath.\nfunc Gopaths() []string {\n\tp := strings.Trim(gopaths, string(filepath.ListSeparator))\n\treturn filepath.SplitList(p)\n}\n\n// Basepath returns the current working directory.\n//\n// If there is an error getting the working directory, this returns \".\", which\n// should function in cases where the directory is unlinked... Then again,\n// maybe not.\nfunc Basepath() string {\n\tbase, err := os.Getwd()\n\tif err != nil {\n\t\treturn \".\"\n\t}\n\treturn base\n}\n\n// StripBasepath removes the base directory from a passed in path.\nfunc StripBasepath(p string) string {\n\tbp := Basepath()\n\treturn strings.TrimPrefix(p, bp+string(os.PathSeparator))\n}\n\n// IsLink returns true if the given FileInfo references a link.\nfunc IsLink(fi os.FileInfo) bool {\n\treturn fi.Mode()&os.ModeSymlink == os.ModeSymlink\n}\n\n// HasLock returns true if this can stat a lockfile at the givin location.\nfunc HasLock(basepath string) bool {\n\t_, err := os.Stat(filepath.Join(basepath, LockFile))\n\treturn err == nil\n}\n\n// IsDirectoryEmpty checks if a directory is empty.\nfunc IsDirectoryEmpty(dir string) (bool, error) {\n\tf, err := os.Open(dir)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tdefer f.Close()\n\n\t_, err = f.Readdir(1)\n\n\tif err == io.EOF {\n\t\treturn true, nil\n\t}\n\n\treturn false, err\n}\n\n// CopyDir copies an entire source directory to the dest directory.\n//\n// This is akin to `cp -a src/* dest/`\n//\n// We copy the directory here rather than jumping out to a shell so we can\n// support multiple operating systems.\nfunc CopyDir(source string, dest string) error {\n\n\t// get properties of source dir\n\tsi, err := os.Stat(source)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = os.MkdirAll(dest, si.Mode())\n\tif err != nil {\n\t\treturn err\n\t}\n\n\td, err := os.Open(source)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer d.Close()\n\n\tobjects, err := d.Readdir(-1)\n\n\tfor _, obj := range objects {\n\n\t\tsp := filepath.Join(source, \"/\", obj.Name())\n\n\t\tdp := filepath.Join(dest, \"/\", obj.Name())\n\n\t\tif obj.IsDir() {\n\t\t\terr = CopyDir(sp, dp)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\t// perform copy\n\t\t\terr = CopyFile(sp, dp)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\treturn nil\n}\n\n// CopyFile copies a source file to a destination.\n//\n// It follows symbolic links and retains modes.\nfunc CopyFile(source string, dest string) error {\n\tln, err := os.Readlink(source)\n\tif err == nil {\n\t\treturn os.Symlink(ln, dest)\n\t}\n\ts, err := os.Open(source)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdefer s.Close()\n\n\td, err := os.Create(dest)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdefer d.Close()\n\n\t_, err = io.Copy(d, s)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tsi, err := os.Stat(source)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = os.Chmod(dest, si.Mode())\n\n\treturn err\n}\n"
  },
  {
    "path": "path/path_test.go",
    "content": "package path\n\nimport (\n\t\"os\"\n\t\"path/filepath\"\n\t\"runtime\"\n\t\"testing\"\n)\n\nconst testdata = \"../testdata/path\"\n\nfunc TestGlideWD(t *testing.T) {\n\twd := filepath.Join(testdata, \"a/b/c\")\n\tfound, err := GlideWD(wd)\n\tif err != nil {\n\t\tt.Errorf(\"Failed to get Glide directory: %s\", err)\n\t}\n\n\tif found != filepath.Join(testdata, \"a\") {\n\t\tt.Errorf(\"Expected %s to match %s\", found, filepath.Join(wd, \"a\"))\n\t}\n\n\t// This should fail\n\twd = \"/No/Such/Dir\"\n\tfound, err = GlideWD(wd)\n\tif err == nil {\n\t\tt.Errorf(\"Expected to get an error on a non-existent directory, not %s\", found)\n\t}\n\n}\n\nfunc TestVendor(t *testing.T) {\n\ttd, err := filepath.Abs(testdata)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\twd, _ := os.Getwd()\n\n\tos.Chdir(filepath.Join(td, \"a\", \"b\", \"c\"))\n\tres, err := Vendor()\n\tif err != nil {\n\t\tt.Errorf(\"Failed to resolve vendor directory: %s\", err)\n\t}\n\texpect := filepath.Join(td, \"a\", \"vendor\")\n\tif res != expect {\n\t\tt.Errorf(\"Failed to find vendor: expected %s got %s\", expect, res)\n\t}\n\n\tos.Chdir(filepath.Join(td, \"x\", \"y\", \"z\"))\n\tres, err = Vendor()\n\tif err != nil {\n\t\tt.Errorf(\"Failed to resolve vendor directory: %s\", err)\n\t}\n\n\t// Windows symlinks are different than *nix and they can be inconsistent.\n\t// The current testing only works for *nix testing and windows doesn't follow\n\t// the symlinks. If this is a vendor.lnk file in windows this won't work for\n\t// the go toolchain. If this is a windows link you need access to create one\n\t// which isn't consistent.\n\t// If there is a better way would love to know.\n\tif runtime.GOOS == \"windows\" {\n\t\texpect = filepath.Join(td, \"x\", \"vendor\")\n\t} else {\n\t\texpect = filepath.Join(td, \"x\", \"symlinked_vendor\")\n\t}\n\tif res != expect {\n\t\tt.Errorf(\"Failed to find vendor: expected %s got %s\", expect, res)\n\t}\n\n\tos.Chdir(wd)\n}\nfunc TestGlide(t *testing.T) {\n\twd, _ := os.Getwd()\n\ttd, err := filepath.Abs(testdata)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tos.Chdir(filepath.Join(td, \"a/b/c\"))\n\tres, err := Glide()\n\tif err != nil {\n\t\tt.Errorf(\"Failed to resolve vendor directory: %s\", err)\n\t}\n\texpect := filepath.Join(td, \"a\", \"glide.yaml\")\n\tif res != expect {\n\t\tt.Errorf(\"Failed to find vendor: expected %s got %s\", expect, res)\n\t}\n\tos.Chdir(wd)\n}\n\nfunc TestCustomRemoveAll(t *testing.T) {\n\ttd, err := filepath.Abs(testdata)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\t// test that deleting a non-existent directory does not throw an error\n\terr = CustomRemoveAll(filepath.Join(td, \"directory/doesnt/exist\"))\n\tif err != nil {\n\t\tt.Errorf(\"Failed when removing non-existent directory %s\", err)\n\t}\n\t// test that deleting a path with spaces does not throw an error\n\tspaceyPath := filepath.Join(td, \"10942384 12341234 12343214 324134132323\")\n\terr = os.MkdirAll(spaceyPath, 0777)\n\tif err != nil {\n\t\tt.Fatalf(\"Failed to make test directory %s\", err)\n\t}\n\terr = CustomRemoveAll(spaceyPath)\n\tif err != nil {\n\t\tt.Errorf(\"Errored incorrectly when deleting a path with spaces %s\", err)\n\t}\n\tif _, err = os.Stat(spaceyPath); !os.IsNotExist(err) {\n\t\tt.Errorf(\"Failed to successfully delete a path with spaces\")\n\t}\n}\n"
  },
  {
    "path": "path/strip.go",
    "content": "package path\n\nimport (\n\t\"os\"\n\t\"path/filepath\"\n\n\t\"github.com/Masterminds/glide/godep/strip\"\n\t\"github.com/Masterminds/glide/msg\"\n)\n\nfunc getWalkFunction(searchPath string, removeAll func(p string) error) func(path string,\n\tinfo os.FileInfo, err error) error {\n\treturn func(path string, info os.FileInfo, err error) error {\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Skip the base vendor directory\n\t\tif path == searchPath {\n\t\t\treturn nil\n\t\t}\n\n\t\tif info.Name() == \"vendor\" && info.IsDir() {\n\t\t\tmsg.Info(\"Removing: %s\", path)\n\t\t\terr = removeAll(path)\n\t\t\tif nil != err {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\treturn filepath.SkipDir\n\t\t}\n\t\treturn nil\n\t}\n}\n\n// StripVendor removes nested vendor and Godeps/_workspace/ directories.\nfunc StripVendor() error {\n\tsearchPath, _ := Vendor()\n\tif _, err := os.Stat(searchPath); err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\tmsg.Debug(\"Vendor directory does not exist.\")\n\t\t}\n\n\t\treturn err\n\t}\n\n\terr := filepath.Walk(searchPath, getWalkFunction(searchPath, CustomRemoveAll))\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn strip.GodepWorkspace(searchPath)\n}\n"
  },
  {
    "path": "path/strip_int_test.go",
    "content": "package path\n\nimport (\n\t\"io/ioutil\"\n\t\"os\"\n\t\"path\"\n\t\"testing\"\n)\n\nfunc generateTestDirectory(t *testing.T) string {\n\tbaseDir, err := ioutil.TempDir(os.TempDir(), \"mgt\")\n\tif nil != err {\n\t\tt.Error(\"Unable to create temp directory: \", err.Error())\n\t}\n\tpaths := map[string][]string{\n\t\t\"github.com/fake/log\":                                                                            {\"log.go\"},\n\t\t\"github.com/phoney/foo\":                                                                          {\"bar.go\"},\n\t\t\"github.com/phoney/foo/vendor\":                                                                   {\"test.go\", \"foo.bar\"},\n\t\t\"github.com/aws/aws-sdk-go/awsmigrate/awsmigrate-renamer/vendor\":                                 {},\n\t\t\"github.com/aws/aws-sdk-go/awsmigrate/awsmigrate-renamer/vendor/golang.org/x/tools/go/buildutil\": {\"allpackages.go\", \"tags.go\", \"fakecontext.go\"},\n\t\t\"github.com/aws/aws-sdk-go/vendor\":                                                               {\"key_test.go\", \"key.go\"},\n\t\t\"github.com/aws/aws-sdk-go/vendor/github.com/go-ini/ini\":                                         {\"struct_test.go\", \"error.go\", \"ini_test.go\"},\n\t}\n\tos.OpenFile(path.Join(baseDir, \"glide.yaml\"), os.O_RDONLY|os.O_CREATE, 0666)\n\tfor p, files := range paths {\n\t\tp = path.Join(baseDir, \"vendor\", p)\n\t\tif err = os.MkdirAll(p, 0777); nil != err {\n\t\t\tt.Errorf(\"Unable to create vendor dir: %s\\n%s\", p, err.Error())\n\t\t}\n\t\tfor _, f := range files {\n\t\t\tos.OpenFile(path.Join(p, f), os.O_RDONLY|os.O_CREATE, 0666)\n\t\t}\n\t}\n\treturn baseDir\n}\n\nfunc TestNestVendorNoError(t *testing.T) {\n\tworkingDir := generateTestDirectory(t)\n\tos.Chdir(workingDir)\n\terr := StripVendor()\n\tif nil != err {\n\t\tt.Errorf(\"Unexpected error in StripVendor: %s\", err.Error())\n\t}\n}\n"
  },
  {
    "path": "path/strip_test.go",
    "content": "package path\n\nimport (\n\t\"errors\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"reflect\"\n\t\"testing\"\n\t\"time\"\n)\n\ntype mockFileInfo struct {\n\tname  string\n\tisDir bool\n}\n\nfunc (mfi *mockFileInfo) Name() string {\n\treturn mfi.name\n}\n\nfunc (mfi *mockFileInfo) Size() int64 {\n\tpanic(\"not implemented\")\n}\n\nfunc (mfi *mockFileInfo) Mode() os.FileMode {\n\tpanic(\"not implemented\")\n}\n\nfunc (mfi *mockFileInfo) ModTime() time.Time {\n\tpanic(\"not implemented\")\n}\n\nfunc (mfi *mockFileInfo) IsDir() bool {\n\treturn mfi.isDir\n}\n\nfunc (mfi *mockFileInfo) Sys() interface{} {\n\tpanic(\"not implemented\")\n}\n\ntype removeAll struct {\n\tcalledWith string\n\terr        error\n}\n\nfunc (rah *removeAll) removeAll(p string) error {\n\trah.calledWith = p\n\treturn rah.err\n}\n\nfunc TestWalkFunction(t *testing.T) {\n\ttype args struct {\n\t\tsearchPath string\n\t\tremoveAll  *removeAll\n\t\tpath       string\n\t\tinfo       os.FileInfo\n\t\terr        error\n\t}\n\ttests := []struct {\n\t\tname           string\n\t\targs           args\n\t\twant           error\n\t\twantCalledWith string\n\t}{\n\t\t{\n\t\t\tname: \"WalkFunctionSkipsNonVendor\",\n\t\t\targs: args{searchPath: \"foo\",\n\t\t\t\tremoveAll: &removeAll{},\n\t\t\t\tpath:      \"foo/bar\",\n\t\t\t\tinfo:      &mockFileInfo{name: \"bar\", isDir: true},\n\t\t\t\terr:       nil,\n\t\t\t},\n\t\t\twant:           nil,\n\t\t\twantCalledWith: \"\",\n\t\t},\n\t\t{\n\t\t\tname: \"WalkFunctionSkipsNonDir\",\n\t\t\targs: args{searchPath: \"foo\",\n\t\t\t\tremoveAll: &removeAll{},\n\t\t\t\tpath:      \"foo/vendor\",\n\t\t\t\tinfo:      &mockFileInfo{name: \"vendor\", isDir: false},\n\t\t\t\terr:       nil,\n\t\t\t},\n\t\t\twant:           nil,\n\t\t\twantCalledWith: \"\",\n\t\t},\n\t\t{\n\t\t\tname: \"WalkFunctionDeletesVendor\",\n\t\t\targs: args{searchPath: \"foo\",\n\t\t\t\tremoveAll: &removeAll{},\n\t\t\t\tpath:      \"foo/vendor\",\n\t\t\t\tinfo:      &mockFileInfo{name: \"vendor\", isDir: true},\n\t\t\t\terr:       nil,\n\t\t\t},\n\t\t\twant:           filepath.SkipDir,\n\t\t\twantCalledWith: \"foo/vendor\",\n\t\t},\n\t\t{\n\t\t\tname: \"WalkFunctionReturnsPassedError\",\n\t\t\targs: args{searchPath: \"foo\",\n\t\t\t\tremoveAll: &removeAll{},\n\t\t\t\tpath:      \"foo/vendor\",\n\t\t\t\tinfo:      &mockFileInfo{name: \"vendor\", isDir: true},\n\t\t\t\terr:       errors.New(\"expected\"),\n\t\t\t},\n\t\t\twant:           errors.New(\"expected\"),\n\t\t\twantCalledWith: \"\",\n\t\t},\n\t\t{\n\t\t\tname: \"WalkFunctionReturnsRemoveAllError\",\n\t\t\targs: args{searchPath: \"foo\",\n\t\t\t\tremoveAll: &removeAll{err: errors.New(\"expected\")},\n\t\t\t\tpath:      \"foo/vendor\",\n\t\t\t\tinfo:      &mockFileInfo{name: \"vendor\", isDir: true},\n\t\t\t\terr:       nil,\n\t\t\t},\n\t\t\twant:           errors.New(\"expected\"),\n\t\t\twantCalledWith: \"foo/vendor\",\n\t\t},\n\t\t{\n\t\t\tname: \"WalkFunctionSkipsBaseDir\",\n\t\t\targs: args{searchPath: \"vendor\",\n\t\t\t\tremoveAll: &removeAll{},\n\t\t\t\tpath:      \"vendor\",\n\t\t\t\tinfo:      &mockFileInfo{name: \"vendor\", isDir: true},\n\t\t\t\terr:       nil,\n\t\t\t},\n\t\t\twant:           nil,\n\t\t\twantCalledWith: \"\",\n\t\t},\n\t}\n\tfor _, test := range tests {\n\t\twalkFunction := getWalkFunction(test.args.searchPath, test.args.removeAll.removeAll)\n\t\tif actual := walkFunction(test.args.path, test.args.info, test.args.err); !reflect.DeepEqual(actual, test.want) {\n\t\t\tt.Errorf(\"walkFunction() = %v, want %v\", actual, test.want)\n\t\t}\n\t\tif test.args.removeAll.calledWith != test.wantCalledWith {\n\t\t\tt.Errorf(\"removeAll argument = \\\"%s\\\", want \\\"%s\\\"\", test.args.removeAll.calledWith, test.wantCalledWith)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "path/winbug.go",
    "content": "package path\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"os/exec\"\n\t\"runtime\"\n\t\"syscall\"\n\n\t\"bytes\"\n\t\"io/ioutil\"\n\n\t\"github.com/Masterminds/glide/msg\"\n)\n\n// extract the exit code from an os.exec error\nfunc getExitCode(err error) int {\n\tif err != nil {\n\t\tif exitError, ok := err.(*exec.ExitError); ok {\n\t\t\twaitStatus := exitError.Sys().(syscall.WaitStatus)\n\t\t\treturn waitStatus.ExitStatus()\n\t\t}\n\t}\n\treturn 0\n}\n\n// Hard to track down these codes - they are from windows.h and documented here:\n// https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx\nconst (\n\twinErrorFileNotFound = 2\n\twinErrorPathNotFound = 3\n)\n\n// This file and its contents are to handle a Windows bug where large sets of\n// files fail when using the `os` package. This has been seen in Windows 10\n// including the Windows Linux Subsystem.\n// Tracking the issue in https://github.com/golang/go/issues/20841. Once the\n// upstream issue is fixed this change can be reverted.\n\n// CustomRemoveAll is similar to os.RemoveAll but deals with the bug outlined\n// at https://github.com/golang/go/issues/20841.\nfunc CustomRemoveAll(p string) error {\n\n\t// Handle the windows case first\n\tif runtime.GOOS == \"windows\" {\n\t\tmsg.Debug(\"Detected Windows. Removing files using windows command\")\n\t\tcmd := exec.Command(\"cmd.exe\", \"/c\", \"rd\", \"/s\", \"/q\", p)\n\t\toutput, err := cmd.CombinedOutput()\n\t\tif err != nil {\n\t\t\texitCode := getExitCode(err)\n\t\t\tif exitCode != winErrorFileNotFound && exitCode != winErrorPathNotFound {\n\t\t\t\treturn fmt.Errorf(\"Error removing files: %s. output: %s\", err, output)\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t} else if detectWsl() {\n\t\tcmd := exec.Command(\"rm\", \"-rf\", p)\n\t\toutput, err2 := cmd.CombinedOutput()\n\t\tmsg.Debug(\"Detected Windows Subsystem for Linux. Removing files using subsystem command\")\n\t\tif err2 != nil {\n\t\t\treturn fmt.Errorf(\"Error removing files: %s. output: %s\", err2, output)\n\t\t}\n\t\treturn nil\n\t}\n\treturn os.RemoveAll(p)\n}\n\n// CustomRename is similar to os.Rename but deals with the bug outlined\n// at https://github.com/golang/go/issues/20841.\nfunc CustomRename(o, n string) error {\n\n\t// Handking windows cases first\n\tif runtime.GOOS == \"windows\" {\n\t\tmsg.Debug(\"Detected Windows. Moving files using windows command\")\n\t\tcmd := exec.Command(\"cmd.exe\", \"/c\", \"move\", o, n)\n\t\toutput, err := cmd.CombinedOutput()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Error moving files: %s. output: %s\", err, output)\n\t\t}\n\n\t\treturn nil\n\t} else if detectWsl() {\n\t\tcmd := exec.Command(\"mv\", o, n)\n\t\toutput, err2 := cmd.CombinedOutput()\n\t\tmsg.Debug(\"Detected Windows Subsystem for Linux. Removing files using subsystem command\")\n\t\tif err2 != nil {\n\t\t\treturn fmt.Errorf(\"Error moving files: %s. output: %s\", err2, output)\n\t\t}\n\n\t\treturn nil\n\t}\n\n\treturn os.Rename(o, n)\n}\n\nvar procIsWin bool\nvar procDet bool\n\nfunc detectWsl() bool {\n\n\tif !procDet {\n\t\tprocDet = true\n\t\t_, err := os.Stat(\"/proc/version\")\n\t\tif err == nil {\n\t\t\tb, err := ioutil.ReadFile(\"/proc/version\")\n\t\t\tif err != nil {\n\t\t\t\tmsg.Warn(\"Unable to read /proc/version that was detected. May incorrectly detect WSL\")\n\t\t\t\tmsg.Debug(\"Windows Subsystem for Linux detection error: %s\", err)\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\tif bytes.Contains(b, []byte(\"Microsoft\")) {\n\t\t\t\tmsg.Debug(\"Windows Subsystem for Linux detected\")\n\t\t\t\tprocIsWin = true\n\t\t\t}\n\t\t}\n\t}\n\n\treturn procIsWin\n}\n"
  },
  {
    "path": "repo/installer.go",
    "content": "package repo\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"runtime\"\n\t\"strings\"\n\t\"sync\"\n\t\"syscall\"\n\t\"time\"\n\n\t\"github.com/Masterminds/glide/cache\"\n\t\"github.com/Masterminds/glide/cfg\"\n\t\"github.com/Masterminds/glide/dependency\"\n\t\"github.com/Masterminds/glide/importer\"\n\t\"github.com/Masterminds/glide/msg\"\n\tgpath \"github.com/Masterminds/glide/path\"\n\t\"github.com/Masterminds/glide/util\"\n\t\"github.com/Masterminds/semver\"\n\t\"github.com/Masterminds/vcs\"\n\t\"github.com/codegangsta/cli\"\n)\n\n// Installer provides facilities for installing the repos in a config file.\ntype Installer struct {\n\n\t// Force the install when certain normally stopping conditions occur.\n\tForce bool\n\n\t// Home is the location of cache\n\tHome string\n\n\t// Vendor contains the path to put the vendor packages\n\tVendor string\n\n\t// ResolveAllFiles enables a resolver that will examine the dependencies\n\t// of every file of every package, rather than only following imported\n\t// packages.\n\tResolveAllFiles bool\n\n\t// ResolveTest sets if test dependencies should be resolved.\n\tResolveTest bool\n\n\t// Updated tracks the packages that have been remotely fetched.\n\tUpdated *UpdateTracker\n}\n\n// NewInstaller returns an Installer instance ready to use. This is the constructor.\nfunc NewInstaller() *Installer {\n\ti := &Installer{}\n\ti.Updated = NewUpdateTracker()\n\treturn i\n}\n\n// VendorPath returns the path to the location to put vendor packages\nfunc (i *Installer) VendorPath() string {\n\tif i.Vendor != \"\" {\n\t\treturn i.Vendor\n\t}\n\n\tvp, err := gpath.Vendor()\n\tif err != nil {\n\t\treturn filepath.FromSlash(\"./vendor\")\n\t}\n\n\treturn vp\n}\n\n// Install installs the dependencies from a Lockfile.\nfunc (i *Installer) Install(lock *cfg.Lockfile, conf *cfg.Config) (*cfg.Config, error) {\n\n\t// Create a config setup based on the Lockfile data to process with\n\t// existing commands.\n\tnewConf := &cfg.Config{}\n\tnewConf.Name = conf.Name\n\n\tnewConf.Imports = make(cfg.Dependencies, len(lock.Imports))\n\tfor k, v := range lock.Imports {\n\t\tnewConf.Imports[k] = cfg.DependencyFromLock(v)\n\t}\n\n\tnewConf.DevImports = make(cfg.Dependencies, len(lock.DevImports))\n\tfor k, v := range lock.DevImports {\n\t\tnewConf.DevImports[k] = cfg.DependencyFromLock(v)\n\t}\n\n\tnewConf.DeDupe()\n\n\tif len(newConf.Imports) == 0 && len(newConf.DevImports) == 0 {\n\t\tmsg.Info(\"No dependencies found. Nothing installed.\")\n\t\treturn newConf, nil\n\t}\n\n\tmsg.Info(\"Downloading dependencies. Please wait...\")\n\n\terr := LazyConcurrentUpdate(newConf.Imports, i, newConf)\n\tif err != nil {\n\t\treturn newConf, err\n\t}\n\terr = LazyConcurrentUpdate(newConf.DevImports, i, newConf)\n\n\treturn newConf, err\n}\n\n// Checkout reads the config file and checks out all dependencies mentioned there.\n//\n// This is used when initializing an empty vendor directory, or when updating a\n// vendor directory based on changed config.\nfunc (i *Installer) Checkout(conf *cfg.Config) error {\n\n\tmsg.Info(\"Downloading dependencies. Please wait...\")\n\n\tif err := ConcurrentUpdate(conf.Imports, i, conf); err != nil {\n\t\treturn err\n\t}\n\n\tif i.ResolveTest {\n\t\treturn ConcurrentUpdate(conf.DevImports, i, conf)\n\t}\n\n\treturn nil\n}\n\n// Update updates all dependencies.\n//\n// It begins with the dependencies in the config file, but also resolves\n// transitive dependencies. The returned lockfile has all of the dependencies\n// listed, but the version reconciliation has not been done.\n//\n// In other words, all versions in the Lockfile will be empty.\nfunc (i *Installer) Update(conf *cfg.Config) error {\n\tbase := \".\"\n\n\tic := newImportCache()\n\n\tm := &MissingPackageHandler{\n\t\thome:    i.Home,\n\t\tforce:   i.Force,\n\t\tConfig:  conf,\n\t\tUse:     ic,\n\t\tupdated: i.Updated,\n\t}\n\n\tv := &VersionHandler{\n\t\tUse:       ic,\n\t\tImported:  make(map[string]bool),\n\t\tConflicts: make(map[string]bool),\n\t\tConfig:    conf,\n\t}\n\n\t// Update imports\n\tres, err := dependency.NewResolver(base)\n\tres.ResolveTest = i.ResolveTest\n\tif err != nil {\n\t\tmsg.Die(\"Failed to create a resolver: %s\", err)\n\t}\n\tres.Config = conf\n\tres.Handler = m\n\tres.VersionHandler = v\n\tres.ResolveAllFiles = i.ResolveAllFiles\n\tmsg.Info(\"Resolving imports\")\n\n\timps, timps, err := res.ResolveLocal(false)\n\tif err != nil {\n\t\tmsg.Die(\"Failed to resolve local packages: %s\", err)\n\t}\n\tvar deps cfg.Dependencies\n\tvar tdeps cfg.Dependencies\n\tfor _, v := range imps {\n\t\tn := res.Stripv(v)\n\t\tif conf.HasIgnore(n) {\n\t\t\tcontinue\n\t\t}\n\t\trt, sub := util.NormalizeName(n)\n\t\tif sub == \"\" {\n\t\t\tsub = \".\"\n\t\t}\n\t\td := deps.Get(rt)\n\t\tif d == nil {\n\t\t\tnd := &cfg.Dependency{\n\t\t\t\tName:        rt,\n\t\t\t\tSubpackages: []string{sub},\n\t\t\t}\n\t\t\tdeps = append(deps, nd)\n\t\t} else if !d.HasSubpackage(sub) {\n\t\t\td.Subpackages = append(d.Subpackages, sub)\n\t\t}\n\t}\n\tif i.ResolveTest {\n\t\tfor _, v := range timps {\n\t\t\tn := res.Stripv(v)\n\t\t\tif conf.HasIgnore(n) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\trt, sub := util.NormalizeName(n)\n\t\t\tif sub == \"\" {\n\t\t\t\tsub = \".\"\n\t\t\t}\n\t\t\td := deps.Get(rt)\n\t\t\tif d == nil {\n\t\t\t\td = tdeps.Get(rt)\n\t\t\t}\n\t\t\tif d == nil {\n\t\t\t\tnd := &cfg.Dependency{\n\t\t\t\t\tName:        rt,\n\t\t\t\t\tSubpackages: []string{sub},\n\t\t\t\t}\n\t\t\t\ttdeps = append(tdeps, nd)\n\t\t\t} else if !d.HasSubpackage(sub) {\n\t\t\t\td.Subpackages = append(d.Subpackages, sub)\n\t\t\t}\n\t\t}\n\t}\n\n\t_, err = allPackages(deps, res, false)\n\tif err != nil {\n\t\tmsg.Die(\"Failed to retrieve a list of dependencies: %s\", err)\n\t}\n\n\tif i.ResolveTest {\n\t\tmsg.Debug(\"Resolving test dependencies\")\n\t\t_, err = allPackages(tdeps, res, true)\n\t\tif err != nil {\n\t\t\tmsg.Die(\"Failed to retrieve a list of test dependencies: %s\", err)\n\t\t}\n\t}\n\n\tmsg.Info(\"Downloading dependencies. Please wait...\")\n\n\terr = ConcurrentUpdate(conf.Imports, i, conf)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif i.ResolveTest {\n\t\terr = ConcurrentUpdate(conf.DevImports, i, conf)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// Export from the cache to the vendor directory\nfunc (i *Installer) Export(conf *cfg.Config) error {\n\ttempDir, err := ioutil.TempDir(gpath.Tmp, \"glide-vendor\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir)\n\t\tif err != nil {\n\t\t\tmsg.Err(err.Error())\n\t\t}\n\t}()\n\n\tvp := filepath.Join(tempDir, \"vendor\")\n\terr = os.MkdirAll(vp, 0755)\n\n\tmsg.Info(\"Exporting resolved dependencies...\")\n\tdone := make(chan struct{}, concurrentWorkers)\n\tin := make(chan *cfg.Dependency, concurrentWorkers)\n\tvar wg sync.WaitGroup\n\tvar lock sync.Mutex\n\tvar returnErr error\n\n\tfor ii := 0; ii < concurrentWorkers; ii++ {\n\t\tgo func(ch <-chan *cfg.Dependency) {\n\t\t\tfor {\n\t\t\t\tselect {\n\t\t\t\tcase dep := <-ch:\n\t\t\t\t\tloc := dep.Remote()\n\t\t\t\t\tkey, err := cache.Key(loc)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tmsg.Die(err.Error())\n\t\t\t\t\t}\n\t\t\t\t\tcache.Lock(key)\n\n\t\t\t\t\tcdir := filepath.Join(cache.Location(), \"src\", key)\n\t\t\t\t\trepo, err := dep.GetRepo(cdir)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tmsg.Die(err.Error())\n\t\t\t\t\t}\n\t\t\t\t\tmsg.Info(\"--> Exporting %s\", dep.Name)\n\t\t\t\t\tif err := repo.ExportDir(filepath.Join(vp, filepath.ToSlash(dep.Name))); err != nil {\n\t\t\t\t\t\tmsg.Err(\"Export failed for %s: %s\\n\", dep.Name, err)\n\t\t\t\t\t\t// Capture the error while making sure the concurrent\n\t\t\t\t\t\t// operations don't step on each other.\n\t\t\t\t\t\tlock.Lock()\n\t\t\t\t\t\tif returnErr == nil {\n\t\t\t\t\t\t\treturnErr = err\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturnErr = cli.NewMultiError(returnErr, err)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlock.Unlock()\n\t\t\t\t\t}\n\t\t\t\t\tcache.Unlock(key)\n\t\t\t\t\twg.Done()\n\t\t\t\tcase <-done:\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}(in)\n\t}\n\n\tfor _, dep := range conf.Imports {\n\t\tif !conf.HasIgnore(dep.Name) {\n\t\t\terr = os.MkdirAll(filepath.Join(vp, filepath.ToSlash(dep.Name)), 0755)\n\t\t\tif err != nil {\n\t\t\t\tlock.Lock()\n\t\t\t\tif returnErr == nil {\n\t\t\t\t\treturnErr = err\n\t\t\t\t} else {\n\t\t\t\t\treturnErr = cli.NewMultiError(returnErr, err)\n\t\t\t\t}\n\t\t\t\tlock.Unlock()\n\t\t\t}\n\t\t\twg.Add(1)\n\t\t\tin <- dep\n\t\t}\n\t}\n\n\tif i.ResolveTest {\n\t\tfor _, dep := range conf.DevImports {\n\t\t\tif !conf.HasIgnore(dep.Name) {\n\t\t\t\terr = os.MkdirAll(filepath.Join(vp, filepath.ToSlash(dep.Name)), 0755)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlock.Lock()\n\t\t\t\t\tif returnErr == nil {\n\t\t\t\t\t\treturnErr = err\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturnErr = cli.NewMultiError(returnErr, err)\n\t\t\t\t\t}\n\t\t\t\t\tlock.Unlock()\n\t\t\t\t}\n\t\t\t\twg.Add(1)\n\t\t\t\tin <- dep\n\t\t\t}\n\t\t}\n\t}\n\n\twg.Wait()\n\n\t// Close goroutines setting the version\n\tfor ii := 0; ii < concurrentWorkers; ii++ {\n\t\tdone <- struct{}{}\n\t}\n\n\tif returnErr != nil {\n\t\treturn returnErr\n\t}\n\n\tmsg.Info(\"Replacing existing vendor dependencies\")\n\n\t// Check if a .git directory exists under the old vendor dir. If it does,\n\t// move it over to the newly-generated vendor dir - the user is probably\n\t// submoduling, and it's easy enough not to break their setup.\n\tivg := filepath.Join(i.VendorPath(), \".git\")\n\tgitInfo, err := os.Stat(ivg)\n\tif err == nil {\n\t\tmsg.Info(\"Preserving existing vendor/.git\")\n\t\tvpg := filepath.Join(vp, \".git\")\n\t\terr = os.Rename(ivg, vpg)\n\n\t\tif terr, ok := err.(*os.LinkError); ok {\n\t\t\tif gitInfo.IsDir() {\n\t\t\t\terr = fixcle(ivg, vpg, terr)\n\t\t\t} else {\n\t\t\t\t// When this is a submodule, .git is just a file. Don't try to copy\n\t\t\t\t// it as a directory in this case (see #828).\n\t\t\t\terr = gpath.CopyFile(ivg, vpg)\n\t\t\t}\n\n\t\t\tif err != nil {\n\t\t\t\tmsg.Warn(\"Failed to preserve existing vendor/.git\")\n\t\t\t}\n\t\t}\n\t}\n\n\terr = gpath.CustomRemoveAll(i.VendorPath())\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = gpath.CustomRename(vp, i.VendorPath())\n\tif terr, ok := err.(*os.LinkError); ok {\n\t\treturn fixcle(vp, i.VendorPath(), terr)\n\t}\n\n\treturn err\n\n}\n\n// fixcle is a helper function that tries to recover from cross-device rename\n// errors by falling back to copying.\nfunc fixcle(from, to string, terr *os.LinkError) error {\n\t// When there are different physical devices we cannot rename cross device.\n\t// Instead we copy.\n\n\t// syscall.EXDEV is the common name for the cross device link error\n\t// which has varying output text across different operating systems.\n\tif terr.Err == syscall.EXDEV {\n\t\tmsg.Debug(\"Cross link err, trying manual copy: %s\", terr)\n\t\treturn gpath.CopyDir(from, to)\n\t} else if runtime.GOOS == \"windows\" {\n\t\t// In windows it can drop down to an operating system call that\n\t\t// returns an operating system error with a different number and\n\t\t// message. Checking for that as a fall back.\n\t\tnoerr, ok := terr.Err.(syscall.Errno)\n\t\t// 0x11 (ERROR_NOT_SAME_DEVICE) is the windows error.\n\t\t// See https://msdn.microsoft.com/en-us/library/cc231199.aspx\n\t\tif ok && noerr == 0x11 {\n\t\t\tmsg.Debug(\"Cross link err on Windows, trying manual copy: %s\", terr)\n\t\t\treturn gpath.CopyDir(from, to)\n\t\t}\n\t}\n\n\treturn terr\n}\n\n// List resolves the complete dependency tree and returns a list of dependencies.\nfunc (i *Installer) List(conf *cfg.Config) []*cfg.Dependency {\n\tbase := \".\"\n\n\tic := newImportCache()\n\n\tv := &VersionHandler{\n\t\tUse:       ic,\n\t\tImported:  make(map[string]bool),\n\t\tConflicts: make(map[string]bool),\n\t\tConfig:    conf,\n\t}\n\n\t// Update imports\n\tres, err := dependency.NewResolver(base)\n\tif err != nil {\n\t\tmsg.Die(\"Failed to create a resolver: %s\", err)\n\t}\n\tres.Config = conf\n\tres.VersionHandler = v\n\tres.ResolveAllFiles = i.ResolveAllFiles\n\n\tmsg.Info(\"Resolving imports\")\n\t_, _, err = res.ResolveLocal(false)\n\tif err != nil {\n\t\tmsg.Die(\"Failed to resolve local packages: %s\", err)\n\t}\n\n\t_, err = allPackages(conf.Imports, res, false)\n\tif err != nil {\n\t\tmsg.Die(\"Failed to retrieve a list of dependencies: %s\", err)\n\t}\n\n\tif len(conf.DevImports) > 0 {\n\t\tmsg.Warn(\"dev imports not resolved.\")\n\t}\n\n\treturn conf.Imports\n}\n\n// LazyConcurrentUpdate updates only deps that are not already checkout out at the right version.\n//\n// This is only safe when updating from a lock file.\nfunc LazyConcurrentUpdate(deps []*cfg.Dependency, i *Installer, c *cfg.Config) error {\n\n\tnewDeps := []*cfg.Dependency{}\n\tfor _, dep := range deps {\n\n\t\tkey, err := cache.Key(dep.Remote())\n\t\tif err != nil {\n\t\t\tnewDeps = append(newDeps, dep)\n\t\t\tcontinue\n\t\t}\n\t\tdestPath := filepath.Join(cache.Location(), \"src\", key)\n\n\t\t// Get a VCS object for this directory\n\t\trepo, err := dep.GetRepo(destPath)\n\t\tif err != nil {\n\t\t\tnewDeps = append(newDeps, dep)\n\t\t\tcontinue\n\t\t}\n\n\t\tver, err := repo.Version()\n\t\tif err != nil {\n\t\t\tnewDeps = append(newDeps, dep)\n\t\t\tcontinue\n\t\t}\n\t\tif dep.Reference != \"\" {\n\t\t\tci, err := repo.CommitInfo(dep.Reference)\n\t\t\tif err == nil && ci.Commit == dep.Reference {\n\t\t\t\tmsg.Info(\"--> Found desired version locally %s %s!\", dep.Name, dep.Reference)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tmsg.Debug(\"--> Queue %s for update (%s != %s).\", dep.Name, ver, dep.Reference)\n\t\tnewDeps = append(newDeps, dep)\n\t}\n\tif len(newDeps) > 0 {\n\t\treturn ConcurrentUpdate(newDeps, i, c)\n\t}\n\n\treturn nil\n}\n\n// ConcurrentUpdate takes a list of dependencies and updates in parallel.\nfunc ConcurrentUpdate(deps []*cfg.Dependency, i *Installer, c *cfg.Config) error {\n\tdone := make(chan struct{}, concurrentWorkers)\n\tin := make(chan *cfg.Dependency, concurrentWorkers)\n\tvar wg sync.WaitGroup\n\tvar lock sync.Mutex\n\tvar returnErr error\n\n\tfor ii := 0; ii < concurrentWorkers; ii++ {\n\t\tgo func(ch <-chan *cfg.Dependency) {\n\t\t\tfor {\n\t\t\t\tselect {\n\t\t\t\tcase dep := <-ch:\n\t\t\t\t\tloc := dep.Remote()\n\t\t\t\t\tkey, err := cache.Key(loc)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tmsg.Die(err.Error())\n\t\t\t\t\t}\n\t\t\t\t\tcache.Lock(key)\n\t\t\t\t\tif err := VcsUpdate(dep, i.Force, i.Updated); err != nil {\n\t\t\t\t\t\tmsg.Err(\"Update failed for %s: %s\\n\", dep.Name, err)\n\t\t\t\t\t\t// Capture the error while making sure the concurrent\n\t\t\t\t\t\t// operations don't step on each other.\n\t\t\t\t\t\tlock.Lock()\n\t\t\t\t\t\tif returnErr == nil {\n\t\t\t\t\t\t\treturnErr = err\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturnErr = cli.NewMultiError(returnErr, err)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlock.Unlock()\n\t\t\t\t\t}\n\t\t\t\t\tcache.Unlock(key)\n\t\t\t\t\twg.Done()\n\t\t\t\tcase <-done:\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}(in)\n\t}\n\n\tfor _, dep := range deps {\n\t\tif !c.HasIgnore(dep.Name) {\n\t\t\twg.Add(1)\n\t\t\tin <- dep\n\t\t}\n\t}\n\n\twg.Wait()\n\n\t// Close goroutines setting the version\n\tfor ii := 0; ii < concurrentWorkers; ii++ {\n\t\tdone <- struct{}{}\n\t}\n\n\treturn returnErr\n}\n\n// allPackages gets a list of all packages required to satisfy the given deps.\nfunc allPackages(deps []*cfg.Dependency, res *dependency.Resolver, addTest bool) ([]string, error) {\n\tif len(deps) == 0 {\n\t\treturn []string{}, nil\n\t}\n\n\tvdir, err := gpath.Vendor()\n\tif err != nil {\n\t\treturn []string{}, err\n\t}\n\tvdir += string(os.PathSeparator)\n\tll, err := res.ResolveAll(deps, addTest)\n\tif err != nil {\n\t\treturn []string{}, err\n\t}\n\n\tfor i := 0; i < len(ll); i++ {\n\t\tll[i] = strings.TrimPrefix(ll[i], vdir)\n\t}\n\treturn ll, nil\n}\n\n// MissingPackageHandler is a dependency.MissingPackageHandler.\n//\n// When a package is not found, this attempts to resolve and fetch.\n//\n// When a package is found on the GOPATH, this notifies the user.\ntype MissingPackageHandler struct {\n\thome    string\n\tforce   bool\n\tConfig  *cfg.Config\n\tUse     *importCache\n\tupdated *UpdateTracker\n}\n\n// NotFound attempts to retrieve a package when not found in the local cache\n// folder. It will attempt to get it from the remote location info.\nfunc (m *MissingPackageHandler) NotFound(pkg string, addTest bool) (bool, error) {\n\terr := m.fetchToCache(pkg, addTest)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\treturn true, err\n}\n\n// OnGopath will either copy a package, already found in the GOPATH, to the\n// vendor/ directory or download it from the internet. This is dependent if\n// useGopath on the installer is set to true to copy from the GOPATH.\nfunc (m *MissingPackageHandler) OnGopath(pkg string, addTest bool) (bool, error) {\n\n\terr := m.fetchToCache(pkg, addTest)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\treturn true, err\n}\n\n// InVendor updates a package in the vendor/ directory to make sure the latest\n// is available.\nfunc (m *MissingPackageHandler) InVendor(pkg string, addTest bool) error {\n\treturn m.fetchToCache(pkg, addTest)\n}\n\n// PkgPath resolves the location on the filesystem where the package should be.\n// This handles making sure to use the cache location.\nfunc (m *MissingPackageHandler) PkgPath(pkg string) string {\n\troot, sub := util.NormalizeName(pkg)\n\n\t// For the parent applications source skip the cache.\n\tif root == m.Config.Name {\n\t\tpth := gpath.Basepath()\n\t\treturn filepath.Join(pth, filepath.FromSlash(sub))\n\t}\n\n\td := m.Config.Imports.Get(root)\n\tif d == nil {\n\t\td = m.Config.DevImports.Get(root)\n\t}\n\n\tif d == nil {\n\t\td, _ = m.Use.Get(root)\n\n\t\tif d == nil {\n\t\t\td = &cfg.Dependency{Name: root}\n\t\t}\n\t}\n\n\tkey, err := cache.Key(d.Remote())\n\tif err != nil {\n\t\tmsg.Die(\"Error generating cache key for %s\", d.Name)\n\t}\n\n\treturn filepath.Join(cache.Location(), \"src\", key, filepath.FromSlash(sub))\n}\n\nfunc (m *MissingPackageHandler) fetchToCache(pkg string, addTest bool) error {\n\troot := util.GetRootFromPackage(pkg)\n\t// Skip any references to the root package.\n\tif root == m.Config.Name {\n\t\treturn nil\n\t}\n\n\td := m.Config.Imports.Get(root)\n\tif d == nil && addTest {\n\t\td = m.Config.DevImports.Get(root)\n\t}\n\n\t// If the dependency is nil it means the Config doesn't yet know about it.\n\tif d == nil {\n\t\td, _ = m.Use.Get(root)\n\t\t// We don't know about this dependency so we create a basic instance.\n\t\tif d == nil {\n\t\t\td = &cfg.Dependency{Name: root}\n\t\t}\n\n\t\tif addTest {\n\t\t\tm.Config.DevImports = append(m.Config.DevImports, d)\n\t\t} else {\n\t\t\tm.Config.Imports = append(m.Config.Imports, d)\n\t\t}\n\t}\n\n\treturn VcsUpdate(d, m.force, m.updated)\n}\n\n// VersionHandler handles setting the proper version in the VCS.\ntype VersionHandler struct {\n\n\t// If Try to use the version here if we have one. This is a cache and will\n\t// change over the course of setting versions.\n\tUse *importCache\n\n\t// Cache if importing scan has already occurred here.\n\tImported map[string]bool\n\n\tConfig *cfg.Config\n\n\t// There's a problem where many sub-packages have been asked to set a version\n\t// and you can end up with numerous conflict messages that are exactly the\n\t// same. We are keeping track to only display them once.\n\t// the parent pac\n\tConflicts map[string]bool\n}\n\n// Process imports dependencies for a package\nfunc (d *VersionHandler) Process(pkg string) (e error) {\n\troot := util.GetRootFromPackage(pkg)\n\n\t// Skip any references to the root package.\n\tif root == d.Config.Name {\n\t\treturn nil\n\t}\n\n\t// We have not tried to import, yet.\n\t// Should we look in places other than the root of the project?\n\tif d.Imported[root] == false {\n\t\td.Imported[root] = true\n\t\tp := d.pkgPath(root)\n\t\tf, deps, err := importer.Import(p)\n\t\tif f && err == nil {\n\t\t\tfor _, dep := range deps {\n\n\t\t\t\t// The fist one wins. Would something smater than this be better?\n\t\t\t\texists, _ := d.Use.Get(dep.Name)\n\t\t\t\tif exists == nil && (dep.Reference != \"\" || dep.Repository != \"\") {\n\t\t\t\t\td.Use.Add(dep.Name, dep, root)\n\t\t\t\t}\n\t\t\t}\n\t\t} else if err != nil {\n\t\t\tmsg.Err(\"Unable to import from %s. Err: %s\", root, err)\n\t\t\te = err\n\t\t}\n\t}\n\n\treturn\n}\n\n// SetVersion sets the version for a package. If that package version is already\n// set it handles the case by:\n// - keeping the already set version\n// - proviting messaging about the version conflict\n// TODO(mattfarina): The way version setting happens can be improved. Currently not optimal.\nfunc (d *VersionHandler) SetVersion(pkg string, addTest bool) (e error) {\n\troot := util.GetRootFromPackage(pkg)\n\n\t// Skip any references to the root package.\n\tif root == d.Config.Name {\n\t\treturn nil\n\t}\n\n\tv := d.Config.Imports.Get(root)\n\tif addTest {\n\t\tif v == nil {\n\t\t\tv = d.Config.DevImports.Get(root)\n\t\t} else if d.Config.DevImports.Has(root) {\n\t\t\t// Both imports and test imports lists the same dependency.\n\t\t\t// There are import chains (because the import tree is resolved\n\t\t\t// before the test tree) that can cause this.\n\t\t\ttempD := d.Config.DevImports.Get(root)\n\t\t\tif tempD.Reference != v.Reference {\n\t\t\t\tmsg.Warn(\"Using import %s (version %s) for test instead of testImport (version %s).\", v.Name, v.Reference, tempD.Reference)\n\t\t\t}\n\t\t\t// TODO(mattfarina): Note repo difference in a warning.\n\t\t}\n\t}\n\n\tdep, req := d.Use.Get(root)\n\tif dep != nil && v != nil {\n\t\tif v.Reference == \"\" && dep.Reference != \"\" {\n\t\t\tv.Reference = dep.Reference\n\t\t\t// Clear the pin, if set, so the new version can be used.\n\t\t\tv.Pin = \"\"\n\t\t\tdep = v\n\t\t} else if v.Reference != \"\" && dep.Reference != \"\" && v.Reference != dep.Reference {\n\t\t\tdest := d.pkgPath(pkg)\n\t\t\tdep = determineDependency(v, dep, dest, req)\n\t\t} else {\n\t\t\tdep = v\n\t\t}\n\n\t} else if v != nil {\n\t\tdep = v\n\t} else if dep != nil {\n\t\t// We've got an imported dependency to use and don't already have a\n\t\t// record of it. Append it to the Imports.\n\t\tif addTest {\n\t\t\td.Config.DevImports = append(d.Config.DevImports, dep)\n\t\t} else {\n\t\t\td.Config.Imports = append(d.Config.Imports, dep)\n\t\t}\n\t} else {\n\t\t// If we've gotten here we don't have any depenency objects.\n\t\tr, sp := util.NormalizeName(pkg)\n\t\tdep = &cfg.Dependency{\n\t\t\tName: r,\n\t\t}\n\t\tif sp != \"\" {\n\t\t\tdep.Subpackages = []string{sp}\n\t\t}\n\t\tif addTest {\n\t\t\td.Config.DevImports = append(d.Config.DevImports, dep)\n\t\t} else {\n\t\t\td.Config.Imports = append(d.Config.Imports, dep)\n\t\t}\n\t}\n\n\terr := VcsVersion(dep)\n\tif err != nil {\n\t\tmsg.Warn(\"Unable to set version on %s to %s. Err: %s\", root, dep.Reference, err)\n\t\te = err\n\t}\n\n\treturn\n}\n\nfunc (d *VersionHandler) pkgPath(pkg string) string {\n\troot, sub := util.NormalizeName(pkg)\n\n\t// For the parent applications source skip the cache.\n\tif root == d.Config.Name {\n\t\tpth := gpath.Basepath()\n\t\treturn filepath.Join(pth, filepath.FromSlash(sub))\n\t}\n\n\tdep := d.Config.Imports.Get(root)\n\tif dep == nil {\n\t\tdep = d.Config.DevImports.Get(root)\n\t}\n\n\tif dep == nil {\n\t\tdep, _ = d.Use.Get(root)\n\n\t\tif dep == nil {\n\t\t\tdep = &cfg.Dependency{Name: root}\n\t\t}\n\t}\n\n\tkey, err := cache.Key(dep.Remote())\n\tif err != nil {\n\t\tmsg.Die(\"Error generating cache key for %s\", dep.Name)\n\t}\n\n\treturn filepath.Join(cache.Location(), \"src\", key, filepath.FromSlash(sub))\n}\n\nfunc determineDependency(v, dep *cfg.Dependency, dest, req string) *cfg.Dependency {\n\trepo, err := v.GetRepo(dest)\n\tif err != nil {\n\t\tsingleWarn(\"Unable to access repo for %s\\n\", v.Name)\n\t\tsingleInfo(\"Keeping %s %s\", v.Name, v.Reference)\n\t\treturn v\n\t}\n\n\tvIsRef := repo.IsReference(v.Reference)\n\tdepIsRef := repo.IsReference(dep.Reference)\n\n\t// Both are references and they are different ones.\n\tif vIsRef && depIsRef {\n\t\tsingleWarn(\"Conflict: %s rev is currently %s, but %s wants %s\\n\", v.Name, v.Reference, req, dep.Reference)\n\n\t\tdisplayCommitInfo(repo, v)\n\t\tdisplayCommitInfo(repo, dep)\n\n\t\tsingleInfo(\"Keeping %s %s\", v.Name, v.Reference)\n\t\treturn v\n\t} else if vIsRef {\n\t\t// The current one is a reference and the suggestion is a SemVer constraint.\n\t\tcon, err := semver.NewConstraint(dep.Reference)\n\t\tif err != nil {\n\t\t\tsingleWarn(\"Version issue for %s: '%s' is neither a reference or semantic version constraint\\n\", dep.Name, dep.Reference)\n\t\t\tsingleInfo(\"Keeping %s %s\", v.Name, v.Reference)\n\t\t\treturn v\n\t\t}\n\n\t\tver, err := semver.NewVersion(v.Reference)\n\t\tif err != nil {\n\t\t\t// The existing version is not a semantic version.\n\t\t\tsingleWarn(\"Conflict: %s version is %s, but also asked for %s\\n\", v.Name, v.Reference, dep.Reference)\n\t\t\tdisplayCommitInfo(repo, v)\n\t\t\tsingleInfo(\"Keeping %s %s\", v.Name, v.Reference)\n\t\t\treturn v\n\t\t}\n\n\t\tif con.Check(ver) {\n\t\t\tsingleInfo(\"Keeping %s %s because it fits constraint '%s'\", v.Name, v.Reference, dep.Reference)\n\t\t\treturn v\n\t\t}\n\t\tsingleWarn(\"Conflict: %s version is %s but does not meet constraint '%s'\\n\", v.Name, v.Reference, dep.Reference)\n\t\tsingleInfo(\"Keeping %s %s\", v.Name, v.Reference)\n\t\treturn v\n\t} else if depIsRef {\n\n\t\tcon, err := semver.NewConstraint(v.Reference)\n\t\tif err != nil {\n\t\t\tsingleWarn(\"Version issue for %s: '%s' is neither a reference or semantic version constraint\\n\", v.Name, v.Reference)\n\t\t\tsingleInfo(\"Keeping %s %s\", v.Name, v.Reference)\n\t\t\treturn v\n\t\t}\n\n\t\tver, err := semver.NewVersion(dep.Reference)\n\t\tif err != nil {\n\t\t\tsingleWarn(\"Conflict: %s version is %s, but also asked for %s\\n\", v.Name, v.Reference, dep.Reference)\n\t\t\tdisplayCommitInfo(repo, dep)\n\t\t\tsingleInfo(\"Keeping %s %s\", v.Name, v.Reference)\n\t\t\treturn v\n\t\t}\n\n\t\tif con.Check(ver) {\n\t\t\tv.Reference = dep.Reference\n\t\t\tsingleInfo(\"Using %s %s because it fits constraint '%s'\", v.Name, v.Reference, v.Reference)\n\t\t\treturn v\n\t\t}\n\t\tsingleWarn(\"Conflict: %s semantic version constraint is %s but '%s' does not meet the constraint\\n\", v.Name, v.Reference, v.Reference)\n\t\tsingleInfo(\"Keeping %s %s\", v.Name, v.Reference)\n\t\treturn v\n\t}\n\t// Neither is a vcs reference and both could be semantic version\n\t// constraints that are different.\n\n\t_, err = semver.NewConstraint(dep.Reference)\n\tif err != nil {\n\t\t// dd.Reference is not a reference or a valid constraint.\n\t\tsingleWarn(\"Version %s %s is not a reference or valid semantic version constraint\\n\", dep.Name, dep.Reference)\n\t\tsingleInfo(\"Keeping %s %s\", v.Name, v.Reference)\n\t\treturn v\n\t}\n\n\t_, err = semver.NewConstraint(v.Reference)\n\tif err != nil {\n\t\t// existing.Reference is not a reference or a valid constraint.\n\t\t// We really should never end up here.\n\t\tsingleWarn(\"Version %s %s is not a reference or valid semantic version constraint\\n\", v.Name, v.Reference)\n\n\t\tv.Reference = dep.Reference\n\t\tv.Pin = \"\"\n\t\tsingleInfo(\"Using %s %s because it is a valid version\", v.Name, v.Reference)\n\t\treturn v\n\t}\n\n\t// Both versions are constraints. Try to merge them.\n\t// If either comparison has an || skip merging. That's complicated.\n\tddor := strings.Index(dep.Reference, \"||\")\n\teor := strings.Index(v.Reference, \"||\")\n\tif ddor == -1 && eor == -1 {\n\t\t// Add the comparisons together.\n\t\tnewRef := v.Reference + \", \" + dep.Reference\n\t\tv.Reference = newRef\n\t\tv.Pin = \"\"\n\t\tsingleInfo(\"Combining %s semantic version constraints %s and %s\", v.Name, v.Reference, dep.Reference)\n\t\treturn v\n\t}\n\tsingleWarn(\"Conflict: %s version is %s, but also asked for %s\\n\", v.Name, v.Reference, dep.Reference)\n\tsingleInfo(\"Keeping %s %s\", v.Name, v.Reference)\n\treturn v\n}\n\nvar warningMessage = make(map[string]bool)\nvar infoMessage = make(map[string]bool)\n\nfunc singleWarn(ft string, v ...interface{}) {\n\tm := fmt.Sprintf(ft, v...)\n\t_, f := warningMessage[m]\n\tif !f {\n\t\tmsg.Warn(m)\n\t\twarningMessage[m] = true\n\t}\n}\n\nfunc singleInfo(ft string, v ...interface{}) {\n\tm := fmt.Sprintf(ft, v...)\n\t_, f := infoMessage[m]\n\tif !f {\n\t\tmsg.Info(m)\n\t\tinfoMessage[m] = true\n\t}\n}\n\ntype importCache struct {\n\tcache map[string]*cfg.Dependency\n\tfrom  map[string]string\n}\n\nfunc newImportCache() *importCache {\n\treturn &importCache{\n\t\tcache: make(map[string]*cfg.Dependency),\n\t\tfrom:  make(map[string]string),\n\t}\n}\n\nfunc (i *importCache) Get(name string) (*cfg.Dependency, string) {\n\td, f := i.cache[name]\n\tif f {\n\t\treturn d, i.from[name]\n\t}\n\n\treturn nil, \"\"\n}\n\nfunc (i *importCache) Add(name string, dep *cfg.Dependency, root string) {\n\ti.cache[name] = dep\n\ti.from[name] = root\n}\n\nvar displayCommitInfoPrefix = msg.Default.Color(msg.Green, \"[INFO] \")\nvar displayCommitInfoTemplate = \"%s reference %s:\\n\" +\n\tdisplayCommitInfoPrefix + \"- author: %s\\n\" +\n\tdisplayCommitInfoPrefix + \"- commit date: %s\\n\" +\n\tdisplayCommitInfoPrefix + \"- subject (first line): %s\\n\"\n\nfunc displayCommitInfo(repo vcs.Repo, dep *cfg.Dependency) {\n\tc, err := repo.CommitInfo(dep.Reference)\n\tref := dep.Reference\n\n\tif err == nil {\n\t\ttgs, err2 := repo.TagsFromCommit(c.Commit)\n\t\tif err2 == nil && len(tgs) > 0 {\n\t\t\tif tgs[0] != dep.Reference {\n\t\t\t\tref = ref + \" (\" + tgs[0] + \")\"\n\t\t\t}\n\t\t}\n\t\tsingleInfo(displayCommitInfoTemplate, dep.Name, ref, c.Author, c.Date.Format(time.RFC1123Z), commitSubjectFirstLine(c.Message))\n\t}\n}\n\nfunc commitSubjectFirstLine(sub string) string {\n\tlines := strings.Split(sub, \"\\n\")\n\tif len(lines) <= 1 {\n\t\treturn sub\n\t}\n\n\treturn lines[0]\n}\n"
  },
  {
    "path": "repo/repo.go",
    "content": "// Package repo provides tools for working with VCS repositories.\n//\n// Glide manages repositories in the vendor directory by using the native VCS\n// systems of each repository upon which the code relies.\npackage repo\n\n// concurrentWorkers is the number of workers to be used in concurrent operations.\nvar concurrentWorkers = 20\n\n// UpdatingVendored indicates whether this run of Glide is updating a vendored vendor/ path.\n//\n// It is related to the --update-vendor flag for update and install.\n//\n// TODO: This is legacy, and maybe we should handle it differently. It should\n// be set either 0 or 1 times, and only at startup.\n//var UpdatingVendored bool = false\n"
  },
  {
    "path": "repo/semver.go",
    "content": "package repo\n\nimport (\n\t\"github.com/Masterminds/semver\"\n\t\"github.com/Masterminds/vcs\"\n)\n\n// Filter a list of versions to only included semantic versions. The response\n// is a mapping of the original version to the semantic version.\nfunc getSemVers(refs []string) []*semver.Version {\n\tsv := []*semver.Version{}\n\tfor _, r := range refs {\n\t\tv, err := semver.NewVersion(r)\n\t\tif err == nil {\n\t\t\tsv = append(sv, v)\n\t\t}\n\t}\n\n\treturn sv\n}\n\n// Get all the references for a repo. This includes the tags and branches.\nfunc getAllVcsRefs(repo vcs.Repo) ([]string, error) {\n\ttags, err := repo.Tags()\n\tif err != nil {\n\t\treturn []string{}, err\n\t}\n\n\tbranches, err := repo.Branches()\n\tif err != nil {\n\t\treturn []string{}, err\n\t}\n\n\treturn append(branches, tags...), nil\n}\n"
  },
  {
    "path": "repo/set_reference.go",
    "content": "package repo\n\nimport (\n\t\"sync\"\n\n\t\"github.com/Masterminds/glide/cache\"\n\t\"github.com/Masterminds/glide/cfg\"\n\t\"github.com/Masterminds/glide/msg\"\n\t\"github.com/codegangsta/cli\"\n)\n\n// SetReference is a command to set the VCS reference (commit id, tag, etc) for\n// a project.\nfunc SetReference(conf *cfg.Config, resolveTest bool) error {\n\n\tif len(conf.Imports) == 0 && len(conf.DevImports) == 0 {\n\t\tmsg.Info(\"No references set.\\n\")\n\t\treturn nil\n\t}\n\n\tdone := make(chan struct{}, concurrentWorkers)\n\tin := make(chan *cfg.Dependency, concurrentWorkers)\n\tvar wg sync.WaitGroup\n\tvar lock sync.Mutex\n\tvar returnErr error\n\n\tfor i := 0; i < concurrentWorkers; i++ {\n\t\tgo func(ch <-chan *cfg.Dependency) {\n\t\t\tfor {\n\t\t\t\tselect {\n\t\t\t\tcase dep := <-ch:\n\n\t\t\t\t\tvar loc string\n\t\t\t\t\tif dep.Repository != \"\" {\n\t\t\t\t\t\tloc = dep.Repository\n\t\t\t\t\t} else {\n\t\t\t\t\t\tloc = \"https://\" + dep.Name\n\t\t\t\t\t}\n\t\t\t\t\tkey, err := cache.Key(loc)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tmsg.Die(err.Error())\n\t\t\t\t\t}\n\t\t\t\t\tcache.Lock(key)\n\t\t\t\t\tif err := VcsVersion(dep); err != nil {\n\t\t\t\t\t\tmsg.Err(\"Failed to set version on %s to %s: %s\\n\", dep.Name, dep.Reference, err)\n\n\t\t\t\t\t\t// Capture the error while making sure the concurrent\n\t\t\t\t\t\t// operations don't step on each other.\n\t\t\t\t\t\tlock.Lock()\n\t\t\t\t\t\tif returnErr == nil {\n\t\t\t\t\t\t\treturnErr = err\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturnErr = cli.NewMultiError(returnErr, err)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlock.Unlock()\n\t\t\t\t\t}\n\t\t\t\t\tcache.Unlock(key)\n\t\t\t\t\twg.Done()\n\t\t\t\tcase <-done:\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}(in)\n\t}\n\n\tfor _, dep := range conf.Imports {\n\t\tif !conf.HasIgnore(dep.Name) {\n\t\t\twg.Add(1)\n\t\t\tin <- dep\n\t\t}\n\t}\n\n\tif resolveTest {\n\t\tfor _, dep := range conf.DevImports {\n\t\t\tif !conf.HasIgnore(dep.Name) {\n\t\t\t\twg.Add(1)\n\t\t\t\tin <- dep\n\t\t\t}\n\t\t}\n\t}\n\n\twg.Wait()\n\t// Close goroutines setting the version\n\tfor i := 0; i < concurrentWorkers; i++ {\n\t\tdone <- struct{}{}\n\t}\n\t// close(done)\n\t// close(in)\n\n\treturn returnErr\n}\n"
  },
  {
    "path": "repo/tracker.go",
    "content": "package repo\n\nimport (\n\t\"sync\"\n)\n\n// UpdateTracker holds a list of all the packages that have been updated from\n// an external source. This is a concurrency safe implementation.\ntype UpdateTracker struct {\n\tsync.RWMutex\n\n\tupdated map[string]bool\n}\n\n// NewUpdateTracker creates a new instance of UpdateTracker ready for use.\nfunc NewUpdateTracker() *UpdateTracker {\n\tu := &UpdateTracker{}\n\tu.updated = map[string]bool{}\n\treturn u\n}\n\n// Add adds a name to the list of items being tracked.\nfunc (u *UpdateTracker) Add(name string) {\n\tu.Lock()\n\tu.updated[name] = true\n\tu.Unlock()\n}\n\n// Check returns if an item is on the list or not.\nfunc (u *UpdateTracker) Check(name string) bool {\n\tu.RLock()\n\t_, f := u.updated[name]\n\tu.RUnlock()\n\treturn f\n}\n\n// Remove takes a package off the list\nfunc (u *UpdateTracker) Remove(name string) {\n\tu.Lock()\n\tdelete(u.updated, name)\n\tu.Unlock()\n}\n"
  },
  {
    "path": "repo/tracker_test.go",
    "content": "package repo\n\nimport \"testing\"\n\nfunc TestUpdateTracker(t *testing.T) {\n\ttr := NewUpdateTracker()\n\n\tif f := tr.Check(\"github.com/foo/bar\"); f != false {\n\t\tt.Error(\"Error, package Check passed on empty tracker\")\n\t}\n\n\ttr.Add(\"github.com/foo/bar\")\n\n\tif f := tr.Check(\"github.com/foo/bar\"); f != true {\n\t\tt.Error(\"Error, failed to add package to tracker\")\n\t}\n\n\ttr.Remove(\"github.com/foo/bar\")\n\n\tif f := tr.Check(\"github.com/foo/bar\"); f != false {\n\t\tt.Error(\"Error, failed to remove package from tracker\")\n\t}\n}\n"
  },
  {
    "path": "repo/vcs.go",
    "content": "package repo\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"runtime\"\n\t\"sort\"\n\t\"strings\"\n\n\tcp \"github.com/Masterminds/glide/cache\"\n\t\"github.com/Masterminds/glide/cfg\"\n\t\"github.com/Masterminds/glide/msg\"\n\tgpath \"github.com/Masterminds/glide/path\"\n\t\"github.com/Masterminds/semver\"\n\tv \"github.com/Masterminds/vcs\"\n)\n\n// VcsUpdate updates to a particular checkout based on the VCS setting.\nfunc VcsUpdate(dep *cfg.Dependency, force bool, updated *UpdateTracker) error {\n\n\t// If the dependency has already been pinned we can skip it. This is a\n\t// faster path so we don't need to resolve it again.\n\tif dep.Pin != \"\" {\n\t\tmsg.Debug(\"Dependency %s has already been pinned. Fetching updates skipped\", dep.Name)\n\t\treturn nil\n\t}\n\n\tif updated.Check(dep.Name) {\n\t\tmsg.Debug(\"%s was already updated, skipping\", dep.Name)\n\t\treturn nil\n\t}\n\tupdated.Add(dep.Name)\n\n\tif filterArchOs(dep) {\n\t\tmsg.Info(\"%s is not used for %s/%s.\\n\", dep.Name, runtime.GOOS, runtime.GOARCH)\n\t\treturn nil\n\t}\n\n\tkey, err := cp.Key(dep.Remote())\n\tif err != nil {\n\t\tmsg.Die(\"Cache key generation error: %s\", err)\n\t}\n\tlocation := cp.Location()\n\tdest := filepath.Join(location, \"src\", key)\n\n\t// If destination doesn't exist we need to perform an initial checkout.\n\tif _, err := os.Stat(dest); os.IsNotExist(err) {\n\t\tmsg.Info(\"--> Fetching %s\", dep.Name)\n\t\tif err = VcsGet(dep); err != nil {\n\t\t\tmsg.Warn(\"Unable to checkout %s\\n\", dep.Name)\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\t// At this point we have a directory for the package.\n\t\tmsg.Info(\"--> Fetching updates for %s\", dep.Name)\n\n\t\t// When the directory is not empty and has no VCS directory it's\n\t\t// a vendored files situation.\n\t\tempty, err := gpath.IsDirectoryEmpty(dest)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t_, err = v.DetectVcsFromFS(dest)\n\t\tif empty == true && err == v.ErrCannotDetectVCS {\n\t\t\tmsg.Warn(\"Cached version of %s is an empty directory. Fetching a new copy of the dependency\", dep.Name)\n\t\t\tmsg.Debug(\"Removing empty directory %s\", dest)\n\t\t\terr := os.RemoveAll(dest)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif err = VcsGet(dep); err != nil {\n\t\t\t\tmsg.Warn(\"Unable to checkout %s\\n\", dep.Name)\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\trepo, err := dep.GetRepo(dest)\n\n\t\t\t// Tried to checkout a repo to a path that does not work. Either the\n\t\t\t// type or endpoint has changed. Force is being passed in so the old\n\t\t\t// location can be removed and replaced with the new one.\n\t\t\t// Warning, any changes in the old location will be deleted.\n\t\t\t// TODO: Put dirty checking in on the existing local checkout.\n\t\t\tif (err == v.ErrWrongVCS || err == v.ErrWrongRemote) && force == true {\n\t\t\t\tnewRemote := dep.Remote()\n\n\t\t\t\tmsg.Warn(\"Replacing %s with contents from %s\\n\", dep.Name, newRemote)\n\t\t\t\trerr := os.RemoveAll(dest)\n\t\t\t\tif rerr != nil {\n\t\t\t\t\treturn rerr\n\t\t\t\t}\n\t\t\t\tif err = VcsGet(dep); err != nil {\n\t\t\t\t\tmsg.Warn(\"Unable to checkout %s\\n\", dep.Name)\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\trepo, err = dep.GetRepo(dest)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t} else if err != nil {\n\t\t\t\treturn err\n\t\t\t} else if repo.IsDirty() {\n\t\t\t\treturn fmt.Errorf(\"%s contains uncommitted changes. Skipping update\", dep.Name)\n\t\t\t}\n\n\t\t\tver := dep.Reference\n\t\t\tif ver == \"\" {\n\t\t\t\tver = defaultBranch(repo)\n\t\t\t}\n\t\t\t// Check if the current version is a tag or commit id. If it is\n\t\t\t// and that version is already checked out we can skip updating\n\t\t\t// which is faster than going out to the Internet to perform\n\t\t\t// an update.\n\t\t\tif ver != \"\" {\n\t\t\t\tversion, err := repo.Version()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tib, err := isBranch(ver, repo)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\t// If the current version equals the ref and it's not a\n\t\t\t\t// branch it's a tag or commit id so we can skip\n\t\t\t\t// performing an update.\n\t\t\t\tif version == ver && !ib {\n\t\t\t\t\tmsg.Debug(\"%s is already set to version %s. Skipping update\", dep.Name, dep.Reference)\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif err := repo.Update(); err != nil {\n\t\t\t\tmsg.Warn(\"Download failed.\\n\")\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// VcsVersion set the VCS version for a checkout.\nfunc VcsVersion(dep *cfg.Dependency) error {\n\n\t// If the dependency has already been pinned we can skip it. This is a\n\t// faster path so we don't need to resolve it again.\n\tif dep.Pin != \"\" {\n\t\tmsg.Debug(\"Dependency %s has already been pinned. Setting version skipped\", dep.Name)\n\t\treturn nil\n\t}\n\n\tkey, err := cp.Key(dep.Remote())\n\tif err != nil {\n\t\tmsg.Die(\"Cache key generation error: %s\", err)\n\t}\n\tlocation := cp.Location()\n\tcwd := filepath.Join(location, \"src\", key)\n\n\t// If there is no reference configured there is nothing to set.\n\tif dep.Reference == \"\" {\n\t\t// Before exiting update the pinned version\n\t\trepo, err := dep.GetRepo(cwd)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdep.Pin, err = repo.Version()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t}\n\n\t// When the directory is not empty and has no VCS directory it's\n\t// a vendored files situation.\n\tempty, err := gpath.IsDirectoryEmpty(cwd)\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, err = v.DetectVcsFromFS(cwd)\n\tif empty == false && err == v.ErrCannotDetectVCS {\n\t\treturn fmt.Errorf(\"Cache directory missing VCS information for %s\", dep.Name)\n\t}\n\n\trepo, err := dep.GetRepo(cwd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tver := dep.Reference\n\t// References in Git can begin with a ^ which is similar to semver.\n\t// If there is a ^ prefix we assume it's a semver constraint rather than\n\t// part of the git/VCS commit id.\n\tif repo.IsReference(ver) && !strings.HasPrefix(ver, \"^\") {\n\t\tmsg.Info(\"--> Setting version for %s to %s.\\n\", dep.Name, ver)\n\t} else {\n\n\t\t// Create the constraint first to make sure it's valid before\n\t\t// working on the repo.\n\t\tconstraint, err := semver.NewConstraint(ver)\n\n\t\t// Make sure the constriant is valid. At this point it's not a valid\n\t\t// reference so if it's not a valid constrint we can exit early.\n\t\tif err != nil {\n\t\t\tmsg.Warn(\"The reference '%s' is not valid\\n\", ver)\n\t\t\treturn err\n\t\t}\n\n\t\t// Get the tags and branches (in that order)\n\t\trefs, err := getAllVcsRefs(repo)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Convert and filter the list to semver.Version instances\n\t\tsemvers := getSemVers(refs)\n\n\t\t// Sort semver list\n\t\tsort.Sort(sort.Reverse(semver.Collection(semvers)))\n\t\tfound := false\n\t\tfor _, v := range semvers {\n\t\t\tif constraint.Check(v) {\n\t\t\t\tfound = true\n\t\t\t\t// If the constrint passes get the original reference\n\t\t\t\tver = v.Original()\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif found {\n\t\t\tmsg.Info(\"--> Detected semantic version. Setting version for %s to %s\", dep.Name, ver)\n\t\t} else {\n\t\t\tmsg.Warn(\"--> Unable to find semantic version for constraint %s %s\", dep.Name, ver)\n\t\t}\n\t}\n\tif err := repo.UpdateVersion(ver); err != nil {\n\t\treturn err\n\t}\n\tdep.Pin, err = repo.Version()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\n// VcsGet figures out how to fetch a dependency, and then gets it.\n//\n// VcsGet installs into the cache.\nfunc VcsGet(dep *cfg.Dependency) error {\n\n\tkey, err := cp.Key(dep.Remote())\n\tif err != nil {\n\t\tmsg.Die(\"Cache key generation error: %s\", err)\n\t}\n\tlocation := cp.Location()\n\td := filepath.Join(location, \"src\", key)\n\n\trepo, err := dep.GetRepo(d)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// If the directory does not exist this is a first cache.\n\tif _, err = os.Stat(d); os.IsNotExist(err) {\n\t\tmsg.Debug(\"Adding %s to the cache for the first time\", dep.Name)\n\t\terr = repo.Get()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tbranch := findCurrentBranch(repo)\n\t\tif branch != \"\" {\n\t\t\tmsg.Debug(\"Saving default branch for %s\", repo.Remote())\n\t\t\tc := cp.RepoInfo{DefaultBranch: branch}\n\t\t\terr = cp.SaveRepoData(key, c)\n\t\t\tif err == cp.ErrCacheDisabled {\n\t\t\t\tmsg.Debug(\"Unable to cache default branch because caching is disabled\")\n\t\t\t} else if err != nil {\n\t\t\t\tmsg.Debug(\"Error saving %s to cache. Error: %s\", repo.Remote(), err)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tmsg.Debug(\"Updating %s in the cache\", dep.Name)\n\t\terr = repo.Update()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// filterArchOs indicates a dependency should be filtered out because it is\n// the wrong GOOS or GOARCH.\n//\n// FIXME: Should this be moved to the dependency package?\nfunc filterArchOs(dep *cfg.Dependency) bool {\n\tfound := false\n\tif len(dep.Arch) > 0 {\n\t\tfor _, a := range dep.Arch {\n\t\t\tif a == runtime.GOARCH {\n\t\t\t\tfound = true\n\t\t\t}\n\t\t}\n\t\t// If it's not found, it should be filtered out.\n\t\tif !found {\n\t\t\treturn true\n\t\t}\n\t}\n\n\tfound = false\n\tif len(dep.Os) > 0 {\n\t\tfor _, o := range dep.Os {\n\t\t\tif o == runtime.GOOS {\n\t\t\t\tfound = true\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\treturn true\n\t\t}\n\n\t}\n\n\treturn false\n}\n\n// isBranch returns true if the given string is a branch in VCS.\nfunc isBranch(branch string, repo v.Repo) (bool, error) {\n\tbranches, err := repo.Branches()\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tfor _, b := range branches {\n\t\tif b == branch {\n\t\t\treturn true, nil\n\t\t}\n\t}\n\treturn false, nil\n}\n\n// defaultBranch tries to ascertain the default branch for the given repo.\n// Some repos will have multiple branches in them (e.g. Git) while others\n// (e.g. Svn) will not.\nfunc defaultBranch(repo v.Repo) string {\n\n\t// Svn and Bzr use different locations (paths or entire locations)\n\t// for branches so we won't have a default branch.\n\tif repo.Vcs() == v.Svn || repo.Vcs() == v.Bzr {\n\t\treturn \"\"\n\t}\n\n\t// Check the cache for a value.\n\tkey, kerr := cp.Key(repo.Remote())\n\tvar d cp.RepoInfo\n\tif kerr == nil {\n\t\td, err := cp.RepoData(key)\n\t\tif err == nil {\n\t\t\tif d.DefaultBranch != \"\" {\n\t\t\t\treturn d.DefaultBranch\n\t\t\t}\n\t\t}\n\t}\n\n\t// If we don't have it in the store try some APIs\n\tr := repo.Remote()\n\tu, err := url.Parse(r)\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\tif u.Scheme == \"\" {\n\t\t// Where there is no scheme we try urls like git@github.com:foo/bar\n\t\tr = strings.Replace(r, \":\", \"/\", -1)\n\t\tr = \"ssh://\" + r\n\t\tu, err = url.Parse(r)\n\t\tif err != nil {\n\t\t\treturn \"\"\n\t\t}\n\t\tu.Scheme = \"\"\n\t}\n\tif u.Host == \"github.com\" {\n\t\tparts := strings.Split(u.Path, \"/\")\n\t\tif len(parts) != 2 {\n\t\t\treturn \"\"\n\t\t}\n\t\tapi := fmt.Sprintf(\"https://api.github.com/repos/%s/%s\", parts[0], parts[1])\n\t\tresp, err := http.Get(api)\n\t\tif err != nil {\n\t\t\treturn \"\"\n\t\t}\n\t\tdefer resp.Body.Close()\n\t\tif resp.StatusCode >= 300 || resp.StatusCode < 200 {\n\t\t\treturn \"\"\n\t\t}\n\t\tbody, err := ioutil.ReadAll(resp.Body)\n\t\tvar data interface{}\n\t\terr = json.Unmarshal(body, &data)\n\t\tif err != nil {\n\t\t\treturn \"\"\n\t\t}\n\t\tgh := data.(map[string]interface{})\n\t\tdb := gh[\"default_branch\"].(string)\n\t\tif kerr == nil {\n\t\t\td.DefaultBranch = db\n\t\t\terr := cp.SaveRepoData(key, d)\n\t\t\tif err == cp.ErrCacheDisabled {\n\t\t\t\tmsg.Debug(\"Unable to cache default branch because caching is disabled\")\n\t\t\t} else if err != nil {\n\t\t\t\tmsg.Debug(\"Error saving %s to cache. Error: %s\", repo.Remote(), err)\n\t\t\t}\n\t\t}\n\t\treturn db\n\t}\n\n\tif u.Host == \"bitbucket.org\" {\n\t\tparts := strings.Split(u.Path, \"/\")\n\t\tif len(parts) != 2 {\n\t\t\treturn \"\"\n\t\t}\n\t\tapi := fmt.Sprintf(\"https://bitbucket.org/api/1.0/repositories/%s/%s/main-branch/\", parts[0], parts[1])\n\t\tresp, err := http.Get(api)\n\t\tif err != nil {\n\t\t\treturn \"\"\n\t\t}\n\t\tdefer resp.Body.Close()\n\t\tif resp.StatusCode >= 300 || resp.StatusCode < 200 {\n\t\t\treturn \"\"\n\t\t}\n\t\tbody, err := ioutil.ReadAll(resp.Body)\n\t\tvar data interface{}\n\t\terr = json.Unmarshal(body, &data)\n\t\tif err != nil {\n\t\t\treturn \"\"\n\t\t}\n\t\tbb := data.(map[string]interface{})\n\t\tdb := bb[\"name\"].(string)\n\t\tif kerr == nil {\n\t\t\td.DefaultBranch = db\n\t\t\terr := cp.SaveRepoData(key, d)\n\t\t\tif err == cp.ErrCacheDisabled {\n\t\t\t\tmsg.Debug(\"Unable to cache default branch because caching is disabled\")\n\t\t\t} else if err != nil {\n\t\t\t\tmsg.Debug(\"Error saving %s to cache. Error: %s\", repo.Remote(), err)\n\t\t\t}\n\t\t}\n\t\treturn db\n\t}\n\n\treturn \"\"\n}\n\n// From a local repo find out the current branch name if there is one.\n// Note, this should only be used right after a fresh clone to get accurate\n// information.\nfunc findCurrentBranch(repo v.Repo) string {\n\tmsg.Debug(\"Attempting to find current branch for %s\", repo.Remote())\n\t// Svn and Bzr don't have default branches.\n\tif repo.Vcs() == v.Svn || repo.Vcs() == v.Bzr {\n\t\treturn \"\"\n\t}\n\n\tif repo.Vcs() == v.Git || repo.Vcs() == v.Hg {\n\t\tver, err := repo.Current()\n\t\tif err != nil {\n\t\t\tmsg.Debug(\"Unable to find current branch for %s, error: %s\", repo.Remote(), err)\n\t\t\treturn \"\"\n\t\t}\n\t\treturn ver\n\t}\n\n\treturn \"\"\n}\n\nfunc envForDir(dir string) []string {\n\tenv := os.Environ()\n\treturn mergeEnvLists([]string{\"PWD=\" + dir}, env)\n}\n\nfunc mergeEnvLists(in, out []string) []string {\nNextVar:\n\tfor _, inkv := range in {\n\t\tk := strings.SplitAfterN(inkv, \"=\", 2)[0]\n\t\tfor i, outkv := range out {\n\t\t\tif strings.HasPrefix(outkv, k) {\n\t\t\t\tout[i] = inkv\n\t\t\t\tcontinue NextVar\n\t\t\t}\n\t\t}\n\t\tout = append(out, inkv)\n\t}\n\treturn out\n}\n"
  },
  {
    "path": "testdata/name/glide.yaml",
    "content": "package: technosophos.com/x/foo\nimport: []\n"
  },
  {
    "path": "testdata/name/glide2.yaml",
    "content": "package: another/name\nimport: []\n"
  },
  {
    "path": "testdata/nv/a/foo.empty",
    "content": ""
  },
  {
    "path": "testdata/nv/b/foo.empty",
    "content": ""
  },
  {
    "path": "testdata/nv/c/foo.empty",
    "content": ""
  },
  {
    "path": "testdata/path/a/b/c/placeholder.empty",
    "content": ""
  },
  {
    "path": "testdata/path/a/glide.yaml",
    "content": ""
  },
  {
    "path": "testdata/path/x/glide.yaml",
    "content": ""
  },
  {
    "path": "testdata/path/x/symlinked_vendor/placeholder.empty",
    "content": ""
  },
  {
    "path": "testdata/path/x/y/z/placeholder.empty",
    "content": ""
  },
  {
    "path": "testdata/plugin/glide-hello",
    "content": "#!/bin/bash\necho \"Hello from the other glide\"\n"
  },
  {
    "path": "testdata/plugin/glide-hello-win.bat",
    "content": "@echo off\necho \"Hello from the other glide\"\n"
  },
  {
    "path": "testdata/rebuild/glide.yaml",
    "content": "package: github.com/Masterminds/glide/testdata/plugin\nimport:\n  - package: example.com/x/foo\n"
  },
  {
    "path": "tree/tree.go",
    "content": "package tree\n\nimport (\n\t\"container/list\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/Masterminds/glide/dependency\"\n\t\"github.com/Masterminds/glide/msg\"\n\tgpath \"github.com/Masterminds/glide/path\"\n\t\"github.com/Masterminds/glide/util\"\n)\n\n// Display displays a tree view of the given project.\n//\n// FIXME: The output formatting could use some TLC.\nfunc Display(b *util.BuildCtxt, basedir, myName string, level int, core bool, l *list.List) {\n\tdeps := walkDeps(b, basedir, myName)\n\tfor _, name := range deps {\n\t\tfound := findPkg(b, name, basedir)\n\t\tif found.Loc == dependency.LocUnknown {\n\t\t\tm := \"glide get \" + found.Name\n\t\t\tmsg.Puts(\"\\t%s\\t(%s)\", found.Name, m)\n\t\t\tcontinue\n\t\t}\n\t\tif !core && found.Loc == dependency.LocGoroot || found.Loc == dependency.LocCgo {\n\t\t\tcontinue\n\t\t}\n\t\tmsg.Print(strings.Repeat(\"|\\t\", level-1) + \"|-- \")\n\n\t\tf := findInList(found.Name, l)\n\t\tif f == true {\n\t\t\tmsg.Puts(\"(Recursion) %s   (%s)\", found.Name, found.Path)\n\t\t} else {\n\t\t\t// Every branch in the tree is a copy to handle all the branches\n\t\t\tcl := copyList(l)\n\t\t\tcl.PushBack(found.Name)\n\t\t\tmsg.Puts(\"%s   (%s)\", found.Name, found.Path)\n\t\t\tDisplay(b, found.Path, found.Name, level+1, core, cl)\n\t\t}\n\t}\n}\n\nfunc walkDeps(b *util.BuildCtxt, base, myName string) []string {\n\texternalDeps := []string{}\n\tfilepath.Walk(base, func(path string, fi os.FileInfo, err error) error {\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif !dependency.IsSrcDir(fi) {\n\t\t\tif fi.IsDir() {\n\t\t\t\treturn filepath.SkipDir\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\n\t\tvar imps []string\n\t\tpkg, err := b.ImportDir(path, 0)\n\t\tif err != nil && strings.HasPrefix(err.Error(), \"found packages \") {\n\t\t\t// If we got here it's because a package and multiple packages\n\t\t\t// declared. This is often because of an example with a package\n\t\t\t// or main but +build ignore as a build tag. In that case we\n\t\t\t// try to brute force the packages with a slower scan.\n\t\t\timps, _, err = dependency.IterativeScan(path)\n\t\t\tif err != nil {\n\t\t\t\tmsg.Err(\"Error walking dependencies for %s: %s\", path, err)\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else if err != nil {\n\t\t\tif !strings.HasPrefix(err.Error(), \"no buildable Go source\") {\n\t\t\t\tmsg.Warn(\"Error: %s (%s)\", err, path)\n\t\t\t\t// Not sure if we should return here.\n\t\t\t\t//return err\n\t\t\t}\n\t\t} else {\n\t\t\timps = pkg.Imports\n\t\t}\n\n\t\tif pkg.Goroot {\n\t\t\treturn nil\n\t\t}\n\n\t\tfor _, imp := range imps {\n\t\t\t//if strings.HasPrefix(imp, myName) {\n\t\t\t////Info(\"Skipping %s because it is a subpackage of %s\", imp, myName)\n\t\t\t//continue\n\t\t\t//}\n\t\t\tif imp == myName {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\texternalDeps = append(externalDeps, imp)\n\t\t}\n\n\t\treturn nil\n\t})\n\treturn externalDeps\n}\n\nfunc findPkg(b *util.BuildCtxt, name, cwd string) *dependency.PkgInfo {\n\tvar fi os.FileInfo\n\tvar err error\n\tvar p string\n\n\tinfo := &dependency.PkgInfo{\n\t\tName: name,\n\t}\n\n\tif strings.HasPrefix(name, \"./\") || strings.HasPrefix(name, \"../\") {\n\t\tinfo.Loc = dependency.LocRelative\n\t\treturn info\n\t}\n\n\t// Recurse backward to scan other vendor/ directories\n\t// If the cwd isn't an absolute path walking upwards looking for vendor/\n\t// folders can get into an infinate loop.\n\tabs, err := filepath.Abs(cwd)\n\tif err != nil {\n\t\tabs = cwd\n\t}\n\tif abs != \".\" {\n\t\t// Previously there was a check on the loop that wd := \"/\". The path\n\t\t// \"/\" is a POSIX path so this fails on Windows. Now the check is to\n\t\t// make sure the same wd isn't seen twice. When the same wd happens\n\t\t// more than once it's the beginning of looping on the same location\n\t\t// which is the top level.\n\t\tpwd := \"\"\n\t\tfor wd := abs; wd != pwd; wd = filepath.Dir(wd) {\n\t\t\tpwd = wd\n\n\t\t\t// Don't look for packages outside the GOPATH\n\t\t\t// Note, the GOPATH may or may not end with the path separator.\n\t\t\t// The output of filepath.Dir does not the the path separator on the\n\t\t\t// end so we need to test both.\n\t\t\tif wd == b.GOPATH || wd+string(os.PathSeparator) == b.GOPATH {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tp = filepath.Join(wd, \"vendor\", name)\n\t\t\tif fi, err = os.Stat(p); err == nil && (fi.IsDir() || gpath.IsLink(fi)) {\n\t\t\t\tinfo.Path = p\n\t\t\t\tinfo.Loc = dependency.LocVendor\n\t\t\t\tinfo.Vendored = true\n\t\t\t\treturn info\n\t\t\t}\n\t\t}\n\t}\n\t// Check $GOPATH\n\tfor _, r := range strings.Split(b.GOPATH, \":\") {\n\t\tp = filepath.Join(r, \"src\", name)\n\t\tif fi, err = os.Stat(p); err == nil && (fi.IsDir() || gpath.IsLink(fi)) {\n\t\t\tinfo.Path = p\n\t\t\tinfo.Loc = dependency.LocGopath\n\t\t\treturn info\n\t\t}\n\t}\n\n\t// Check $GOROOT\n\tfor _, r := range strings.Split(b.GOROOT, \":\") {\n\t\tp = filepath.Join(r, \"src\", name)\n\t\tif fi, err = os.Stat(p); err == nil && (fi.IsDir() || gpath.IsLink(fi)) {\n\t\t\tinfo.Path = p\n\t\t\tinfo.Loc = dependency.LocGoroot\n\t\t\treturn info\n\t\t}\n\t}\n\n\t// If this is \"C\", we're dealing with cgo\n\tif name == \"C\" {\n\t\tinfo.Loc = dependency.LocCgo\n\t} else if name == \"appengine\" || name == \"appengine_internal\" ||\n\t\tstrings.HasPrefix(name, \"appengine/\") ||\n\t\tstrings.HasPrefix(name, \"appengine_internal/\") {\n\t\t// Appengine is a special case when it comes to Go builds. It is a local\n\t\t// looking package only available within appengine. It's a special case\n\t\t// where Google products are playing with each other.\n\t\t// https://blog.golang.org/the-app-engine-sdk-and-workspaces-gopath\n\t\tinfo.Loc = dependency.LocAppengine\n\t} else if _, ok := dependency.PackagesAddedToStdlib[name]; ok {\n\t\t// Various packages are being added to the Go standard library, and being imported\n\t\t// with build flags. Need to detect this and handle it.\n\t\tinfo.Loc = dependency.LocGoroot\n\t}\n\n\treturn info\n}\n\n// copyList copies an existing list to a new list.\nfunc copyList(l *list.List) *list.List {\n\tn := list.New()\n\tfor e := l.Front(); e != nil; e = e.Next() {\n\t\tn.PushBack(e.Value.(string))\n\t}\n\treturn n\n}\n\n// findInList searches a list haystack for a string needle.\nfunc findInList(n string, l *list.List) bool {\n\tfor e := l.Front(); e != nil; e = e.Next() {\n\t\tif e.Value.(string) == n {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n"
  },
  {
    "path": "tree/tree_test.go",
    "content": "/* Package tree contains functions for printing a dependency tree.\n\nThe future of the tree functionality is uncertain, as it is neither core to\nthe functionality of Glide, nor particularly complementary. Its principal use\ncase is for debugging the generated dependency tree.\n\nCurrently, the tree package builds its dependency tree in a slightly different\nway than the `dependency` package does. This should not make any practical\ndifference, though code-wise it would be nice to change this over to use the\n`dependency` resolver.\n*/\npackage tree\n\nimport (\n\t\"container/list\"\n\t\"testing\"\n)\n\nfunc TestFindInTree(t *testing.T) {\n\tl := list.New()\n\tl.PushBack(\"github.com/Masterminds/glide\")\n\tl.PushBack(\"github.com/Masterminds/vcs\")\n\tl.PushBack(\"github.com/Masterminds/semver\")\n\n\tf := findInList(\"foo\", l)\n\tif f != false {\n\t\tt.Error(\"findInList found true instead of false\")\n\t}\n\n\tf = findInList(\"github.com/Masterminds/vcs\", l)\n\tif f != true {\n\t\tt.Error(\"findInList found false instead of true\")\n\t}\n}\n"
  },
  {
    "path": "util/normalizename_test.go",
    "content": "package util\n\nimport (\n\t\"testing\"\n)\n\nfunc TestNormalizeName(t *testing.T) {\n\tpackages := []struct {\n\t\tinput string\n\t\troot  string\n\t\textra string\n\t}{\n\t\t{\n\t\t\tinput: \"github.com/Masterminds/cookoo/web/io/foo\",\n\t\t\troot:  \"github.com/Masterminds/cookoo\",\n\t\t\textra: \"web/io/foo\",\n\t\t},\n\t\t{\n\t\t\tinput: `github.com\\Masterminds\\cookoo\\web\\io\\foo`,\n\t\t\troot:  \"github.com/Masterminds/cookoo\",\n\t\t\textra: \"web/io/foo\",\n\t\t},\n\t\t{\n\t\t\tinput: \"golang.org/x/crypto/ssh\",\n\t\t\troot:  \"golang.org/x/crypto\",\n\t\t\textra: \"ssh\",\n\t\t},\n\t\t{\n\t\t\tinput: \"incomplete/example\",\n\t\t\troot:  \"incomplete/example\",\n\t\t\textra: \"\",\n\t\t},\n\t\t{\n\t\t\tinput: \"otherurl/example/root/sub\",\n\t\t\troot:  \"otherurl/example/root\",\n\t\t\textra: \"sub\",\n\t\t},\n\t\t{\n\t\t\tinput: \"net\",\n\t\t\troot:  \"net\",\n\t\t\textra: \"\",\n\t\t},\n\t}\n\tremotePackageCache[\"otherurl/example/root\"] = \"otherurl/example/root\"\n\n\tfor _, test := range packages {\n\t\troot, extra := NormalizeName(test.input)\n\t\tif root != test.root {\n\t\t\tt.Errorf(\"%s: Expected root '%s', got '%s'\", test.input, test.root, root)\n\t\t}\n\t\tif extra != test.extra {\n\t\t\tt.Errorf(\"%s: Expected extra '%s', got '%s'\", test.input, test.extra, extra)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "util/util.go",
    "content": "package util\n\nimport (\n\t\"encoding/xml\"\n\t\"fmt\"\n\t\"go/build\"\n\t\"io\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n\t\"regexp\"\n\t\"strings\"\n\n\t\"github.com/Masterminds/vcs\"\n)\n\n// ResolveCurrent selects whether the package should only the dependencies for\n// the current OS/ARCH instead of all possible permutations.\n// This is not concurrently safe which is ok for the current application. If\n// other needs arise it may need to be re-written.\nvar ResolveCurrent = false\n\n// goRoot caches the GOROOT variable for build contexts. If $GOROOT is not set in\n// the user's environment, then the context's root path is 'go env GOROOT'.\nvar goRoot string\n\nfunc init() {\n\t// Precompile the regular expressions used to check VCS locations.\n\tfor _, v := range vcsList {\n\t\tv.regex = regexp.MustCompile(v.pattern)\n\t}\n\tif goRoot = os.Getenv(\"GOROOT\"); len(goRoot) == 0 {\n\t\tgoExecutable := os.Getenv(\"GLIDE_GO_EXECUTABLE\")\n\t\tif len(goExecutable) <= 0 {\n\t\t\tgoExecutable = \"go\"\n\t\t}\n\t\tout, err := exec.Command(goExecutable, \"env\", \"GOROOT\").Output()\n\t\tif err == nil {\n\t\t\tgoRoot = strings.TrimSpace(string(out))\n\t\t}\n\t}\n}\n\nfunc toSlash(v string) string {\n\treturn strings.Replace(v, \"\\\\\", \"/\", -1)\n}\n\n// GetRootFromPackage retrives the top level package from a name.\n//\n// From a package name find the root repo. For example,\n// the package github.com/Masterminds/cookoo/io has a root repo\n// at github.com/Masterminds/cookoo\nfunc GetRootFromPackage(pkg string) string {\n\tpkg = toSlash(pkg)\n\tfor _, v := range vcsList {\n\t\tm := v.regex.FindStringSubmatch(pkg)\n\t\tif m == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tif m[1] != \"\" {\n\t\t\treturn m[1]\n\t\t}\n\t}\n\n\t// There are cases where a package uses the special go get magic for\n\t// redirects. If we've not discovered the location already try that.\n\tpkg = getRootFromGoGet(pkg)\n\n\treturn pkg\n}\n\n// Pages like https://golang.org/x/net provide an html document with\n// meta tags containing a location to work with. The go tool uses\n// a meta tag with the name go-import which is what we use here.\n// godoc.org also has one call go-source that we do not need to use.\n// The value of go-import is in the form \"prefix vcs repo\". The prefix\n// should match the vcsURL and the repo is a location that can be\n// checked out. Note, to get the html document you you need to add\n// ?go-get=1 to the url.\nfunc getRootFromGoGet(pkg string) string {\n\n\tp, found := checkRemotePackageCache(pkg)\n\tif found {\n\t\treturn p\n\t}\n\n\tvcsURL := \"https://\" + pkg\n\tu, err := url.Parse(vcsURL)\n\tif err != nil {\n\t\treturn pkg\n\t}\n\tif u.RawQuery == \"\" {\n\t\tu.RawQuery = \"go-get=1\"\n\t} else {\n\t\tu.RawQuery = u.RawQuery + \"&go-get=1\"\n\t}\n\tcheckURL := u.String()\n\tresp, err := http.Get(checkURL)\n\tif err != nil {\n\t\taddToRemotePackageCache(pkg, pkg)\n\t\treturn pkg\n\t}\n\tdefer resp.Body.Close()\n\n\tnu, err := parseImportFromBody(u, resp.Body)\n\tif err != nil {\n\t\taddToRemotePackageCache(pkg, pkg)\n\t\treturn pkg\n\t} else if nu == \"\" {\n\t\taddToRemotePackageCache(pkg, pkg)\n\t\treturn pkg\n\t}\n\n\taddToRemotePackageCache(pkg, nu)\n\treturn nu\n}\n\n// The caching is not concurrency safe but should be made to be that way.\n// This implementation is far too much of a hack... rewrite needed.\nvar remotePackageCache = make(map[string]string)\n\nfunc checkRemotePackageCache(pkg string) (string, bool) {\n\tfor k, v := range remotePackageCache {\n\t\tif pkg == k || strings.HasPrefix(pkg, k+\"/\") {\n\t\t\treturn v, true\n\t\t}\n\t}\n\n\treturn pkg, false\n}\n\nfunc addToRemotePackageCache(pkg, v string) {\n\tremotePackageCache[pkg] = v\n}\n\nfunc parseImportFromBody(ur *url.URL, r io.ReadCloser) (u string, err error) {\n\td := xml.NewDecoder(r)\n\td.CharsetReader = charsetReader\n\td.Strict = false\n\tvar t xml.Token\n\tfor {\n\t\tt, err = d.Token()\n\t\tif err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\t// If we hit the end of the markup and don't have anything\n\t\t\t\t// we return an error.\n\t\t\t\terr = vcs.ErrCannotDetectVCS\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tif e, ok := t.(xml.StartElement); ok && strings.EqualFold(e.Name.Local, \"body\") {\n\t\t\treturn\n\t\t}\n\t\tif e, ok := t.(xml.EndElement); ok && strings.EqualFold(e.Name.Local, \"head\") {\n\t\t\treturn\n\t\t}\n\t\te, ok := t.(xml.StartElement)\n\t\tif !ok || !strings.EqualFold(e.Name.Local, \"meta\") {\n\t\t\tcontinue\n\t\t}\n\t\tif attrValue(e.Attr, \"name\") != \"go-import\" {\n\t\t\tcontinue\n\t\t}\n\t\tif f := strings.Fields(attrValue(e.Attr, \"content\")); len(f) == 3 {\n\n\t\t\t// If the prefix supplied by the remote system isn't a prefix to the\n\t\t\t// url we're fetching return continue looking for more go-imports.\n\t\t\t// This will work for exact matches and prefixes. For example,\n\t\t\t// golang.org/x/net as a prefix will match for golang.org/x/net and\n\t\t\t// golang.org/x/net/context.\n\t\t\tvcsURL := ur.Host + ur.Path\n\t\t\tif !strings.HasPrefix(vcsURL, f[0]) {\n\t\t\t\tcontinue\n\t\t\t} else {\n\t\t\t\tu = f[0]\n\t\t\t\treturn\n\t\t\t}\n\n\t\t}\n\t}\n}\n\nfunc charsetReader(charset string, input io.Reader) (io.Reader, error) {\n\tswitch strings.ToLower(charset) {\n\tcase \"ascii\":\n\t\treturn input, nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"can't decode XML document using charset %q\", charset)\n\t}\n}\n\nfunc attrValue(attrs []xml.Attr, name string) string {\n\tfor _, a := range attrs {\n\t\tif strings.EqualFold(a.Name.Local, name) {\n\t\t\treturn a.Value\n\t\t}\n\t}\n\treturn \"\"\n}\n\ntype vcsInfo struct {\n\thost    string\n\tpattern string\n\tregex   *regexp.Regexp\n}\n\nvar vcsList = []*vcsInfo{\n\t{\n\t\thost:    \"github.com\",\n\t\tpattern: `^(?P<rootpkg>github\\.com/[A-Za-z0-9_.\\-]+/[A-Za-z0-9_.\\-]+)(/[A-Za-z0-9_.\\-]+)*$`,\n\t},\n\t{\n\t\thost:    \"bitbucket.org\",\n\t\tpattern: `^(?P<rootpkg>bitbucket\\.org/([A-Za-z0-9_.\\-]+/[A-Za-z0-9_.\\-]+))(/[A-Za-z0-9_.\\-]+)*$`,\n\t},\n\t{\n\t\thost:    \"launchpad.net\",\n\t\tpattern: `^(?P<rootpkg>launchpad\\.net/(([A-Za-z0-9_.\\-]+)(/[A-Za-z0-9_.\\-]+)?|~[A-Za-z0-9_.\\-]+/(\\+junk|[A-Za-z0-9_.\\-]+)/[A-Za-z0-9_.\\-]+))(/[A-Za-z0-9_.\\-]+)*$`,\n\t},\n\t{\n\t\thost:    \"git.launchpad.net\",\n\t\tpattern: `^(?P<rootpkg>git\\.launchpad\\.net/(([A-Za-z0-9_.\\-]+)|~[A-Za-z0-9_.\\-]+/(\\+git|[A-Za-z0-9_.\\-]+)/[A-Za-z0-9_.\\-]+))$`,\n\t},\n\t{\n\t\thost:    \"hub.jazz.net\",\n\t\tpattern: `^(?P<rootpkg>hub\\.jazz\\.net/git/[a-z0-9]+/[A-Za-z0-9_.\\-]+)(/[A-Za-z0-9_.\\-]+)*$`,\n\t},\n\t{\n\t\thost:    \"go.googlesource.com\",\n\t\tpattern: `^(?P<rootpkg>go\\.googlesource\\.com/[A-Za-z0-9_.\\-]+/?)$`,\n\t},\n\t// TODO: Once Google Code becomes fully deprecated this can be removed.\n\t{\n\t\thost:    \"code.google.com\",\n\t\tpattern: `^(?P<rootpkg>code\\.google\\.com/[pr]/([a-z0-9\\-]+)(\\.([a-z0-9\\-]+))?)(/[A-Za-z0-9_.\\-]+)*$`,\n\t},\n\t// Alternative Google setup for SVN. This is the previous structure but it still works... until Google Code goes away.\n\t{\n\t\tpattern: `^(?P<rootpkg>[a-z0-9_\\-.]+\\.googlecode\\.com/svn(/.*)?)$`,\n\t},\n\t// Alternative Google setup. This is the previous structure but it still works... until Google Code goes away.\n\t{\n\t\tpattern: `^(?P<rootpkg>[a-z0-9_\\-.]+\\.googlecode\\.com/(git|hg))(/.*)?$`,\n\t},\n\t// If none of the previous detect the type they will fall to this looking for the type in a generic sense\n\t// by the extension to the path.\n\t{\n\t\tpattern: `^(?P<rootpkg>(?P<repo>([a-z0-9.\\-]+\\.)+[a-z0-9.\\-]+(:[0-9]+)?/[A-Za-z0-9_.\\-/]*?)\\.(bzr|git|hg|svn))(/[A-Za-z0-9_.\\-]+)*$`,\n\t},\n}\n\n// BuildCtxt is a convenience wrapper for not having to import go/build\n// anywhere else\ntype BuildCtxt struct {\n\tbuild.Context\n}\n\n// PackageName attempts to determine the name of the base package.\n//\n// If resolution fails, this will return \"main\".\nfunc (b *BuildCtxt) PackageName(base string) string {\n\tcwd, err := os.Getwd()\n\tif err != nil {\n\t\treturn \"main\"\n\t}\n\n\tpkg, err := b.Import(base, cwd, 0)\n\tif err != nil {\n\t\t// There may not be any top level Go source files but the project may\n\t\t// still be within the GOPATH.\n\t\tif strings.HasPrefix(base, b.GOPATH) {\n\t\t\tp := strings.TrimPrefix(base, filepath.Join(b.GOPATH, \"src\"))\n\t\t\treturn strings.Trim(p, string(os.PathSeparator))\n\t\t}\n\t}\n\n\treturn pkg.ImportPath\n}\n\n// GetBuildContext returns a build context from go/build. When the $GOROOT\n// variable is not set in the users environment it sets the context's root\n// path to the path returned by 'go env GOROOT'.\n//\n// TODO: This should be moved to the `dependency` package.\nfunc GetBuildContext() (*BuildCtxt, error) {\n\tif len(goRoot) == 0 {\n\t\treturn nil, fmt.Errorf(\"GOROOT value not found. Please set the GOROOT \" +\n\t\t\t\"environment variable to use this command\")\n\t}\n\n\tbuildContext := &BuildCtxt{build.Default}\n\n\t// If we aren't resolving for the current system set to look at all\n\t// build modes.\n\tif !ResolveCurrent {\n\t\t// This tells the context scanning to skip filtering on +build flags or\n\t\t// file names.\n\t\tbuildContext.UseAllFiles = true\n\t}\n\n\tbuildContext.GOROOT = goRoot\n\treturn buildContext, nil\n}\n\n// NormalizeName takes a package name and normalizes it to the top level package.\n//\n// For example, golang.org/x/crypto/ssh becomes golang.org/x/crypto. 'ssh' is\n// returned as extra data.\n//\n// FIXME: Is this deprecated?\nfunc NormalizeName(name string) (string, string) {\n\t// Fastpath check if a name in the GOROOT. There is an issue when a pkg\n\t// is in the GOROOT and GetRootFromPackage tries to look it up because it\n\t// expects remote names.\n\tb, err := GetBuildContext()\n\tif err == nil {\n\t\tp := filepath.Join(b.GOROOT, \"src\", name)\n\t\tif _, err := os.Stat(p); err == nil {\n\t\t\treturn toSlash(name), \"\"\n\t\t}\n\t}\n\n\tname = toSlash(name)\n\troot := GetRootFromPackage(name)\n\textra := strings.TrimPrefix(name, root)\n\tif len(extra) > 0 && extra != \"/\" {\n\t\textra = strings.TrimPrefix(extra, \"/\")\n\t} else {\n\t\t// If extra is / (which is what it would be here) we want to return \"\"\n\t\textra = \"\"\n\t}\n\n\treturn root, extra\n}\n"
  },
  {
    "path": "util/util_test.go",
    "content": "package util\n\nimport \"testing\"\n\nfunc TestGetRootFromPackage(t *testing.T) {\n\turlList := map[string]string{\n\t\t\"github.com/Masterminds/VCSTestRepo\":                       \"github.com/Masterminds/VCSTestRepo\",\n\t\t\"bitbucket.org/mattfarina/testhgrepo\":                      \"bitbucket.org/mattfarina/testhgrepo\",\n\t\t\"launchpad.net/govcstestbzrrepo/trunk\":                     \"launchpad.net/govcstestbzrrepo/trunk\",\n\t\t\"launchpad.net/~mattfarina/+junk/mygovcstestbzrrepo\":       \"launchpad.net/~mattfarina/+junk/mygovcstestbzrrepo\",\n\t\t\"launchpad.net/~mattfarina/+junk/mygovcstestbzrrepo/trunk\": \"launchpad.net/~mattfarina/+junk/mygovcstestbzrrepo\",\n\t\t\"git.launchpad.net/govcstestgitrepo\":                       \"git.launchpad.net/govcstestgitrepo\",\n\t\t\"git.launchpad.net/~mattfarina/+git/mygovcstestgitrepo\":    \"git.launchpad.net/~mattfarina/+git/mygovcstestgitrepo\",\n\t\t\"hub.jazz.net/git/user/pkgname\":                            \"hub.jazz.net/git/user/pkgname\",\n\t\t\"hub.jazz.net/git/user/pkgname/subpkg/subpkg/subpkg\":       \"hub.jazz.net/git/user/pkgname\",\n\t\t\"farbtastic.googlecode.com/svn/\":                           \"farbtastic.googlecode.com/svn/\",\n\t\t\"farbtastic.googlecode.com/svn/trunk\":                      \"farbtastic.googlecode.com/svn/trunk\",\n\t\t\"code.google.com/p/farbtastic\":                             \"code.google.com/p/farbtastic\",\n\t\t\"code.google.com/p/plotinum\":                               \"code.google.com/p/plotinum\",\n\t\t\"example.com/foo/bar.git\":                                  \"example.com/foo/bar.git\",\n\t\t\"example.com/foo/bar.svn\":                                  \"example.com/foo/bar.svn\",\n\t\t\"example.com/foo/bar/baz.bzr\":                              \"example.com/foo/bar/baz.bzr\",\n\t\t\"example.com/foo/bar/baz.hg\":                               \"example.com/foo/bar/baz.hg\",\n\t\t\"gopkg.in/mgo.v2\":                                          \"gopkg.in/mgo.v2\",\n\t\t\"gopkg.in/mgo.v2/txn\":                                      \"gopkg.in/mgo.v2\",\n\t\t\"gopkg.in/nowk/assert.v2\":                                  \"gopkg.in/nowk/assert.v2\",\n\t\t\"gopkg.in/nowk/assert.v2/tests\":                            \"gopkg.in/nowk/assert.v2\",\n\t\t\"golang.org/x/net\":                                         \"golang.org/x/net\",\n\t\t\"golang.org/x/net/context\":                                 \"golang.org/x/net\",\n\t}\n\n\tfor u, c := range urlList {\n\t\trepo := GetRootFromPackage(u)\n\t\tif repo != c {\n\t\t\tt.Errorf(\"getRepoRootFromPackage expected %s but got %s\", c, repo)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/Masterminds/semver/.travis.yml",
    "content": "language: go\n\ngo:\n  - 1.6.x\n  - 1.7.x\n  - 1.8.x\n  - 1.9.x\n  - 1.10.x\n  - tip\n\n# Setting sudo access to false will let Travis CI use containers rather than\n# VMs to run the tests. For more details see:\n# - http://docs.travis-ci.com/user/workers/container-based-infrastructure/\n# - http://docs.travis-ci.com/user/workers/standard-infrastructure/\nsudo: false\n\nscript:\n  - make setup\n  - make test\n\nnotifications:\n  webhooks:\n    urls:\n      - https://webhooks.gitter.im/e/06e3328629952dabe3e0\n    on_success: change  # options: [always|never|change] default: always\n    on_failure: always  # options: [always|never|change] default: always\n    on_start: never     # options: [always|never|change] default: always\n"
  },
  {
    "path": "vendor/github.com/Masterminds/semver/CHANGELOG.md",
    "content": "# 1.4.2 (2018-04-10)\n\n## Changed\n- #72: Updated the docs to point to vert for a console appliaction\n- #71: Update the docs on pre-release comparator handling\n\n## Fixed\n- #70: Fix the handling of pre-releases and the 0.0.0 release edge case\n\n# 1.4.1 (2018-04-02)\n\n## Fixed\n- Fixed #64: Fix pre-release precedence issue (thanks @uudashr)\n\n# 1.4.0 (2017-10-04)\n\n## Changed\n- #61: Update NewVersion to parse ints with a 64bit int size (thanks @zknill)\n\n# 1.3.1 (2017-07-10)\n\n## Fixed\n- Fixed #57: number comparisons in prerelease sometimes inaccurate\n\n# 1.3.0 (2017-05-02)\n\n## Added\n- #45: Added json (un)marshaling support (thanks @mh-cbon)\n- Stability marker. See https://masterminds.github.io/stability/\n\n## Fixed\n- #51: Fix handling of single digit tilde constraint (thanks @dgodd)\n\n## Changed\n- #55: The godoc icon moved from png to svg\n\n# 1.2.3 (2017-04-03)\n\n## Fixed\n- #46: Fixed 0.x.x and 0.0.x in constraints being treated as *\n\n# Release 1.2.2 (2016-12-13)\n\n## Fixed\n- #34: Fixed issue where hyphen range was not working with pre-release parsing.\n\n# Release 1.2.1 (2016-11-28)\n\n## Fixed\n- #24: Fixed edge case issue where constraint \"> 0\" does not handle \"0.0.1-alpha\"\n  properly.\n\n# Release 1.2.0 (2016-11-04)\n\n## Added\n- #20: Added MustParse function for versions (thanks @adamreese)\n- #15: Added increment methods on versions (thanks @mh-cbon)\n\n## Fixed\n- Issue #21: Per the SemVer spec (section 9) a pre-release is unstable and\n  might not satisfy the intended compatibility. The change here ignores pre-releases\n  on constraint checks (e.g., ~ or ^) when a pre-release is not part of the\n  constraint. For example, `^1.2.3` will ignore pre-releases while\n  `^1.2.3-alpha` will include them.\n\n# Release 1.1.1 (2016-06-30)\n\n## Changed\n- Issue #9: Speed up version comparison performance (thanks @sdboyer)\n- Issue #8: Added benchmarks (thanks @sdboyer)\n- Updated Go Report Card URL to new location\n- Updated Readme to add code snippet formatting (thanks @mh-cbon)\n- Updating tagging to v[SemVer] structure for compatibility with other tools.\n\n# Release 1.1.0 (2016-03-11)\n\n- Issue #2: Implemented validation to provide reasons a versions failed a\n  constraint.\n\n# Release 1.0.1 (2015-12-31)\n\n- Fixed #1: * constraint failing on valid versions.\n\n# Release 1.0.0 (2015-10-20)\n\n- Initial release\n"
  },
  {
    "path": "vendor/github.com/Masterminds/semver/LICENSE.txt",
    "content": "The Masterminds\nCopyright (C) 2014-2015, Matt Butcher and Matt Farina\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "vendor/github.com/Masterminds/semver/Makefile",
    "content": ".PHONY: setup\nsetup:\n\tgo get -u gopkg.in/alecthomas/gometalinter.v1\n\tgometalinter.v1 --install\n\n.PHONY: test\ntest: validate lint\n\t@echo \"==> Running tests\"\n\tgo test -v\n\n.PHONY: validate\nvalidate:\n\t@echo \"==> Running static validations\"\n\t@gometalinter.v1 \\\n\t  --disable-all \\\n\t  --enable deadcode \\\n\t  --severity deadcode:error \\\n\t  --enable gofmt \\\n\t  --enable gosimple \\\n\t  --enable ineffassign \\\n\t  --enable misspell \\\n\t  --enable vet \\\n\t  --tests \\\n\t  --vendor \\\n\t  --deadline 60s \\\n\t  ./... || exit_code=1\n\n.PHONY: lint\nlint:\n\t@echo \"==> Running linters\"\n\t@gometalinter.v1 \\\n\t  --disable-all \\\n\t  --enable golint \\\n\t  --vendor \\\n\t  --deadline 60s \\\n\t  ./... || :\n"
  },
  {
    "path": "vendor/github.com/Masterminds/semver/README.md",
    "content": "# SemVer\n\nThe `semver` package provides the ability to work with [Semantic Versions](http://semver.org) in Go. Specifically it provides the ability to:\n\n* Parse semantic versions\n* Sort semantic versions\n* Check if a semantic version fits within a set of constraints\n* Optionally work with a `v` prefix\n\n[![Stability:\nActive](https://masterminds.github.io/stability/active.svg)](https://masterminds.github.io/stability/active.html)\n[![Build Status](https://travis-ci.org/Masterminds/semver.svg)](https://travis-ci.org/Masterminds/semver) [![Build status](https://ci.appveyor.com/api/projects/status/jfk66lib7hb985k8/branch/master?svg=true&passingText=windows%20build%20passing&failingText=windows%20build%20failing)](https://ci.appveyor.com/project/mattfarina/semver/branch/master) [![GoDoc](https://godoc.org/github.com/Masterminds/semver?status.svg)](https://godoc.org/github.com/Masterminds/semver) [![Go Report Card](https://goreportcard.com/badge/github.com/Masterminds/semver)](https://goreportcard.com/report/github.com/Masterminds/semver)\n\n## Parsing Semantic Versions\n\nTo parse a semantic version use the `NewVersion` function. For example,\n\n```go\n    v, err := semver.NewVersion(\"1.2.3-beta.1+build345\")\n```\n\nIf there is an error the version wasn't parseable. The version object has methods\nto get the parts of the version, compare it to other versions, convert the\nversion back into a string, and get the original string. For more details\nplease see the [documentation](https://godoc.org/github.com/Masterminds/semver).\n\n## Sorting Semantic Versions\n\nA set of versions can be sorted using the [`sort`](https://golang.org/pkg/sort/)\npackage from the standard library. For example,\n\n```go\n    raw := []string{\"1.2.3\", \"1.0\", \"1.3\", \"2\", \"0.4.2\",}\n    vs := make([]*semver.Version, len(raw))\n\tfor i, r := range raw {\n\t\tv, err := semver.NewVersion(r)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Error parsing version: %s\", err)\n\t\t}\n\n\t\tvs[i] = v\n\t}\n\n\tsort.Sort(semver.Collection(vs))\n```\n\n## Checking Version Constraints\n\nChecking a version against version constraints is one of the most featureful\nparts of the package.\n\n```go\n    c, err := semver.NewConstraint(\">= 1.2.3\")\n    if err != nil {\n        // Handle constraint not being parseable.\n    }\n\n    v, _ := semver.NewVersion(\"1.3\")\n    if err != nil {\n        // Handle version not being parseable.\n    }\n    // Check if the version meets the constraints. The a variable will be true.\n    a := c.Check(v)\n```\n\n## Basic Comparisons\n\nThere are two elements to the comparisons. First, a comparison string is a list\nof comma separated and comparisons. These are then separated by || separated or\ncomparisons. For example, `\">= 1.2, < 3.0.0 || >= 4.2.3\"` is looking for a\ncomparison that's greater than or equal to 1.2 and less than 3.0.0 or is\ngreater than or equal to 4.2.3.\n\nThe basic comparisons are:\n\n* `=`: equal (aliased to no operator)\n* `!=`: not equal\n* `>`: greater than\n* `<`: less than\n* `>=`: greater than or equal to\n* `<=`: less than or equal to\n\n_Note, according to the Semantic Version specification pre-releases may not be\nAPI compliant with their release counterpart. It says,_\n\n> _A pre-release version indicates that the version is unstable and might not satisfy the intended compatibility requirements as denoted by its associated normal version._\n\n_SemVer comparisons without a pre-release value will skip pre-release versions.\nFor example, `>1.2.3` will skip pre-releases when looking at a list of values\nwhile `>1.2.3-alpha.1` will evaluate pre-releases._\n\n## Hyphen Range Comparisons\n\nThere are multiple methods to handle ranges and the first is hyphens ranges.\nThese look like:\n\n* `1.2 - 1.4.5` which is equivalent to `>= 1.2, <= 1.4.5`\n* `2.3.4 - 4.5` which is equivalent to `>= 2.3.4, <= 4.5`\n\n## Wildcards In Comparisons\n\nThe `x`, `X`, and `*` characters can be used as a wildcard character. This works\nfor all comparison operators. When used on the `=` operator it falls\nback to the pack level comparison (see tilde below). For example,\n\n* `1.2.x` is equivalent to `>= 1.2.0, < 1.3.0`\n* `>= 1.2.x` is equivalent to `>= 1.2.0`\n* `<= 2.x` is equivalent to `<= 3`\n* `*` is equivalent to `>= 0.0.0`\n\n## Tilde Range Comparisons (Patch)\n\nThe tilde (`~`) comparison operator is for patch level ranges when a minor\nversion is specified and major level changes when the minor number is missing.\nFor example,\n\n* `~1.2.3` is equivalent to `>= 1.2.3, < 1.3.0`\n* `~1` is equivalent to `>= 1, < 2`\n* `~2.3` is equivalent to `>= 2.3, < 2.4`\n* `~1.2.x` is equivalent to `>= 1.2.0, < 1.3.0`\n* `~1.x` is equivalent to `>= 1, < 2`\n\n## Caret Range Comparisons (Major)\n\nThe caret (`^`) comparison operator is for major level changes. This is useful\nwhen comparisons of API versions as a major change is API breaking. For example,\n\n* `^1.2.3` is equivalent to `>= 1.2.3, < 2.0.0`\n* `^1.2.x` is equivalent to `>= 1.2.0, < 2.0.0`\n* `^2.3` is equivalent to `>= 2.3, < 3`\n* `^2.x` is equivalent to `>= 2.0.0, < 3`\n\n# Validation\n\nIn addition to testing a version against a constraint, a version can be validated\nagainst a constraint. When validation fails a slice of errors containing why a\nversion didn't meet the constraint is returned. For example,\n\n```go\n    c, err := semver.NewConstraint(\"<= 1.2.3, >= 1.4\")\n    if err != nil {\n        // Handle constraint not being parseable.\n    }\n\n    v, _ := semver.NewVersion(\"1.3\")\n    if err != nil {\n        // Handle version not being parseable.\n    }\n\n    // Validate a version against a constraint.\n    a, msgs := c.Validate(v)\n    // a is false\n    for _, m := range msgs {\n        fmt.Println(m)\n\n        // Loops over the errors which would read\n        // \"1.3 is greater than 1.2.3\"\n        // \"1.3 is less than 1.4\"\n    }\n```\n\n# Contribute\n\nIf you find an issue or want to contribute please file an [issue](https://github.com/Masterminds/semver/issues)\nor [create a pull request](https://github.com/Masterminds/semver/pulls).\n"
  },
  {
    "path": "vendor/github.com/Masterminds/semver/appveyor.yml",
    "content": "version: build-{build}.{branch}\n\nclone_folder: C:\\gopath\\src\\github.com\\Masterminds\\semver\nshallow_clone: true\n\nenvironment:\n  GOPATH: C:\\gopath\n\nplatform:\n  - x64\n\ninstall:\n  - go version\n  - go env\n  - go get -u gopkg.in/alecthomas/gometalinter.v1\n  - set PATH=%PATH%;%GOPATH%\\bin\n  - gometalinter.v1.exe --install\n\nbuild_script:\n  - go install -v ./...\n\ntest_script:\n  - \"gometalinter.v1 \\\n    --disable-all \\\n    --enable deadcode \\\n    --severity deadcode:error \\\n    --enable gofmt \\\n    --enable gosimple \\\n    --enable ineffassign \\\n    --enable misspell \\\n    --enable vet \\\n    --tests \\\n    --vendor \\\n    --deadline 60s \\\n    ./... || exit_code=1\"\n  - \"gometalinter.v1 \\\n    --disable-all \\\n    --enable golint \\\n    --vendor \\\n    --deadline 60s \\\n    ./... || :\"\n  - go test -v\n\ndeploy: off\n"
  },
  {
    "path": "vendor/github.com/Masterminds/semver/benchmark_test.go",
    "content": "package semver_test\n\nimport (\n\t\"testing\"\n\n\t\"github.com/Masterminds/semver\"\n)\n\n/* Constraint creation benchmarks */\n\nfunc benchNewConstraint(c string, b *testing.B) {\n\tfor i := 0; i < b.N; i++ {\n\t\tsemver.NewConstraint(c)\n\t}\n}\n\nfunc BenchmarkNewConstraintUnary(b *testing.B) {\n\tbenchNewConstraint(\"=2.0\", b)\n}\n\nfunc BenchmarkNewConstraintTilde(b *testing.B) {\n\tbenchNewConstraint(\"~2.0.0\", b)\n}\n\nfunc BenchmarkNewConstraintCaret(b *testing.B) {\n\tbenchNewConstraint(\"^2.0.0\", b)\n}\n\nfunc BenchmarkNewConstraintWildcard(b *testing.B) {\n\tbenchNewConstraint(\"1.x\", b)\n}\n\nfunc BenchmarkNewConstraintRange(b *testing.B) {\n\tbenchNewConstraint(\">=2.1.x, <3.1.0\", b)\n}\n\nfunc BenchmarkNewConstraintUnion(b *testing.B) {\n\tbenchNewConstraint(\"~2.0.0 || =3.1.0\", b)\n}\n\n/* Check benchmarks */\n\nfunc benchCheckVersion(c, v string, b *testing.B) {\n\tversion, _ := semver.NewVersion(v)\n\tconstraint, _ := semver.NewConstraint(c)\n\n\tfor i := 0; i < b.N; i++ {\n\t\tconstraint.Check(version)\n\t}\n}\n\nfunc BenchmarkCheckVersionUnary(b *testing.B) {\n\tbenchCheckVersion(\"=2.0\", \"2.0.0\", b)\n}\n\nfunc BenchmarkCheckVersionTilde(b *testing.B) {\n\tbenchCheckVersion(\"~2.0.0\", \"2.0.5\", b)\n}\n\nfunc BenchmarkCheckVersionCaret(b *testing.B) {\n\tbenchCheckVersion(\"^2.0.0\", \"2.1.0\", b)\n}\n\nfunc BenchmarkCheckVersionWildcard(b *testing.B) {\n\tbenchCheckVersion(\"1.x\", \"1.4.0\", b)\n}\n\nfunc BenchmarkCheckVersionRange(b *testing.B) {\n\tbenchCheckVersion(\">=2.1.x, <3.1.0\", \"2.4.5\", b)\n}\n\nfunc BenchmarkCheckVersionUnion(b *testing.B) {\n\tbenchCheckVersion(\"~2.0.0 || =3.1.0\", \"3.1.0\", b)\n}\n\nfunc benchValidateVersion(c, v string, b *testing.B) {\n\tversion, _ := semver.NewVersion(v)\n\tconstraint, _ := semver.NewConstraint(c)\n\n\tfor i := 0; i < b.N; i++ {\n\t\tconstraint.Validate(version)\n\t}\n}\n\n/* Validate benchmarks, including fails */\n\nfunc BenchmarkValidateVersionUnary(b *testing.B) {\n\tbenchValidateVersion(\"=2.0\", \"2.0.0\", b)\n}\n\nfunc BenchmarkValidateVersionUnaryFail(b *testing.B) {\n\tbenchValidateVersion(\"=2.0\", \"2.0.1\", b)\n}\n\nfunc BenchmarkValidateVersionTilde(b *testing.B) {\n\tbenchValidateVersion(\"~2.0.0\", \"2.0.5\", b)\n}\n\nfunc BenchmarkValidateVersionTildeFail(b *testing.B) {\n\tbenchValidateVersion(\"~2.0.0\", \"1.0.5\", b)\n}\n\nfunc BenchmarkValidateVersionCaret(b *testing.B) {\n\tbenchValidateVersion(\"^2.0.0\", \"2.1.0\", b)\n}\n\nfunc BenchmarkValidateVersionCaretFail(b *testing.B) {\n\tbenchValidateVersion(\"^2.0.0\", \"4.1.0\", b)\n}\n\nfunc BenchmarkValidateVersionWildcard(b *testing.B) {\n\tbenchValidateVersion(\"1.x\", \"1.4.0\", b)\n}\n\nfunc BenchmarkValidateVersionWildcardFail(b *testing.B) {\n\tbenchValidateVersion(\"1.x\", \"2.4.0\", b)\n}\n\nfunc BenchmarkValidateVersionRange(b *testing.B) {\n\tbenchValidateVersion(\">=2.1.x, <3.1.0\", \"2.4.5\", b)\n}\n\nfunc BenchmarkValidateVersionRangeFail(b *testing.B) {\n\tbenchValidateVersion(\">=2.1.x, <3.1.0\", \"1.4.5\", b)\n}\n\nfunc BenchmarkValidateVersionUnion(b *testing.B) {\n\tbenchValidateVersion(\"~2.0.0 || =3.1.0\", \"3.1.0\", b)\n}\n\nfunc BenchmarkValidateVersionUnionFail(b *testing.B) {\n\tbenchValidateVersion(\"~2.0.0 || =3.1.0\", \"3.1.1\", b)\n}\n\n/* Version creation benchmarks */\n\nfunc benchNewVersion(v string, b *testing.B) {\n\tfor i := 0; i < b.N; i++ {\n\t\tsemver.NewVersion(v)\n\t}\n}\n\nfunc BenchmarkNewVersionSimple(b *testing.B) {\n\tbenchNewVersion(\"1.0.0\", b)\n}\n\nfunc BenchmarkNewVersionPre(b *testing.B) {\n\tbenchNewVersion(\"1.0.0-alpha\", b)\n}\n\nfunc BenchmarkNewVersionMeta(b *testing.B) {\n\tbenchNewVersion(\"1.0.0+metadata\", b)\n}\n\nfunc BenchmarkNewVersionMetaDash(b *testing.B) {\n\tbenchNewVersion(\"1.0.0+metadata-dash\", b)\n}\n"
  },
  {
    "path": "vendor/github.com/Masterminds/semver/collection.go",
    "content": "package semver\n\n// Collection is a collection of Version instances and implements the sort\n// interface. See the sort package for more details.\n// https://golang.org/pkg/sort/\ntype Collection []*Version\n\n// Len returns the length of a collection. The number of Version instances\n// on the slice.\nfunc (c Collection) Len() int {\n\treturn len(c)\n}\n\n// Less is needed for the sort interface to compare two Version objects on the\n// slice. If checks if one is less than the other.\nfunc (c Collection) Less(i, j int) bool {\n\treturn c[i].LessThan(c[j])\n}\n\n// Swap is needed for the sort interface to replace the Version objects\n// at two different positions in the slice.\nfunc (c Collection) Swap(i, j int) {\n\tc[i], c[j] = c[j], c[i]\n}\n"
  },
  {
    "path": "vendor/github.com/Masterminds/semver/collection_test.go",
    "content": "package semver\n\nimport (\n\t\"reflect\"\n\t\"sort\"\n\t\"testing\"\n)\n\nfunc TestCollection(t *testing.T) {\n\traw := []string{\n\t\t\"1.2.3\",\n\t\t\"1.0\",\n\t\t\"1.3\",\n\t\t\"2\",\n\t\t\"0.4.2\",\n\t}\n\n\tvs := make([]*Version, len(raw))\n\tfor i, r := range raw {\n\t\tv, err := NewVersion(r)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Error parsing version: %s\", err)\n\t\t}\n\n\t\tvs[i] = v\n\t}\n\n\tsort.Sort(Collection(vs))\n\n\te := []string{\n\t\t\"0.4.2\",\n\t\t\"1.0.0\",\n\t\t\"1.2.3\",\n\t\t\"1.3.0\",\n\t\t\"2.0.0\",\n\t}\n\n\ta := make([]string, len(vs))\n\tfor i, v := range vs {\n\t\ta[i] = v.String()\n\t}\n\n\tif !reflect.DeepEqual(a, e) {\n\t\tt.Error(\"Sorting Collection failed\")\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/Masterminds/semver/constraints.go",
    "content": "package semver\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"regexp\"\n\t\"strings\"\n)\n\n// Constraints is one or more constraint that a semantic version can be\n// checked against.\ntype Constraints struct {\n\tconstraints [][]*constraint\n}\n\n// NewConstraint returns a Constraints instance that a Version instance can\n// be checked against. If there is a parse error it will be returned.\nfunc NewConstraint(c string) (*Constraints, error) {\n\n\t// Rewrite - ranges into a comparison operation.\n\tc = rewriteRange(c)\n\n\tors := strings.Split(c, \"||\")\n\tor := make([][]*constraint, len(ors))\n\tfor k, v := range ors {\n\t\tcs := strings.Split(v, \",\")\n\t\tresult := make([]*constraint, len(cs))\n\t\tfor i, s := range cs {\n\t\t\tpc, err := parseConstraint(s)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tresult[i] = pc\n\t\t}\n\t\tor[k] = result\n\t}\n\n\to := &Constraints{constraints: or}\n\treturn o, nil\n}\n\n// Check tests if a version satisfies the constraints.\nfunc (cs Constraints) Check(v *Version) bool {\n\t// loop over the ORs and check the inner ANDs\n\tfor _, o := range cs.constraints {\n\t\tjoy := true\n\t\tfor _, c := range o {\n\t\t\tif !c.check(v) {\n\t\t\t\tjoy = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif joy {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n// Validate checks if a version satisfies a constraint. If not a slice of\n// reasons for the failure are returned in addition to a bool.\nfunc (cs Constraints) Validate(v *Version) (bool, []error) {\n\t// loop over the ORs and check the inner ANDs\n\tvar e []error\n\tfor _, o := range cs.constraints {\n\t\tjoy := true\n\t\tfor _, c := range o {\n\t\t\tif !c.check(v) {\n\t\t\t\tem := fmt.Errorf(c.msg, v, c.orig)\n\t\t\t\te = append(e, em)\n\t\t\t\tjoy = false\n\t\t\t}\n\t\t}\n\n\t\tif joy {\n\t\t\treturn true, []error{}\n\t\t}\n\t}\n\n\treturn false, e\n}\n\nvar constraintOps map[string]cfunc\nvar constraintMsg map[string]string\nvar constraintRegex *regexp.Regexp\n\nfunc init() {\n\tconstraintOps = map[string]cfunc{\n\t\t\"\":   constraintTildeOrEqual,\n\t\t\"=\":  constraintTildeOrEqual,\n\t\t\"!=\": constraintNotEqual,\n\t\t\">\":  constraintGreaterThan,\n\t\t\"<\":  constraintLessThan,\n\t\t\">=\": constraintGreaterThanEqual,\n\t\t\"=>\": constraintGreaterThanEqual,\n\t\t\"<=\": constraintLessThanEqual,\n\t\t\"=<\": constraintLessThanEqual,\n\t\t\"~\":  constraintTilde,\n\t\t\"~>\": constraintTilde,\n\t\t\"^\":  constraintCaret,\n\t}\n\n\tconstraintMsg = map[string]string{\n\t\t\"\":   \"%s is not equal to %s\",\n\t\t\"=\":  \"%s is not equal to %s\",\n\t\t\"!=\": \"%s is equal to %s\",\n\t\t\">\":  \"%s is less than or equal to %s\",\n\t\t\"<\":  \"%s is greater than or equal to %s\",\n\t\t\">=\": \"%s is less than %s\",\n\t\t\"=>\": \"%s is less than %s\",\n\t\t\"<=\": \"%s is greater than %s\",\n\t\t\"=<\": \"%s is greater than %s\",\n\t\t\"~\":  \"%s does not have same major and minor version as %s\",\n\t\t\"~>\": \"%s does not have same major and minor version as %s\",\n\t\t\"^\":  \"%s does not have same major version as %s\",\n\t}\n\n\tops := make([]string, 0, len(constraintOps))\n\tfor k := range constraintOps {\n\t\tops = append(ops, regexp.QuoteMeta(k))\n\t}\n\n\tconstraintRegex = regexp.MustCompile(fmt.Sprintf(\n\t\t`^\\s*(%s)\\s*(%s)\\s*$`,\n\t\tstrings.Join(ops, \"|\"),\n\t\tcvRegex))\n\n\tconstraintRangeRegex = regexp.MustCompile(fmt.Sprintf(\n\t\t`\\s*(%s)\\s+-\\s+(%s)\\s*`,\n\t\tcvRegex, cvRegex))\n}\n\n// An individual constraint\ntype constraint struct {\n\t// The callback function for the restraint. It performs the logic for\n\t// the constraint.\n\tfunction cfunc\n\n\tmsg string\n\n\t// The version used in the constraint check. For example, if a constraint\n\t// is '<= 2.0.0' the con a version instance representing 2.0.0.\n\tcon *Version\n\n\t// The original parsed version (e.g., 4.x from != 4.x)\n\torig string\n\n\t// When an x is used as part of the version (e.g., 1.x)\n\tminorDirty bool\n\tdirty      bool\n\tpatchDirty bool\n}\n\n// Check if a version meets the constraint\nfunc (c *constraint) check(v *Version) bool {\n\treturn c.function(v, c)\n}\n\ntype cfunc func(v *Version, c *constraint) bool\n\nfunc parseConstraint(c string) (*constraint, error) {\n\tm := constraintRegex.FindStringSubmatch(c)\n\tif m == nil {\n\t\treturn nil, fmt.Errorf(\"improper constraint: %s\", c)\n\t}\n\n\tver := m[2]\n\torig := ver\n\tminorDirty := false\n\tpatchDirty := false\n\tdirty := false\n\tif isX(m[3]) {\n\t\tver = \"0.0.0\"\n\t\tdirty = true\n\t} else if isX(strings.TrimPrefix(m[4], \".\")) || m[4] == \"\" {\n\t\tminorDirty = true\n\t\tdirty = true\n\t\tver = fmt.Sprintf(\"%s.0.0%s\", m[3], m[6])\n\t} else if isX(strings.TrimPrefix(m[5], \".\")) {\n\t\tdirty = true\n\t\tpatchDirty = true\n\t\tver = fmt.Sprintf(\"%s%s.0%s\", m[3], m[4], m[6])\n\t}\n\n\tcon, err := NewVersion(ver)\n\tif err != nil {\n\n\t\t// The constraintRegex should catch any regex parsing errors. So,\n\t\t// we should never get here.\n\t\treturn nil, errors.New(\"constraint Parser Error\")\n\t}\n\n\tcs := &constraint{\n\t\tfunction:   constraintOps[m[1]],\n\t\tmsg:        constraintMsg[m[1]],\n\t\tcon:        con,\n\t\torig:       orig,\n\t\tminorDirty: minorDirty,\n\t\tpatchDirty: patchDirty,\n\t\tdirty:      dirty,\n\t}\n\treturn cs, nil\n}\n\n// Constraint functions\nfunc constraintNotEqual(v *Version, c *constraint) bool {\n\tif c.dirty {\n\n\t\t// If there is a pre-release on the version but the constraint isn't looking\n\t\t// for them assume that pre-releases are not compatible. See issue 21 for\n\t\t// more details.\n\t\tif v.Prerelease() != \"\" && c.con.Prerelease() == \"\" {\n\t\t\treturn false\n\t\t}\n\n\t\tif c.con.Major() != v.Major() {\n\t\t\treturn true\n\t\t}\n\t\tif c.con.Minor() != v.Minor() && !c.minorDirty {\n\t\t\treturn true\n\t\t} else if c.minorDirty {\n\t\t\treturn false\n\t\t}\n\n\t\treturn false\n\t}\n\n\treturn !v.Equal(c.con)\n}\n\nfunc constraintGreaterThan(v *Version, c *constraint) bool {\n\n\t// An edge case the constraint is 0.0.0 and the version is 0.0.0-someprerelease\n\t// exists. This that case.\n\tif !isNonZero(c.con) && isNonZero(v) {\n\t\treturn true\n\t}\n\n\t// If there is a pre-release on the version but the constraint isn't looking\n\t// for them assume that pre-releases are not compatible. See issue 21 for\n\t// more details.\n\tif v.Prerelease() != \"\" && c.con.Prerelease() == \"\" {\n\t\treturn false\n\t}\n\n\treturn v.Compare(c.con) == 1\n}\n\nfunc constraintLessThan(v *Version, c *constraint) bool {\n\t// If there is a pre-release on the version but the constraint isn't looking\n\t// for them assume that pre-releases are not compatible. See issue 21 for\n\t// more details.\n\tif v.Prerelease() != \"\" && c.con.Prerelease() == \"\" {\n\t\treturn false\n\t}\n\n\tif !c.dirty {\n\t\treturn v.Compare(c.con) < 0\n\t}\n\n\tif v.Major() > c.con.Major() {\n\t\treturn false\n\t} else if v.Minor() > c.con.Minor() && !c.minorDirty {\n\t\treturn false\n\t}\n\n\treturn true\n}\n\nfunc constraintGreaterThanEqual(v *Version, c *constraint) bool {\n\t// An edge case the constraint is 0.0.0 and the version is 0.0.0-someprerelease\n\t// exists. This that case.\n\tif !isNonZero(c.con) && isNonZero(v) {\n\t\treturn true\n\t}\n\n\t// If there is a pre-release on the version but the constraint isn't looking\n\t// for them assume that pre-releases are not compatible. See issue 21 for\n\t// more details.\n\tif v.Prerelease() != \"\" && c.con.Prerelease() == \"\" {\n\t\treturn false\n\t}\n\n\treturn v.Compare(c.con) >= 0\n}\n\nfunc constraintLessThanEqual(v *Version, c *constraint) bool {\n\t// If there is a pre-release on the version but the constraint isn't looking\n\t// for them assume that pre-releases are not compatible. See issue 21 for\n\t// more details.\n\tif v.Prerelease() != \"\" && c.con.Prerelease() == \"\" {\n\t\treturn false\n\t}\n\n\tif !c.dirty {\n\t\treturn v.Compare(c.con) <= 0\n\t}\n\n\tif v.Major() > c.con.Major() {\n\t\treturn false\n\t} else if v.Minor() > c.con.Minor() && !c.minorDirty {\n\t\treturn false\n\t}\n\n\treturn true\n}\n\n// ~*, ~>* --> >= 0.0.0 (any)\n// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0, <3.0.0\n// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0, <2.1.0\n// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0, <1.3.0\n// ~1.2.3, ~>1.2.3 --> >=1.2.3, <1.3.0\n// ~1.2.0, ~>1.2.0 --> >=1.2.0, <1.3.0\nfunc constraintTilde(v *Version, c *constraint) bool {\n\t// If there is a pre-release on the version but the constraint isn't looking\n\t// for them assume that pre-releases are not compatible. See issue 21 for\n\t// more details.\n\tif v.Prerelease() != \"\" && c.con.Prerelease() == \"\" {\n\t\treturn false\n\t}\n\n\tif v.LessThan(c.con) {\n\t\treturn false\n\t}\n\n\t// ~0.0.0 is a special case where all constraints are accepted. It's\n\t// equivalent to >= 0.0.0.\n\tif c.con.Major() == 0 && c.con.Minor() == 0 && c.con.Patch() == 0 &&\n\t\t!c.minorDirty && !c.patchDirty {\n\t\treturn true\n\t}\n\n\tif v.Major() != c.con.Major() {\n\t\treturn false\n\t}\n\n\tif v.Minor() != c.con.Minor() && !c.minorDirty {\n\t\treturn false\n\t}\n\n\treturn true\n}\n\n// When there is a .x (dirty) status it automatically opts in to ~. Otherwise\n// it's a straight =\nfunc constraintTildeOrEqual(v *Version, c *constraint) bool {\n\t// If there is a pre-release on the version but the constraint isn't looking\n\t// for them assume that pre-releases are not compatible. See issue 21 for\n\t// more details.\n\tif v.Prerelease() != \"\" && c.con.Prerelease() == \"\" {\n\t\treturn false\n\t}\n\n\tif c.dirty {\n\t\tc.msg = constraintMsg[\"~\"]\n\t\treturn constraintTilde(v, c)\n\t}\n\n\treturn v.Equal(c.con)\n}\n\n// ^* --> (any)\n// ^2, ^2.x, ^2.x.x --> >=2.0.0, <3.0.0\n// ^2.0, ^2.0.x --> >=2.0.0, <3.0.0\n// ^1.2, ^1.2.x --> >=1.2.0, <2.0.0\n// ^1.2.3 --> >=1.2.3, <2.0.0\n// ^1.2.0 --> >=1.2.0, <2.0.0\nfunc constraintCaret(v *Version, c *constraint) bool {\n\t// If there is a pre-release on the version but the constraint isn't looking\n\t// for them assume that pre-releases are not compatible. See issue 21 for\n\t// more details.\n\tif v.Prerelease() != \"\" && c.con.Prerelease() == \"\" {\n\t\treturn false\n\t}\n\n\tif v.LessThan(c.con) {\n\t\treturn false\n\t}\n\n\tif v.Major() != c.con.Major() {\n\t\treturn false\n\t}\n\n\treturn true\n}\n\nvar constraintRangeRegex *regexp.Regexp\n\nconst cvRegex string = `v?([0-9|x|X|\\*]+)(\\.[0-9|x|X|\\*]+)?(\\.[0-9|x|X|\\*]+)?` +\n\t`(-([0-9A-Za-z\\-]+(\\.[0-9A-Za-z\\-]+)*))?` +\n\t`(\\+([0-9A-Za-z\\-]+(\\.[0-9A-Za-z\\-]+)*))?`\n\nfunc isX(x string) bool {\n\tswitch x {\n\tcase \"x\", \"*\", \"X\":\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc rewriteRange(i string) string {\n\tm := constraintRangeRegex.FindAllStringSubmatch(i, -1)\n\tif m == nil {\n\t\treturn i\n\t}\n\to := i\n\tfor _, v := range m {\n\t\tt := fmt.Sprintf(\">= %s, <= %s\", v[1], v[11])\n\t\to = strings.Replace(o, v[0], t, 1)\n\t}\n\n\treturn o\n}\n\n// Detect if a version is not zero (0.0.0)\nfunc isNonZero(v *Version) bool {\n\tif v.Major() != 0 || v.Minor() != 0 || v.Patch() != 0 || v.Prerelease() != \"\" {\n\t\treturn true\n\t}\n\n\treturn false\n}\n"
  },
  {
    "path": "vendor/github.com/Masterminds/semver/constraints_test.go",
    "content": "package semver\n\nimport (\n\t\"reflect\"\n\t\"testing\"\n)\n\nfunc TestParseConstraint(t *testing.T) {\n\ttests := []struct {\n\t\tin  string\n\t\tf   cfunc\n\t\tv   string\n\t\terr bool\n\t}{\n\t\t{\">= 1.2\", constraintGreaterThanEqual, \"1.2.0\", false},\n\t\t{\"1.0\", constraintTildeOrEqual, \"1.0.0\", false},\n\t\t{\"foo\", nil, \"\", true},\n\t\t{\"<= 1.2\", constraintLessThanEqual, \"1.2.0\", false},\n\t\t{\"=< 1.2\", constraintLessThanEqual, \"1.2.0\", false},\n\t\t{\"=> 1.2\", constraintGreaterThanEqual, \"1.2.0\", false},\n\t\t{\"v1.2\", constraintTildeOrEqual, \"1.2.0\", false},\n\t\t{\"=1.5\", constraintTildeOrEqual, \"1.5.0\", false},\n\t\t{\"> 1.3\", constraintGreaterThan, \"1.3.0\", false},\n\t\t{\"< 1.4.1\", constraintLessThan, \"1.4.1\", false},\n\t}\n\n\tfor _, tc := range tests {\n\t\tc, err := parseConstraint(tc.in)\n\t\tif tc.err && err == nil {\n\t\t\tt.Errorf(\"Expected error for %s didn't occur\", tc.in)\n\t\t} else if !tc.err && err != nil {\n\t\t\tt.Errorf(\"Unexpected error for %s\", tc.in)\n\t\t}\n\n\t\t// If an error was expected continue the loop and don't try the other\n\t\t// tests as they will cause errors.\n\t\tif tc.err {\n\t\t\tcontinue\n\t\t}\n\n\t\tif tc.v != c.con.String() {\n\t\t\tt.Errorf(\"Incorrect version found on %s\", tc.in)\n\t\t}\n\n\t\tf1 := reflect.ValueOf(tc.f)\n\t\tf2 := reflect.ValueOf(c.function)\n\t\tif f1 != f2 {\n\t\t\tt.Errorf(\"Wrong constraint found for %s\", tc.in)\n\t\t}\n\t}\n}\n\nfunc TestConstraintCheck(t *testing.T) {\n\ttests := []struct {\n\t\tconstraint string\n\t\tversion    string\n\t\tcheck      bool\n\t}{\n\t\t{\"= 2.0\", \"1.2.3\", false},\n\t\t{\"= 2.0\", \"2.0.0\", true},\n\t\t{\"4.1\", \"4.1.0\", true},\n\t\t{\"!=4.1\", \"4.1.0\", false},\n\t\t{\"!=4.1\", \"5.1.0\", true},\n\t\t{\">1.1\", \"4.1.0\", true},\n\t\t{\">1.1\", \"1.1.0\", false},\n\t\t{\"<1.1\", \"0.1.0\", true},\n\t\t{\"<1.1\", \"1.1.0\", false},\n\t\t{\"<1.1\", \"1.1.1\", false},\n\t\t{\">=1.1\", \"4.1.0\", true},\n\t\t{\">=1.1\", \"1.1.0\", true},\n\t\t{\">=1.1\", \"0.0.9\", false},\n\t\t{\"<=1.1\", \"0.1.0\", true},\n\t\t{\"<=1.1\", \"1.1.0\", true},\n\t\t{\"<=1.1\", \"1.1.1\", false},\n\t\t{\">0\", \"0.0.1-alpha\", true},\n\t\t{\">=0\", \"0.0.1-alpha\", true},\n\t\t{\">0\", \"0\", false},\n\t\t{\">=0\", \"0\", true},\n\t\t{\"=0\", \"1\", false},\n\t}\n\n\tfor _, tc := range tests {\n\t\tc, err := parseConstraint(tc.constraint)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"err: %s\", err)\n\t\t\tcontinue\n\t\t}\n\n\t\tv, err := NewVersion(tc.version)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"err: %s\", err)\n\t\t\tcontinue\n\t\t}\n\n\t\ta := c.check(v)\n\t\tif a != tc.check {\n\t\t\tt.Errorf(\"Constraint %q failing with %q\", tc.constraint, tc.version)\n\t\t}\n\t}\n}\n\nfunc TestNewConstraint(t *testing.T) {\n\ttests := []struct {\n\t\tinput string\n\t\tors   int\n\t\tcount int\n\t\terr   bool\n\t}{\n\t\t{\">= 1.1\", 1, 1, false},\n\t\t{\"2.0\", 1, 1, false},\n\t\t{\"v2.3.5-20161202202307-sha.e8fc5e5\", 1, 1, false},\n\t\t{\">= bar\", 0, 0, true},\n\t\t{\">= 1.2.3, < 2.0\", 1, 2, false},\n\t\t{\">= 1.2.3, < 2.0 || => 3.0, < 4\", 2, 2, false},\n\n\t\t// The 3 - 4 should be broken into 2 by the range rewriting\n\t\t{\"3 - 4 || => 3.0, < 4\", 2, 2, false},\n\t}\n\n\tfor _, tc := range tests {\n\t\tv, err := NewConstraint(tc.input)\n\t\tif tc.err && err == nil {\n\t\t\tt.Errorf(\"expected but did not get error for: %s\", tc.input)\n\t\t\tcontinue\n\t\t} else if !tc.err && err != nil {\n\t\t\tt.Errorf(\"unexpectederror for input %s: %s\", tc.input, err)\n\t\t\tcontinue\n\t\t}\n\t\tif tc.err {\n\t\t\tcontinue\n\t\t}\n\n\t\tl := len(v.constraints)\n\t\tif tc.ors != l {\n\t\t\tt.Errorf(\"Expected %s to have %d ORs but got %d\",\n\t\t\t\ttc.input, tc.ors, l)\n\t\t}\n\n\t\tl = len(v.constraints[0])\n\t\tif tc.count != l {\n\t\t\tt.Errorf(\"Expected %s to have %d constraints but got %d\",\n\t\t\t\ttc.input, tc.count, l)\n\t\t}\n\t}\n}\n\nfunc TestConstraintsCheck(t *testing.T) {\n\ttests := []struct {\n\t\tconstraint string\n\t\tversion    string\n\t\tcheck      bool\n\t}{\n\t\t{\"*\", \"1.2.3\", true},\n\t\t{\"~0.0.0\", \"1.2.3\", true},\n\t\t{\"0.x.x\", \"1.2.3\", false},\n\t\t{\"0.0.x\", \"1.2.3\", false},\n\t\t{\"0.0.0\", \"1.2.3\", false},\n\t\t{\"*\", \"1.2.3\", true},\n\t\t{\"^0.0.0\", \"1.2.3\", false},\n\t\t{\"= 2.0\", \"1.2.3\", false},\n\t\t{\"= 2.0\", \"2.0.0\", true},\n\t\t{\"4.1\", \"4.1.0\", true},\n\t\t{\"4.1.x\", \"4.1.3\", true},\n\t\t{\"1.x\", \"1.4\", true},\n\t\t{\"!=4.1\", \"4.1.0\", false},\n\t\t{\"!=4.1-alpha\", \"4.1.0-alpha\", false},\n\t\t{\"!=4.1-alpha\", \"4.1.0\", true},\n\t\t{\"!=4.1\", \"5.1.0\", true},\n\t\t{\"!=4.x\", \"5.1.0\", true},\n\t\t{\"!=4.x\", \"4.1.0\", false},\n\t\t{\"!=4.1.x\", \"4.2.0\", true},\n\t\t{\"!=4.2.x\", \"4.2.3\", false},\n\t\t{\">1.1\", \"4.1.0\", true},\n\t\t{\">1.1\", \"1.1.0\", false},\n\t\t{\"<1.1\", \"0.1.0\", true},\n\t\t{\"<1.1\", \"1.1.0\", false},\n\t\t{\"<1.1\", \"1.1.1\", false},\n\t\t{\"<1.x\", \"1.1.1\", true},\n\t\t{\"<1.x\", \"2.1.1\", false},\n\t\t{\"<1.1.x\", \"1.2.1\", false},\n\t\t{\"<1.1.x\", \"1.1.500\", true},\n\t\t{\"<1.2.x\", \"1.1.1\", true},\n\t\t{\">=1.1\", \"4.1.0\", true},\n\t\t{\">=1.1\", \"4.1.0-beta\", false},\n\t\t{\">=1.1\", \"1.1.0\", true},\n\t\t{\">=1.1\", \"0.0.9\", false},\n\t\t{\"<=1.1\", \"0.1.0\", true},\n\t\t{\"<=1.1\", \"0.1.0-alpha\", false},\n\t\t{\"<=1.1-a\", \"0.1.0-alpha\", true},\n\t\t{\"<=1.1\", \"1.1.0\", true},\n\t\t{\"<=1.x\", \"1.1.0\", true},\n\t\t{\"<=2.x\", \"3.1.0\", false},\n\t\t{\"<=1.1\", \"1.1.1\", false},\n\t\t{\"<=1.1.x\", \"1.2.500\", false},\n\t\t{\">1.1, <2\", \"1.1.1\", true},\n\t\t{\">1.1, <3\", \"4.3.2\", false},\n\t\t{\">=1.1, <2, !=1.2.3\", \"1.2.3\", false},\n\t\t{\">=1.1, <2, !=1.2.3 || > 3\", \"3.1.2\", true},\n\t\t{\">=1.1, <2, !=1.2.3 || >= 3\", \"3.0.0\", true},\n\t\t{\">=1.1, <2, !=1.2.3 || > 3\", \"3.0.0\", false},\n\t\t{\">=1.1, <2, !=1.2.3 || > 3\", \"1.2.3\", false},\n\t\t{\"1.1 - 2\", \"1.1.1\", true},\n\t\t{\"1.1-3\", \"4.3.2\", false},\n\t\t{\"^1.1\", \"1.1.1\", true},\n\t\t{\"^1.1\", \"4.3.2\", false},\n\t\t{\"^1.x\", \"1.1.1\", true},\n\t\t{\"^2.x\", \"1.1.1\", false},\n\t\t{\"^1.x\", \"2.1.1\", false},\n\t\t{\"^1.x\", \"1.1.1-beta1\", false},\n\t\t{\"^1.1.2-alpha\", \"1.2.1-beta1\", true},\n\t\t{\"^1.2.x-alpha\", \"1.1.1-beta1\", false},\n\t\t{\"~*\", \"2.1.1\", true},\n\t\t{\"~1\", \"2.1.1\", false},\n\t\t{\"~1\", \"1.3.5\", true},\n\t\t{\"~1\", \"1.4\", true},\n\t\t{\"~1.x\", \"2.1.1\", false},\n\t\t{\"~1.x\", \"1.3.5\", true},\n\t\t{\"~1.x\", \"1.4\", true},\n\t\t{\"~1.1\", \"1.1.1\", true},\n\t\t{\"~1.1\", \"1.1.1-alpha\", false},\n\t\t{\"~1.1-alpha\", \"1.1.1-beta\", true},\n\t\t{\"~1.1.1-beta\", \"1.1.1-alpha\", false},\n\t\t{\"~1.1.1-beta\", \"1.1.1\", true},\n\t\t{\"~1.2.3\", \"1.2.5\", true},\n\t\t{\"~1.2.3\", \"1.2.2\", false},\n\t\t{\"~1.2.3\", \"1.3.2\", false},\n\t\t{\"~1.1\", \"1.2.3\", false},\n\t\t{\"~1.3\", \"2.4.5\", false},\n\t}\n\n\tfor _, tc := range tests {\n\t\tc, err := NewConstraint(tc.constraint)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"err: %s\", err)\n\t\t\tcontinue\n\t\t}\n\n\t\tv, err := NewVersion(tc.version)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"err: %s\", err)\n\t\t\tcontinue\n\t\t}\n\n\t\ta := c.Check(v)\n\t\tif a != tc.check {\n\t\t\tt.Errorf(\"Constraint '%s' failing with '%s'\", tc.constraint, tc.version)\n\t\t}\n\t}\n}\n\nfunc TestRewriteRange(t *testing.T) {\n\ttests := []struct {\n\t\tc  string\n\t\tnc string\n\t}{\n\t\t{\"2 - 3\", \">= 2, <= 3\"},\n\t\t{\"2 - 3, 2 - 3\", \">= 2, <= 3,>= 2, <= 3\"},\n\t\t{\"2 - 3, 4.0.0 - 5.1\", \">= 2, <= 3,>= 4.0.0, <= 5.1\"},\n\t}\n\n\tfor _, tc := range tests {\n\t\to := rewriteRange(tc.c)\n\n\t\tif o != tc.nc {\n\t\t\tt.Errorf(\"Range %s rewritten incorrectly as '%s'\", tc.c, o)\n\t\t}\n\t}\n}\n\nfunc TestIsX(t *testing.T) {\n\ttests := []struct {\n\t\tt string\n\t\tc bool\n\t}{\n\t\t{\"A\", false},\n\t\t{\"%\", false},\n\t\t{\"X\", true},\n\t\t{\"x\", true},\n\t\t{\"*\", true},\n\t}\n\n\tfor _, tc := range tests {\n\t\ta := isX(tc.t)\n\t\tif a != tc.c {\n\t\t\tt.Errorf(\"Function isX error on %s\", tc.t)\n\t\t}\n\t}\n}\n\nfunc TestConstraintsValidate(t *testing.T) {\n\ttests := []struct {\n\t\tconstraint string\n\t\tversion    string\n\t\tcheck      bool\n\t}{\n\t\t{\"*\", \"1.2.3\", true},\n\t\t{\"~0.0.0\", \"1.2.3\", true},\n\t\t{\"= 2.0\", \"1.2.3\", false},\n\t\t{\"= 2.0\", \"2.0.0\", true},\n\t\t{\"4.1\", \"4.1.0\", true},\n\t\t{\"4.1.x\", \"4.1.3\", true},\n\t\t{\"1.x\", \"1.4\", true},\n\t\t{\"!=4.1\", \"4.1.0\", false},\n\t\t{\"!=4.1\", \"5.1.0\", true},\n\t\t{\"!=4.x\", \"5.1.0\", true},\n\t\t{\"!=4.x\", \"4.1.0\", false},\n\t\t{\"!=4.1.x\", \"4.2.0\", true},\n\t\t{\"!=4.2.x\", \"4.2.3\", false},\n\t\t{\">1.1\", \"4.1.0\", true},\n\t\t{\">1.1\", \"1.1.0\", false},\n\t\t{\"<1.1\", \"0.1.0\", true},\n\t\t{\"<1.1\", \"1.1.0\", false},\n\t\t{\"<1.1\", \"1.1.1\", false},\n\t\t{\"<1.x\", \"1.1.1\", true},\n\t\t{\"<1.x\", \"2.1.1\", false},\n\t\t{\"<1.1.x\", \"1.2.1\", false},\n\t\t{\"<1.1.x\", \"1.1.500\", true},\n\t\t{\"<1.2.x\", \"1.1.1\", true},\n\t\t{\">=1.1\", \"4.1.0\", true},\n\t\t{\">=1.1\", \"1.1.0\", true},\n\t\t{\">=1.1\", \"0.0.9\", false},\n\t\t{\"<=1.1\", \"0.1.0\", true},\n\t\t{\"<=1.1\", \"1.1.0\", true},\n\t\t{\"<=1.x\", \"1.1.0\", true},\n\t\t{\"<=2.x\", \"3.1.0\", false},\n\t\t{\"<=1.1\", \"1.1.1\", false},\n\t\t{\"<=1.1.x\", \"1.2.500\", false},\n\t\t{\">1.1, <2\", \"1.1.1\", true},\n\t\t{\">1.1, <3\", \"4.3.2\", false},\n\t\t{\">=1.1, <2, !=1.2.3\", \"1.2.3\", false},\n\t\t{\">=1.1, <2, !=1.2.3 || > 3\", \"3.1.2\", true},\n\t\t{\">=1.1, <2, !=1.2.3 || >= 3\", \"3.0.0\", true},\n\t\t{\">=1.1, <2, !=1.2.3 || > 3\", \"3.0.0\", false},\n\t\t{\">=1.1, <2, !=1.2.3 || > 3\", \"1.2.3\", false},\n\t\t{\"1.1 - 2\", \"1.1.1\", true},\n\t\t{\"1.1-3\", \"4.3.2\", false},\n\t\t{\"^1.1\", \"1.1.1\", true},\n\t\t{\"^1.1\", \"1.1.1-alpha\", false},\n\t\t{\"^1.1.1-alpha\", \"1.1.1-beta\", true},\n\t\t{\"^1.1.1-beta\", \"1.1.1-alpha\", false},\n\t\t{\"^1.1\", \"4.3.2\", false},\n\t\t{\"^1.x\", \"1.1.1\", true},\n\t\t{\"^2.x\", \"1.1.1\", false},\n\t\t{\"^1.x\", \"2.1.1\", false},\n\t\t{\"~*\", \"2.1.1\", true},\n\t\t{\"~1\", \"2.1.1\", false},\n\t\t{\"~1\", \"1.3.5\", true},\n\t\t{\"~1\", \"1.3.5-beta\", false},\n\t\t{\"~1.x\", \"2.1.1\", false},\n\t\t{\"~1.x\", \"1.3.5\", true},\n\t\t{\"~1.x\", \"1.3.5-beta\", false},\n\t\t{\"~1.3.6-alpha\", \"1.3.5-beta\", false},\n\t\t{\"~1.3.5-alpha\", \"1.3.5-beta\", true},\n\t\t{\"~1.3.5-beta\", \"1.3.5-alpha\", false},\n\t\t{\"~1.x\", \"1.4\", true},\n\t\t{\"~1.1\", \"1.1.1\", true},\n\t\t{\"~1.2.3\", \"1.2.5\", true},\n\t\t{\"~1.2.3\", \"1.2.2\", false},\n\t\t{\"~1.2.3\", \"1.3.2\", false},\n\t\t{\"~1.1\", \"1.2.3\", false},\n\t\t{\"~1.3\", \"2.4.5\", false},\n\t}\n\n\tfor _, tc := range tests {\n\t\tc, err := NewConstraint(tc.constraint)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"err: %s\", err)\n\t\t\tcontinue\n\t\t}\n\n\t\tv, err := NewVersion(tc.version)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"err: %s\", err)\n\t\t\tcontinue\n\t\t}\n\n\t\ta, msgs := c.Validate(v)\n\t\tif a != tc.check {\n\t\t\tt.Errorf(\"Constraint '%s' failing with '%s'\", tc.constraint, tc.version)\n\t\t} else if !a && len(msgs) == 0 {\n\t\t\tt.Errorf(\"%q failed with %q but no errors returned\", tc.constraint, tc.version)\n\t\t}\n\n\t\t// if a == false {\n\t\t// \tfor _, m := range msgs {\n\t\t// \t\tt.Errorf(\"%s\", m)\n\t\t// \t}\n\t\t// }\n\t}\n\n\tv, err := NewVersion(\"1.2.3\")\n\tif err != nil {\n\t\tt.Errorf(\"err: %s\", err)\n\t}\n\n\tc, err := NewConstraint(\"!= 1.2.5, ^2, <= 1.1.x\")\n\tif err != nil {\n\t\tt.Errorf(\"err: %s\", err)\n\t}\n\n\t_, msgs := c.Validate(v)\n\tif len(msgs) != 2 {\n\t\tt.Error(\"Invalid number of validations found\")\n\t}\n\te := msgs[0].Error()\n\tif e != \"1.2.3 does not have same major version as 2\" {\n\t\tt.Error(\"Did not get expected message: 1.2.3 does not have same major version as 2\")\n\t}\n\te = msgs[1].Error()\n\tif e != \"1.2.3 is greater than 1.1.x\" {\n\t\tt.Error(\"Did not get expected message: 1.2.3 is greater than 1.1.x\")\n\t}\n\n\ttests2 := []struct {\n\t\tconstraint, version, msg string\n\t}{\n\t\t{\"= 2.0\", \"1.2.3\", \"1.2.3 is not equal to 2.0\"},\n\t\t{\"!=4.1\", \"4.1.0\", \"4.1.0 is equal to 4.1\"},\n\t\t{\"!=4.x\", \"4.1.0\", \"4.1.0 is equal to 4.x\"},\n\t\t{\"!=4.2.x\", \"4.2.3\", \"4.2.3 is equal to 4.2.x\"},\n\t\t{\">1.1\", \"1.1.0\", \"1.1.0 is less than or equal to 1.1\"},\n\t\t{\"<1.1\", \"1.1.0\", \"1.1.0 is greater than or equal to 1.1\"},\n\t\t{\"<1.1\", \"1.1.1\", \"1.1.1 is greater than or equal to 1.1\"},\n\t\t{\"<1.x\", \"2.1.1\", \"2.1.1 is greater than or equal to 1.x\"},\n\t\t{\"<1.1.x\", \"1.2.1\", \"1.2.1 is greater than or equal to 1.1.x\"},\n\t\t{\">=1.1\", \"0.0.9\", \"0.0.9 is less than 1.1\"},\n\t\t{\"<=2.x\", \"3.1.0\", \"3.1.0 is greater than 2.x\"},\n\t\t{\"<=1.1\", \"1.1.1\", \"1.1.1 is greater than 1.1\"},\n\t\t{\"<=1.1.x\", \"1.2.500\", \"1.2.500 is greater than 1.1.x\"},\n\t\t{\">1.1, <3\", \"4.3.2\", \"4.3.2 is greater than or equal to 3\"},\n\t\t{\">=1.1, <2, !=1.2.3\", \"1.2.3\", \"1.2.3 is equal to 1.2.3\"},\n\t\t{\">=1.1, <2, !=1.2.3 || > 3\", \"3.0.0\", \"3.0.0 is greater than or equal to 2\"},\n\t\t{\">=1.1, <2, !=1.2.3 || > 3\", \"1.2.3\", \"1.2.3 is equal to 1.2.3\"},\n\t\t{\"1.1 - 3\", \"4.3.2\", \"4.3.2 is greater than 3\"},\n\t\t{\"^1.1\", \"4.3.2\", \"4.3.2 does not have same major version as 1.1\"},\n\t\t{\"^2.x\", \"1.1.1\", \"1.1.1 does not have same major version as 2.x\"},\n\t\t{\"^1.x\", \"2.1.1\", \"2.1.1 does not have same major version as 1.x\"},\n\t\t{\"~1\", \"2.1.2\", \"2.1.2 does not have same major and minor version as 1\"},\n\t\t{\"~1.x\", \"2.1.1\", \"2.1.1 does not have same major and minor version as 1.x\"},\n\t\t{\"~1.2.3\", \"1.2.2\", \"1.2.2 does not have same major and minor version as 1.2.3\"},\n\t\t{\"~1.2.3\", \"1.3.2\", \"1.3.2 does not have same major and minor version as 1.2.3\"},\n\t\t{\"~1.1\", \"1.2.3\", \"1.2.3 does not have same major and minor version as 1.1\"},\n\t\t{\"~1.3\", \"2.4.5\", \"2.4.5 does not have same major and minor version as 1.3\"},\n\t}\n\n\tfor _, tc := range tests2 {\n\t\tc, err := NewConstraint(tc.constraint)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"err: %s\", err)\n\t\t\tcontinue\n\t\t}\n\n\t\tv, err := NewVersion(tc.version)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"err: %s\", err)\n\t\t\tcontinue\n\t\t}\n\n\t\t_, msgs := c.Validate(v)\n\t\te := msgs[0].Error()\n\t\tif e != tc.msg {\n\t\t\tt.Errorf(\"Did not get expected message %q: %s\", tc.msg, e)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/Masterminds/semver/doc.go",
    "content": "/*\nPackage semver provides the ability to work with Semantic Versions (http://semver.org) in Go.\n\nSpecifically it provides the ability to:\n\n    * Parse semantic versions\n    * Sort semantic versions\n    * Check if a semantic version fits within a set of constraints\n    * Optionally work with a `v` prefix\n\nParsing Semantic Versions\n\nTo parse a semantic version use the `NewVersion` function. For example,\n\n    v, err := semver.NewVersion(\"1.2.3-beta.1+build345\")\n\nIf there is an error the version wasn't parseable. The version object has methods\nto get the parts of the version, compare it to other versions, convert the\nversion back into a string, and get the original string. For more details\nplease see the documentation at https://godoc.org/github.com/Masterminds/semver.\n\nSorting Semantic Versions\n\nA set of versions can be sorted using the `sort` package from the standard library.\nFor example,\n\n    raw := []string{\"1.2.3\", \"1.0\", \"1.3\", \"2\", \"0.4.2\",}\n    vs := make([]*semver.Version, len(raw))\n\tfor i, r := range raw {\n\t\tv, err := semver.NewVersion(r)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Error parsing version: %s\", err)\n\t\t}\n\n\t\tvs[i] = v\n\t}\n\n\tsort.Sort(semver.Collection(vs))\n\nChecking Version Constraints\n\nChecking a version against version constraints is one of the most featureful\nparts of the package.\n\n    c, err := semver.NewConstraint(\">= 1.2.3\")\n    if err != nil {\n        // Handle constraint not being parseable.\n    }\n\n    v, _ := semver.NewVersion(\"1.3\")\n    if err != nil {\n        // Handle version not being parseable.\n    }\n    // Check if the version meets the constraints. The a variable will be true.\n    a := c.Check(v)\n\nBasic Comparisons\n\nThere are two elements to the comparisons. First, a comparison string is a list\nof comma separated and comparisons. These are then separated by || separated or\ncomparisons. For example, `\">= 1.2, < 3.0.0 || >= 4.2.3\"` is looking for a\ncomparison that's greater than or equal to 1.2 and less than 3.0.0 or is\ngreater than or equal to 4.2.3.\n\nThe basic comparisons are:\n\n    * `=`: equal (aliased to no operator)\n    * `!=`: not equal\n    * `>`: greater than\n    * `<`: less than\n    * `>=`: greater than or equal to\n    * `<=`: less than or equal to\n\nHyphen Range Comparisons\n\nThere are multiple methods to handle ranges and the first is hyphens ranges.\nThese look like:\n\n    * `1.2 - 1.4.5` which is equivalent to `>= 1.2, <= 1.4.5`\n    * `2.3.4 - 4.5` which is equivalent to `>= 2.3.4, <= 4.5`\n\nWildcards In Comparisons\n\nThe `x`, `X`, and `*` characters can be used as a wildcard character. This works\nfor all comparison operators. When used on the `=` operator it falls\nback to the pack level comparison (see tilde below). For example,\n\n    * `1.2.x` is equivalent to `>= 1.2.0, < 1.3.0`\n    * `>= 1.2.x` is equivalent to `>= 1.2.0`\n    * `<= 2.x` is equivalent to `<= 3`\n    * `*` is equivalent to `>= 0.0.0`\n\nTilde Range Comparisons (Patch)\n\nThe tilde (`~`) comparison operator is for patch level ranges when a minor\nversion is specified and major level changes when the minor number is missing.\nFor example,\n\n    * `~1.2.3` is equivalent to `>= 1.2.3, < 1.3.0`\n    * `~1` is equivalent to `>= 1, < 2`\n    * `~2.3` is equivalent to `>= 2.3, < 2.4`\n    * `~1.2.x` is equivalent to `>= 1.2.0, < 1.3.0`\n    * `~1.x` is equivalent to `>= 1, < 2`\n\nCaret Range Comparisons (Major)\n\nThe caret (`^`) comparison operator is for major level changes. This is useful\nwhen comparisons of API versions as a major change is API breaking. For example,\n\n    * `^1.2.3` is equivalent to `>= 1.2.3, < 2.0.0`\n    * `^1.2.x` is equivalent to `>= 1.2.0, < 2.0.0`\n    * `^2.3` is equivalent to `>= 2.3, < 3`\n    * `^2.x` is equivalent to `>= 2.0.0, < 3`\n*/\npackage semver\n"
  },
  {
    "path": "vendor/github.com/Masterminds/semver/version.go",
    "content": "package semver\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\t\"regexp\"\n\t\"strconv\"\n\t\"strings\"\n)\n\n// The compiled version of the regex created at init() is cached here so it\n// only needs to be created once.\nvar versionRegex *regexp.Regexp\nvar validPrereleaseRegex *regexp.Regexp\n\nvar (\n\t// ErrInvalidSemVer is returned a version is found to be invalid when\n\t// being parsed.\n\tErrInvalidSemVer = errors.New(\"Invalid Semantic Version\")\n\n\t// ErrInvalidMetadata is returned when the metadata is an invalid format\n\tErrInvalidMetadata = errors.New(\"Invalid Metadata string\")\n\n\t// ErrInvalidPrerelease is returned when the pre-release is an invalid format\n\tErrInvalidPrerelease = errors.New(\"Invalid Prerelease string\")\n)\n\n// SemVerRegex is the regular expression used to parse a semantic version.\nconst SemVerRegex string = `v?([0-9]+)(\\.[0-9]+)?(\\.[0-9]+)?` +\n\t`(-([0-9A-Za-z\\-]+(\\.[0-9A-Za-z\\-]+)*))?` +\n\t`(\\+([0-9A-Za-z\\-]+(\\.[0-9A-Za-z\\-]+)*))?`\n\n// ValidPrerelease is the regular expression which validates\n// both prerelease and metadata values.\nconst ValidPrerelease string = `^([0-9A-Za-z\\-]+(\\.[0-9A-Za-z\\-]+)*)`\n\n// Version represents a single semantic version.\ntype Version struct {\n\tmajor, minor, patch int64\n\tpre                 string\n\tmetadata            string\n\toriginal            string\n}\n\nfunc init() {\n\tversionRegex = regexp.MustCompile(\"^\" + SemVerRegex + \"$\")\n\tvalidPrereleaseRegex = regexp.MustCompile(ValidPrerelease)\n}\n\n// NewVersion parses a given version and returns an instance of Version or\n// an error if unable to parse the version.\nfunc NewVersion(v string) (*Version, error) {\n\tm := versionRegex.FindStringSubmatch(v)\n\tif m == nil {\n\t\treturn nil, ErrInvalidSemVer\n\t}\n\n\tsv := &Version{\n\t\tmetadata: m[8],\n\t\tpre:      m[5],\n\t\toriginal: v,\n\t}\n\n\tvar temp int64\n\ttemp, err := strconv.ParseInt(m[1], 10, 64)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Error parsing version segment: %s\", err)\n\t}\n\tsv.major = temp\n\n\tif m[2] != \"\" {\n\t\ttemp, err = strconv.ParseInt(strings.TrimPrefix(m[2], \".\"), 10, 64)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Error parsing version segment: %s\", err)\n\t\t}\n\t\tsv.minor = temp\n\t} else {\n\t\tsv.minor = 0\n\t}\n\n\tif m[3] != \"\" {\n\t\ttemp, err = strconv.ParseInt(strings.TrimPrefix(m[3], \".\"), 10, 64)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Error parsing version segment: %s\", err)\n\t\t}\n\t\tsv.patch = temp\n\t} else {\n\t\tsv.patch = 0\n\t}\n\n\treturn sv, nil\n}\n\n// MustParse parses a given version and panics on error.\nfunc MustParse(v string) *Version {\n\tsv, err := NewVersion(v)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn sv\n}\n\n// String converts a Version object to a string.\n// Note, if the original version contained a leading v this version will not.\n// See the Original() method to retrieve the original value. Semantic Versions\n// don't contain a leading v per the spec. Instead it's optional on\n// impelementation.\nfunc (v *Version) String() string {\n\tvar buf bytes.Buffer\n\n\tfmt.Fprintf(&buf, \"%d.%d.%d\", v.major, v.minor, v.patch)\n\tif v.pre != \"\" {\n\t\tfmt.Fprintf(&buf, \"-%s\", v.pre)\n\t}\n\tif v.metadata != \"\" {\n\t\tfmt.Fprintf(&buf, \"+%s\", v.metadata)\n\t}\n\n\treturn buf.String()\n}\n\n// Original returns the original value passed in to be parsed.\nfunc (v *Version) Original() string {\n\treturn v.original\n}\n\n// Major returns the major version.\nfunc (v *Version) Major() int64 {\n\treturn v.major\n}\n\n// Minor returns the minor version.\nfunc (v *Version) Minor() int64 {\n\treturn v.minor\n}\n\n// Patch returns the patch version.\nfunc (v *Version) Patch() int64 {\n\treturn v.patch\n}\n\n// Prerelease returns the pre-release version.\nfunc (v *Version) Prerelease() string {\n\treturn v.pre\n}\n\n// Metadata returns the metadata on the version.\nfunc (v *Version) Metadata() string {\n\treturn v.metadata\n}\n\n// originalVPrefix returns the original 'v' prefix if any.\nfunc (v *Version) originalVPrefix() string {\n\n\t// Note, only lowercase v is supported as a prefix by the parser.\n\tif v.original != \"\" && v.original[:1] == \"v\" {\n\t\treturn v.original[:1]\n\t}\n\treturn \"\"\n}\n\n// IncPatch produces the next patch version.\n// If the current version does not have prerelease/metadata information,\n// it unsets metadata and prerelease values, increments patch number.\n// If the current version has any of prerelease or metadata information,\n// it unsets both values and keeps curent patch value\nfunc (v Version) IncPatch() Version {\n\tvNext := v\n\t// according to http://semver.org/#spec-item-9\n\t// Pre-release versions have a lower precedence than the associated normal version.\n\t// according to http://semver.org/#spec-item-10\n\t// Build metadata SHOULD be ignored when determining version precedence.\n\tif v.pre != \"\" {\n\t\tvNext.metadata = \"\"\n\t\tvNext.pre = \"\"\n\t} else {\n\t\tvNext.metadata = \"\"\n\t\tvNext.pre = \"\"\n\t\tvNext.patch = v.patch + 1\n\t}\n\tvNext.original = v.originalVPrefix() + \"\" + vNext.String()\n\treturn vNext\n}\n\n// IncMinor produces the next minor version.\n// Sets patch to 0.\n// Increments minor number.\n// Unsets metadata.\n// Unsets prerelease status.\nfunc (v Version) IncMinor() Version {\n\tvNext := v\n\tvNext.metadata = \"\"\n\tvNext.pre = \"\"\n\tvNext.patch = 0\n\tvNext.minor = v.minor + 1\n\tvNext.original = v.originalVPrefix() + \"\" + vNext.String()\n\treturn vNext\n}\n\n// IncMajor produces the next major version.\n// Sets patch to 0.\n// Sets minor to 0.\n// Increments major number.\n// Unsets metadata.\n// Unsets prerelease status.\nfunc (v Version) IncMajor() Version {\n\tvNext := v\n\tvNext.metadata = \"\"\n\tvNext.pre = \"\"\n\tvNext.patch = 0\n\tvNext.minor = 0\n\tvNext.major = v.major + 1\n\tvNext.original = v.originalVPrefix() + \"\" + vNext.String()\n\treturn vNext\n}\n\n// SetPrerelease defines the prerelease value.\n// Value must not include the required 'hypen' prefix.\nfunc (v Version) SetPrerelease(prerelease string) (Version, error) {\n\tvNext := v\n\tif len(prerelease) > 0 && !validPrereleaseRegex.MatchString(prerelease) {\n\t\treturn vNext, ErrInvalidPrerelease\n\t}\n\tvNext.pre = prerelease\n\tvNext.original = v.originalVPrefix() + \"\" + vNext.String()\n\treturn vNext, nil\n}\n\n// SetMetadata defines metadata value.\n// Value must not include the required 'plus' prefix.\nfunc (v Version) SetMetadata(metadata string) (Version, error) {\n\tvNext := v\n\tif len(metadata) > 0 && !validPrereleaseRegex.MatchString(metadata) {\n\t\treturn vNext, ErrInvalidMetadata\n\t}\n\tvNext.metadata = metadata\n\tvNext.original = v.originalVPrefix() + \"\" + vNext.String()\n\treturn vNext, nil\n}\n\n// LessThan tests if one version is less than another one.\nfunc (v *Version) LessThan(o *Version) bool {\n\treturn v.Compare(o) < 0\n}\n\n// GreaterThan tests if one version is greater than another one.\nfunc (v *Version) GreaterThan(o *Version) bool {\n\treturn v.Compare(o) > 0\n}\n\n// Equal tests if two versions are equal to each other.\n// Note, versions can be equal with different metadata since metadata\n// is not considered part of the comparable version.\nfunc (v *Version) Equal(o *Version) bool {\n\treturn v.Compare(o) == 0\n}\n\n// Compare compares this version to another one. It returns -1, 0, or 1 if\n// the version smaller, equal, or larger than the other version.\n//\n// Versions are compared by X.Y.Z. Build metadata is ignored. Prerelease is\n// lower than the version without a prerelease.\nfunc (v *Version) Compare(o *Version) int {\n\t// Compare the major, minor, and patch version for differences. If a\n\t// difference is found return the comparison.\n\tif d := compareSegment(v.Major(), o.Major()); d != 0 {\n\t\treturn d\n\t}\n\tif d := compareSegment(v.Minor(), o.Minor()); d != 0 {\n\t\treturn d\n\t}\n\tif d := compareSegment(v.Patch(), o.Patch()); d != 0 {\n\t\treturn d\n\t}\n\n\t// At this point the major, minor, and patch versions are the same.\n\tps := v.pre\n\tpo := o.Prerelease()\n\n\tif ps == \"\" && po == \"\" {\n\t\treturn 0\n\t}\n\tif ps == \"\" {\n\t\treturn 1\n\t}\n\tif po == \"\" {\n\t\treturn -1\n\t}\n\n\treturn comparePrerelease(ps, po)\n}\n\n// UnmarshalJSON implements JSON.Unmarshaler interface.\nfunc (v *Version) UnmarshalJSON(b []byte) error {\n\tvar s string\n\tif err := json.Unmarshal(b, &s); err != nil {\n\t\treturn err\n\t}\n\ttemp, err := NewVersion(s)\n\tif err != nil {\n\t\treturn err\n\t}\n\tv.major = temp.major\n\tv.minor = temp.minor\n\tv.patch = temp.patch\n\tv.pre = temp.pre\n\tv.metadata = temp.metadata\n\tv.original = temp.original\n\ttemp = nil\n\treturn nil\n}\n\n// MarshalJSON implements JSON.Marshaler interface.\nfunc (v *Version) MarshalJSON() ([]byte, error) {\n\treturn json.Marshal(v.String())\n}\n\nfunc compareSegment(v, o int64) int {\n\tif v < o {\n\t\treturn -1\n\t}\n\tif v > o {\n\t\treturn 1\n\t}\n\n\treturn 0\n}\n\nfunc comparePrerelease(v, o string) int {\n\n\t// split the prelease versions by their part. The separator, per the spec,\n\t// is a .\n\tsparts := strings.Split(v, \".\")\n\toparts := strings.Split(o, \".\")\n\n\t// Find the longer length of the parts to know how many loop iterations to\n\t// go through.\n\tslen := len(sparts)\n\tolen := len(oparts)\n\n\tl := slen\n\tif olen > slen {\n\t\tl = olen\n\t}\n\n\t// Iterate over each part of the prereleases to compare the differences.\n\tfor i := 0; i < l; i++ {\n\t\t// Since the lentgh of the parts can be different we need to create\n\t\t// a placeholder. This is to avoid out of bounds issues.\n\t\tstemp := \"\"\n\t\tif i < slen {\n\t\t\tstemp = sparts[i]\n\t\t}\n\n\t\totemp := \"\"\n\t\tif i < olen {\n\t\t\totemp = oparts[i]\n\t\t}\n\n\t\td := comparePrePart(stemp, otemp)\n\t\tif d != 0 {\n\t\t\treturn d\n\t\t}\n\t}\n\n\t// Reaching here means two versions are of equal value but have different\n\t// metadata (the part following a +). They are not identical in string form\n\t// but the version comparison finds them to be equal.\n\treturn 0\n}\n\nfunc comparePrePart(s, o string) int {\n\t// Fastpath if they are equal\n\tif s == o {\n\t\treturn 0\n\t}\n\n\t// When s or o are empty we can use the other in an attempt to determine\n\t// the response.\n\tif s == \"\" {\n\t\tif o != \"\" {\n\t\t\treturn -1\n\t\t}\n\t\treturn 1\n\t}\n\n\tif o == \"\" {\n\t\tif s != \"\" {\n\t\t\treturn 1\n\t\t}\n\t\treturn -1\n\t}\n\n\t// When comparing strings \"99\" is greater than \"103\". To handle\n\t// cases like this we need to detect numbers and compare them.\n\n\toi, n1 := strconv.ParseInt(o, 10, 64)\n\tsi, n2 := strconv.ParseInt(s, 10, 64)\n\n\t// The case where both are strings compare the strings\n\tif n1 != nil && n2 != nil {\n\t\tif s > o {\n\t\t\treturn 1\n\t\t}\n\t\treturn -1\n\t} else if n1 != nil {\n\t\t// o is a string and s is a number\n\t\treturn -1\n\t} else if n2 != nil {\n\t\t// s is a string and o is a number\n\t\treturn 1\n\t}\n\t// Both are numbers\n\tif si > oi {\n\t\treturn 1\n\t}\n\treturn -1\n\n}\n"
  },
  {
    "path": "vendor/github.com/Masterminds/semver/version_test.go",
    "content": "package semver\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"testing\"\n)\n\nfunc TestNewVersion(t *testing.T) {\n\ttests := []struct {\n\t\tversion string\n\t\terr     bool\n\t}{\n\t\t{\"1.2.3\", false},\n\t\t{\"v1.2.3\", false},\n\t\t{\"1.0\", false},\n\t\t{\"v1.0\", false},\n\t\t{\"1\", false},\n\t\t{\"v1\", false},\n\t\t{\"1.2.beta\", true},\n\t\t{\"v1.2.beta\", true},\n\t\t{\"foo\", true},\n\t\t{\"1.2-5\", false},\n\t\t{\"v1.2-5\", false},\n\t\t{\"1.2-beta.5\", false},\n\t\t{\"v1.2-beta.5\", false},\n\t\t{\"\\n1.2\", true},\n\t\t{\"\\nv1.2\", true},\n\t\t{\"1.2.0-x.Y.0+metadata\", false},\n\t\t{\"v1.2.0-x.Y.0+metadata\", false},\n\t\t{\"1.2.0-x.Y.0+metadata-width-hypen\", false},\n\t\t{\"v1.2.0-x.Y.0+metadata-width-hypen\", false},\n\t\t{\"1.2.3-rc1-with-hypen\", false},\n\t\t{\"v1.2.3-rc1-with-hypen\", false},\n\t\t{\"1.2.3.4\", true},\n\t\t{\"v1.2.3.4\", true},\n\t\t{\"1.2.2147483648\", false},\n\t\t{\"1.2147483648.3\", false},\n\t\t{\"2147483648.3.0\", false},\n\t}\n\n\tfor _, tc := range tests {\n\t\t_, err := NewVersion(tc.version)\n\t\tif tc.err && err == nil {\n\t\t\tt.Fatalf(\"expected error for version: %s\", tc.version)\n\t\t} else if !tc.err && err != nil {\n\t\t\tt.Fatalf(\"error for version %s: %s\", tc.version, err)\n\t\t}\n\t}\n}\n\nfunc TestOriginal(t *testing.T) {\n\ttests := []string{\n\t\t\"1.2.3\",\n\t\t\"v1.2.3\",\n\t\t\"1.0\",\n\t\t\"v1.0\",\n\t\t\"1\",\n\t\t\"v1\",\n\t\t\"1.2-5\",\n\t\t\"v1.2-5\",\n\t\t\"1.2-beta.5\",\n\t\t\"v1.2-beta.5\",\n\t\t\"1.2.0-x.Y.0+metadata\",\n\t\t\"v1.2.0-x.Y.0+metadata\",\n\t\t\"1.2.0-x.Y.0+metadata-width-hypen\",\n\t\t\"v1.2.0-x.Y.0+metadata-width-hypen\",\n\t\t\"1.2.3-rc1-with-hypen\",\n\t\t\"v1.2.3-rc1-with-hypen\",\n\t}\n\n\tfor _, tc := range tests {\n\t\tv, err := NewVersion(tc)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Error parsing version %s\", tc)\n\t\t}\n\n\t\to := v.Original()\n\t\tif o != tc {\n\t\t\tt.Errorf(\"Error retrieving originl. Expected '%s' but got '%s'\", tc, v)\n\t\t}\n\t}\n}\n\nfunc TestParts(t *testing.T) {\n\tv, err := NewVersion(\"1.2.3-beta.1+build.123\")\n\tif err != nil {\n\t\tt.Error(\"Error parsing version 1.2.3-beta.1+build.123\")\n\t}\n\n\tif v.Major() != 1 {\n\t\tt.Error(\"Major() returning wrong value\")\n\t}\n\tif v.Minor() != 2 {\n\t\tt.Error(\"Minor() returning wrong value\")\n\t}\n\tif v.Patch() != 3 {\n\t\tt.Error(\"Patch() returning wrong value\")\n\t}\n\tif v.Prerelease() != \"beta.1\" {\n\t\tt.Error(\"Prerelease() returning wrong value\")\n\t}\n\tif v.Metadata() != \"build.123\" {\n\t\tt.Error(\"Metadata() returning wrong value\")\n\t}\n}\n\nfunc TestString(t *testing.T) {\n\ttests := []struct {\n\t\tversion  string\n\t\texpected string\n\t}{\n\t\t{\"1.2.3\", \"1.2.3\"},\n\t\t{\"v1.2.3\", \"1.2.3\"},\n\t\t{\"1.0\", \"1.0.0\"},\n\t\t{\"v1.0\", \"1.0.0\"},\n\t\t{\"1\", \"1.0.0\"},\n\t\t{\"v1\", \"1.0.0\"},\n\t\t{\"1.2-5\", \"1.2.0-5\"},\n\t\t{\"v1.2-5\", \"1.2.0-5\"},\n\t\t{\"1.2-beta.5\", \"1.2.0-beta.5\"},\n\t\t{\"v1.2-beta.5\", \"1.2.0-beta.5\"},\n\t\t{\"1.2.0-x.Y.0+metadata\", \"1.2.0-x.Y.0+metadata\"},\n\t\t{\"v1.2.0-x.Y.0+metadata\", \"1.2.0-x.Y.0+metadata\"},\n\t\t{\"1.2.0-x.Y.0+metadata-width-hypen\", \"1.2.0-x.Y.0+metadata-width-hypen\"},\n\t\t{\"v1.2.0-x.Y.0+metadata-width-hypen\", \"1.2.0-x.Y.0+metadata-width-hypen\"},\n\t\t{\"1.2.3-rc1-with-hypen\", \"1.2.3-rc1-with-hypen\"},\n\t\t{\"v1.2.3-rc1-with-hypen\", \"1.2.3-rc1-with-hypen\"},\n\t}\n\n\tfor _, tc := range tests {\n\t\tv, err := NewVersion(tc.version)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Error parsing version %s\", tc)\n\t\t}\n\n\t\ts := v.String()\n\t\tif s != tc.expected {\n\t\t\tt.Errorf(\"Error generating string. Expected '%s' but got '%s'\", tc.expected, s)\n\t\t}\n\t}\n}\n\nfunc TestCompare(t *testing.T) {\n\ttests := []struct {\n\t\tv1       string\n\t\tv2       string\n\t\texpected int\n\t}{\n\t\t{\"1.2.3\", \"1.5.1\", -1},\n\t\t{\"2.2.3\", \"1.5.1\", 1},\n\t\t{\"2.2.3\", \"2.2.2\", 1},\n\t\t{\"3.2-beta\", \"3.2-beta\", 0},\n\t\t{\"1.3\", \"1.1.4\", 1},\n\t\t{\"4.2\", \"4.2-beta\", 1},\n\t\t{\"4.2-beta\", \"4.2\", -1},\n\t\t{\"4.2-alpha\", \"4.2-beta\", -1},\n\t\t{\"4.2-alpha\", \"4.2-alpha\", 0},\n\t\t{\"4.2-beta.2\", \"4.2-beta.1\", 1},\n\t\t{\"4.2-beta2\", \"4.2-beta1\", 1},\n\t\t{\"4.2-beta\", \"4.2-beta.2\", -1},\n\t\t{\"4.2-beta\", \"4.2-beta.foo\", -1},\n\t\t{\"4.2-beta.2\", \"4.2-beta\", 1},\n\t\t{\"4.2-beta.foo\", \"4.2-beta\", 1},\n\t\t{\"1.2+bar\", \"1.2+baz\", 0},\n\t}\n\n\tfor _, tc := range tests {\n\t\tv1, err := NewVersion(tc.v1)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Error parsing version: %s\", err)\n\t\t}\n\n\t\tv2, err := NewVersion(tc.v2)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Error parsing version: %s\", err)\n\t\t}\n\n\t\ta := v1.Compare(v2)\n\t\te := tc.expected\n\t\tif a != e {\n\t\t\tt.Errorf(\n\t\t\t\t\"Comparison of '%s' and '%s' failed. Expected '%d', got '%d'\",\n\t\t\t\ttc.v1, tc.v2, e, a,\n\t\t\t)\n\t\t}\n\t}\n}\n\nfunc TestLessThan(t *testing.T) {\n\ttests := []struct {\n\t\tv1       string\n\t\tv2       string\n\t\texpected bool\n\t}{\n\t\t{\"1.2.3\", \"1.5.1\", true},\n\t\t{\"2.2.3\", \"1.5.1\", false},\n\t\t{\"3.2-beta\", \"3.2-beta\", false},\n\t}\n\n\tfor _, tc := range tests {\n\t\tv1, err := NewVersion(tc.v1)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Error parsing version: %s\", err)\n\t\t}\n\n\t\tv2, err := NewVersion(tc.v2)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Error parsing version: %s\", err)\n\t\t}\n\n\t\ta := v1.LessThan(v2)\n\t\te := tc.expected\n\t\tif a != e {\n\t\t\tt.Errorf(\n\t\t\t\t\"Comparison of '%s' and '%s' failed. Expected '%t', got '%t'\",\n\t\t\t\ttc.v1, tc.v2, e, a,\n\t\t\t)\n\t\t}\n\t}\n}\n\nfunc TestGreaterThan(t *testing.T) {\n\ttests := []struct {\n\t\tv1       string\n\t\tv2       string\n\t\texpected bool\n\t}{\n\t\t{\"1.2.3\", \"1.5.1\", false},\n\t\t{\"2.2.3\", \"1.5.1\", true},\n\t\t{\"3.2-beta\", \"3.2-beta\", false},\n\t\t{\"3.2.0-beta.1\", \"3.2.0-beta.5\", false},\n\t\t{\"3.2-beta.4\", \"3.2-beta.2\", true},\n\t\t{\"7.43.0-SNAPSHOT.99\", \"7.43.0-SNAPSHOT.103\", false},\n\t\t{\"7.43.0-SNAPSHOT.FOO\", \"7.43.0-SNAPSHOT.103\", true},\n\t\t{\"7.43.0-SNAPSHOT.99\", \"7.43.0-SNAPSHOT.BAR\", false},\n\t}\n\n\tfor _, tc := range tests {\n\t\tv1, err := NewVersion(tc.v1)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Error parsing version: %s\", err)\n\t\t}\n\n\t\tv2, err := NewVersion(tc.v2)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Error parsing version: %s\", err)\n\t\t}\n\n\t\ta := v1.GreaterThan(v2)\n\t\te := tc.expected\n\t\tif a != e {\n\t\t\tt.Errorf(\n\t\t\t\t\"Comparison of '%s' and '%s' failed. Expected '%t', got '%t'\",\n\t\t\t\ttc.v1, tc.v2, e, a,\n\t\t\t)\n\t\t}\n\t}\n}\n\nfunc TestEqual(t *testing.T) {\n\ttests := []struct {\n\t\tv1       string\n\t\tv2       string\n\t\texpected bool\n\t}{\n\t\t{\"1.2.3\", \"1.5.1\", false},\n\t\t{\"2.2.3\", \"1.5.1\", false},\n\t\t{\"3.2-beta\", \"3.2-beta\", true},\n\t\t{\"3.2-beta+foo\", \"3.2-beta+bar\", true},\n\t}\n\n\tfor _, tc := range tests {\n\t\tv1, err := NewVersion(tc.v1)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Error parsing version: %s\", err)\n\t\t}\n\n\t\tv2, err := NewVersion(tc.v2)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Error parsing version: %s\", err)\n\t\t}\n\n\t\ta := v1.Equal(v2)\n\t\te := tc.expected\n\t\tif a != e {\n\t\t\tt.Errorf(\n\t\t\t\t\"Comparison of '%s' and '%s' failed. Expected '%t', got '%t'\",\n\t\t\t\ttc.v1, tc.v2, e, a,\n\t\t\t)\n\t\t}\n\t}\n}\n\nfunc TestInc(t *testing.T) {\n\ttests := []struct {\n\t\tv1               string\n\t\texpected         string\n\t\thow              string\n\t\texpectedOriginal string\n\t}{\n\t\t{\"1.2.3\", \"1.2.4\", \"patch\", \"1.2.4\"},\n\t\t{\"v1.2.4\", \"1.2.5\", \"patch\", \"v1.2.5\"},\n\t\t{\"1.2.3\", \"1.3.0\", \"minor\", \"1.3.0\"},\n\t\t{\"v1.2.4\", \"1.3.0\", \"minor\", \"v1.3.0\"},\n\t\t{\"1.2.3\", \"2.0.0\", \"major\", \"2.0.0\"},\n\t\t{\"v1.2.4\", \"2.0.0\", \"major\", \"v2.0.0\"},\n\t\t{\"1.2.3+meta\", \"1.2.4\", \"patch\", \"1.2.4\"},\n\t\t{\"1.2.3-beta+meta\", \"1.2.3\", \"patch\", \"1.2.3\"},\n\t\t{\"v1.2.4-beta+meta\", \"1.2.4\", \"patch\", \"v1.2.4\"},\n\t\t{\"1.2.3-beta+meta\", \"1.3.0\", \"minor\", \"1.3.0\"},\n\t\t{\"v1.2.4-beta+meta\", \"1.3.0\", \"minor\", \"v1.3.0\"},\n\t\t{\"1.2.3-beta+meta\", \"2.0.0\", \"major\", \"2.0.0\"},\n\t\t{\"v1.2.4-beta+meta\", \"2.0.0\", \"major\", \"v2.0.0\"},\n\t}\n\n\tfor _, tc := range tests {\n\t\tv1, err := NewVersion(tc.v1)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Error parsing version: %s\", err)\n\t\t}\n\t\tvar v2 Version\n\t\tswitch tc.how {\n\t\tcase \"patch\":\n\t\t\tv2 = v1.IncPatch()\n\t\tcase \"minor\":\n\t\t\tv2 = v1.IncMinor()\n\t\tcase \"major\":\n\t\t\tv2 = v1.IncMajor()\n\t\t}\n\n\t\ta := v2.String()\n\t\te := tc.expected\n\t\tif a != e {\n\t\t\tt.Errorf(\n\t\t\t\t\"Inc %q failed. Expected %q got %q\",\n\t\t\t\ttc.how, e, a,\n\t\t\t)\n\t\t}\n\n\t\ta = v2.Original()\n\t\te = tc.expectedOriginal\n\t\tif a != e {\n\t\t\tt.Errorf(\n\t\t\t\t\"Inc %q failed. Expected original %q got %q\",\n\t\t\t\ttc.how, e, a,\n\t\t\t)\n\t\t}\n\t}\n}\n\nfunc TestSetPrerelease(t *testing.T) {\n\ttests := []struct {\n\t\tv1                 string\n\t\tprerelease         string\n\t\texpectedVersion    string\n\t\texpectedPrerelease string\n\t\texpectedOriginal   string\n\t\texpectedErr        error\n\t}{\n\t\t{\"1.2.3\", \"**\", \"1.2.3\", \"\", \"1.2.3\", ErrInvalidPrerelease},\n\t\t{\"1.2.3\", \"beta\", \"1.2.3-beta\", \"beta\", \"1.2.3-beta\", nil},\n\t\t{\"v1.2.4\", \"beta\", \"1.2.4-beta\", \"beta\", \"v1.2.4-beta\", nil},\n\t}\n\n\tfor _, tc := range tests {\n\t\tv1, err := NewVersion(tc.v1)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Error parsing version: %s\", err)\n\t\t}\n\n\t\tv2, err := v1.SetPrerelease(tc.prerelease)\n\t\tif err != tc.expectedErr {\n\t\t\tt.Errorf(\"Expected to get err=%s, but got err=%s\", tc.expectedErr, err)\n\t\t}\n\n\t\ta := v2.Prerelease()\n\t\te := tc.expectedPrerelease\n\t\tif a != e {\n\t\t\tt.Errorf(\"Expected prerelease value=%q, but got %q\", e, a)\n\t\t}\n\n\t\ta = v2.String()\n\t\te = tc.expectedVersion\n\t\tif a != e {\n\t\t\tt.Errorf(\"Expected version string=%q, but got %q\", e, a)\n\t\t}\n\n\t\ta = v2.Original()\n\t\te = tc.expectedOriginal\n\t\tif a != e {\n\t\t\tt.Errorf(\"Expected version original=%q, but got %q\", e, a)\n\t\t}\n\t}\n}\n\nfunc TestSetMetadata(t *testing.T) {\n\ttests := []struct {\n\t\tv1               string\n\t\tmetadata         string\n\t\texpectedVersion  string\n\t\texpectedMetadata string\n\t\texpectedOriginal string\n\t\texpectedErr      error\n\t}{\n\t\t{\"1.2.3\", \"**\", \"1.2.3\", \"\", \"1.2.3\", ErrInvalidMetadata},\n\t\t{\"1.2.3\", \"meta\", \"1.2.3+meta\", \"meta\", \"1.2.3+meta\", nil},\n\t\t{\"v1.2.4\", \"meta\", \"1.2.4+meta\", \"meta\", \"v1.2.4+meta\", nil},\n\t}\n\n\tfor _, tc := range tests {\n\t\tv1, err := NewVersion(tc.v1)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Error parsing version: %s\", err)\n\t\t}\n\n\t\tv2, err := v1.SetMetadata(tc.metadata)\n\t\tif err != tc.expectedErr {\n\t\t\tt.Errorf(\"Expected to get err=%s, but got err=%s\", tc.expectedErr, err)\n\t\t}\n\n\t\ta := v2.Metadata()\n\t\te := tc.expectedMetadata\n\t\tif a != e {\n\t\t\tt.Errorf(\"Expected metadata value=%q, but got %q\", e, a)\n\t\t}\n\n\t\ta = v2.String()\n\t\te = tc.expectedVersion\n\t\tif e != a {\n\t\t\tt.Errorf(\"Expected version string=%q, but got %q\", e, a)\n\t\t}\n\n\t\ta = v2.Original()\n\t\te = tc.expectedOriginal\n\t\tif a != e {\n\t\t\tt.Errorf(\"Expected version original=%q, but got %q\", e, a)\n\t\t}\n\t}\n}\n\nfunc TestOriginalVPrefix(t *testing.T) {\n\ttests := []struct {\n\t\tversion string\n\t\tvprefix string\n\t}{\n\t\t{\"1.2.3\", \"\"},\n\t\t{\"v1.2.4\", \"v\"},\n\t}\n\n\tfor _, tc := range tests {\n\t\tv1, _ := NewVersion(tc.version)\n\t\ta := v1.originalVPrefix()\n\t\te := tc.vprefix\n\t\tif a != e {\n\t\t\tt.Errorf(\"Expected vprefix=%q, but got %q\", e, a)\n\t\t}\n\t}\n}\n\nfunc TestJsonMarshal(t *testing.T) {\n\tsVer := \"1.1.1\"\n\tx, err := NewVersion(sVer)\n\tif err != nil {\n\t\tt.Errorf(\"Error creating version: %s\", err)\n\t}\n\tout, err2 := json.Marshal(x)\n\tif err2 != nil {\n\t\tt.Errorf(\"Error marshaling version: %s\", err2)\n\t}\n\tgot := string(out)\n\twant := fmt.Sprintf(\"%q\", sVer)\n\tif got != want {\n\t\tt.Errorf(\"Error marshaling unexpected marshaled content: got=%q want=%q\", got, want)\n\t}\n}\n\nfunc TestJsonUnmarshal(t *testing.T) {\n\tsVer := \"1.1.1\"\n\tver := &Version{}\n\terr := json.Unmarshal([]byte(fmt.Sprintf(\"%q\", sVer)), ver)\n\tif err != nil {\n\t\tt.Errorf(\"Error unmarshaling version: %s\", err)\n\t}\n\tgot := ver.String()\n\twant := sVer\n\tif got != want {\n\t\tt.Errorf(\"Error unmarshaling unexpected object content: got=%q want=%q\", got, want)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/.gitignore",
    "content": "# Compiled Object files, Static and Dynamic libs (Shared Objects)\n*.o\n*.a\n*.so\n\n# Folders\n_obj\n_test\n\n# Architecture specific extensions/prefixes\n*.[568vq]\n[568vq].out\n\n*.cgo1.go\n*.cgo2.c\n_cgo_defun.c\n_cgo_gotypes.go\n_cgo_export.*\n\n_testmain.go\n\n*.exe\n*.test\n*.prof\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/.travis.yml",
    "content": "language: go\ndist: xenial\n\ngo:\n  - 1.6.x\n  - 1.7.x\n  - 1.8.x\n  - 1.9.x\n  - 1.10.x\n  - 1.11.x\n  - 1.12.x\n  - master\n\nbefore_script:\n  - git version\n  - svn --version\n  # Need a more up to date verion of mercurial to handle TLS with\n  # bitbucket properly. Also need python greater than 2.7.9.\n  - pyenv versions && pyenv rehash && pyenv versions\n  - pyenv global 2.7.15\n  - openssl ciphers -v | awk '{print $2}' | sort | uniq\n  - sudo pip install mercurial --upgrade\n  # The below is a complete hack to have hg use the pyenv version of python\n  - sudo sed -i '1s/.*/\\#\\!\\/usr\\/bin\\/env\\ python/' /usr/local/bin/hg\n  - hg --version\n\n\n# Setting sudo access to false will let Travis CI use containers rather than\n# VMs to run the tests. For more details see:\n# - http://docs.travis-ci.com/user/workers/container-based-infrastructure/\n# - http://docs.travis-ci.com/user/workers/standard-infrastructure/\nsudo: false\n\nscript:\n  - make setup\n  - make test\n\nnotifications:\n  webhooks:\n    urls:\n      - https://webhooks.gitter.im/e/06e3328629952dabe3e0\n    on_success: change  # options: [always|never|change] default: always\n    on_failure: always  # options: [always|never|change] default: always\n    on_start: never     # options: [always|never|change] default: always\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/CHANGELOG.md",
    "content": "# Changelog\n\n## 1.13.1 (2019-07-09)\n\n### Fixed\n\n- #101: Updated bitbucket API call as previous API was removed\n- #97: Fixed travis ci building\n- #95: Fixed \"git clean\" invocation for submodule\n\n## 1.13.0 (2019-02-27)\n\n### Changed\n\n- #92: Allow non-200 remote lookup responses for Go style redirects\n\n### Fixed\n\n- #91: For Mercurial/Hg return an error if Version() called and Hg prints to stderr\n- #87 and #93: Fix CI issues\n\n## 1.12.0 (2017-09-11)\n\n### Changed\n\n- #79: Include the error context in the error string (thanks @guywithnose)\n- #80: Bump the Go versions for Travis CI testing (thanks @AlekSi)\n\n## 1.11.1 (2017-04-28)\n\n### Fixed\n\n- #76: Fix submodule handling for Windows (thanks @m0j0hn)\n\n## 1.11.0 (2017-03-23)\n\n### Added\n\n- #65: Exposed CmdFromDir function (thanks @erizocosmico)\n\n### Changed\n\n- #69: Updated testing for Go 1.8\n\n### Fixed\n\n- #64: Testing fatal error if bzr not installed (thanks @kevinburke)\n\n## 1.10.2 (2017-01-24)\n\n### Fixed\n\n- #63: Remove extra quotes in submodule export (thanks @dt)\n\n## 1.10.1 (2017-01-18)\n\n### Fixed\n\n- #62: Added windows testing via appveyor and fixed issues under windows.\n\n## 1.10.0 (2017-01-09)\n\n### Added\n\n- #60: Handle Git submodules (thanks @sdboyer)\n- #61: Add gometalinter to testing\n\n## 1.9.0 (2016-11-18)\n\n### Added\n\n- #50: Auto-detect remotes with file:// prefix.\n- #59: Testing against Go 1.7\n\n### Changed\n\n- Removed auto-detection for Google Code as the service is deprecated\n- Added auto-detection of git.openstack.org\n\n### Fixed\n\n- #53: Git not fetching tags off branch\n\n## 1.8.0 (2016-06-29)\n\n### Added\n\n- #43: Detect when tool (e.g., git, svn, etc) not installed\n- #49: Detect access denied and not found situations\n\n### Changed\n\n- #48: Updated Go Report Gard url to new format\n- Refactored SVN handling to detect when not in a top level directory\n- Updating tagging to v[SemVer] structure for compatibility with other tools.\n\n### Fixed\n\n- #45: Fixed hg's update method so that it pulls from remote before updates\n\n## 1.7.0 (2016-05-05)\n\n- Adds a glide.yaml file with some limited information.\n- Implements #37: Ability to export source as a directory.\n- Implements #36: Get current version-ish with Current method. This returns\n  a branch (if on tip) or equivalent tip, a tag if on a tag, or a revision if\n  on an individual revision. Note, the tip of branch is VCS specific so usage\n  may require detecting VCS type.\n\n## 1.6.1 (2016-04-27)\n\n- Fixed #30: tags from commit should not have ^{} appended (seen in git)\n- Fixed #29: isDetachedHead fails with non-english locales (git)\n- Fixed #33: Access denied and not found http errors causing xml parsing errors\n\n## 1.6.0 (2016-04-18)\n\n- Issue #26: Added Init method to initialize a repo at the local location\n  (thanks tony).\n- Issue #19: Added method to retrieve tags for a commit.\n- Issue #24: Reworked errors returned from common methods. Now differing\n  VCS implementations return the same errors. The original VCS specific error\n  is available on the error. See the docs for more details.\n- Issue #25: Export the function RunFromDir which runs VCS commands from the\n  root of the local directory. This is useful for those that want to build and\n  extend on top of the vcs package (thanks tony).\n- Issue #22: Added Ping command to test if remote location is present and\n  accessible.\n\n## 1.5.1 (2016-03-23)\n\n- Fixing bug parsing some Git commit dates.\n\n## 1.5.0 (2016-03-22)\n\n- Add Travis CI testing for Go 1.6.\n- Issue #17: Add CommitInfo method allowing for a common way to get commit\n  metadata from all VCS.\n- Autodetect types that have git@ or hg@ users.\n- Autodetect git+ssh, bzr+ssh, git, and svn+ssh scheme urls.\n- On Bitbucket for ssh style URLs retrieve the type from the URL. This allows\n  for private repo type detection.\n- Issue #14: Autodetect ssh/scp style urls (thanks chonthu).\n\n## 1.4.1 (2016-03-07)\n\n- Fixes #16: some windows situations are unable to create parent directory.\n\n## 1.4.0 (2016-02-15)\n\n- Adding support for IBM JazzHub.\n\n## 1.3.1 (2016-01-27)\n\n- Issue #12: Failed to checkout Bzr repo when parent directory didn't\n  exist (thanks cyrilleverrier).\n\n## 1.3.0 (2015-11-09)\n\n- Issue #9: Added Date method to get the date/time of latest commit (thanks kamilchm).\n\n## 1.2.0 (2015-10-29)\n\n- Adding IsDirty method to detect a checkout with uncommitted changes.\n\n## 1.1.4 (2015-10-28)\n\n- Fixed #8: Git IsReference not detecting branches that have not been checked\n  out yet.\n\n## 1.1.3 (2015-10-21)\n\n- Fixing issue where there are multiple go-import statements for go redirects\n\n## 1.1.2 (2015-10-20)\n\n- Fixes #7: hg not checking out code when Get is called\n\n## 1.1.1 (2015-10-20)\n\n- Issue #6: Allow VCS commands to be run concurrently.\n\n## 1.1.0 (2015-10-19)\n\n- #5: Added output of failed command to returned errors.\n\n## 1.0.0 (2015-10-06)\n\n- Initial release.\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/LICENSE.txt",
    "content": "The Masterminds\nCopyright (C) 2014-2015, Matt Butcher and Matt Farina\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/Makefile",
    "content": ".PHONY: setup\nsetup:\n\tgo get -u gopkg.in/alecthomas/gometalinter.v1\n\tgometalinter.v1 --install\n\n.PHONY: test\ntest: validate lint\n\t@echo \"==> Running tests\"\n\tgo test -v\n\n.PHONY: validate\nvalidate:\n# misspell finds the work adresář (used in bzr.go) as a mispelling of\n# address. It finds adres. An issue has been filed at\n# https://github.com/client9/misspell/issues/99. In the meantime adding\n# adres to the ignore list.\n\t@echo \"==> Running static validations\"\n\t@gometalinter.v1 \\\n\t  --disable-all \\\n\t  --linter \"misspell:misspell -i adres -j 1 {path}/*.go:PATH:LINE:COL:MESSAGE\" \\\n\t  --enable deadcode \\\n\t  --severity deadcode:error \\\n\t  --enable gofmt \\\n\t  --enable gosimple \\\n\t  --enable ineffassign \\\n\t  --enable misspell \\\n\t  --enable vet \\\n\t  --tests \\\n\t  --vendor \\\n\t  --deadline 60s \\\n\t  ./... || exit_code=1\n\n.PHONY: lint\nlint:\n\t@echo \"==> Running linters\"\n\t@gometalinter.v1 \\\n\t  --disable-all \\\n\t  --enable golint \\\n\t  --vendor \\\n\t  --deadline 60s \\\n\t  ./... || :\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/README.md",
    "content": "# VCS Repository Management for Go\n\nManage repos in varying version control systems with ease through a common\ninterface.\n\n[![Build Status](https://travis-ci.org/Masterminds/vcs.svg)](https://travis-ci.org/Masterminds/vcs) [![GoDoc](https://godoc.org/github.com/Masterminds/vcs?status.png)](https://godoc.org/github.com/Masterminds/vcs) [![Go Report Card](https://goreportcard.com/badge/github.com/Masterminds/vcs)](https://goreportcard.com/report/github.com/Masterminds/vcs)\n[![Build status](https://ci.appveyor.com/api/projects/status/vg3cjc561q2trobm?svg=true&passingText=windows%20build%20passing&failingText=windows%20build%20failing)](https://ci.appveyor.com/project/mattfarina/vcs)\n\n\n## Quick Usage\n\nQuick usage:\n\n\tremote := \"https://github.com/Masterminds/vcs\"\n    local, _ := ioutil.TempDir(\"\", \"go-vcs\")\n    repo, err := NewRepo(remote, local)\n\nIn this case `NewRepo` will detect the VCS is Git and return a `GitRepo`. All of\nthe repos implement the `Repo` interface with a common set of features between\nthem.\n\n## Supported VCS\n\nGit, SVN, Bazaar (Bzr), and Mercurial (Hg) are currently supported. They each\nhave their own type (e.g., `GitRepo`) that follow a simple naming pattern. Each\ntype implements the `Repo` interface and has a constructor (e.g., `NewGitRepo`).\nThe constructors have the same signature as `NewRepo`.\n\n## Features\n\n- Clone or checkout a repository depending on the version control system.\n- Pull updates to a repository.\n- Get the currently checked out commit id.\n- Checkout a commit id, branch, or tag (depending on the availability in the VCS).\n- Get a list of tags and branches in the VCS.\n- Check if a string value is a valid reference within the VCS.\n- More...\n\nFor more details see [the documentation](https://godoc.org/github.com/Masterminds/vcs).\n\n## Motivation\n\nThe package `golang.org/x/tools/go/vcs` provides some valuable functionality\nfor working with packages in repositories in varying source control management\nsystems. That package, while useful and well tested, is designed with a specific\npurpose in mind. Our uses went beyond the scope of that package. To implement\nour scope we built a package that went beyond the functionality and scope\nof `golang.org/x/tools/go/vcs`.\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/appveyor.yml",
    "content": "\nversion: build-{build}.{branch}\n\nclone_folder: C:\\gopath\\src\\github.com\\Masterminds\\vcs\nshallow_clone: true\n\nenvironment:\n  GOPATH: C:\\gopath\n\nplatform:\n  - x64\n\ninstall:\n  - go version\n  - go env\n  - choco install -y bzr\n  - set PATH=C:\\Program Files (x86)\\Bazaar;%PATH%\n  - bzr --version\n\nbuild_script:\n  - go install -v ./...\n\ntest_script:\n  - go test -v\n\ndeploy: off\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/bzr.go",
    "content": "package vcs\n\nimport (\n\t\"fmt\"\n\t\"net/url\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n\t\"regexp\"\n\t\"strings\"\n\t\"time\"\n)\n\nvar bzrDetectURL = regexp.MustCompile(\"parent branch: (?P<foo>.+)\\n\")\n\n// NewBzrRepo creates a new instance of BzrRepo. The remote and local directories\n// need to be passed in.\nfunc NewBzrRepo(remote, local string) (*BzrRepo, error) {\n\tins := depInstalled(\"bzr\")\n\tif !ins {\n\t\treturn nil, NewLocalError(\"bzr is not installed\", nil, \"\")\n\t}\n\tltype, err := DetectVcsFromFS(local)\n\n\t// Found a VCS other than Bzr. Need to report an error.\n\tif err == nil && ltype != Bzr {\n\t\treturn nil, ErrWrongVCS\n\t}\n\n\tr := &BzrRepo{}\n\tr.setRemote(remote)\n\tr.setLocalPath(local)\n\tr.Logger = Logger\n\n\t// With the other VCS we can check if the endpoint locally is different\n\t// from the one configured internally. But, with Bzr you can't. For example,\n\t// if you do `bzr branch https://launchpad.net/govcstestbzrrepo` and then\n\t// use `bzr info` to get the parent branch you'll find it set to\n\t// http://bazaar.launchpad.net/~mattfarina/govcstestbzrrepo/trunk/. Notice\n\t// the change from https to http and the path chance.\n\t// Here we set the remote to be the local one if none is passed in.\n\tif err == nil && r.CheckLocal() && remote == \"\" {\n\t\tc := exec.Command(\"bzr\", \"info\")\n\t\tc.Dir = local\n\t\tc.Env = envForDir(c.Dir)\n\t\tout, err := c.CombinedOutput()\n\t\tif err != nil {\n\t\t\treturn nil, NewLocalError(\"Unable to retrieve local repo information\", err, string(out))\n\t\t}\n\t\tm := bzrDetectURL.FindStringSubmatch(string(out))\n\n\t\t// If no remote was passed in but one is configured for the locally\n\t\t// checked out Bzr repo use that one.\n\t\tif m[1] != \"\" {\n\t\t\tr.setRemote(m[1])\n\t\t}\n\t}\n\n\treturn r, nil\n}\n\n// BzrRepo implements the Repo interface for the Bzr source control.\ntype BzrRepo struct {\n\tbase\n}\n\n// Vcs retrieves the underlying VCS being implemented.\nfunc (s BzrRepo) Vcs() Type {\n\treturn Bzr\n}\n\n// Get is used to perform an initial clone of a repository.\nfunc (s *BzrRepo) Get() error {\n\n\tbasePath := filepath.Dir(filepath.FromSlash(s.LocalPath()))\n\tif _, err := os.Stat(basePath); os.IsNotExist(err) {\n\t\terr = os.MkdirAll(basePath, 0755)\n\t\tif err != nil {\n\t\t\treturn NewLocalError(\"Unable to create directory\", err, \"\")\n\t\t}\n\t}\n\n\tout, err := s.run(\"bzr\", \"branch\", s.Remote(), s.LocalPath())\n\tif err != nil {\n\t\treturn NewRemoteError(\"Unable to get repository\", err, string(out))\n\t}\n\n\treturn nil\n}\n\n// Init initializes a bazaar repository at local location.\nfunc (s *BzrRepo) Init() error {\n\tout, err := s.run(\"bzr\", \"init\", s.LocalPath())\n\n\t// There are some windows cases where bazaar cannot create the parent\n\t// directory if it does not already exist, to the location it's trying\n\t// to create the repo. Catch that error and try to handle it.\n\tif err != nil && s.isUnableToCreateDir(err) {\n\n\t\tbasePath := filepath.Dir(filepath.FromSlash(s.LocalPath()))\n\t\tif _, err := os.Stat(basePath); os.IsNotExist(err) {\n\t\t\terr = os.MkdirAll(basePath, 0755)\n\t\t\tif err != nil {\n\t\t\t\treturn NewLocalError(\"Unable to initialize repository\", err, \"\")\n\t\t\t}\n\n\t\t\tout, err = s.run(\"bzr\", \"init\", s.LocalPath())\n\t\t\tif err != nil {\n\t\t\t\treturn NewLocalError(\"Unable to initialize repository\", err, string(out))\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\n\t} else if err != nil {\n\t\treturn NewLocalError(\"Unable to initialize repository\", err, string(out))\n\t}\n\n\treturn nil\n}\n\n// Update performs a Bzr pull and update to an existing checkout.\nfunc (s *BzrRepo) Update() error {\n\tout, err := s.RunFromDir(\"bzr\", \"pull\")\n\tif err != nil {\n\t\treturn NewRemoteError(\"Unable to update repository\", err, string(out))\n\t}\n\tout, err = s.RunFromDir(\"bzr\", \"update\")\n\tif err != nil {\n\t\treturn NewRemoteError(\"Unable to update repository\", err, string(out))\n\t}\n\treturn nil\n}\n\n// UpdateVersion sets the version of a package currently checked out via Bzr.\nfunc (s *BzrRepo) UpdateVersion(version string) error {\n\tout, err := s.RunFromDir(\"bzr\", \"update\", \"-r\", version)\n\tif err != nil {\n\t\treturn NewLocalError(\"Unable to update checked out version\", err, string(out))\n\t}\n\treturn nil\n}\n\n// Version retrieves the current version.\nfunc (s *BzrRepo) Version() (string, error) {\n\n\tout, err := s.RunFromDir(\"bzr\", \"revno\", \"--tree\")\n\tif err != nil {\n\t\treturn \"\", NewLocalError(\"Unable to retrieve checked out version\", err, string(out))\n\t}\n\n\treturn strings.TrimSpace(string(out)), nil\n}\n\n// Current returns the current version-ish. This means:\n// * -1 if on the tip of the branch (this is the Bzr value for HEAD)\n// * A tag if on a tag\n// * Otherwise a revision\nfunc (s *BzrRepo) Current() (string, error) {\n\ttip, err := s.CommitInfo(\"-1\")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tcurr, err := s.Version()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif tip.Commit == curr {\n\t\treturn \"-1\", nil\n\t}\n\n\tts, err := s.TagsFromCommit(curr)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif len(ts) > 0 {\n\t\treturn ts[0], nil\n\t}\n\n\treturn curr, nil\n}\n\n// Date retrieves the date on the latest commit.\nfunc (s *BzrRepo) Date() (time.Time, error) {\n\tout, err := s.RunFromDir(\"bzr\", \"version-info\", \"--custom\", \"--template={date}\")\n\tif err != nil {\n\t\treturn time.Time{}, NewLocalError(\"Unable to retrieve revision date\", err, string(out))\n\t}\n\tt, err := time.Parse(longForm, string(out))\n\tif err != nil {\n\t\treturn time.Time{}, NewLocalError(\"Unable to retrieve revision date\", err, string(out))\n\t}\n\treturn t, nil\n}\n\n// CheckLocal verifies the local location is a Bzr repo.\nfunc (s *BzrRepo) CheckLocal() bool {\n\tif _, err := os.Stat(s.LocalPath() + \"/.bzr\"); err == nil {\n\t\treturn true\n\t}\n\n\treturn false\n}\n\n// Branches returns a list of available branches on the repository.\n// In Bazaar (Bzr) clones and branches are the same. A different branch will\n// have a different URL location which we cannot detect from the repo. This\n// is a little different from other VCS.\nfunc (s *BzrRepo) Branches() ([]string, error) {\n\tvar branches []string\n\treturn branches, nil\n}\n\n// Tags returns a list of available tags on the repository.\nfunc (s *BzrRepo) Tags() ([]string, error) {\n\tout, err := s.RunFromDir(\"bzr\", \"tags\")\n\tif err != nil {\n\t\treturn []string{}, NewLocalError(\"Unable to retrieve tags\", err, string(out))\n\t}\n\ttags := s.referenceList(string(out), `(?m-s)^(\\S+)`)\n\treturn tags, nil\n}\n\n// IsReference returns if a string is a reference. A reference can be a\n// commit id or tag.\nfunc (s *BzrRepo) IsReference(r string) bool {\n\t_, err := s.RunFromDir(\"bzr\", \"revno\", \"-r\", r)\n\treturn err == nil\n}\n\n// IsDirty returns if the checkout has been modified from the checked\n// out reference.\nfunc (s *BzrRepo) IsDirty() bool {\n\tout, err := s.RunFromDir(\"bzr\", \"diff\")\n\treturn err != nil || len(out) != 0\n}\n\n// CommitInfo retrieves metadata about a commit.\nfunc (s *BzrRepo) CommitInfo(id string) (*CommitInfo, error) {\n\tr := \"-r\" + id\n\tout, err := s.RunFromDir(\"bzr\", \"log\", r, \"--log-format=long\")\n\tif err != nil {\n\t\treturn nil, ErrRevisionUnavailable\n\t}\n\n\tci := &CommitInfo{}\n\tlines := strings.Split(string(out), \"\\n\")\n\tconst format = \"Mon 2006-01-02 15:04:05 -0700\"\n\tvar track int\n\tvar trackOn bool\n\n\t// Note, bzr does not appear to use i18m.\n\tfor i, l := range lines {\n\t\tif strings.HasPrefix(l, \"revno:\") {\n\t\t\tci.Commit = strings.TrimSpace(strings.TrimPrefix(l, \"revno:\"))\n\t\t} else if strings.HasPrefix(l, \"committer:\") {\n\t\t\tci.Author = strings.TrimSpace(strings.TrimPrefix(l, \"committer:\"))\n\t\t} else if strings.HasPrefix(l, \"timestamp:\") {\n\t\t\tts := strings.TrimSpace(strings.TrimPrefix(l, \"timestamp:\"))\n\t\t\tci.Date, err = time.Parse(format, ts)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, NewLocalError(\"Unable to retrieve commit information\", err, string(out))\n\t\t\t}\n\t\t} else if strings.TrimSpace(l) == \"message:\" {\n\t\t\ttrack = i\n\t\t\ttrackOn = true\n\t\t} else if trackOn && i > track {\n\t\t\tci.Message = ci.Message + l\n\t\t}\n\t}\n\tci.Message = strings.TrimSpace(ci.Message)\n\n\t// Didn't find the revision\n\tif ci.Author == \"\" {\n\t\treturn nil, ErrRevisionUnavailable\n\t}\n\n\treturn ci, nil\n}\n\n// TagsFromCommit retrieves tags from a commit id.\nfunc (s *BzrRepo) TagsFromCommit(id string) ([]string, error) {\n\tout, err := s.RunFromDir(\"bzr\", \"tags\", \"-r\", id)\n\tif err != nil {\n\t\treturn []string{}, NewLocalError(\"Unable to retrieve tags\", err, string(out))\n\t}\n\n\ttags := s.referenceList(string(out), `(?m-s)^(\\S+)`)\n\treturn tags, nil\n}\n\n// Ping returns if remote location is accessible.\nfunc (s *BzrRepo) Ping() bool {\n\n\t// Running bzr info is slow. Many of the projects are on launchpad which\n\t// has a public 1.0 API we can use.\n\tu, err := url.Parse(s.Remote())\n\tif err == nil {\n\t\tif u.Host == \"launchpad.net\" {\n\t\t\ttry := strings.TrimPrefix(u.Path, \"/\")\n\n\t\t\t// get returns the body and an err. If the status code is not a 200\n\t\t\t// an error is returned. Launchpad returns a 404 for a codebase that\n\t\t\t// does not exist. Otherwise it returns a JSON object describing it.\n\t\t\t_, er := get(\"https://api.launchpad.net/1.0/\" + try)\n\t\t\treturn er == nil\n\t\t}\n\t}\n\n\t// This is the same command that Go itself uses but it's not fast (or fast\n\t// enough by my standards). A faster method would be useful.\n\t_, err = s.run(\"bzr\", \"info\", s.Remote())\n\treturn err == nil\n}\n\n// ExportDir exports the current revision to the passed in directory.\nfunc (s *BzrRepo) ExportDir(dir string) error {\n\tout, err := s.RunFromDir(\"bzr\", \"export\", dir)\n\ts.log(out)\n\tif err != nil {\n\t\treturn NewLocalError(\"Unable to export source\", err, string(out))\n\t}\n\n\treturn nil\n}\n\n// Multi-lingual manner check for the VCS error that it couldn't create directory.\n// https://bazaar.launchpad.net/~bzr-pqm/bzr/bzr.dev/files/head:/po/\nfunc (s *BzrRepo) isUnableToCreateDir(err error) bool {\n\tmsg := err.Error()\n\n\tif strings.HasPrefix(msg, fmt.Sprintf(\"Parent directory of %s does not exist.\", s.LocalPath())) ||\n\t\tstrings.HasPrefix(msg, fmt.Sprintf(\"Nadřazený adresář %s neexistuje.\", s.LocalPath())) ||\n\t\tstrings.HasPrefix(msg, fmt.Sprintf(\"El directorio padre de %s no existe.\", s.LocalPath())) ||\n\t\tstrings.HasPrefix(msg, fmt.Sprintf(\"%s の親ディレクトリがありません。\", s.LocalPath())) ||\n\t\tstrings.HasPrefix(msg, fmt.Sprintf(\"Родительская директория для %s не существует.\", s.LocalPath())) {\n\t\treturn true\n\t}\n\n\treturn false\n}\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/bzr_test.go",
    "content": "package vcs\n\nimport (\n\t\"io/ioutil\"\n\t\"path/filepath\"\n\t\"time\"\n\t//\"log\"\n\t\"os\"\n\t\"testing\"\n)\n\n// Canary test to ensure BzrRepo implements the Repo interface.\nvar _ Repo = &BzrRepo{}\n\n// To verify bzr is working we perform integration testing\n// with a known bzr service. Due to the long time of repeatedly checking out\n// repos these tests are structured to work together.\n\nfunc TestBzr(t *testing.T) {\n\n\ttempDir, err := ioutil.TempDir(\"\", \"go-vcs-bzr-tests\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\trepo, err := NewBzrRepo(\"https://launchpad.net/govcstestbzrrepo\", tempDir+\"/govcstestbzrrepo\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif repo.Vcs() != Bzr {\n\t\tt.Error(\"Bzr is detecting the wrong type\")\n\t}\n\n\t// Check the basic getters.\n\tif repo.Remote() != \"https://launchpad.net/govcstestbzrrepo\" {\n\t\tt.Error(\"Remote not set properly\")\n\t}\n\tif repo.LocalPath() != tempDir+\"/govcstestbzrrepo\" {\n\t\tt.Error(\"Local disk location not set properly\")\n\t}\n\n\t//Logger = log.New(os.Stdout, \"\", log.LstdFlags)\n\n\t// Do an initial clone.\n\terr = repo.Get()\n\tif err != nil {\n\t\tt.Errorf(\"Unable to clone Bzr repo. Err was %s\", err)\n\t}\n\n\t// Verify Bzr repo is a Bzr repo\n\tif !repo.CheckLocal() {\n\t\tt.Error(\"Problem checking out repo or Bzr CheckLocal is not working\")\n\t}\n\n\t// Test internal lookup mechanism used outside of Bzr specific functionality.\n\tltype, err := DetectVcsFromFS(tempDir + \"/govcstestbzrrepo\")\n\tif err != nil {\n\t\tt.Error(\"detectVcsFromFS unable to Bzr repo\")\n\t}\n\tif ltype != Bzr {\n\t\tt.Errorf(\"detectVcsFromFS detected %s instead of Bzr type\", ltype)\n\t}\n\n\t// Test NewRepo on existing checkout. This should simply provide a working\n\t// instance without error based on looking at the local directory.\n\tnrepo, nrerr := NewRepo(\"https://launchpad.net/govcstestbzrrepo\", tempDir+\"/govcstestbzrrepo\")\n\tif nrerr != nil {\n\t\tt.Error(nrerr)\n\t}\n\t// Verify the right oject is returned. It will check the local repo type.\n\tif !nrepo.CheckLocal() {\n\t\tt.Error(\"Wrong version returned from NewRepo\")\n\t}\n\n\tv, err := repo.Current()\n\tif err != nil {\n\t\tt.Errorf(\"Error trying Bzr Current: %s\", err)\n\t}\n\tif v != \"-1\" {\n\t\tt.Errorf(\"Current failed to detect Bzr on tip of branch. Got version: %s\", v)\n\t}\n\n\terr = repo.UpdateVersion(\"2\")\n\tif err != nil {\n\t\tt.Errorf(\"Unable to update Bzr repo version. Err was %s\", err)\n\t}\n\n\t// Use Version to verify we are on the right version.\n\tv, err = repo.Version()\n\tif v != \"2\" {\n\t\tt.Error(\"Error checking checked out Bzr version\")\n\t}\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tv, err = repo.Current()\n\tif err != nil {\n\t\tt.Errorf(\"Error trying Bzr Current: %s\", err)\n\t}\n\tif v != \"2\" {\n\t\tt.Errorf(\"Current failed to detect Bzr on rev 2 of branch. Got version: %s\", v)\n\t}\n\n\t// Use Date to verify we are on the right commit.\n\td, err := repo.Date()\n\tif d.Format(longForm) != \"2015-07-31 09:50:42 -0400\" {\n\t\tt.Error(\"Error checking checked out Bzr commit date\")\n\t}\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\t// Perform an update.\n\terr = repo.Update()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tv, err = repo.Version()\n\tif v != \"3\" {\n\t\tt.Error(\"Error checking checked out Bzr version\")\n\t}\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\ttags, err := repo.Tags()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif tags[0] != \"1.0.0\" {\n\t\tt.Error(\"Bzr tags is not reporting the correct version\")\n\t}\n\n\ttags, err = repo.TagsFromCommit(\"2\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif len(tags) != 0 {\n\t\tt.Error(\"Bzr is incorrectly returning tags for a commit\")\n\t}\n\n\ttags, err = repo.TagsFromCommit(\"3\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif len(tags) != 1 || tags[0] != \"1.0.0\" {\n\t\tt.Error(\"Bzr is incorrectly returning tags for a commit\")\n\t}\n\n\tbranches, err := repo.Branches()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif len(branches) != 0 {\n\t\tt.Error(\"Bzr is incorrectly returning branches\")\n\t}\n\n\tif !repo.IsReference(\"1.0.0\") {\n\t\tt.Error(\"Bzr is reporting a reference is not one\")\n\t}\n\n\tif repo.IsReference(\"foo\") {\n\t\tt.Error(\"Bzr is reporting a non-existent reference is one\")\n\t}\n\n\tif repo.IsDirty() {\n\t\tt.Error(\"Bzr incorrectly reporting dirty\")\n\t}\n\n\tci, err := repo.CommitInfo(\"3\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif ci.Commit != \"3\" {\n\t\tt.Error(\"Bzr.CommitInfo wrong commit id\")\n\t}\n\tif ci.Author != \"Matt Farina <matt@mattfarina.com>\" {\n\t\tt.Error(\"Bzr.CommitInfo wrong author\")\n\t}\n\tif ci.Message != \"Updated Readme with pointer.\" {\n\t\tt.Error(\"Bzr.CommitInfo wrong message\")\n\t}\n\tti, err := time.Parse(time.RFC1123Z, \"Fri, 31 Jul 2015 09:51:37 -0400\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif !ti.Equal(ci.Date) {\n\t\tt.Error(\"Bzr.CommitInfo wrong date\")\n\t}\n\n\t_, err = repo.CommitInfo(\"asdfasdfasdf\")\n\tif err != ErrRevisionUnavailable {\n\t\tt.Error(\"Bzr didn't return expected ErrRevisionUnavailable\")\n\t}\n\n\ttempDir2, err := ioutil.TempDir(\"\", \"go-vcs-bzr-tests-export\")\n\tif err != nil {\n\t\tt.Fatalf(\"Error creating temp directory: %s\", err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir2)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\texportDir := filepath.Join(tempDir2, \"src\")\n\n\terr = repo.ExportDir(exportDir)\n\tif err != nil {\n\t\tt.Errorf(\"Unable to export Bzr repo. Err was %s\", err)\n\t}\n\n\t_, err = os.Stat(filepath.Join(exportDir, \"Readme.md\"))\n\tif err != nil {\n\t\tt.Errorf(\"Error checking exported file in Bzr: %s\", err)\n\t}\n\n\t_, err = os.Stat(filepath.Join(exportDir, string(repo.Vcs())))\n\tif err != nil {\n\t\tif found := os.IsNotExist(err); !found {\n\t\t\tt.Errorf(\"Error checking exported metadata in Bzr: %s\", err)\n\t\t}\n\t} else {\n\t\tt.Error(\"Error checking Bzr metadata. It exists.\")\n\t}\n}\n\nfunc TestBzrCheckLocal(t *testing.T) {\n\t// Verify repo.CheckLocal fails for non-Bzr directories.\n\t// TestBzr is already checking on a valid repo\n\ttempDir, err := ioutil.TempDir(\"\", \"go-vcs-bzr-tests\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\trepo, _ := NewBzrRepo(\"\", tempDir)\n\tif repo.CheckLocal() {\n\t\tt.Error(\"Bzr CheckLocal does not identify non-Bzr location\")\n\t}\n\n\t// Test NewRepo when there's no local. This should simply provide a working\n\t// instance without error based on looking at the remote localtion.\n\t_, nrerr := NewRepo(\"https://launchpad.net/govcstestbzrrepo\", tempDir+\"/govcstestbzrrepo\")\n\tif nrerr != nil {\n\t\tt.Error(nrerr)\n\t}\n}\n\nfunc TestBzrPing(t *testing.T) {\n\ttempDir, err := ioutil.TempDir(\"\", \"go-vcs-bzr-tests\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\trepo, err := NewBzrRepo(\"https://launchpad.net/govcstestbzrrepo\", tempDir)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tping := repo.Ping()\n\tif !ping {\n\t\tt.Error(\"Bzr unable to ping working repo\")\n\t}\n\n\trepo, err = NewBzrRepo(\"https://launchpad.net/ihopethisneverexistsbecauseitshouldnt\", tempDir)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tping = repo.Ping()\n\tif ping {\n\t\tt.Error(\"Bzr got a ping response from when it should not have\")\n\t}\n}\n\nfunc TestBzrInit(t *testing.T) {\n\ttempDir, err := ioutil.TempDir(\"\", \"go-vcs-bzr-tests\")\n\trepoDir := tempDir + \"/repo\"\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\trepo, err := NewBzrRepo(repoDir, repoDir)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\terr = repo.Init()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tv, err := repo.Version()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif v != \"0\" {\n\t\tt.Errorf(\"Bzr Init returns wrong version: %s\", v)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/errors.go",
    "content": "package vcs\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n)\n\n// The vcs package provides ways to work with errors that hide the underlying\n// implementation details but make them accessible if needed. For basic errors\n// that do not have underlying implementation specific details or the underlying\n// details are not necessary there are errors for comparison.\n//\n// For example:\n//\n//     ci, err := repo.CommitInfo(\"123\")\n//     if err == vcs.ErrRevisionUnavailable {\n//         // The commit id was not available in the VCS.\n//     }\n//\n// There are other times where getting the details are more useful. For example,\n// if you're performing a repo.Get() and an error occurs. In general you'll want\n// to consistently know it failed. But, you may want to know the underlying\n// details (opt-in) to them. For those cases there is a different form of error\n// handling.\n//\n// For example:\n//\n//     err := repo.Get()\n//     if err != nil {\n//         // A RemoteError was returned. This has access to the output of the\n//         // vcs command, original error, and has a consistent cross vcs message.\n//     }\n//\n// The errors returned here can be used in type switches to detect the underlying\n// error. For example:\n//\n//     switch err.(type) {\n//     case *vcs.RemoteError:\n//         // This an error connecting to a remote system.\n//     }\n//\n// For more information on using type switches to detect error types you can\n// read the Go wiki at https://github.com/golang/go/wiki/Errors\n\nvar (\n\t// ErrWrongVCS is returned when an action is tried on the wrong VCS.\n\tErrWrongVCS = errors.New(\"Wrong VCS detected\")\n\n\t// ErrCannotDetectVCS is returned when VCS cannot be detected from URI string.\n\tErrCannotDetectVCS = errors.New(\"Cannot detect VCS\")\n\n\t// ErrWrongRemote occurs when the passed in remote does not match the VCS\n\t// configured endpoint.\n\tErrWrongRemote = errors.New(\"The Remote does not match the VCS endpoint\")\n\n\t// ErrRevisionUnavailable happens when commit revision information is\n\t// unavailable.\n\tErrRevisionUnavailable = errors.New(\"Revision unavailable\")\n)\n\n// RemoteError is returned when an operation fails against a remote repo\ntype RemoteError struct {\n\tvcsError\n}\n\n// NewRemoteError constructs a RemoteError\nfunc NewRemoteError(msg string, err error, out string) error {\n\te := &RemoteError{}\n\te.s = msg\n\te.e = err\n\te.o = out\n\n\treturn e\n}\n\n// LocalError is returned when a local operation has an error\ntype LocalError struct {\n\tvcsError\n}\n\n// NewLocalError constructs a LocalError\nfunc NewLocalError(msg string, err error, out string) error {\n\te := &LocalError{}\n\te.s = msg\n\te.e = err\n\te.o = out\n\n\treturn e\n}\n\ntype vcsError struct {\n\ts string\n\te error  // The original error\n\to string // The output from executing the command\n}\n\n// Error implements the Error interface\nfunc (e *vcsError) Error() string {\n\tif e.e == nil {\n\t\treturn e.s\n\t}\n\n\treturn fmt.Sprintf(\"%s: %v\", e.s, e.e)\n}\n\n// Original retrieves the underlying implementation specific error.\nfunc (e *vcsError) Original() error {\n\treturn e.e\n}\n\n// Out retrieves the output of the original command that was run.\nfunc (e *vcsError) Out() string {\n\treturn e.o\n}\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/errors_test.go",
    "content": "package vcs\n\nimport (\n\t\"errors\"\n\t\"testing\"\n)\n\nfunc TestNewRemoteError(t *testing.T) {\n\tbase := errors.New(\"Foo error\")\n\tout := \"This is a test\"\n\tmsg := \"remote error msg\"\n\n\te := NewRemoteError(msg, base, out)\n\n\tswitch e.(type) {\n\tcase *RemoteError:\n\t\t// This is the right error type\n\tdefault:\n\t\tt.Error(\"Wrong error type returned from NewRemoteError\")\n\t}\n}\n\nfunc TestNewLocalError(t *testing.T) {\n\tbase := errors.New(\"Foo error\")\n\tout := \"This is a test\"\n\tmsg := \"local error msg\"\n\n\te := NewLocalError(msg, base, out)\n\n\tswitch e.(type) {\n\tcase *LocalError:\n\t\t// This is the right error type\n\tdefault:\n\t\tt.Error(\"Wrong error type returned from NewLocalError\")\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/git.go",
    "content": "package vcs\n\nimport (\n\t\"bytes\"\n\t\"encoding/xml\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n\t\"runtime\"\n\t\"strings\"\n\t\"time\"\n)\n\n// NewGitRepo creates a new instance of GitRepo. The remote and local directories\n// need to be passed in.\nfunc NewGitRepo(remote, local string) (*GitRepo, error) {\n\tins := depInstalled(\"git\")\n\tif !ins {\n\t\treturn nil, NewLocalError(\"git is not installed\", nil, \"\")\n\t}\n\tltype, err := DetectVcsFromFS(local)\n\n\t// Found a VCS other than Git. Need to report an error.\n\tif err == nil && ltype != Git {\n\t\treturn nil, ErrWrongVCS\n\t}\n\n\tr := &GitRepo{}\n\tr.setRemote(remote)\n\tr.setLocalPath(local)\n\tr.RemoteLocation = \"origin\"\n\tr.Logger = Logger\n\n\t// Make sure the local Git repo is configured the same as the remote when\n\t// A remote value was passed in.\n\tif err == nil && r.CheckLocal() {\n\t\tc := exec.Command(\"git\", \"config\", \"--get\", \"remote.origin.url\")\n\t\tc.Dir = local\n\t\tc.Env = envForDir(c.Dir)\n\t\tout, err := c.CombinedOutput()\n\t\tif err != nil {\n\t\t\treturn nil, NewLocalError(\"Unable to retrieve local repo information\", err, string(out))\n\t\t}\n\n\t\tlocalRemote := strings.TrimSpace(string(out))\n\t\tif remote != \"\" && localRemote != remote {\n\t\t\treturn nil, ErrWrongRemote\n\t\t}\n\n\t\t// If no remote was passed in but one is configured for the locally\n\t\t// checked out Git repo use that one.\n\t\tif remote == \"\" && localRemote != \"\" {\n\t\t\tr.setRemote(localRemote)\n\t\t}\n\t}\n\n\treturn r, nil\n}\n\n// GitRepo implements the Repo interface for the Git source control.\ntype GitRepo struct {\n\tbase\n\tRemoteLocation string\n}\n\n// Vcs retrieves the underlying VCS being implemented.\nfunc (s GitRepo) Vcs() Type {\n\treturn Git\n}\n\n// Get is used to perform an initial clone of a repository.\nfunc (s *GitRepo) Get() error {\n\tout, err := s.run(\"git\", \"clone\", \"--recursive\", s.Remote(), s.LocalPath())\n\n\t// There are some windows cases where Git cannot create the parent directory,\n\t// if it does not already exist, to the location it's trying to create the\n\t// repo. Catch that error and try to handle it.\n\tif err != nil && s.isUnableToCreateDir(err) {\n\n\t\tbasePath := filepath.Dir(filepath.FromSlash(s.LocalPath()))\n\t\tif _, err := os.Stat(basePath); os.IsNotExist(err) {\n\t\t\terr = os.MkdirAll(basePath, 0755)\n\t\t\tif err != nil {\n\t\t\t\treturn NewLocalError(\"Unable to create directory\", err, \"\")\n\t\t\t}\n\n\t\t\tout, err = s.run(\"git\", \"clone\", s.Remote(), s.LocalPath())\n\t\t\tif err != nil {\n\t\t\t\treturn NewRemoteError(\"Unable to get repository\", err, string(out))\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\n\t} else if err != nil {\n\t\treturn NewRemoteError(\"Unable to get repository\", err, string(out))\n\t}\n\n\treturn nil\n}\n\n// Init initializes a git repository at local location.\nfunc (s *GitRepo) Init() error {\n\tout, err := s.run(\"git\", \"init\", s.LocalPath())\n\n\t// There are some windows cases where Git cannot create the parent directory,\n\t// if it does not already exist, to the location it's trying to create the\n\t// repo. Catch that error and try to handle it.\n\tif err != nil && s.isUnableToCreateDir(err) {\n\n\t\tbasePath := filepath.Dir(filepath.FromSlash(s.LocalPath()))\n\t\tif _, err := os.Stat(basePath); os.IsNotExist(err) {\n\t\t\terr = os.MkdirAll(basePath, 0755)\n\t\t\tif err != nil {\n\t\t\t\treturn NewLocalError(\"Unable to initialize repository\", err, \"\")\n\t\t\t}\n\n\t\t\tout, err = s.run(\"git\", \"init\", s.LocalPath())\n\t\t\tif err != nil {\n\t\t\t\treturn NewLocalError(\"Unable to initialize repository\", err, string(out))\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\n\t} else if err != nil {\n\t\treturn NewLocalError(\"Unable to initialize repository\", err, string(out))\n\t}\n\n\treturn nil\n}\n\n// Update performs an Git fetch and pull to an existing checkout.\nfunc (s *GitRepo) Update() error {\n\t// Perform a fetch to make sure everything is up to date.\n\tout, err := s.RunFromDir(\"git\", \"fetch\", \"--tags\", s.RemoteLocation)\n\tif err != nil {\n\t\treturn NewRemoteError(\"Unable to update repository\", err, string(out))\n\t}\n\n\t// When in a detached head state, such as when an individual commit is checked\n\t// out do not attempt a pull. It will cause an error.\n\tdetached, err := isDetachedHead(s.LocalPath())\n\tif err != nil {\n\t\treturn NewLocalError(\"Unable to update repository\", err, \"\")\n\t}\n\n\tif detached {\n\t\treturn nil\n\t}\n\n\tout, err = s.RunFromDir(\"git\", \"pull\")\n\tif err != nil {\n\t\treturn NewRemoteError(\"Unable to update repository\", err, string(out))\n\t}\n\n\treturn s.defendAgainstSubmodules()\n}\n\n// UpdateVersion sets the version of a package currently checked out via Git.\nfunc (s *GitRepo) UpdateVersion(version string) error {\n\tout, err := s.RunFromDir(\"git\", \"checkout\", version)\n\tif err != nil {\n\t\treturn NewLocalError(\"Unable to update checked out version\", err, string(out))\n\t}\n\n\treturn s.defendAgainstSubmodules()\n}\n\n// defendAgainstSubmodules tries to keep repo state sane in the event of\n// submodules. Or nested submodules. What a great idea, submodules.\nfunc (s *GitRepo) defendAgainstSubmodules() error {\n\t// First, update them to whatever they should be, if there should happen to be any.\n\tout, err := s.RunFromDir(\"git\", \"submodule\", \"update\", \"--init\", \"--recursive\")\n\tif err != nil {\n\t\treturn NewLocalError(\"Unexpected error while defensively updating submodules\", err, string(out))\n\t}\n\t// Now, do a special extra-aggressive clean in case changing versions caused\n\t// one or more submodules to go away.\n\tout, err = s.RunFromDir(\"git\", \"clean\", \"-x\", \"-d\", \"-f\", \"-f\")\n\tif err != nil {\n\t\treturn NewLocalError(\"Unexpected error while defensively cleaning up after possible derelict submodule directories\", err, string(out))\n\t}\n\t// Then, repeat just in case there are any nested submodules that went away.\n\tout, err = s.RunFromDir(\"git\", \"submodule\", \"foreach\", \"--recursive\", \"git clean -x -d -f -f\")\n\tif err != nil {\n\t\treturn NewLocalError(\"Unexpected error while defensively cleaning up after possible derelict nested submodule directories\", err, string(out))\n\t}\n\n\treturn nil\n}\n\n// Version retrieves the current version.\nfunc (s *GitRepo) Version() (string, error) {\n\tout, err := s.RunFromDir(\"git\", \"rev-parse\", \"HEAD\")\n\tif err != nil {\n\t\treturn \"\", NewLocalError(\"Unable to retrieve checked out version\", err, string(out))\n\t}\n\n\treturn strings.TrimSpace(string(out)), nil\n}\n\n// Current returns the current version-ish. This means:\n// * Branch name if on the tip of the branch\n// * Tag if on a tag\n// * Otherwise a revision id\nfunc (s *GitRepo) Current() (string, error) {\n\tout, err := s.RunFromDir(\"git\", \"symbolic-ref\", \"HEAD\")\n\tif err == nil {\n\t\to := bytes.TrimSpace(bytes.TrimPrefix(out, []byte(\"refs/heads/\")))\n\t\treturn string(o), nil\n\t}\n\n\tv, err := s.Version()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tts, err := s.TagsFromCommit(v)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif len(ts) > 0 {\n\t\treturn ts[0], nil\n\t}\n\n\treturn v, nil\n}\n\n// Date retrieves the date on the latest commit.\nfunc (s *GitRepo) Date() (time.Time, error) {\n\tout, err := s.RunFromDir(\"git\", \"log\", \"-1\", \"--date=iso\", \"--pretty=format:%cd\")\n\tif err != nil {\n\t\treturn time.Time{}, NewLocalError(\"Unable to retrieve revision date\", err, string(out))\n\t}\n\tt, err := time.Parse(longForm, string(out))\n\tif err != nil {\n\t\treturn time.Time{}, NewLocalError(\"Unable to retrieve revision date\", err, string(out))\n\t}\n\treturn t, nil\n}\n\n// Branches returns a list of available branches on the RemoteLocation\nfunc (s *GitRepo) Branches() ([]string, error) {\n\tout, err := s.RunFromDir(\"git\", \"show-ref\")\n\tif err != nil {\n\t\treturn []string{}, NewLocalError(\"Unable to retrieve branches\", err, string(out))\n\t}\n\tbranches := s.referenceList(string(out), `(?m-s)(?:`+s.RemoteLocation+`)/(\\S+)$`)\n\treturn branches, nil\n}\n\n// Tags returns a list of available tags on the RemoteLocation\nfunc (s *GitRepo) Tags() ([]string, error) {\n\tout, err := s.RunFromDir(\"git\", \"show-ref\")\n\tif err != nil {\n\t\treturn []string{}, NewLocalError(\"Unable to retrieve tags\", err, string(out))\n\t}\n\ttags := s.referenceList(string(out), `(?m-s)(?:tags)/(\\S+)$`)\n\treturn tags, nil\n}\n\n// CheckLocal verifies the local location is a Git repo.\nfunc (s *GitRepo) CheckLocal() bool {\n\tif _, err := os.Stat(s.LocalPath() + \"/.git\"); err == nil {\n\t\treturn true\n\t}\n\n\treturn false\n}\n\n// IsReference returns if a string is a reference. A reference can be a\n// commit id, branch, or tag.\nfunc (s *GitRepo) IsReference(r string) bool {\n\t_, err := s.RunFromDir(\"git\", \"rev-parse\", \"--verify\", r)\n\tif err == nil {\n\t\treturn true\n\t}\n\n\t// Some refs will fail rev-parse. For example, a remote branch that has\n\t// not been checked out yet. This next step should pickup the other\n\t// possible references.\n\t_, err = s.RunFromDir(\"git\", \"show-ref\", r)\n\treturn err == nil\n}\n\n// IsDirty returns if the checkout has been modified from the checked\n// out reference.\nfunc (s *GitRepo) IsDirty() bool {\n\tout, err := s.RunFromDir(\"git\", \"diff\")\n\treturn err != nil || len(out) != 0\n}\n\n// CommitInfo retrieves metadata about a commit.\nfunc (s *GitRepo) CommitInfo(id string) (*CommitInfo, error) {\n\tfm := `--pretty=format:\"<logentry><commit>%H</commit><author>%an &lt;%ae&gt;</author><date>%aD</date><message>%s</message></logentry>\"`\n\tout, err := s.RunFromDir(\"git\", \"log\", id, fm, \"-1\")\n\tif err != nil {\n\t\treturn nil, ErrRevisionUnavailable\n\t}\n\n\tcis := struct {\n\t\tCommit  string `xml:\"commit\"`\n\t\tAuthor  string `xml:\"author\"`\n\t\tDate    string `xml:\"date\"`\n\t\tMessage string `xml:\"message\"`\n\t}{}\n\terr = xml.Unmarshal(out, &cis)\n\tif err != nil {\n\t\treturn nil, NewLocalError(\"Unable to retrieve commit information\", err, string(out))\n\t}\n\n\tt, err := time.Parse(\"Mon, _2 Jan 2006 15:04:05 -0700\", cis.Date)\n\tif err != nil {\n\t\treturn nil, NewLocalError(\"Unable to retrieve commit information\", err, string(out))\n\t}\n\n\tci := &CommitInfo{\n\t\tCommit:  cis.Commit,\n\t\tAuthor:  cis.Author,\n\t\tDate:    t,\n\t\tMessage: cis.Message,\n\t}\n\n\treturn ci, nil\n}\n\n// TagsFromCommit retrieves tags from a commit id.\nfunc (s *GitRepo) TagsFromCommit(id string) ([]string, error) {\n\t// This is imperfect and a better method would be great.\n\n\tvar re []string\n\n\tout, err := s.RunFromDir(\"git\", \"show-ref\", \"-d\")\n\tif err != nil {\n\t\treturn []string{}, NewLocalError(\"Unable to retrieve tags\", err, string(out))\n\t}\n\n\tlines := strings.Split(string(out), \"\\n\")\n\tvar list []string\n\tfor _, i := range lines {\n\t\tif strings.HasPrefix(strings.TrimSpace(i), id) {\n\t\t\tlist = append(list, i)\n\t\t}\n\t}\n\ttags := s.referenceList(strings.Join(list, \"\\n\"), `(?m-s)(?:tags)/(\\S+)$`)\n\tfor _, t := range tags {\n\t\t// Dereferenced tags have ^{} appended to them.\n\t\tre = append(re, strings.TrimSuffix(t, \"^{}\"))\n\t}\n\n\treturn re, nil\n}\n\n// Ping returns if remote location is accessible.\nfunc (s *GitRepo) Ping() bool {\n\tc := exec.Command(\"git\", \"ls-remote\", s.Remote())\n\n\t// If prompted for a username and password, which GitHub does for all things\n\t// not public, it's considered not available. To make it available the\n\t// remote needs to be different.\n\tc.Env = mergeEnvLists([]string{\"GIT_TERMINAL_PROMPT=0\"}, os.Environ())\n\t_, err := c.CombinedOutput()\n\treturn err == nil\n}\n\n// EscapePathSeparator escapes the path separator by replacing it with several.\n// Note: this is harmless on Unix, and needed on Windows.\nfunc EscapePathSeparator(path string) string {\n\tswitch runtime.GOOS {\n\tcase `windows`:\n\t\t// On Windows, triple all path separators.\n\t\t// Needed to escape backslash(s) preceding doublequotes,\n\t\t// because of how Windows strings treats backslash+doublequote combo,\n\t\t// and Go seems to be implicitly passing around a doublequoted string on Windows,\n\t\t// so we cannot use default string instead.\n\t\t// See: https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/\n\t\t// e.g., C:\\foo\\bar\\ -> C:\\\\\\foo\\\\\\bar\\\\\\\n\t\t// used with --prefix, like this: --prefix=C:\\foo\\bar\\ -> --prefix=C:\\\\\\foo\\\\\\bar\\\\\\\n\t\treturn strings.Replace(path,\n\t\t\tstring(os.PathSeparator),\n\t\t\tstring(os.PathSeparator)+string(os.PathSeparator)+string(os.PathSeparator),\n\t\t\t-1)\n\tdefault:\n\t\treturn path\n\t}\n}\n\n// ExportDir exports the current revision to the passed in directory.\nfunc (s *GitRepo) ExportDir(dir string) error {\n\n\tvar path string\n\n\t// Without the trailing / there can be problems.\n\tif !strings.HasSuffix(dir, string(os.PathSeparator)) {\n\t\tdir = dir + string(os.PathSeparator)\n\t}\n\n\t// checkout-index on some systems, such as some Windows cases, does not\n\t// create the parent directory to export into if it does not exist. Explicitly\n\t// creating it.\n\terr := os.MkdirAll(dir, 0755)\n\tif err != nil {\n\t\treturn NewLocalError(\"Unable to create directory\", err, \"\")\n\t}\n\n\tpath = EscapePathSeparator(dir)\n\tout, err := s.RunFromDir(\"git\", \"checkout-index\", \"-f\", \"-a\", \"--prefix=\"+path)\n\ts.log(out)\n\tif err != nil {\n\t\treturn NewLocalError(\"Unable to export source\", err, string(out))\n\t}\n\n\t// and now, the horror of submodules\n\tpath = EscapePathSeparator(dir + \"$path\" + string(os.PathSeparator))\n\tout, err = s.RunFromDir(\"git\", \"submodule\", \"foreach\", \"--recursive\", \"git checkout-index -f -a --prefix=\"+path)\n\ts.log(out)\n\tif err != nil {\n\t\treturn NewLocalError(\"Error while exporting submodule sources\", err, string(out))\n\t}\n\n\treturn nil\n}\n\n// isDetachedHead will detect if git repo is in \"detached head\" state.\nfunc isDetachedHead(dir string) (bool, error) {\n\tp := filepath.Join(dir, \".git\", \"HEAD\")\n\tcontents, err := ioutil.ReadFile(p)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\tcontents = bytes.TrimSpace(contents)\n\tif bytes.HasPrefix(contents, []byte(\"ref: \")) {\n\t\treturn false, nil\n\t}\n\n\treturn true, nil\n}\n\n// isUnableToCreateDir checks for an error in Init() to see if an error\n// where the parent directory of the VCS local path doesn't exist. This is\n// done in a multi-lingual manner.\nfunc (s *GitRepo) isUnableToCreateDir(err error) bool {\n\tmsg := err.Error()\n\tif strings.HasPrefix(msg, \"could not create work tree dir\") ||\n\t\tstrings.HasPrefix(msg, \"不能创建工作区目录\") ||\n\t\tstrings.HasPrefix(msg, \"no s'ha pogut crear el directori d'arbre de treball\") ||\n\t\tstrings.HasPrefix(msg, \"impossible de créer le répertoire de la copie de travail\") ||\n\t\tstrings.HasPrefix(msg, \"kunde inte skapa arbetskatalogen\") ||\n\t\t(strings.HasPrefix(msg, \"Konnte Arbeitsverzeichnis\") && strings.Contains(msg, \"nicht erstellen\")) ||\n\t\t(strings.HasPrefix(msg, \"작업 디렉터리를\") && strings.Contains(msg, \"만들 수 없습니다\")) {\n\t\treturn true\n\t}\n\n\treturn false\n}\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/git_test.go",
    "content": "package vcs\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"path/filepath\"\n\t\"time\"\n\t//\"log\"\n\t\"os\"\n\t\"testing\"\n)\n\n// Canary test to ensure GitRepo implements the Repo interface.\nvar _ Repo = &GitRepo{}\n\n// To verify git is working we perform integration testing\n// with a known git service.\n\nfunc TestGit(t *testing.T) {\n\ttempDir, err := ioutil.TempDir(\"\", \"go-vcs-git-tests\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\trepo, err := NewGitRepo(\"https://github.com/Masterminds/VCSTestRepo\", tempDir+\"/VCSTestRepo\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tif repo.Vcs() != Git {\n\t\tt.Error(\"Git is detecting the wrong type\")\n\t}\n\n\t// Check the basic getters.\n\tif repo.Remote() != \"https://github.com/Masterminds/VCSTestRepo\" {\n\t\tt.Error(\"Remote not set properly\")\n\t}\n\tif repo.LocalPath() != tempDir+\"/VCSTestRepo\" {\n\t\tt.Error(\"Local disk location not set properly\")\n\t}\n\n\t//Logger = log.New(os.Stdout, \"\", log.LstdFlags)\n\n\t// Do an initial clone.\n\terr = repo.Get()\n\tif err != nil {\n\t\tt.Errorf(\"Unable to clone Git repo. Err was %s\", err)\n\t}\n\n\t// Verify Git repo is a Git repo\n\tif !repo.CheckLocal() {\n\t\tt.Error(\"Problem checking out repo or Git CheckLocal is not working\")\n\t}\n\n\t// Test internal lookup mechanism used outside of Git specific functionality.\n\tltype, err := DetectVcsFromFS(tempDir + \"/VCSTestRepo\")\n\tif err != nil {\n\t\tt.Error(\"detectVcsFromFS unable to Git repo\")\n\t}\n\tif ltype != Git {\n\t\tt.Errorf(\"detectVcsFromFS detected %s instead of Git type\", ltype)\n\t}\n\n\t// Test NewRepo on existing checkout. This should simply provide a working\n\t// instance without error based on looking at the local directory.\n\tnrepo, nrerr := NewRepo(\"https://github.com/Masterminds/VCSTestRepo\", tempDir+\"/VCSTestRepo\")\n\tif nrerr != nil {\n\t\tt.Error(nrerr)\n\t}\n\t// Verify the right oject is returned. It will check the local repo type.\n\tif !nrepo.CheckLocal() {\n\t\tt.Error(\"Wrong version returned from NewRepo\")\n\t}\n\n\t// Perform an update.\n\terr = repo.Update()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tv, err := repo.Current()\n\tif err != nil {\n\t\tt.Errorf(\"Error trying Git Current: %s\", err)\n\t}\n\tif v != \"master\" {\n\t\tt.Errorf(\"Current failed to detect Git on tip of master. Got version: %s\", v)\n\t}\n\n\t// Set the version using the short hash.\n\terr = repo.UpdateVersion(\"806b07b\")\n\tif err != nil {\n\t\tt.Errorf(\"Unable to update Git repo version. Err was %s\", err)\n\t}\n\n\t// Once a ref has been checked out the repo is in a detached head state.\n\t// Trying to pull in an update in this state will cause an error. Update\n\t// should cleanly handle this. Pulling on a branch (tested elsewhere) and\n\t// skipping that here.\n\terr = repo.Update()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\t// Use Version to verify we are on the right version.\n\tv, err = repo.Version()\n\tif v != \"806b07b08faa21cfbdae93027904f80174679402\" {\n\t\tt.Error(\"Error checking checked out Git version\")\n\t}\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tv, err = repo.Current()\n\tif err != nil {\n\t\tt.Errorf(\"Error trying Git Current for ref: %s\", err)\n\t}\n\tif v != \"806b07b08faa21cfbdae93027904f80174679402\" {\n\t\tt.Errorf(\"Current failed to detect Git on ref of branch. Got version: %s\", v)\n\t}\n\n\t// Use Date to verify we are on the right commit.\n\td, err := repo.Date()\n\tif d.Format(longForm) != \"2015-07-29 09:46:39 -0400\" {\n\t\tt.Error(\"Error checking checked out Git commit date\")\n\t}\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\t// Verify that we can set the version something other than short hash\n\terr = repo.UpdateVersion(\"master\")\n\tif err != nil {\n\t\tt.Errorf(\"Unable to update Git repo version. Err was %s\", err)\n\t}\n\terr = repo.UpdateVersion(\"806b07b08faa21cfbdae93027904f80174679402\")\n\tif err != nil {\n\t\tt.Errorf(\"Unable to update Git repo version. Err was %s\", err)\n\t}\n\tv, err = repo.Version()\n\tif v != \"806b07b08faa21cfbdae93027904f80174679402\" {\n\t\tt.Error(\"Error checking checked out Git version\")\n\t}\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\ttags, err := repo.Tags()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tvar hasRelTag bool\n\tvar hasOffMasterTag bool\n\n\tfor _, tv := range tags {\n\t\tif tv == \"1.0.0\" {\n\t\t\thasRelTag = true\n\t\t} else if tv == \"off-master-tag\" {\n\t\t\thasOffMasterTag = true\n\t\t}\n\t}\n\n\tif !hasRelTag {\n\t\tt.Error(\"Git tags unable to find release tag on master\")\n\t}\n\tif !hasOffMasterTag {\n\t\tt.Error(\"Git tags did not fetch tags not on master\")\n\t}\n\n\ttags, err = repo.TagsFromCommit(\"74dd547545b7df4aa285bcec1b54e2b76f726395\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif len(tags) != 0 {\n\t\tt.Error(\"Git is incorrectly returning tags for a commit\")\n\t}\n\n\ttags, err = repo.TagsFromCommit(\"30605f6ac35fcb075ad0bfa9296f90a7d891523e\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif len(tags) != 1 || tags[0] != \"1.0.0\" {\n\t\tt.Error(\"Git is incorrectly returning tags for a commit\")\n\t}\n\n\tbranches, err := repo.Branches()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\t// The branches should be HEAD, master, other, and test.\n\tif branches[3] != \"test\" {\n\t\tt.Error(\"Git is incorrectly returning branches\")\n\t}\n\n\tif !repo.IsReference(\"1.0.0\") {\n\t\tt.Error(\"Git is reporting a reference is not one\")\n\t}\n\n\tif repo.IsReference(\"foo\") {\n\t\tt.Error(\"Git is reporting a non-existent reference is one\")\n\t}\n\n\tif repo.IsDirty() {\n\t\tt.Error(\"Git incorrectly reporting dirty\")\n\t}\n\n\tci, err := repo.CommitInfo(\"806b07b08faa21cfbdae93027904f80174679402\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif ci.Commit != \"806b07b08faa21cfbdae93027904f80174679402\" {\n\t\tt.Error(\"Git.CommitInfo wrong commit id\")\n\t}\n\tif ci.Author != \"Matt Farina <matt@mattfarina.com>\" {\n\t\tt.Error(\"Git.CommitInfo wrong author\")\n\t}\n\tif ci.Message != \"Update README.md\" {\n\t\tt.Error(\"Git.CommitInfo wrong message\")\n\t}\n\tti, err := time.Parse(time.RFC1123Z, \"Wed, 29 Jul 2015 09:46:39 -0400\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif !ti.Equal(ci.Date) {\n\t\tt.Error(\"Git.CommitInfo wrong date\")\n\t}\n\n\t_, err = repo.CommitInfo(\"asdfasdfasdf\")\n\tif err != ErrRevisionUnavailable {\n\t\tt.Error(\"Git didn't return expected ErrRevisionUnavailable\")\n\t}\n\n\ttempDir2, err := ioutil.TempDir(\"\", \"go-vcs-git-tests-export\")\n\tif err != nil {\n\t\tt.Fatalf(\"Error creating temp directory: %s\", err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir2)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\texportDir := filepath.Join(tempDir2, \"src\")\n\n\terr = repo.ExportDir(exportDir)\n\tif err != nil {\n\t\tt.Errorf(\"Unable to export Git repo. Err was %s\", err)\n\t}\n\n\t_, err = os.Stat(filepath.Join(exportDir, \"README.md\"))\n\tif err != nil {\n\t\tt.Errorf(\"Error checking exported file in Git: %s\", err)\n\t}\n\n\t_, err = os.Stat(filepath.Join(exportDir, string(repo.Vcs())))\n\tif err != nil {\n\t\tif found := os.IsNotExist(err); !found {\n\t\t\tt.Errorf(\"Error checking exported metadata in Git: %s\", err)\n\t\t}\n\t} else {\n\t\tt.Error(\"Error checking Git metadata. It exists.\")\n\t}\n}\n\nfunc TestGitCheckLocal(t *testing.T) {\n\t// Verify repo.CheckLocal fails for non-Git directories.\n\t// TestGit is already checking on a valid repo\n\ttempDir, err := ioutil.TempDir(\"\", \"go-vcs-git-tests\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\trepo, _ := NewGitRepo(\"\", tempDir)\n\tif repo.CheckLocal() {\n\t\tt.Error(\"Git CheckLocal does not identify non-Git location\")\n\t}\n\n\t// Test NewRepo when there's no local. This should simply provide a working\n\t// instance without error based on looking at the remote localtion.\n\t_, nrerr := NewRepo(\"https://github.com/Masterminds/VCSTestRepo\", tempDir+\"/VCSTestRepo\")\n\tif nrerr != nil {\n\t\tt.Error(nrerr)\n\t}\n}\n\nfunc TestGitPing(t *testing.T) {\n\ttempDir, err := ioutil.TempDir(\"\", \"go-vcs-git-tests\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\trepo, err := NewGitRepo(\"https://github.com/Masterminds/VCSTestRepo\", tempDir)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tping := repo.Ping()\n\tif !ping {\n\t\tt.Error(\"Git unable to ping working repo\")\n\t}\n\n\trepo, err = NewGitRepo(\"https://github.com/Masterminds/ihopethisneverexistsbecauseitshouldnt\", tempDir)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tping = repo.Ping()\n\tif ping {\n\t\tt.Error(\"Git got a ping response from when it should not have\")\n\t}\n}\n\nfunc TestGitInit(t *testing.T) {\n\ttempDir, err := ioutil.TempDir(\"\", \"go-vcs-git-tests\")\n\trepoDir := tempDir + \"/repo\"\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\trepo, err := NewGitRepo(repoDir, repoDir)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\terr = repo.Init()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\t_, err = repo.RunFromDir(\"git\", \"status\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n}\n\nfunc TestGitSubmoduleHandling(t *testing.T) {\n\ttempDir, err := ioutil.TempDir(\"\", \"go-vcs-git-submodule-tests\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\tdumplocal := func(err error) string {\n\t\tif terr, ok := err.(*LocalError); ok {\n\t\t\treturn fmt.Sprintf(\"msg: %s\\norig: %s\\nout: %s\", terr.Error(), terr.Original(), terr.Out())\n\t\t}\n\t\treturn err.Error()\n\t}\n\n\tsubdirExists := func(dir ...string) bool {\n\t\t_, err := os.Stat(filepath.Join(append([]string{tempDir}, dir...)...))\n\t\treturn err == nil\n\t}\n\n\t// Initial clone should get version with two submodules, each of which have\n\t// their own submodule\n\trepo, err := NewGitRepo(\"https://github.com/sdboyer/subm\", tempDir)\n\tif err != nil {\n\t\tt.Fatal(dumplocal(err))\n\t}\n\terr = repo.Get()\n\tif err != nil {\n\t\tt.Fatalf(\"unable to clone Git repo. Err was %s\", dumplocal(err))\n\t}\n\n\t// Verify we are on the right version.\n\tv, err := repo.Version()\n\tif v != \"18e3a5f6fc7f6d577e732e7a5ab2caf990efbf8f\" {\n\t\tt.Fatalf(\"did not start from expected rev, tests could fail - bailing out (got %s)\", v)\n\t}\n\tif err != nil {\n\t\tt.Fatal(dumplocal(err))\n\t}\n\n\tif !subdirExists(\"subm1\", \".git\") {\n\t\tt.Fatal(\"subm1 submodule does not exist on initial clone/checkout\")\n\t}\n\tif !subdirExists(\"subm1\", \"dep-test\", \".git\") {\n\t\tt.Fatal(\"dep-test submodule nested under subm1 does not exist on initial clone/checkout\")\n\t}\n\n\tif !subdirExists(\"subm-again\", \".git\") {\n\t\tt.Fatal(\"subm-again submodule does not exist on initial clone/checkout\")\n\t}\n\tif !subdirExists(\"subm-again\", \"dep-test\", \".git\") {\n\t\tt.Fatal(\"dep-test submodule nested under subm-again does not exist on initial clone/checkout\")\n\t}\n\n\t// Now switch to version with no submodules, make sure they all go away\n\terr = repo.UpdateVersion(\"e677f82015f72ac1c8fafa66b5463163b3597af2\")\n\tif err != nil {\n\t\tt.Fatalf(\"checking out needed version failed with err: %s\", dumplocal(err))\n\t}\n\n\tif subdirExists(\"subm1\") {\n\t\tt.Fatal(\"checking out version without submodule did not clean up immediate submodules\")\n\t}\n\tif subdirExists(\"subm1\", \"dep-test\") {\n\t\tt.Fatal(\"checking out version without submodule did not clean up nested submodules\")\n\t}\n\tif subdirExists(\"subm-again\") {\n\t\tt.Fatal(\"checking out version without submodule did not clean up immediate submodules\")\n\t}\n\tif subdirExists(\"subm-again\", \"dep-test\") {\n\t\tt.Fatal(\"checking out version without submodule did not clean up nested submodules\")\n\t}\n\n\terr = repo.UpdateVersion(\"aaf7aa1bc4c3c682cc530eca8f80417088ee8540\")\n\tif err != nil {\n\t\tt.Fatalf(\"checking out needed version failed with err: %s\", dumplocal(err))\n\t}\n\n\tif !subdirExists(\"subm1\", \".git\") {\n\t\tt.Fatal(\"checking out version with immediate submodule did not set up git subrepo\")\n\t}\n\n\terr = repo.UpdateVersion(\"6cc4669af468f3b4f16e7e96275ad01ade5b522f\")\n\tif err != nil {\n\t\tt.Fatalf(\"checking out needed version failed with err: %s\", dumplocal(err))\n\t}\n\n\tif !subdirExists(\"subm1\", \"dep-test\", \".git\") {\n\t\tt.Fatal(\"checking out version with nested submodule did not set up nested git subrepo\")\n\t}\n\n\terr = repo.UpdateVersion(\"aaf7aa1bc4c3c682cc530eca8f80417088ee8540\")\n\tif err != nil {\n\t\tt.Fatalf(\"checking out needed version failed with err: %s\", dumplocal(err))\n\t}\n\n\tif subdirExists(\"subm1\", \"dep-test\") {\n\t\tt.Fatal(\"rolling back to version without nested submodule did not clean up the nested submodule\")\n\t}\n\n\terr = repo.UpdateVersion(\"18e3a5f6fc7f6d577e732e7a5ab2caf990efbf8f\")\n\tif err != nil {\n\t\tt.Fatalf(\"checking out needed version failed with err: %s\", dumplocal(err))\n\t}\n\n\tif !subdirExists(\"subm1\", \".git\") {\n\t\tt.Fatal(\"subm1 submodule does not exist after switch from other commit\")\n\t}\n\tif !subdirExists(\"subm1\", \"dep-test\", \".git\") {\n\t\tt.Fatal(\"dep-test submodule nested under subm1 does not exist after switch from other commit\")\n\t}\n\n\tif !subdirExists(\"subm-again\", \".git\") {\n\t\tt.Fatal(\"subm-again submodule does not exist after switch from other commit\")\n\t}\n\tif !subdirExists(\"subm-again\", \"dep-test\", \".git\") {\n\t\tt.Fatal(\"dep-test submodule nested under subm-again does not exist after switch from other commit\")\n\t}\n\n}\n\nfunc TestGitSubmoduleHandling2(t *testing.T) {\n\ttempDir, err := ioutil.TempDir(\"\", \"go-vcs-git-submodule-tests2\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\trepo, err := NewGitRepo(\"https://github.com/cloudfoundry/sonde-go\", tempDir+\"/VCSTestRepo2\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tif repo.Vcs() != Git {\n\t\tt.Error(\"Git is detecting the wrong type\")\n\t}\n\n\t// Check the basic getters.\n\tif repo.Remote() != \"https://github.com/cloudfoundry/sonde-go\" {\n\t\tt.Error(\"Remote not set properly\")\n\t}\n\tif repo.LocalPath() != tempDir+\"/VCSTestRepo2\" {\n\t\tt.Error(\"Local disk location not set properly\")\n\t}\n\n\t//Logger = log.New(os.Stdout, \"\", log.LstdFlags)\n\n\t// Do an initial clone.\n\terr = repo.Get()\n\tif err != nil {\n\t\tt.Errorf(\"Unable to clone Git repo. Err was %s\", err)\n\t}\n\n\t// Verify Git repo is a Git repo\n\tif !repo.CheckLocal() {\n\t\tt.Error(\"Problem checking out repo or Git CheckLocal is not working\")\n\t}\n\n\t// Test internal lookup mechanism used outside of Git specific functionality.\n\tltype, err := DetectVcsFromFS(tempDir + \"/VCSTestRepo2\")\n\tif err != nil {\n\t\tt.Error(\"detectVcsFromFS unable to Git repo\")\n\t}\n\tif ltype != Git {\n\t\tt.Errorf(\"detectVcsFromFS detected %s instead of Git type\", ltype)\n\t}\n\n\t// Test NewRepo on existing checkout. This should simply provide a working\n\t// instance without error based on looking at the local directory.\n\tnrepo, nrerr := NewRepo(\"https://github.com/cloudfoundry/sonde-go\", tempDir+\"/VCSTestRepo2\")\n\tif nrerr != nil {\n\t\tt.Error(nrerr)\n\t}\n\t// Verify the right oject is returned. It will check the local repo type.\n\tif !nrepo.CheckLocal() {\n\t\tt.Error(\"Wrong version returned from NewRepo\")\n\t}\n\n\t// Perform an update.\n\terr = repo.Update()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tv, err := repo.Current()\n\tif err != nil {\n\t\tt.Errorf(\"Error trying Git Current: %s\", err)\n\t}\n\tif v != \"master\" {\n\t\tt.Errorf(\"Current failed to detect Git on tip of master. Got version: %s\", v)\n\t}\n\n\ttempDir2, err := ioutil.TempDir(\"\", \"go-vcs-git-tests-export\")\n\tif err != nil {\n\t\tt.Fatalf(\"Error creating temp directory: %s\", err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir2)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\texportDir := filepath.Join(tempDir2, \"src\")\n\n\terr = repo.ExportDir(exportDir)\n\tif err != nil {\n\t\tt.Errorf(\"Unable to export Git repo. Err was %s\", err)\n\t}\n\n\t_, err = os.Stat(filepath.Join(exportDir, \"README.md\"))\n\tif err != nil {\n\t\tt.Errorf(\"Error checking exported file in Git: %s\", err)\n\t}\n\n\t_, err = os.Stat(filepath.Join(filepath.Join(exportDir, \"definitions\"), \"README.md\"))\n\tif err != nil {\n\t\tt.Errorf(\"Error checking exported file in Git: %s\", err)\n\t}\n\n\t_, err = os.Stat(filepath.Join(exportDir, string(repo.Vcs())))\n\tif err != nil {\n\t\tif found := os.IsNotExist(err); !found {\n\t\t\tt.Errorf(\"Error checking exported metadata in Git: %s\", err)\n\t\t}\n\t} else {\n\t\tt.Error(\"Error checking Git metadata. It exists.\")\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/glide.yaml",
    "content": "package: github.com/Masterminds/vcs\nhomepage: https://github.com/Masterminds/vcs\nlicense: MIT\nowners:\n- name: Matt Farina\n  email: matt@mattfarina.com\n  homepage: https://www.mattfarina.com/\nimport: []\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/hg.go",
    "content": "package vcs\n\nimport (\n\t\"bytes\"\n\t\"encoding/xml\"\n\t\"errors\"\n\t\"os\"\n\t\"os/exec\"\n\t\"regexp\"\n\t\"strings\"\n\t\"time\"\n)\n\nvar hgDetectURL = regexp.MustCompile(\"default = (?P<foo>.+)\\n\")\n\n// NewHgRepo creates a new instance of HgRepo. The remote and local directories\n// need to be passed in.\nfunc NewHgRepo(remote, local string) (*HgRepo, error) {\n\tins := depInstalled(\"hg\")\n\tif !ins {\n\t\treturn nil, NewLocalError(\"hg is not installed\", nil, \"\")\n\t}\n\tltype, err := DetectVcsFromFS(local)\n\n\t// Found a VCS other than Hg. Need to report an error.\n\tif err == nil && ltype != Hg {\n\t\treturn nil, ErrWrongVCS\n\t}\n\n\tr := &HgRepo{}\n\tr.setRemote(remote)\n\tr.setLocalPath(local)\n\tr.Logger = Logger\n\n\t// Make sure the local Hg repo is configured the same as the remote when\n\t// A remote value was passed in.\n\tif err == nil && r.CheckLocal() {\n\t\t// An Hg repo was found so test that the URL there matches\n\t\t// the repo passed in here.\n\t\tc := exec.Command(\"hg\", \"paths\")\n\t\tc.Dir = local\n\t\tc.Env = envForDir(c.Dir)\n\t\tout, err := c.CombinedOutput()\n\t\tif err != nil {\n\t\t\treturn nil, NewLocalError(\"Unable to retrieve local repo information\", err, string(out))\n\t\t}\n\n\t\tm := hgDetectURL.FindStringSubmatch(string(out))\n\t\tif m[1] != \"\" && m[1] != remote {\n\t\t\treturn nil, ErrWrongRemote\n\t\t}\n\n\t\t// If no remote was passed in but one is configured for the locally\n\t\t// checked out Hg repo use that one.\n\t\tif remote == \"\" && m[1] != \"\" {\n\t\t\tr.setRemote(m[1])\n\t\t}\n\t}\n\n\treturn r, nil\n}\n\n// HgRepo implements the Repo interface for the Mercurial source control.\ntype HgRepo struct {\n\tbase\n}\n\n// Vcs retrieves the underlying VCS being implemented.\nfunc (s HgRepo) Vcs() Type {\n\treturn Hg\n}\n\n// Get is used to perform an initial clone of a repository.\nfunc (s *HgRepo) Get() error {\n\tout, err := s.run(\"hg\", \"clone\", s.Remote(), s.LocalPath())\n\tif err != nil {\n\t\treturn NewRemoteError(\"Unable to get repository\", err, string(out))\n\t}\n\treturn nil\n}\n\n// Init will initialize a mercurial repository at local location.\nfunc (s *HgRepo) Init() error {\n\tout, err := s.run(\"hg\", \"init\", s.LocalPath())\n\tif err != nil {\n\t\treturn NewLocalError(\"Unable to initialize repository\", err, string(out))\n\t}\n\treturn nil\n}\n\n// Update performs a Mercurial pull to an existing checkout.\nfunc (s *HgRepo) Update() error {\n\treturn s.UpdateVersion(``)\n}\n\n// UpdateVersion sets the version of a package currently checked out via Hg.\nfunc (s *HgRepo) UpdateVersion(version string) error {\n\tout, err := s.RunFromDir(\"hg\", \"pull\")\n\tif err != nil {\n\t\treturn NewLocalError(\"Unable to update checked out version\", err, string(out))\n\t}\n\tif len(strings.TrimSpace(version)) > 0 {\n\t\tout, err = s.RunFromDir(\"hg\", \"update\", version)\n\t} else {\n\t\tout, err = s.RunFromDir(\"hg\", \"update\")\n\t}\n\tif err != nil {\n\t\treturn NewLocalError(\"Unable to update checked out version\", err, string(out))\n\t}\n\treturn nil\n}\n\n// Version retrieves the current version.\nfunc (s *HgRepo) Version() (string, error) {\n\tc := s.CmdFromDir(\"hg\", \"--debug\", \"identify\")\n\tstdout, stderr := new(bytes.Buffer), new(bytes.Buffer)\n\tc.Stdout = stdout\n\tc.Stderr = stderr\n\tif err := c.Run(); err != nil {\n\t\treturn \"\", NewLocalError(\"Unable to retrieve checked out version\", err, stderr.String())\n\t}\n\tif stderr.Len() > 0 {\n\t\t// \"hg --debug identify\" can print out errors before it actually prints\n\t\t// the version.\n\t\t// https://github.com/Masterminds/vcs/issues/90\n\t\treturn \"\", NewLocalError(\"Unable to retrieve checked out version\", errors.New(\"Error output printed before identify\"), stderr.String())\n\t}\n\tparts := strings.SplitN(stdout.String(), \" \", 2)\n\tsha := parts[0]\n\treturn strings.TrimSpace(sha), nil\n}\n\n// Current returns the current version-ish. This means:\n// * Branch name if on the tip of the branch\n// * Tag if on a tag\n// * Otherwise a revision id\nfunc (s *HgRepo) Current() (string, error) {\n\tout, err := s.RunFromDir(\"hg\", \"branch\")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tbranch := strings.TrimSpace(string(out))\n\n\ttip, err := s.CommitInfo(\"max(branch(\" + branch + \"))\")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tcurr, err := s.Version()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif tip.Commit == curr {\n\n\t\treturn branch, nil\n\t}\n\n\tts, err := s.TagsFromCommit(curr)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif len(ts) > 0 {\n\t\treturn ts[0], nil\n\t}\n\n\treturn curr, nil\n}\n\n// Date retrieves the date on the latest commit.\nfunc (s *HgRepo) Date() (time.Time, error) {\n\tversion, err := s.Version()\n\tif err != nil {\n\t\treturn time.Time{}, NewLocalError(\"Unable to retrieve revision date\", err, \"\")\n\t}\n\tout, err := s.RunFromDir(\"hg\", \"log\", \"-r\", version, \"--template\", \"{date|isodatesec}\")\n\tif err != nil {\n\t\treturn time.Time{}, NewLocalError(\"Unable to retrieve revision date\", err, string(out))\n\t}\n\tt, err := time.Parse(longForm, string(out))\n\tif err != nil {\n\t\treturn time.Time{}, NewLocalError(\"Unable to retrieve revision date\", err, string(out))\n\t}\n\treturn t, nil\n}\n\n// CheckLocal verifies the local location is a Git repo.\nfunc (s *HgRepo) CheckLocal() bool {\n\tif _, err := os.Stat(s.LocalPath() + \"/.hg\"); err == nil {\n\t\treturn true\n\t}\n\n\treturn false\n}\n\n// Branches returns a list of available branches\nfunc (s *HgRepo) Branches() ([]string, error) {\n\tout, err := s.RunFromDir(\"hg\", \"branches\")\n\tif err != nil {\n\t\treturn []string{}, NewLocalError(\"Unable to retrieve branches\", err, string(out))\n\t}\n\tbranches := s.referenceList(string(out), `(?m-s)^(\\S+)`)\n\treturn branches, nil\n}\n\n// Tags returns a list of available tags\nfunc (s *HgRepo) Tags() ([]string, error) {\n\tout, err := s.RunFromDir(\"hg\", \"tags\")\n\tif err != nil {\n\t\treturn []string{}, NewLocalError(\"Unable to retrieve tags\", err, string(out))\n\t}\n\ttags := s.referenceList(string(out), `(?m-s)^(\\S+)`)\n\treturn tags, nil\n}\n\n// IsReference returns if a string is a reference. A reference can be a\n// commit id, branch, or tag.\nfunc (s *HgRepo) IsReference(r string) bool {\n\t_, err := s.RunFromDir(\"hg\", \"log\", \"-r\", r)\n\treturn err == nil\n}\n\n// IsDirty returns if the checkout has been modified from the checked\n// out reference.\nfunc (s *HgRepo) IsDirty() bool {\n\tout, err := s.RunFromDir(\"hg\", \"diff\")\n\treturn err != nil || len(out) != 0\n}\n\n// CommitInfo retrieves metadata about a commit.\nfunc (s *HgRepo) CommitInfo(id string) (*CommitInfo, error) {\n\tout, err := s.RunFromDir(\"hg\", \"log\", \"-r\", id, \"--style=xml\")\n\tif err != nil {\n\t\treturn nil, ErrRevisionUnavailable\n\t}\n\n\ttype Author struct {\n\t\tName  string `xml:\",chardata\"`\n\t\tEmail string `xml:\"email,attr\"`\n\t}\n\ttype Logentry struct {\n\t\tNode   string `xml:\"node,attr\"`\n\t\tAuthor Author `xml:\"author\"`\n\t\tDate   string `xml:\"date\"`\n\t\tMsg    string `xml:\"msg\"`\n\t}\n\ttype Log struct {\n\t\tXMLName xml.Name   `xml:\"log\"`\n\t\tLogs    []Logentry `xml:\"logentry\"`\n\t}\n\n\tlogs := &Log{}\n\terr = xml.Unmarshal(out, &logs)\n\tif err != nil {\n\t\treturn nil, NewLocalError(\"Unable to retrieve commit information\", err, string(out))\n\t}\n\tif len(logs.Logs) == 0 {\n\t\treturn nil, ErrRevisionUnavailable\n\t}\n\n\tci := &CommitInfo{\n\t\tCommit:  logs.Logs[0].Node,\n\t\tAuthor:  logs.Logs[0].Author.Name + \" <\" + logs.Logs[0].Author.Email + \">\",\n\t\tMessage: logs.Logs[0].Msg,\n\t}\n\n\tif logs.Logs[0].Date != \"\" {\n\t\tci.Date, err = time.Parse(time.RFC3339, logs.Logs[0].Date)\n\t\tif err != nil {\n\t\t\treturn nil, NewLocalError(\"Unable to retrieve commit information\", err, string(out))\n\t\t}\n\t}\n\n\treturn ci, nil\n}\n\n// TagsFromCommit retrieves tags from a commit id.\nfunc (s *HgRepo) TagsFromCommit(id string) ([]string, error) {\n\t// Hg has a single tag per commit. If a second tag is added to a commit a\n\t// new commit is created and the tag is attached to that new commit.\n\tout, err := s.RunFromDir(\"hg\", \"log\", \"-r\", id, \"--style=xml\")\n\tif err != nil {\n\t\treturn []string{}, NewLocalError(\"Unable to retrieve tags\", err, string(out))\n\t}\n\n\ttype Logentry struct {\n\t\tNode string `xml:\"node,attr\"`\n\t\tTag  string `xml:\"tag\"`\n\t}\n\ttype Log struct {\n\t\tXMLName xml.Name   `xml:\"log\"`\n\t\tLogs    []Logentry `xml:\"logentry\"`\n\t}\n\n\tlogs := &Log{}\n\terr = xml.Unmarshal(out, &logs)\n\tif err != nil {\n\t\treturn []string{}, NewLocalError(\"Unable to retrieve tags\", err, string(out))\n\t}\n\tif len(logs.Logs) == 0 {\n\t\treturn []string{}, NewLocalError(\"Unable to retrieve tags\", err, string(out))\n\t}\n\n\tt := strings.TrimSpace(logs.Logs[0].Tag)\n\tif t != \"\" {\n\t\treturn []string{t}, nil\n\t}\n\treturn []string{}, nil\n}\n\n// Ping returns if remote location is accessible.\nfunc (s *HgRepo) Ping() bool {\n\t_, err := s.run(\"hg\", \"identify\", s.Remote())\n\treturn err == nil\n}\n\n// ExportDir exports the current revision to the passed in directory.\nfunc (s *HgRepo) ExportDir(dir string) error {\n\n\tout, err := s.RunFromDir(\"hg\", \"archive\", dir)\n\ts.log(out)\n\tif err != nil {\n\t\treturn NewLocalError(\"Unable to export source\", err, string(out))\n\t}\n\n\treturn nil\n}\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/hg_test.go",
    "content": "package vcs\n\nimport (\n\t\"io/ioutil\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\t\"testing\"\n\t\"time\"\n)\n\n// Canary test to ensure HgRepo implements the Repo interface.\nvar _ Repo = &HgRepo{}\n\n// To verify hg is working we perform integration testing\n// with a known hg service.\n\nfunc TestHg(t *testing.T) {\n\n\ttempDir, err := ioutil.TempDir(\"\", \"go-vcs-hg-tests\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\trepo, err := NewHgRepo(\"https://bitbucket.org/mattfarina/testhgrepo\", tempDir+\"/testhgrepo\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tif repo.Vcs() != Hg {\n\t\tt.Error(\"Hg is detecting the wrong type\")\n\t}\n\n\t// Check the basic getters.\n\tif repo.Remote() != \"https://bitbucket.org/mattfarina/testhgrepo\" {\n\t\tt.Error(\"Remote not set properly\")\n\t}\n\tif repo.LocalPath() != tempDir+\"/testhgrepo\" {\n\t\tt.Error(\"Local disk location not set properly\")\n\t}\n\n\t//Logger = log.New(os.Stdout, \"\", log.LstdFlags)\n\n\t// Do an initial clone.\n\terr = repo.Get()\n\tif err != nil {\n\t\tt.Errorf(\"Unable to clone Hg repo. Err was %s\", err)\n\t}\n\n\t// Verify Hg repo is a Hg repo\n\tif !repo.CheckLocal() {\n\t\tt.Error(\"Problem checking out repo or Hg CheckLocal is not working\")\n\t}\n\n\t// Test internal lookup mechanism used outside of Hg specific functionality.\n\tltype, err := DetectVcsFromFS(tempDir + \"/testhgrepo\")\n\tif err != nil {\n\t\tt.Error(\"detectVcsFromFS unable to Hg repo\")\n\t}\n\tif ltype != Hg {\n\t\tt.Errorf(\"detectVcsFromFS detected %s instead of Hg type\", ltype)\n\t}\n\n\t// Test NewRepo on existing checkout. This should simply provide a working\n\t// instance without error based on looking at the local directory.\n\tnrepo, nrerr := NewRepo(\"https://bitbucket.org/mattfarina/testhgrepo\", tempDir+\"/testhgrepo\")\n\tif nrerr != nil {\n\t\tt.Error(nrerr)\n\t}\n\t// Verify the right oject is returned. It will check the local repo type.\n\tif !nrepo.CheckLocal() {\n\t\tt.Error(\"Wrong version returned from NewRepo\")\n\t}\n\n\tv, err := repo.Current()\n\tif err != nil {\n\t\tt.Errorf(\"Error trying Hg Current: %s\", err)\n\t}\n\tif v != \"default\" {\n\t\tt.Errorf(\"Current failed to detect Hg on tip of default. Got version: %s\", v)\n\t}\n\n\t// Set the version using the short hash.\n\terr = repo.UpdateVersion(\"a5494ba2177f\")\n\tif err != nil {\n\t\tt.Errorf(\"Unable to update Hg repo version. Err was %s\", err)\n\t}\n\n\t// Use Version to verify we are on the right version.\n\tv, err = repo.Version()\n\tif v != \"a5494ba2177ff9ef26feb3c155dfecc350b1a8ef\" {\n\t\tt.Errorf(\"Error checking checked out Hg version: %s\", v)\n\t}\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tv, err = repo.Current()\n\tif err != nil {\n\t\tt.Errorf(\"Error trying Hg Current for ref: %s\", err)\n\t}\n\tif v != \"a5494ba2177ff9ef26feb3c155dfecc350b1a8ef\" {\n\t\tt.Errorf(\"Current failed to detect Hg on ref of branch. Got version: %s\", v)\n\t}\n\n\t// Use Date to verify we are on the right commit.\n\td, err := repo.Date()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif d.Format(longForm) != \"2015-07-30 16:14:08 -0400\" {\n\t\tt.Error(\"Error checking checked out Hg commit date. Got wrong date:\", d)\n\t}\n\n\t// Perform an update.\n\terr = repo.Update()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tv, err = repo.Version()\n\tif v != \"9c6ccbca73e8a1351c834f33f57f1f7a0329ad35\" {\n\t\tt.Errorf(\"Error checking checked out Hg version: %s\", v)\n\t}\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\ttags, err := repo.Tags()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif tags[1] != \"1.0.0\" {\n\t\tt.Error(\"Hg tags is not reporting the correct version\")\n\t}\n\n\ttags, err = repo.TagsFromCommit(\"a5494ba2177f\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif len(tags) != 0 {\n\t\tt.Error(\"Hg is incorrectly returning tags for a commit\")\n\t}\n\n\ttags, err = repo.TagsFromCommit(\"d680e82228d2\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif len(tags) != 1 || tags[0] != \"1.0.0\" {\n\t\tt.Error(\"Hg is incorrectly returning tags for a commit\")\n\t}\n\n\tbranches, err := repo.Branches()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\t// The branches should be HEAD, master, and test.\n\tif branches[0] != \"test\" {\n\t\tt.Error(\"Hg is incorrectly returning branches\")\n\t}\n\n\tif !repo.IsReference(\"1.0.0\") {\n\t\tt.Error(\"Hg is reporting a reference is not one\")\n\t}\n\n\tif !repo.IsReference(\"test\") {\n\t\tt.Error(\"Hg is reporting a reference is not one\")\n\t}\n\n\tif repo.IsReference(\"foo\") {\n\t\tt.Error(\"Hg is reporting a non-existent reference is one\")\n\t}\n\n\tif repo.IsDirty() {\n\t\tt.Error(\"Hg incorrectly reporting dirty\")\n\t}\n\n\tci, err := repo.CommitInfo(\"a5494ba2177f\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif ci.Commit != \"a5494ba2177ff9ef26feb3c155dfecc350b1a8ef\" {\n\t\tt.Error(\"Hg.CommitInfo wrong commit id\")\n\t}\n\tif ci.Author != \"Matt Farina <matt@mattfarina.com>\" {\n\t\tt.Error(\"Hg.CommitInfo wrong author\")\n\t}\n\tif ci.Message != \"A commit\" {\n\t\tt.Error(\"Hg.CommitInfo wrong message\")\n\t}\n\n\tti := time.Unix(1438287248, 0)\n\tif !ti.Equal(ci.Date) {\n\t\tt.Error(\"Hg.CommitInfo wrong date\")\n\t}\n\n\t_, err = repo.CommitInfo(\"asdfasdfasdf\")\n\tif err != ErrRevisionUnavailable {\n\t\tt.Error(\"Hg didn't return expected ErrRevisionUnavailable\")\n\t}\n\n\ttempDir2, err := ioutil.TempDir(\"\", \"go-vcs-hg-tests-export\")\n\tif err != nil {\n\t\tt.Fatalf(\"Error creating temp directory: %s\", err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir2)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\texportDir := filepath.Join(tempDir2, \"src\")\n\n\terr = repo.ExportDir(exportDir)\n\tif err != nil {\n\t\tt.Errorf(\"Unable to export Hg repo. Err was %s\", err)\n\t}\n\n\t_, err = os.Stat(filepath.Join(exportDir, \"Readme.md\"))\n\tif err != nil {\n\t\tt.Errorf(\"Error checking exported file in Hg: %s\", err)\n\t}\n\n\t_, err = os.Stat(filepath.Join(exportDir, string(repo.Vcs())))\n\tif err != nil {\n\t\tif found := os.IsNotExist(err); !found {\n\t\t\tt.Errorf(\"Error checking exported metadata in Hg: %s\", err)\n\t\t}\n\t} else {\n\t\tt.Error(\"Error checking Hg metadata. It exists.\")\n\t}\n}\n\nfunc TestHgCheckLocal(t *testing.T) {\n\t// Verify repo.CheckLocal fails for non-Hg directories.\n\t// TestHg is already checking on a valid repo\n\ttempDir, err := ioutil.TempDir(\"\", \"go-vcs-hg-tests\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\trepo, _ := NewHgRepo(\"\", tempDir)\n\tif repo.CheckLocal() {\n\t\tt.Error(\"Hg CheckLocal does not identify non-Hg location\")\n\t}\n\n\t// Test NewRepo when there's no local. This should simply provide a working\n\t// instance without error based on looking at the remote localtion.\n\t_, nrerr := NewRepo(\"https://bitbucket.org/mattfarina/testhgrepo\", tempDir+\"/testhgrepo\")\n\tif nrerr != nil {\n\t\tt.Error(nrerr)\n\t}\n}\n\nfunc TestHgPing(t *testing.T) {\n\ttempDir, err := ioutil.TempDir(\"\", \"go-vcs-hg-tests\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\trepo, err := NewHgRepo(\"https://bitbucket.org/mattfarina/testhgrepo\", tempDir)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tping := repo.Ping()\n\tif !ping {\n\t\tt.Error(\"Hg unable to ping working repo\")\n\t}\n\n\trepo, err = NewHgRepo(\"https://bitbucket.org/mattfarina/ihopethisneverexistsbecauseitshouldnt\", tempDir)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tping = repo.Ping()\n\tif ping {\n\t\tt.Error(\"Hg got a ping response from when it should not have\")\n\t}\n}\n\nfunc TestHgInit(t *testing.T) {\n\ttempDir, err := ioutil.TempDir(\"\", \"go-vcs-hg-tests\")\n\trepoDir := tempDir + \"/repo\"\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\trepo, err := NewHgRepo(repoDir, repoDir)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\terr = repo.Init()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tv, err := repo.Version()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif !strings.HasPrefix(v, \"000000\") {\n\t\tt.Errorf(\"Hg Init reporting wrong initial version: %s\", v)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/repo.go",
    "content": "// Package vcs provides the ability to work with varying version control systems\n// (VCS),  also known as source control systems (SCM) though the same interface.\n//\n// This package includes a function that attempts to detect the repo type from\n// the remote URL and return the proper type. For example,\n//\n//     remote := \"https://github.com/Masterminds/vcs\"\n//     local, _ := ioutil.TempDir(\"\", \"go-vcs\")\n//     repo, err := NewRepo(remote, local)\n//\n// In this case repo will be a GitRepo instance. NewRepo can detect the VCS for\n// numerous popular VCS and from the URL. For example, a URL ending in .git\n// that's not from one of the popular VCS will be detected as a Git repo and\n// the correct type will be returned.\n//\n// If you know the repository type and would like to create an instance of a\n// specific type you can use one of constructors for a type. They are NewGitRepo,\n// NewSvnRepo, NewBzrRepo, and NewHgRepo. The definition and usage is the same\n// as NewRepo.\n//\n// Once you have an object implementing the Repo interface the operations are\n// the same no matter which VCS you're using. There are some caveats. For\n// example, each VCS has its own version formats that need to be respected and\n// checkout out branches, if a branch is being worked with, is different in\n// each VCS.\npackage vcs\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"os/exec\"\n\t\"regexp\"\n\t\"strings\"\n\t\"time\"\n)\n\n// Logger is where you can provide a logger, implementing the log.Logger interface,\n// where verbose output from each VCS will be written. The default logger does\n// not log data. To log data supply your own logger or change the output location\n// of the provided logger.\nvar Logger *log.Logger\n\nfunc init() {\n\t// Initialize the logger to one that does not actually log anywhere. This is\n\t// to be overridden by the package user by setting vcs.Logger to a different\n\t// logger.\n\tLogger = log.New(ioutil.Discard, \"go-vcs\", log.LstdFlags)\n}\n\nconst longForm = \"2006-01-02 15:04:05 -0700\"\n\n// Type describes the type of VCS\ntype Type string\n\n// VCS types\nconst (\n\tNoVCS Type = \"\"\n\tGit   Type = \"git\"\n\tSvn   Type = \"svn\"\n\tBzr   Type = \"bzr\"\n\tHg    Type = \"hg\"\n)\n\n// Repo provides an interface to work with repositories using different source\n// control systems such as Git, Bzr, Mercurial, and SVN. For implementations\n// of this interface see BzrRepo, GitRepo, HgRepo, and SvnRepo.\ntype Repo interface {\n\n\t// Vcs retrieves the underlying VCS being implemented.\n\tVcs() Type\n\n\t// Remote retrieves the remote location for a repo.\n\tRemote() string\n\n\t// LocalPath retrieves the local file system location for a repo.\n\tLocalPath() string\n\n\t// Get is used to perform an initial clone/checkout of a repository.\n\tGet() error\n\n\t// Initializes a new repository locally.\n\tInit() error\n\n\t// Update performs an update to an existing checkout of a repository.\n\tUpdate() error\n\n\t// UpdateVersion sets the version of a package of a repository.\n\tUpdateVersion(string) error\n\n\t// Version retrieves the current version.\n\tVersion() (string, error)\n\n\t// Current retrieves the current version-ish. This is different from the\n\t// Version method. The output could be a branch name if on the tip of a\n\t// branch (git), a tag if on a tag, a revision if on a specific revision\n\t// that's not the tip of the branch. The values here vary based on the VCS.\n\tCurrent() (string, error)\n\n\t// Date retrieves the date on the latest commit.\n\tDate() (time.Time, error)\n\n\t// CheckLocal verifies the local location is of the correct VCS type\n\tCheckLocal() bool\n\n\t// Branches returns a list of available branches on the repository.\n\tBranches() ([]string, error)\n\n\t// Tags returns a list of available tags on the repository.\n\tTags() ([]string, error)\n\n\t// IsReference returns if a string is a reference. A reference can be a\n\t// commit id, branch, or tag.\n\tIsReference(string) bool\n\n\t// IsDirty returns if the checkout has been modified from the checked\n\t// out reference.\n\tIsDirty() bool\n\n\t// CommitInfo retrieves metadata about a commit.\n\tCommitInfo(string) (*CommitInfo, error)\n\n\t// TagsFromCommit retrieves tags from a commit id.\n\tTagsFromCommit(string) ([]string, error)\n\n\t// Ping returns if remote location is accessible.\n\tPing() bool\n\n\t// RunFromDir executes a command from repo's directory.\n\tRunFromDir(cmd string, args ...string) ([]byte, error)\n\n\t// CmdFromDir creates a new command that will be executed from repo's\n\t// directory.\n\tCmdFromDir(cmd string, args ...string) *exec.Cmd\n\n\t// ExportDir exports the current revision to the passed in directory.\n\tExportDir(string) error\n}\n\n// NewRepo returns a Repo based on trying to detect the source control from the\n// remote and local locations. The appropriate implementation will be returned\n// or an ErrCannotDetectVCS if the VCS type cannot be detected.\n// Note, this function may make calls to the Internet to determind help determine\n// the VCS.\nfunc NewRepo(remote, local string) (Repo, error) {\n\tvtype, remote, err := detectVcsFromRemote(remote)\n\n\t// From the remote URL the VCS could not be detected. See if the local\n\t// repo contains enough information to figure out the VCS. The reason the\n\t// local repo is not checked first is because of the potential for VCS type\n\t// switches which will be detected in each of the type builders.\n\tif err == ErrCannotDetectVCS {\n\t\tvtype, err = DetectVcsFromFS(local)\n\t}\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tswitch vtype {\n\tcase Git:\n\t\treturn NewGitRepo(remote, local)\n\tcase Svn:\n\t\treturn NewSvnRepo(remote, local)\n\tcase Hg:\n\t\treturn NewHgRepo(remote, local)\n\tcase Bzr:\n\t\treturn NewBzrRepo(remote, local)\n\t}\n\n\t// Should never fall through to here but just in case.\n\treturn nil, ErrCannotDetectVCS\n}\n\n// CommitInfo contains metadata about a commit.\ntype CommitInfo struct {\n\t// The commit id\n\tCommit string\n\n\t// Who authored the commit\n\tAuthor string\n\n\t// Date of the commit\n\tDate time.Time\n\n\t// Commit message\n\tMessage string\n}\n\ntype base struct {\n\tremote, local string\n\tLogger        *log.Logger\n}\n\nfunc (b *base) log(v interface{}) {\n\tb.Logger.Printf(\"%s\", v)\n}\n\n// Remote retrieves the remote location for a repo.\nfunc (b *base) Remote() string {\n\treturn b.remote\n}\n\n// LocalPath retrieves the local file system location for a repo.\nfunc (b *base) LocalPath() string {\n\treturn b.local\n}\n\nfunc (b *base) setRemote(remote string) {\n\tb.remote = remote\n}\n\nfunc (b *base) setLocalPath(local string) {\n\tb.local = local\n}\n\nfunc (b base) run(cmd string, args ...string) ([]byte, error) {\n\tout, err := exec.Command(cmd, args...).CombinedOutput()\n\tb.log(out)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"%s: %s\", out, err)\n\t}\n\treturn out, err\n}\n\nfunc (b *base) CmdFromDir(cmd string, args ...string) *exec.Cmd {\n\tc := exec.Command(cmd, args...)\n\tc.Dir = b.local\n\tc.Env = envForDir(c.Dir)\n\treturn c\n}\n\nfunc (b *base) RunFromDir(cmd string, args ...string) ([]byte, error) {\n\tc := b.CmdFromDir(cmd, args...)\n\tout, err := c.CombinedOutput()\n\treturn out, err\n}\n\nfunc (b *base) referenceList(c, r string) []string {\n\tvar out []string\n\tre := regexp.MustCompile(r)\n\tfor _, m := range re.FindAllStringSubmatch(c, -1) {\n\t\tout = append(out, m[1])\n\t}\n\n\treturn out\n}\n\nfunc envForDir(dir string) []string {\n\tenv := os.Environ()\n\treturn mergeEnvLists([]string{\"PWD=\" + dir}, env)\n}\n\nfunc mergeEnvLists(in, out []string) []string {\nNextVar:\n\tfor _, inkv := range in {\n\t\tk := strings.SplitAfterN(inkv, \"=\", 2)[0]\n\t\tfor i, outkv := range out {\n\t\t\tif strings.HasPrefix(outkv, k) {\n\t\t\t\tout[i] = inkv\n\t\t\t\tcontinue NextVar\n\t\t\t}\n\t\t}\n\t\tout = append(out, inkv)\n\t}\n\treturn out\n}\n\nfunc depInstalled(name string) bool {\n\tif _, err := exec.LookPath(name); err != nil {\n\t\treturn false\n\t}\n\n\treturn true\n}\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/repo_test.go",
    "content": "package vcs\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"testing\"\n)\n\nfunc ExampleNewRepo() {\n\tremote := \"https://github.com/Masterminds/vcs\"\n\tlocal, _ := ioutil.TempDir(\"\", \"go-vcs\")\n\trepo, _ := NewRepo(remote, local)\n\t// Returns: instance of GitRepo\n\n\trepo.Vcs()\n\t// Returns Git as this is a Git repo\n\n\terr := repo.Get()\n\t// Pulls down a repo, or a checkout in the case of SVN, and returns an\n\t// error if that didn't happen successfully.\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\n\terr = repo.UpdateVersion(\"master\")\n\t// Checkouts out a specific version. In most cases this can be a commit id,\n\t// branch, or tag.\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n}\n\nfunc TestTypeSwitch(t *testing.T) {\n\n\t// To test repo type switching we checkout as SVN and then try to get it as\n\t// a git repo afterwards.\n\ttempDir, err := ioutil.TempDir(\"\", \"go-vcs-svn-tests\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\trepo, err := NewSvnRepo(\"https://github.com/Masterminds/VCSTestRepo/trunk\", tempDir+string(os.PathSeparator)+\"VCSTestRepo\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\terr = repo.Get()\n\tif err != nil {\n\t\tt.Errorf(\"Unable to checkout SVN repo for repo switching tests. Err was %s\", err)\n\t}\n\n\t_, err = NewRepo(\"https://github.com/Masterminds/VCSTestRepo\", tempDir+string(os.PathSeparator)+\"VCSTestRepo\")\n\tif err != ErrWrongVCS {\n\t\tt.Errorf(\"Not detecting repo switch from SVN to Git\")\n\t}\n}\n\nfunc TestDepInstalled(t *testing.T) {\n\ti := depInstalled(\"git\")\n\tif !i {\n\t\tt.Error(\"depInstalled not finding installed dep.\")\n\t}\n\n\ti = depInstalled(\"thisreallyisntinstalled\")\n\tif i {\n\t\tt.Error(\"depInstalled finding not installed dep.\")\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/svn.go",
    "content": "package vcs\n\nimport (\n\t\"encoding/xml\"\n\t\"fmt\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n\t\"runtime\"\n\t\"strings\"\n\t\"time\"\n)\n\n// NewSvnRepo creates a new instance of SvnRepo. The remote and local directories\n// need to be passed in. The remote location should include the branch for SVN.\n// For example, if the package is https://github.com/Masterminds/cookoo/ the remote\n// should be https://github.com/Masterminds/cookoo/trunk for the trunk branch.\nfunc NewSvnRepo(remote, local string) (*SvnRepo, error) {\n\tins := depInstalled(\"svn\")\n\tif !ins {\n\t\treturn nil, NewLocalError(\"svn is not installed\", nil, \"\")\n\t}\n\tltype, err := DetectVcsFromFS(local)\n\n\t// Found a VCS other than Svn. Need to report an error.\n\tif err == nil && ltype != Svn {\n\t\treturn nil, ErrWrongVCS\n\t}\n\n\tr := &SvnRepo{}\n\tr.setRemote(remote)\n\tr.setLocalPath(local)\n\tr.Logger = Logger\n\n\t// Make sure the local SVN repo is configured the same as the remote when\n\t// A remote value was passed in.\n\tif err == nil && r.CheckLocal() {\n\t\t// An SVN repo was found so test that the URL there matches\n\t\t// the repo passed in here.\n\t\tout, err := exec.Command(\"svn\", \"info\", local).CombinedOutput()\n\t\tif err != nil {\n\t\t\treturn nil, NewLocalError(\"Unable to retrieve local repo information\", err, string(out))\n\t\t}\n\n\t\tdetectedRemote, err := detectRemoteFromInfoCommand(string(out))\n\t\tif err != nil {\n\t\t\treturn nil, NewLocalError(\"Unable to retrieve local repo information\", err, string(out))\n\t\t}\n\t\tif detectedRemote != \"\" && remote != \"\" && detectedRemote != remote {\n\t\t\treturn nil, ErrWrongRemote\n\t\t}\n\n\t\t// If no remote was passed in but one is configured for the locally\n\t\t// checked out Svn repo use that one.\n\t\tif remote == \"\" && detectedRemote != \"\" {\n\t\t\tr.setRemote(detectedRemote)\n\t\t}\n\t}\n\n\treturn r, nil\n}\n\n// SvnRepo implements the Repo interface for the Svn source control.\ntype SvnRepo struct {\n\tbase\n}\n\n// Vcs retrieves the underlying VCS being implemented.\nfunc (s SvnRepo) Vcs() Type {\n\treturn Svn\n}\n\n// Get is used to perform an initial checkout of a repository.\n// Note, because SVN isn't distributed this is a checkout without\n// a clone.\nfunc (s *SvnRepo) Get() error {\n\tremote := s.Remote()\n\tif strings.HasPrefix(remote, \"/\") {\n\t\tremote = \"file://\" + remote\n\t} else if runtime.GOOS == \"windows\" && filepath.VolumeName(remote) != \"\" {\n\t\tremote = \"file:///\" + remote\n\t}\n\tout, err := s.run(\"svn\", \"checkout\", remote, s.LocalPath())\n\tif err != nil {\n\t\treturn NewRemoteError(\"Unable to get repository\", err, string(out))\n\t}\n\treturn nil\n}\n\n// Init will create a svn repository at remote location.\nfunc (s *SvnRepo) Init() error {\n\tout, err := s.run(\"svnadmin\", \"create\", s.Remote())\n\n\tif err != nil && s.isUnableToCreateDir(err) {\n\n\t\tbasePath := filepath.Dir(filepath.FromSlash(s.Remote()))\n\t\tif _, err := os.Stat(basePath); os.IsNotExist(err) {\n\t\t\terr = os.MkdirAll(basePath, 0755)\n\t\t\tif err != nil {\n\t\t\t\treturn NewLocalError(\"Unable to initialize repository\", err, \"\")\n\t\t\t}\n\n\t\t\tout, err = s.run(\"svnadmin\", \"create\", s.Remote())\n\t\t\tif err != nil {\n\t\t\t\treturn NewLocalError(\"Unable to initialize repository\", err, string(out))\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\n\t} else if err != nil {\n\t\treturn NewLocalError(\"Unable to initialize repository\", err, string(out))\n\t}\n\n\treturn nil\n}\n\n// Update performs an SVN update to an existing checkout.\nfunc (s *SvnRepo) Update() error {\n\tout, err := s.RunFromDir(\"svn\", \"update\")\n\tif err != nil {\n\t\treturn NewRemoteError(\"Unable to update repository\", err, string(out))\n\t}\n\treturn err\n}\n\n// UpdateVersion sets the version of a package currently checked out via SVN.\nfunc (s *SvnRepo) UpdateVersion(version string) error {\n\tout, err := s.RunFromDir(\"svn\", \"update\", \"-r\", version)\n\tif err != nil {\n\t\treturn NewRemoteError(\"Unable to update checked out version\", err, string(out))\n\t}\n\treturn nil\n}\n\n// Version retrieves the current version.\nfunc (s *SvnRepo) Version() (string, error) {\n\ttype Commit struct {\n\t\tRevision string `xml:\"revision,attr\"`\n\t}\n\ttype Info struct {\n\t\tCommit Commit `xml:\"entry>commit\"`\n\t}\n\n\tout, err := s.RunFromDir(\"svn\", \"info\", \"--xml\")\n\tif err != nil {\n\t\treturn \"\", NewLocalError(\"Unable to retrieve checked out version\", err, string(out))\n\t}\n\ts.log(out)\n\tinfos := &Info{}\n\terr = xml.Unmarshal(out, &infos)\n\tif err != nil {\n\t\treturn \"\", NewLocalError(\"Unable to retrieve checked out version\", err, string(out))\n\t}\n\n\treturn infos.Commit.Revision, nil\n}\n\n// Current returns the current version-ish. This means:\n// * HEAD if on the tip.\n// * Otherwise a revision id\nfunc (s *SvnRepo) Current() (string, error) {\n\ttip, err := s.CommitInfo(\"HEAD\")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tcurr, err := s.Version()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif tip.Commit == curr {\n\t\treturn \"HEAD\", nil\n\t}\n\n\treturn curr, nil\n}\n\n// Date retrieves the date on the latest commit.\nfunc (s *SvnRepo) Date() (time.Time, error) {\n\tversion, err := s.Version()\n\tif err != nil {\n\t\treturn time.Time{}, NewLocalError(\"Unable to retrieve revision date\", err, \"\")\n\t}\n\tout, err := s.RunFromDir(\"svn\", \"pget\", \"svn:date\", \"--revprop\", \"-r\", version)\n\tif err != nil {\n\t\treturn time.Time{}, NewLocalError(\"Unable to retrieve revision date\", err, string(out))\n\t}\n\tconst longForm = \"2006-01-02T15:04:05.000000Z\"\n\tt, err := time.Parse(longForm, strings.TrimSpace(string(out)))\n\tif err != nil {\n\t\treturn time.Time{}, NewLocalError(\"Unable to retrieve revision date\", err, string(out))\n\t}\n\treturn t, nil\n}\n\n// CheckLocal verifies the local location is an SVN repo.\nfunc (s *SvnRepo) CheckLocal() bool {\n\tpth, err := filepath.Abs(s.LocalPath())\n\tif err != nil {\n\t\ts.log(err.Error())\n\t\treturn false\n\t}\n\n\tif _, err := os.Stat(filepath.Join(pth, \".svn\")); err == nil {\n\t\treturn true\n\t}\n\n\toldpth := pth\n\tfor oldpth != pth {\n\t\tpth = filepath.Dir(pth)\n\t\tif _, err := os.Stat(filepath.Join(pth, \".svn\")); err == nil {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n// Tags returns []string{} as there are no formal tags in SVN. Tags are a\n// convention in SVN. They are typically implemented as a copy of the trunk and\n// placed in the /tags/[tag name] directory. Since this is a convention the\n// expectation is to checkout a tag the correct subdirectory will be used\n// as the path. For more information see:\n// http://svnbook.red-bean.com/en/1.7/svn.branchmerge.tags.html\nfunc (s *SvnRepo) Tags() ([]string, error) {\n\treturn []string{}, nil\n}\n\n// Branches returns []string{} as there are no formal branches in SVN. Branches\n// are a convention. They are typically implemented as a copy of the trunk and\n// placed in the /branches/[tag name] directory. Since this is a convention the\n// expectation is to checkout a branch the correct subdirectory will be used\n// as the path. For more information see:\n// http://svnbook.red-bean.com/en/1.7/svn.branchmerge.using.html\nfunc (s *SvnRepo) Branches() ([]string, error) {\n\treturn []string{}, nil\n}\n\n// IsReference returns if a string is a reference. A reference is a commit id.\n// Branches and tags are part of the path.\nfunc (s *SvnRepo) IsReference(r string) bool {\n\tout, err := s.RunFromDir(\"svn\", \"log\", \"-r\", r)\n\n\t// This is a complete hack. There must be a better way to do this. Pull\n\t// requests welcome. When the reference isn't real you get a line of\n\t// repeated - followed by an empty line. If the reference is real there\n\t// is commit information in addition to those. So, we look for responses\n\t// over 2 lines long.\n\tlines := strings.Split(string(out), \"\\n\")\n\tif err == nil && len(lines) > 2 {\n\t\treturn true\n\t}\n\n\treturn false\n}\n\n// IsDirty returns if the checkout has been modified from the checked\n// out reference.\nfunc (s *SvnRepo) IsDirty() bool {\n\tout, err := s.RunFromDir(\"svn\", \"diff\")\n\treturn err != nil || len(out) != 0\n}\n\n// CommitInfo retrieves metadata about a commit.\nfunc (s *SvnRepo) CommitInfo(id string) (*CommitInfo, error) {\n\n\t// There are cases where Svn log doesn't return anything for HEAD or BASE.\n\t// svn info does provide details for these but does not have elements like\n\t// the commit message.\n\tif id == \"HEAD\" || id == \"BASE\" {\n\t\ttype Commit struct {\n\t\t\tRevision string `xml:\"revision,attr\"`\n\t\t}\n\t\ttype Info struct {\n\t\t\tCommit Commit `xml:\"entry>commit\"`\n\t\t}\n\n\t\tout, err := s.RunFromDir(\"svn\", \"info\", \"-r\", id, \"--xml\")\n\t\tif err != nil {\n\t\t\treturn nil, NewLocalError(\"Unable to retrieve commit information\", err, string(out))\n\t\t}\n\t\tinfos := &Info{}\n\t\terr = xml.Unmarshal(out, &infos)\n\t\tif err != nil {\n\t\t\treturn nil, NewLocalError(\"Unable to retrieve commit information\", err, string(out))\n\t\t}\n\n\t\tid = infos.Commit.Revision\n\t\tif id == \"\" {\n\t\t\treturn nil, ErrRevisionUnavailable\n\t\t}\n\t}\n\n\tout, err := s.RunFromDir(\"svn\", \"log\", \"-r\", id, \"--xml\")\n\tif err != nil {\n\t\treturn nil, NewRemoteError(\"Unable to retrieve commit information\", err, string(out))\n\t}\n\n\ttype Logentry struct {\n\t\tAuthor string `xml:\"author\"`\n\t\tDate   string `xml:\"date\"`\n\t\tMsg    string `xml:\"msg\"`\n\t}\n\ttype Log struct {\n\t\tXMLName xml.Name   `xml:\"log\"`\n\t\tLogs    []Logentry `xml:\"logentry\"`\n\t}\n\n\tlogs := &Log{}\n\terr = xml.Unmarshal(out, &logs)\n\tif err != nil {\n\t\treturn nil, NewLocalError(\"Unable to retrieve commit information\", err, string(out))\n\t}\n\tif len(logs.Logs) == 0 {\n\t\treturn nil, ErrRevisionUnavailable\n\t}\n\n\tci := &CommitInfo{\n\t\tCommit:  id,\n\t\tAuthor:  logs.Logs[0].Author,\n\t\tMessage: logs.Logs[0].Msg,\n\t}\n\n\tif len(logs.Logs[0].Date) > 0 {\n\t\tci.Date, err = time.Parse(time.RFC3339Nano, logs.Logs[0].Date)\n\t\tif err != nil {\n\t\t\treturn nil, NewLocalError(\"Unable to retrieve commit information\", err, string(out))\n\t\t}\n\t}\n\n\treturn ci, nil\n}\n\n// TagsFromCommit retrieves tags from a commit id.\nfunc (s *SvnRepo) TagsFromCommit(id string) ([]string, error) {\n\t// Svn tags are a convention implemented as paths. See the details on the\n\t// Tag() method for more information.\n\treturn []string{}, nil\n}\n\n// Ping returns if remote location is accessible.\nfunc (s *SvnRepo) Ping() bool {\n\t_, err := s.run(\"svn\", \"--non-interactive\", \"info\", s.Remote())\n\treturn err == nil\n}\n\n// ExportDir exports the current revision to the passed in directory.\nfunc (s *SvnRepo) ExportDir(dir string) error {\n\n\tout, err := s.RunFromDir(\"svn\", \"export\", \".\", dir)\n\ts.log(out)\n\tif err != nil {\n\t\treturn NewLocalError(\"Unable to export source\", err, string(out))\n\t}\n\n\treturn nil\n}\n\n// isUnableToCreateDir checks for an error in Init() to see if an error\n// where the parent directory of the VCS local path doesn't exist.\nfunc (s *SvnRepo) isUnableToCreateDir(err error) bool {\n\tmsg := err.Error()\n\treturn strings.HasPrefix(msg, \"E000002\")\n}\n\n// detectRemoteFromInfoCommand finds the remote url from the `svn info`\n// command's output without using  a regex. We avoid regex because URLs\n// are notoriously complex to accurately match with a regex and\n// splitting strings is less complex and often faster\nfunc detectRemoteFromInfoCommand(infoOut string) (string, error) {\n\tsBytes := []byte(infoOut)\n\turlIndex := strings.Index(infoOut, \"URL: \")\n\tif urlIndex == -1 {\n\t\treturn \"\", fmt.Errorf(\"Remote not specified in svn info\")\n\t}\n\turlEndIndex := strings.Index(string(sBytes[urlIndex:]), \"\\n\")\n\tif urlEndIndex == -1 {\n\t\turlEndIndex = strings.Index(string(sBytes[urlIndex:]), \"\\r\")\n\t\tif urlEndIndex == -1 {\n\t\t\treturn \"\", fmt.Errorf(\"Unable to parse remote URL for svn info\")\n\t\t}\n\t}\n\n\treturn string(sBytes[(urlIndex + 5):(urlIndex + urlEndIndex)]), nil\n}\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/svn_test.go",
    "content": "package vcs\n\nimport (\n\t\"io/ioutil\"\n\t\"path/filepath\"\n\t\"time\"\n\t//\"log\"\n\t\"os\"\n\t\"testing\"\n)\n\n// To verify svn is working we perform integration testing\n// with a known svn service.\n\n// Canary test to ensure SvnRepo implements the Repo interface.\nvar _ Repo = &SvnRepo{}\n\nfunc TestSvn(t *testing.T) {\n\n\ttempDir, err := ioutil.TempDir(\"\", \"go-vcs-svn-tests\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\trepo, err := NewSvnRepo(\"https://github.com/Masterminds/VCSTestRepo/trunk\", tempDir+string(os.PathSeparator)+\"VCSTestRepo\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tif repo.Vcs() != Svn {\n\t\tt.Error(\"Svn is detecting the wrong type\")\n\t}\n\n\t// Check the basic getters.\n\tif repo.Remote() != \"https://github.com/Masterminds/VCSTestRepo/trunk\" {\n\t\tt.Error(\"Remote not set properly\")\n\t}\n\tif repo.LocalPath() != tempDir+string(os.PathSeparator)+\"VCSTestRepo\" {\n\t\tt.Error(\"Local disk location not set properly\")\n\t}\n\n\t//Logger = log.New(os.Stdout, \"\", log.LstdFlags)\n\n\t// Do an initial checkout.\n\terr = repo.Get()\n\tif err != nil {\n\t\tt.Errorf(\"Unable to checkout SVN repo. Err was %s\", err)\n\t}\n\n\t// Verify SVN repo is a SVN repo\n\tif !repo.CheckLocal() {\n\t\tt.Error(\"Problem checking out repo or SVN CheckLocal is not working\")\n\t}\n\n\t// Verify an incorrect remote is caught when NewSvnRepo is used on an existing location\n\t_, nrerr := NewSvnRepo(\"https://github.com/Masterminds/VCSTestRepo/unknownbranch\", tempDir+\"/VCSTestRepo\")\n\tif nrerr != ErrWrongRemote {\n\t\tt.Error(\"ErrWrongRemote was not triggered for SVN\")\n\t}\n\n\t// Test internal lookup mechanism used outside of Hg specific functionality.\n\tltype, err := DetectVcsFromFS(tempDir + \"/VCSTestRepo\")\n\tif err != nil {\n\t\tt.Error(\"detectVcsFromFS unable to Svn repo\")\n\t}\n\tif ltype != Svn {\n\t\tt.Errorf(\"detectVcsFromFS detected %s instead of Svn type\", ltype)\n\t}\n\n\t// Commenting out auto-detection tests for SVN. NewRepo automatically detects\n\t// GitHub to be a Git repo and that's an issue for this test. Need an\n\t// SVN host that can autodetect from before using this test again.\n\t//\n\t// Test NewRepo on existing checkout. This should simply provide a working\n\t// instance without error based on looking at the local directory.\n\t// nrepo, nrerr := NewRepo(\"https://github.com/Masterminds/VCSTestRepo/trunk\", tempDir+\"/VCSTestRepo\")\n\t// if nrerr != nil {\n\t// \tt.Error(nrerr)\n\t// }\n\t// // Verify the right oject is returned. It will check the local repo type.\n\t// if nrepo.CheckLocal() == false {\n\t// \tt.Error(\"Wrong version returned from NewRepo\")\n\t// }\n\n\tv, err := repo.Current()\n\tif err != nil {\n\t\tt.Errorf(\"Error trying Svn Current: %s\", err)\n\t}\n\tif v != \"HEAD\" {\n\t\tt.Errorf(\"Current failed to detect Svn on HEAD. Got version: %s\", v)\n\t}\n\n\t// Update the version to a previous version.\n\terr = repo.UpdateVersion(\"r2\")\n\tif err != nil {\n\t\tt.Errorf(\"Unable to update SVN repo version. Err was %s\", err)\n\t}\n\n\t// Use Version to verify we are on the right version.\n\tv, err = repo.Version()\n\tif v != \"2\" {\n\t\tt.Error(\"Error checking checked SVN out version\")\n\t}\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tv, err = repo.Current()\n\tif err != nil {\n\t\tt.Errorf(\"Error trying Svn Current for ref: %s\", err)\n\t}\n\tif v != \"2\" {\n\t\tt.Errorf(\"Current failed to detect Svn on HEAD. Got version: %s\", v)\n\t}\n\n\t// Perform an update which should take up back to the latest version.\n\terr = repo.Update()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\t// Make sure we are on a newer version because of the update.\n\tv, err = repo.Version()\n\tif v == \"2\" {\n\t\tt.Error(\"Error with version. Still on old version. Update failed\")\n\t}\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\t// Use Date to verify we are on the right commit.\n\td, err := repo.Date()\n\tif d.Format(longForm) != \"2015-07-29 13:47:03 +0000\" {\n\t\tt.Error(\"Error checking checked out Svn commit date\")\n\t}\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\ttags, err := repo.Tags()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif len(tags) != 0 {\n\t\tt.Error(\"Svn is incorrectly returning tags\")\n\t}\n\n\ttags, err = repo.TagsFromCommit(\"2\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif len(tags) != 0 {\n\t\tt.Error(\"Svn is incorrectly returning tags for a commit\")\n\t}\n\n\tbranches, err := repo.Branches()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif len(branches) != 0 {\n\t\tt.Error(\"Svn is incorrectly returning branches\")\n\t}\n\n\tif !repo.IsReference(\"r4\") {\n\t\tt.Error(\"Svn is reporting a reference is not one\")\n\t}\n\n\tif repo.IsReference(\"55\") {\n\t\tt.Error(\"Svn is reporting a non-existent reference is one\")\n\t}\n\n\tif repo.IsDirty() {\n\t\tt.Error(\"Svn incorrectly reporting dirty\")\n\t}\n\n\tci, err := repo.CommitInfo(\"2\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif ci.Commit != \"2\" {\n\t\tt.Error(\"Svn.CommitInfo wrong commit id\")\n\t}\n\tif ci.Author != \"matt.farina\" {\n\t\tt.Error(\"Svn.CommitInfo wrong author\")\n\t}\n\tif ci.Message != \"Update README.md\" {\n\t\tt.Error(\"Svn.CommitInfo wrong message\")\n\t}\n\tti, err := time.Parse(time.RFC3339Nano, \"2015-07-29T13:46:20.000000Z\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif !ti.Equal(ci.Date) {\n\t\tt.Error(\"Svn.CommitInfo wrong date\")\n\t}\n\n\t_, err = repo.CommitInfo(\"555555555\")\n\tif err != ErrRevisionUnavailable {\n\t\tt.Error(\"Svn didn't return expected ErrRevisionUnavailable\")\n\t}\n\n\ttempDir2, err := ioutil.TempDir(\"\", \"go-vcs-svn-tests-export\")\n\tif err != nil {\n\t\tt.Fatalf(\"Error creating temp directory: %s\", err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir2)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\texportDir := filepath.Join(tempDir2, \"src\")\n\n\terr = repo.ExportDir(exportDir)\n\tif err != nil {\n\t\tt.Errorf(\"Unable to export Svn repo. Err was %s\", err)\n\t}\n\n\t_, err = os.Stat(filepath.Join(exportDir, \"README.md\"))\n\tif err != nil {\n\t\tt.Errorf(\"Error checking exported file in Svn: %s\", err)\n\t}\n\n\t_, err = os.Stat(filepath.Join(exportDir, string(repo.Vcs())))\n\tif err != nil {\n\t\tif found := os.IsNotExist(err); !found {\n\t\t\tt.Errorf(\"Error checking exported metadata in Svn: %s\", err)\n\t\t}\n\t} else {\n\t\tt.Error(\"Error checking Svn metadata. It exists.\")\n\t}\n}\n\nfunc TestSvnCheckLocal(t *testing.T) {\n\t// Verify repo.CheckLocal fails for non-SVN directories.\n\t// TestSvn is already checking on a valid repo\n\ttempDir, err := ioutil.TempDir(\"\", \"go-vcs-svn-tests\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\trepo, _ := NewSvnRepo(\"\", tempDir)\n\tif repo.CheckLocal() {\n\t\tt.Error(\"SVN CheckLocal does not identify non-SVN location\")\n\t}\n\n\t// Test NewRepo when there's no local. This should simply provide a working\n\t// instance without error based on looking at the remote localtion.\n\t_, nrerr := NewRepo(\"https://github.com/Masterminds/VCSTestRepo/trunk\", tempDir+\"/VCSTestRepo\")\n\tif nrerr != nil {\n\t\tt.Error(nrerr)\n\t}\n}\n\nfunc TestSvnPing(t *testing.T) {\n\ttempDir, err := ioutil.TempDir(\"\", \"go-vcs-svn-tests\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\trepo, err := NewSvnRepo(\"https://github.com/Masterminds/VCSTestRepo/trunk\", tempDir)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tping := repo.Ping()\n\tif !ping {\n\t\tt.Error(\"Svn unable to ping working repo\")\n\t}\n\n\trepo, err = NewSvnRepo(\"https://github.com/Masterminds/ihopethisneverexistsbecauseitshouldnt\", tempDir)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tping = repo.Ping()\n\tif ping {\n\t\tt.Error(\"Svn got a ping response from when it should not have\")\n\t}\n}\n\nfunc TestSvnInit(t *testing.T) {\n\ttempDir, err := ioutil.TempDir(\"\", \"go-vcs-svn-tests\")\n\tremoteDir := tempDir + string(os.PathSeparator) + \"remoteDir\"\n\tlocalDir := tempDir + string(os.PathSeparator) + \"localDir\"\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\trepo, err := NewSvnRepo(remoteDir, localDir)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\terr = repo.Init()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\terr = repo.Get()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tv, err := repo.Version()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif v != \"0\" {\n\t\tt.Errorf(\"Svn Init returns wrong version: %s\", v)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/vcs_local_lookup.go",
    "content": "package vcs\n\nimport (\n\t\"os\"\n\t\"runtime\"\n\t\"strings\"\n)\n\n// DetectVcsFromFS detects the type from the local path.\n// Is there a better way to do this?\nfunc DetectVcsFromFS(vcsPath string) (Type, error) {\n\n\t// There are cases under windows that a path could start with a / and it needs\n\t// to be stripped. For example, a path such as /C:\\foio\\bar.\n\tif runtime.GOOS == \"windows\" && strings.HasPrefix(vcsPath, \"/\") {\n\t\tvcsPath = strings.TrimPrefix(vcsPath, \"/\")\n\t}\n\n\t// When the local directory to the package doesn't exist\n\t// it's not yet downloaded so we can't detect the type\n\t// locally.\n\tif _, err := os.Stat(vcsPath); os.IsNotExist(err) {\n\t\treturn \"\", ErrCannotDetectVCS\n\t}\n\n\tseparator := string(os.PathSeparator)\n\n\t// Walk through each of the different VCS types to see if\n\t// one can be detected. Do this is order of guessed popularity.\n\tif _, err := os.Stat(vcsPath + separator + \".git\"); err == nil {\n\t\treturn Git, nil\n\t}\n\tif _, err := os.Stat(vcsPath + separator + \".svn\"); err == nil {\n\t\treturn Svn, nil\n\t}\n\tif _, err := os.Stat(vcsPath + separator + \".hg\"); err == nil {\n\t\treturn Hg, nil\n\t}\n\tif _, err := os.Stat(vcsPath + separator + \".bzr\"); err == nil {\n\t\treturn Bzr, nil\n\t}\n\n\t// If one was not already detected than we default to not finding it.\n\treturn \"\", ErrCannotDetectVCS\n\n}\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/vcs_remote_lookup.go",
    "content": "package vcs\n\nimport (\n\t\"encoding/json\"\n\t\"encoding/xml\"\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"regexp\"\n\t\"strings\"\n)\n\ntype vcsInfo struct {\n\thost     string\n\tpattern  string\n\tvcs      Type\n\taddCheck func(m map[string]string, u *url.URL) (Type, error)\n\tregex    *regexp.Regexp\n}\n\n// scpSyntaxRe matches the SCP-like addresses used by Git to access\n// repositories by SSH.\nvar scpSyntaxRe = regexp.MustCompile(`^([a-zA-Z0-9_]+)@([a-zA-Z0-9._-]+):(.*)$`)\n\nvar vcsList = []*vcsInfo{\n\t{\n\t\thost:    \"github.com\",\n\t\tvcs:     Git,\n\t\tpattern: `^(github\\.com[/|:][A-Za-z0-9_.\\-]+/[A-Za-z0-9_.\\-]+)(/[A-Za-z0-9_.\\-]+)*$`,\n\t},\n\t{\n\t\thost:     \"bitbucket.org\",\n\t\tpattern:  `^(bitbucket\\.org/(?P<name>[A-Za-z0-9_.\\-]+/[A-Za-z0-9_.\\-]+))(/[A-Za-z0-9_.\\-]+)*$`,\n\t\taddCheck: checkBitbucket,\n\t},\n\t{\n\t\thost:    \"launchpad.net\",\n\t\tpattern: `^(launchpad\\.net/(([A-Za-z0-9_.\\-]+)(/[A-Za-z0-9_.\\-]+)?|~[A-Za-z0-9_.\\-]+/(\\+junk|[A-Za-z0-9_.\\-]+)/[A-Za-z0-9_.\\-]+))(/[A-Za-z0-9_.\\-]+)*$`,\n\t\tvcs:     Bzr,\n\t},\n\t{\n\t\thost:    \"git.launchpad.net\",\n\t\tvcs:     Git,\n\t\tpattern: `^(git\\.launchpad\\.net/(([A-Za-z0-9_.\\-]+)|~[A-Za-z0-9_.\\-]+/(\\+git|[A-Za-z0-9_.\\-]+)/[A-Za-z0-9_.\\-]+))$`,\n\t},\n\t{\n\t\thost:    \"hub.jazz.net\",\n\t\tvcs:     Git,\n\t\tpattern: `^(hub\\.jazz\\.net/git/[a-z0-9]+/[A-Za-z0-9_.\\-]+)(/[A-Za-z0-9_.\\-]+)*$`,\n\t},\n\t{\n\t\thost:    \"go.googlesource.com\",\n\t\tvcs:     Git,\n\t\tpattern: `^(go\\.googlesource\\.com/[A-Za-z0-9_.\\-]+/?)$`,\n\t},\n\t{\n\t\thost:    \"git.openstack.org\",\n\t\tvcs:     Git,\n\t\tpattern: `^(git\\.openstack\\.org/[A-Za-z0-9_.\\-]+/[A-Za-z0-9_.\\-]+)$`,\n\t},\n\t// If none of the previous detect the type they will fall to this looking for the type in a generic sense\n\t// by the extension to the path.\n\t{\n\t\taddCheck: checkURL,\n\t\tpattern:  `\\.(?P<type>git|hg|svn|bzr)$`,\n\t},\n}\n\nfunc init() {\n\t// Precompile the regular expressions used to check VCS locations.\n\tfor _, v := range vcsList {\n\t\tv.regex = regexp.MustCompile(v.pattern)\n\t}\n}\n\n// This function is really a hack around Go redirects rather than around\n// something VCS related. Should this be moved to the glide project or a\n// helper function?\nfunc detectVcsFromRemote(vcsURL string) (Type, string, error) {\n\tt, e := detectVcsFromURL(vcsURL)\n\tif e == nil {\n\t\treturn t, vcsURL, nil\n\t} else if e != ErrCannotDetectVCS {\n\t\treturn NoVCS, \"\", e\n\t}\n\n\t// Pages like https://golang.org/x/net provide an html document with\n\t// meta tags containing a location to work with. The go tool uses\n\t// a meta tag with the name go-import which is what we use here.\n\t// godoc.org also has one call go-source that we do not need to use.\n\t// The value of go-import is in the form \"prefix vcs repo\". The prefix\n\t// should match the vcsURL and the repo is a location that can be\n\t// checked out. Note, to get the html document you you need to add\n\t// ?go-get=1 to the url.\n\tu, err := url.Parse(vcsURL)\n\tif err != nil {\n\t\treturn NoVCS, \"\", err\n\t}\n\tif u.RawQuery == \"\" {\n\t\tu.RawQuery = \"go-get=1\"\n\t} else {\n\t\tu.RawQuery = u.RawQuery + \"+go-get=1\"\n\t}\n\tcheckURL := u.String()\n\tresp, err := http.Get(checkURL)\n\tif err != nil {\n\t\treturn NoVCS, \"\", ErrCannotDetectVCS\n\t}\n\tdefer resp.Body.Close()\n\n\tt, nu, err := parseImportFromBody(u, resp.Body)\n\tif err != nil {\n\t\t// TODO(mattfarina): Log the parsing error\n\t\treturn NoVCS, \"\", ErrCannotDetectVCS\n\t} else if t == \"\" || nu == \"\" {\n\t\treturn NoVCS, \"\", ErrCannotDetectVCS\n\t}\n\n\treturn t, nu, nil\n}\n\n// From a remote vcs url attempt to detect the VCS.\nfunc detectVcsFromURL(vcsURL string) (Type, error) {\n\n\tvar u *url.URL\n\tvar err error\n\n\tif m := scpSyntaxRe.FindStringSubmatch(vcsURL); m != nil {\n\t\t// Match SCP-like syntax and convert it to a URL.\n\t\t// Eg, \"git@github.com:user/repo\" becomes\n\t\t// \"ssh://git@github.com/user/repo\".\n\t\tu = &url.URL{\n\t\t\tScheme: \"ssh\",\n\t\t\tUser:   url.User(m[1]),\n\t\t\tHost:   m[2],\n\t\t\tPath:   \"/\" + m[3],\n\t\t}\n\t} else {\n\t\tu, err = url.Parse(vcsURL)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\n\t// Detect file schemes\n\tif u.Scheme == \"file\" {\n\t\treturn DetectVcsFromFS(u.Path)\n\t}\n\n\tif u.Host == \"\" {\n\t\treturn \"\", ErrCannotDetectVCS\n\t}\n\n\t// Try to detect from the scheme\n\tswitch u.Scheme {\n\tcase \"git+ssh\":\n\t\treturn Git, nil\n\tcase \"git\":\n\t\treturn Git, nil\n\tcase \"bzr+ssh\":\n\t\treturn Bzr, nil\n\tcase \"svn+ssh\":\n\t\treturn Svn, nil\n\t}\n\n\t// Try to detect from known hosts, such as Github\n\tfor _, v := range vcsList {\n\t\tif v.host != \"\" && v.host != u.Host {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Make sure the pattern matches for an actual repo location. For example,\n\t\t// we should fail if the VCS listed is github.com/masterminds as that's\n\t\t// not actually a repo.\n\t\tuCheck := u.Host + u.Path\n\t\tm := v.regex.FindStringSubmatch(uCheck)\n\t\tif m == nil {\n\t\t\tif v.host != \"\" {\n\t\t\t\treturn \"\", ErrCannotDetectVCS\n\t\t\t}\n\n\t\t\tcontinue\n\t\t}\n\n\t\t// If we are here the host matches. If the host has a singular\n\t\t// VCS type, such as Github, we can return the type right away.\n\t\tif v.vcs != \"\" {\n\t\t\treturn v.vcs, nil\n\t\t}\n\n\t\t// Run additional checks to determine try and determine the repo\n\t\t// for the matched service.\n\t\tinfo := make(map[string]string)\n\t\tfor i, name := range v.regex.SubexpNames() {\n\t\t\tif name != \"\" {\n\t\t\t\tinfo[name] = m[i]\n\t\t\t}\n\t\t}\n\t\tt, err := v.addCheck(info, u)\n\t\tif err != nil {\n\t\t\tswitch err.(type) {\n\t\t\tcase *RemoteError:\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\treturn \"\", ErrCannotDetectVCS\n\t\t}\n\n\t\treturn t, nil\n\t}\n\n\t// Attempt to ascertain from the username passed in.\n\tif u.User != nil {\n\t\tun := u.User.Username()\n\t\tif un == \"git\" {\n\t\t\treturn Git, nil\n\t\t} else if un == \"hg\" {\n\t\t\treturn Hg, nil\n\t\t}\n\t}\n\n\t// Unable to determine the vcs from the url.\n\treturn \"\", ErrCannotDetectVCS\n}\n\n// Figure out the type for Bitbucket by the passed in information\n// or via the public API.\nfunc checkBitbucket(i map[string]string, ul *url.URL) (Type, error) {\n\n\t// Fast path for ssh urls where we may not even be able to\n\t// anonymously get details from the API.\n\tif ul.User != nil {\n\t\tun := ul.User.Username()\n\t\tif un == \"git\" {\n\t\t\treturn Git, nil\n\t\t} else if un == \"hg\" {\n\t\t\treturn Hg, nil\n\t\t}\n\t}\n\n\t// The part of the response we care about.\n\tvar response struct {\n\t\tSCM Type `json:\"scm\"`\n\t}\n\n\tu := expand(i, \"https://api.bitbucket.org/2.0/repositories/{name}?fields=scm\")\n\tdata, err := get(u)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif err := json.Unmarshal(data, &response); err != nil {\n\t\treturn \"\", fmt.Errorf(\"Decoding error %s: %v\", u, err)\n\t}\n\n\treturn response.SCM, nil\n\n}\n\n// Expect a type key on i with the exact type detected from the regex.\nfunc checkURL(i map[string]string, u *url.URL) (Type, error) {\n\treturn Type(i[\"type\"]), nil\n}\n\nfunc get(url string) ([]byte, error) {\n\tresp, err := http.Get(url)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\tif resp.StatusCode != 200 {\n\t\tif resp.StatusCode == 404 {\n\t\t\treturn nil, NewRemoteError(\"Not Found\", err, resp.Status)\n\t\t} else if resp.StatusCode == 401 || resp.StatusCode == 403 {\n\t\t\treturn nil, NewRemoteError(\"Access Denied\", err, resp.Status)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"%s: %s\", url, resp.Status)\n\t}\n\tb, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: %v\", url, err)\n\t}\n\treturn b, nil\n}\n\nfunc expand(match map[string]string, s string) string {\n\tfor k, v := range match {\n\t\ts = strings.Replace(s, \"{\"+k+\"}\", v, -1)\n\t}\n\treturn s\n}\n\nfunc parseImportFromBody(ur *url.URL, r io.ReadCloser) (tp Type, u string, err error) {\n\td := xml.NewDecoder(r)\n\td.CharsetReader = charsetReader\n\td.Strict = false\n\tvar t xml.Token\n\tfor {\n\t\tt, err = d.Token()\n\t\tif err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\t// When the end is reached it could not detect a VCS if it\n\t\t\t\t// got here.\n\t\t\t\terr = ErrCannotDetectVCS\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tif e, ok := t.(xml.StartElement); ok && strings.EqualFold(e.Name.Local, \"body\") {\n\t\t\treturn\n\t\t}\n\t\tif e, ok := t.(xml.EndElement); ok && strings.EqualFold(e.Name.Local, \"head\") {\n\t\t\treturn\n\t\t}\n\t\te, ok := t.(xml.StartElement)\n\t\tif !ok || !strings.EqualFold(e.Name.Local, \"meta\") {\n\t\t\tcontinue\n\t\t}\n\t\tif attrValue(e.Attr, \"name\") != \"go-import\" {\n\t\t\tcontinue\n\t\t}\n\t\tif f := strings.Fields(attrValue(e.Attr, \"content\")); len(f) == 3 {\n\t\t\t// If the prefix supplied by the remote system isn't a prefix to the\n\t\t\t// url we're fetching continue to look for other imports.\n\t\t\t// This will work for exact matches and prefixes. For example,\n\t\t\t// golang.org/x/net as a prefix will match for golang.org/x/net and\n\t\t\t// golang.org/x/net/context.\n\t\t\tvcsURL := ur.Host + ur.Path\n\t\t\tif !strings.HasPrefix(vcsURL, f[0]) {\n\t\t\t\tcontinue\n\t\t\t} else {\n\t\t\t\tswitch Type(f[1]) {\n\t\t\t\tcase Git:\n\t\t\t\t\ttp = Git\n\t\t\t\tcase Svn:\n\t\t\t\t\ttp = Svn\n\t\t\t\tcase Bzr:\n\t\t\t\t\ttp = Bzr\n\t\t\t\tcase Hg:\n\t\t\t\t\ttp = Hg\n\t\t\t\t}\n\n\t\t\t\tu = f[2]\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc charsetReader(charset string, input io.Reader) (io.Reader, error) {\n\tswitch strings.ToLower(charset) {\n\tcase \"ascii\":\n\t\treturn input, nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"can't decode XML document using charset %q\", charset)\n\t}\n}\n\nfunc attrValue(attrs []xml.Attr, name string) string {\n\tfor _, a := range attrs {\n\t\tif strings.EqualFold(a.Name.Local, name) {\n\t\t\treturn a.Value\n\t\t}\n\t}\n\treturn \"\"\n}\n"
  },
  {
    "path": "vendor/github.com/Masterminds/vcs/vcs_remote_lookup_test.go",
    "content": "package vcs\n\nimport (\n\t\"io/ioutil\"\n\t\"os\"\n\t\"os/exec\"\n\t\"runtime\"\n\t\"strings\"\n\t\"testing\"\n)\n\nfunc TestVCSLookup(t *testing.T) {\n\t// TODO: Expand to make sure it detected the right vcs.\n\turlList := map[string]struct {\n\t\twork bool\n\t\tt    Type\n\t}{\n\t\t\"https://github.com/masterminds\":                                   {work: false, t: Git},\n\t\t\"https://github.com/Masterminds/VCSTestRepo\":                       {work: true, t: Git},\n\t\t\"https://bitbucket.org/mattfarina/testhgrepo\":                      {work: true, t: Hg},\n\t\t\"https://bitbucket.org/mattfarina/repo-does-not-exist\":             {work: false, t: Hg},\n\t\t\"https://bitbucket.org/mattfarina/private-repo-for-vcs-testing\":    {work: false, t: Hg},\n\t\t\"https://launchpad.net/govcstestbzrrepo/trunk\":                     {work: true, t: Bzr},\n\t\t\"https://launchpad.net/~mattfarina/+junk/mygovcstestbzrrepo\":       {work: true, t: Bzr},\n\t\t\"https://launchpad.net/~mattfarina/+junk/mygovcstestbzrrepo/trunk\": {work: true, t: Bzr},\n\t\t\"https://git.launchpad.net/govcstestgitrepo\":                       {work: true, t: Git},\n\t\t\"https://git.launchpad.net/~mattfarina/+git/mygovcstestgitrepo\":    {work: true, t: Git},\n\t\t\"https://hub.jazz.net/git/user1/pkgname\":                           {work: true, t: Git},\n\t\t\"https://hub.jazz.net/git/user1/pkgname/subpkg/subpkg/subpkg\":      {work: true, t: Git},\n\t\t\"https://hubs.jazz.net/git/user1/pkgname\":                          {work: false, t: Git},\n\t\t\"https://example.com/foo/bar.git\":                                  {work: true, t: Git},\n\t\t\"https://example.com/foo/bar.svn\":                                  {work: true, t: Svn},\n\t\t\"https://example.com/foo/bar/baz.bzr\":                              {work: true, t: Bzr},\n\t\t\"https://example.com/foo/bar/baz.hg\":                               {work: true, t: Hg},\n\t\t\"https://gopkg.in/tomb.v1\":                                         {work: true, t: Git},\n\t\t\"https://golang.org/x/net\":                                         {work: true, t: Git},\n\t\t\"https://git.openstack.org/foo/bar\":                                {work: true, t: Git},\n\t\t\"git@github.com:Masterminds/vcs.git\":                               {work: true, t: Git},\n\t\t\"git@example.com:foo.git\":                                          {work: true, t: Git},\n\t\t\"ssh://hg@bitbucket.org/mattfarina/testhgrepo\":                     {work: true, t: Hg},\n\t\t\"git@bitbucket.org:mattfarina/glide-bitbucket-example.git\":         {work: true, t: Git},\n\t\t\"git+ssh://example.com/foo/bar\":                                    {work: true, t: Git},\n\t\t\"git://example.com/foo/bar\":                                        {work: true, t: Git},\n\t\t\"bzr+ssh://example.com/foo/bar\":                                    {work: true, t: Bzr},\n\t\t\"svn+ssh://example.com/foo/bar\":                                    {work: true, t: Svn},\n\t\t\"git@example.com:foo/bar\":                                          {work: true, t: Git},\n\t\t\"hg@example.com:foo/bar\":                                           {work: true, t: Hg},\n\t}\n\n\tfor u, c := range urlList {\n\t\tty, _, err := detectVcsFromRemote(u)\n\t\tif err == nil && !c.work {\n\t\t\tt.Errorf(\"Error detecting VCS from URL(%s)\", u)\n\t\t}\n\n\t\tif err == ErrCannotDetectVCS && c.work {\n\t\t\tt.Errorf(\"Error detecting VCS from URL(%s)\", u)\n\t\t}\n\n\t\tif err != nil && c.work {\n\t\t\tt.Errorf(\"Error detecting VCS from URL(%s): %s\", u, err)\n\t\t}\n\n\t\tif err != nil &&\n\t\t\terr != ErrCannotDetectVCS &&\n\t\t\t!strings.HasSuffix(err.Error(), \"Not Found\") &&\n\t\t\t!strings.HasSuffix(err.Error(), \"Access Denied\") &&\n\t\t\t!c.work {\n\t\t\tt.Errorf(\"Unexpected error returned (%s): %s\", u, err)\n\t\t}\n\n\t\tif c.work && ty != c.t {\n\t\t\tt.Errorf(\"Incorrect VCS type returned(%s)\", u)\n\t\t}\n\t}\n}\n\nfunc TestVCSFileLookup(t *testing.T) {\n\ttempDir, err := ioutil.TempDir(\"\", \"go-vcs-file-lookup-tests\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer func() {\n\t\terr = os.RemoveAll(tempDir)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}()\n\n\t_, err = exec.Command(\"git\", \"init\", tempDir).CombinedOutput()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\t// On Windows it should be file:// followed by /C:\\for\\bar. That / before\n\t// the drive needs to be included in testing.\n\tvar pth string\n\tif runtime.GOOS == \"windows\" {\n\t\tpth = \"file:///\" + tempDir\n\t} else {\n\t\tpth = \"file://\" + tempDir\n\t}\n\tty, _, err := detectVcsFromRemote(pth)\n\n\tif err != nil {\n\t\tt.Errorf(\"Unable to detect file:// path: %s\", err)\n\t}\n\n\tif ty != Git {\n\t\tt.Errorf(\"Detected wrong type from file:// path. Found type %v\", ty)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/.flake8",
    "content": "[flake8]\nmax-line-length = 120\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/.gitignore",
    "content": "*.coverprofile\nnode_modules/\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/.travis.yml",
    "content": "language: go\nsudo: false\ndist: trusty\nosx_image: xcode8.3\ngo: 1.8.x\n\nos:\n- linux\n- osx\n\ncache:\n  directories:\n  - node_modules\n\nbefore_script:\n- go get github.com/urfave/gfmrun/... || true\n- go get golang.org/x/tools/cmd/goimports\n- if [ ! -f node_modules/.bin/markdown-toc ] ; then\n    npm install markdown-toc ;\n  fi\n\nscript:\n- ./runtests gen\n- ./runtests vet\n- ./runtests test\n- ./runtests gfmrun\n- ./runtests toc\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/CHANGELOG.md",
    "content": "# Change Log\n\n**ATTN**: This project uses [semantic versioning](http://semver.org/).\n\n## [Unreleased]\n\n## 1.20.0 - 2017-08-10\n\n### Fixed\n\n* `HandleExitCoder` is now correctly iterates over all errors in\n  a `MultiError`. The exit code is the exit code of the last error or `1` if\n  there are no `ExitCoder`s in the `MultiError`.\n* Fixed YAML file loading on Windows (previously would fail validate the file path)\n* Subcommand `Usage`, `Description`, `ArgsUsage`, `OnUsageError` correctly\n  propogated\n* `ErrWriter` is now passed downwards through command structure to avoid the\n  need to redefine it\n* Pass `Command` context into `OnUsageError` rather than parent context so that\n  all fields are avaiable\n* Errors occuring in `Before` funcs are no longer double printed\n* Use `UsageText` in the help templates for commands and subcommands if\n  defined; otherwise build the usage as before (was previously ignoring this\n  field)\n* `IsSet` and `GlobalIsSet` now correctly return whether a flag is set if\n  a program calls `Set` or `GlobalSet` directly after flag parsing (would\n  previously only return `true` if the flag was set during parsing)\n\n### Changed\n\n* No longer exit the program on command/subcommand error if the error raised is\n  not an `OsExiter`. This exiting behavior was introduced in 1.19.0, but was\n  determined to be a regression in functionality. See [the\n  PR](https://github.com/urfave/cli/pull/595) for discussion.\n\n### Added\n\n* `CommandsByName` type was added to make it easy to sort `Command`s by name,\n  alphabetically\n* `altsrc` now handles loading of string and int arrays from TOML\n* Support for definition of custom help templates for `App` via\n  `CustomAppHelpTemplate`\n* Support for arbitrary key/value fields on `App` to be used with\n  `CustomAppHelpTemplate` via `ExtraInfo`\n* `HelpFlag`, `VersionFlag`, and `BashCompletionFlag` changed to explictly be\n  `cli.Flag`s allowing for the use of custom flags satisfying the `cli.Flag`\n  interface to be used.\n\n\n## [1.19.1] - 2016-11-21\n\n### Fixed\n\n- Fixes regression introduced in 1.19.0 where using an `ActionFunc` as\n  the `Action` for a command would cause it to error rather than calling the\n  function. Should not have a affected declarative cases using `func(c\n  *cli.Context) err)`.\n- Shell completion now handles the case where the user specifies\n  `--generate-bash-completion` immediately after a flag that takes an argument.\n  Previously it call the application with `--generate-bash-completion` as the\n  flag value.\n\n## [1.19.0] - 2016-11-19\n### Added\n- `FlagsByName` was added to make it easy to sort flags (e.g. `sort.Sort(cli.FlagsByName(app.Flags))`)\n- A `Description` field was added to `App` for a more detailed description of\n  the application (similar to the existing `Description` field on `Command`)\n- Flag type code generation via `go generate`\n- Write to stderr and exit 1 if action returns non-nil error\n- Added support for TOML to the `altsrc` loader\n- `SkipArgReorder` was added to allow users to skip the argument reordering.\n  This is useful if you want to consider all \"flags\" after an argument as\n  arguments rather than flags (the default behavior of the stdlib `flag`\n  library). This is backported functionality from the [removal of the flag\n  reordering](https://github.com/urfave/cli/pull/398) in the unreleased version\n  2\n- For formatted errors (those implementing `ErrorFormatter`), the errors will\n  be formatted during output. Compatible with `pkg/errors`.\n\n### Changed\n- Raise minimum tested/supported Go version to 1.2+\n\n### Fixed\n- Consider empty environment variables as set (previously environment variables\n  with the equivalent of `\"\"` would be skipped rather than their value used).\n- Return an error if the value in a given environment variable cannot be parsed\n  as the flag type. Previously these errors were silently swallowed.\n- Print full error when an invalid flag is specified (which includes the invalid flag)\n- `App.Writer` defaults to `stdout` when `nil`\n- If no action is specified on a command or app, the help is now printed instead of `panic`ing\n- `App.Metadata` is initialized automatically now (previously was `nil` unless initialized)\n- Correctly show help message if `-h` is provided to a subcommand\n- `context.(Global)IsSet` now respects environment variables. Previously it\n  would return `false` if a flag was specified in the environment rather than\n  as an argument\n- Removed deprecation warnings to STDERR to avoid them leaking to the end-user\n- `altsrc`s import paths were updated to use `gopkg.in/urfave/cli.v1`. This\n  fixes issues that occurred when `gopkg.in/urfave/cli.v1` was imported as well\n  as `altsrc` where Go would complain that the types didn't match\n\n## [1.18.1] - 2016-08-28\n### Fixed\n- Removed deprecation warnings to STDERR to avoid them leaking to the end-user (backported)\n\n## [1.18.0] - 2016-06-27\n### Added\n- `./runtests` test runner with coverage tracking by default\n- testing on OS X\n- testing on Windows\n- `UintFlag`, `Uint64Flag`, and `Int64Flag` types and supporting code\n\n### Changed\n- Use spaces for alignment in help/usage output instead of tabs, making the\n  output alignment consistent regardless of tab width\n\n### Fixed\n- Printing of command aliases in help text\n- Printing of visible flags for both struct and struct pointer flags\n- Display the `help` subcommand when using `CommandCategories`\n- No longer swallows `panic`s that occur within the `Action`s themselves when\n  detecting the signature of the `Action` field\n\n## [1.17.1] - 2016-08-28\n### Fixed\n- Removed deprecation warnings to STDERR to avoid them leaking to the end-user\n\n## [1.17.0] - 2016-05-09\n### Added\n- Pluggable flag-level help text rendering via `cli.DefaultFlagStringFunc`\n- `context.GlobalBoolT` was added as an analogue to `context.GlobalBool`\n- Support for hiding commands by setting `Hidden: true` -- this will hide the\n  commands in help output\n\n### Changed\n- `Float64Flag`, `IntFlag`, and `DurationFlag` default values are no longer\n  quoted in help text output.\n- All flag types now include `(default: {value})` strings following usage when a\n  default value can be (reasonably) detected.\n- `IntSliceFlag` and `StringSliceFlag` usage strings are now more consistent\n  with non-slice flag types\n- Apps now exit with a code of 3 if an unknown subcommand is specified\n  (previously they printed \"No help topic for...\", but still exited 0. This\n  makes it easier to script around apps built using `cli` since they can trust\n  that a 0 exit code indicated a successful execution.\n- cleanups based on [Go Report Card\n  feedback](https://goreportcard.com/report/github.com/urfave/cli)\n\n## [1.16.1] - 2016-08-28\n### Fixed\n- Removed deprecation warnings to STDERR to avoid them leaking to the end-user\n\n## [1.16.0] - 2016-05-02\n### Added\n- `Hidden` field on all flag struct types to omit from generated help text\n\n### Changed\n- `BashCompletionFlag` (`--enable-bash-completion`) is now omitted from\ngenerated help text via the `Hidden` field\n\n### Fixed\n- handling of error values in `HandleAction` and `HandleExitCoder`\n\n## [1.15.0] - 2016-04-30\n### Added\n- This file!\n- Support for placeholders in flag usage strings\n- `App.Metadata` map for arbitrary data/state management\n- `Set` and `GlobalSet` methods on `*cli.Context` for altering values after\nparsing.\n- Support for nested lookup of dot-delimited keys in structures loaded from\nYAML.\n\n### Changed\n- The `App.Action` and `Command.Action` now prefer a return signature of\n`func(*cli.Context) error`, as defined by `cli.ActionFunc`.  If a non-nil\n`error` is returned, there may be two outcomes:\n    - If the error fulfills `cli.ExitCoder`, then `os.Exit` will be called\n    automatically\n    - Else the error is bubbled up and returned from `App.Run`\n- Specifying an `Action` with the legacy return signature of\n`func(*cli.Context)` will produce a deprecation message to stderr\n- Specifying an `Action` that is not a `func` type will produce a non-zero exit\nfrom `App.Run`\n- Specifying an `Action` func that has an invalid (input) signature will\nproduce a non-zero exit from `App.Run`\n\n### Deprecated\n- <a name=\"deprecated-cli-app-runandexitonerror\"></a>\n`cli.App.RunAndExitOnError`, which should now be done by returning an error\nthat fulfills `cli.ExitCoder` to `cli.App.Run`.\n- <a name=\"deprecated-cli-app-action-signature\"></a> the legacy signature for\n`cli.App.Action` of `func(*cli.Context)`, which should now have a return\nsignature of `func(*cli.Context) error`, as defined by `cli.ActionFunc`.\n\n### Fixed\n- Added missing `*cli.Context.GlobalFloat64` method\n\n## [1.14.0] - 2016-04-03 (backfilled 2016-04-25)\n### Added\n- Codebeat badge\n- Support for categorization via `CategorizedHelp` and `Categories` on app.\n\n### Changed\n- Use `filepath.Base` instead of `path.Base` in `Name` and `HelpName`.\n\n### Fixed\n- Ensure version is not shown in help text when `HideVersion` set.\n\n## [1.13.0] - 2016-03-06 (backfilled 2016-04-25)\n### Added\n- YAML file input support.\n- `NArg` method on context.\n\n## [1.12.0] - 2016-02-17 (backfilled 2016-04-25)\n### Added\n- Custom usage error handling.\n- Custom text support in `USAGE` section of help output.\n- Improved help messages for empty strings.\n- AppVeyor CI configuration.\n\n### Changed\n- Removed `panic` from default help printer func.\n- De-duping and optimizations.\n\n### Fixed\n- Correctly handle `Before`/`After` at command level when no subcommands.\n- Case of literal `-` argument causing flag reordering.\n- Environment variable hints on Windows.\n- Docs updates.\n\n## [1.11.1] - 2015-12-21 (backfilled 2016-04-25)\n### Changed\n- Use `path.Base` in `Name` and `HelpName`\n- Export `GetName` on flag types.\n\n### Fixed\n- Flag parsing when skipping is enabled.\n- Test output cleanup.\n- Move completion check to account for empty input case.\n\n## [1.11.0] - 2015-11-15 (backfilled 2016-04-25)\n### Added\n- Destination scan support for flags.\n- Testing against `tip` in Travis CI config.\n\n### Changed\n- Go version in Travis CI config.\n\n### Fixed\n- Removed redundant tests.\n- Use correct example naming in tests.\n\n## [1.10.2] - 2015-10-29 (backfilled 2016-04-25)\n### Fixed\n- Remove unused var in bash completion.\n\n## [1.10.1] - 2015-10-21 (backfilled 2016-04-25)\n### Added\n- Coverage and reference logos in README.\n\n### Fixed\n- Use specified values in help and version parsing.\n- Only display app version and help message once.\n\n## [1.10.0] - 2015-10-06 (backfilled 2016-04-25)\n### Added\n- More tests for existing functionality.\n- `ArgsUsage` at app and command level for help text flexibility.\n\n### Fixed\n- Honor `HideHelp` and `HideVersion` in `App.Run`.\n- Remove juvenile word from README.\n\n## [1.9.0] - 2015-09-08 (backfilled 2016-04-25)\n### Added\n- `FullName` on command with accompanying help output update.\n- Set default `$PROG` in bash completion.\n\n### Changed\n- Docs formatting.\n\n### Fixed\n- Removed self-referential imports in tests.\n\n## [1.8.0] - 2015-06-30 (backfilled 2016-04-25)\n### Added\n- Support for `Copyright` at app level.\n- `Parent` func at context level to walk up context lineage.\n\n### Fixed\n- Global flag processing at top level.\n\n## [1.7.1] - 2015-06-11 (backfilled 2016-04-25)\n### Added\n- Aggregate errors from `Before`/`After` funcs.\n- Doc comments on flag structs.\n- Include non-global flags when checking version and help.\n- Travis CI config updates.\n\n### Fixed\n- Ensure slice type flags have non-nil values.\n- Collect global flags from the full command hierarchy.\n- Docs prose.\n\n## [1.7.0] - 2015-05-03 (backfilled 2016-04-25)\n### Changed\n- `HelpPrinter` signature includes output writer.\n\n### Fixed\n- Specify go 1.1+ in docs.\n- Set `Writer` when running command as app.\n\n## [1.6.0] - 2015-03-23 (backfilled 2016-04-25)\n### Added\n- Multiple author support.\n- `NumFlags` at context level.\n- `Aliases` at command level.\n\n### Deprecated\n- `ShortName` at command level.\n\n### Fixed\n- Subcommand help output.\n- Backward compatible support for deprecated `Author` and `Email` fields.\n- Docs regarding `Names`/`Aliases`.\n\n## [1.5.0] - 2015-02-20 (backfilled 2016-04-25)\n### Added\n- `After` hook func support at app and command level.\n\n### Fixed\n- Use parsed context when running command as subcommand.\n- Docs prose.\n\n## [1.4.1] - 2015-01-09 (backfilled 2016-04-25)\n### Added\n- Support for hiding `-h / --help` flags, but not `help` subcommand.\n- Stop flag parsing after `--`.\n\n### Fixed\n- Help text for generic flags to specify single value.\n- Use double quotes in output for defaults.\n- Use `ParseInt` instead of `ParseUint` for int environment var values.\n- Use `0` as base when parsing int environment var values.\n\n## [1.4.0] - 2014-12-12 (backfilled 2016-04-25)\n### Added\n- Support for environment variable lookup \"cascade\".\n- Support for `Stdout` on app for output redirection.\n\n### Fixed\n- Print command help instead of app help in `ShowCommandHelp`.\n\n## [1.3.1] - 2014-11-13 (backfilled 2016-04-25)\n### Added\n- Docs and example code updates.\n\n### Changed\n- Default `-v / --version` flag made optional.\n\n## [1.3.0] - 2014-08-10 (backfilled 2016-04-25)\n### Added\n- `FlagNames` at context level.\n- Exposed `VersionPrinter` var for more control over version output.\n- Zsh completion hook.\n- `AUTHOR` section in default app help template.\n- Contribution guidelines.\n- `DurationFlag` type.\n\n## [1.2.0] - 2014-08-02\n### Added\n- Support for environment variable defaults on flags plus tests.\n\n## [1.1.0] - 2014-07-15\n### Added\n- Bash completion.\n- Optional hiding of built-in help command.\n- Optional skipping of flag parsing at command level.\n- `Author`, `Email`, and `Compiled` metadata on app.\n- `Before` hook func support at app and command level.\n- `CommandNotFound` func support at app level.\n- Command reference available on context.\n- `GenericFlag` type.\n- `Float64Flag` type.\n- `BoolTFlag` type.\n- `IsSet` flag helper on context.\n- More flag lookup funcs at context level.\n- More tests &amp; docs.\n\n### Changed\n- Help template updates to account for presence/absence of flags.\n- Separated subcommand help template.\n- Exposed `HelpPrinter` var for more control over help output.\n\n## [1.0.0] - 2013-11-01\n### Added\n- `help` flag in default app flag set and each command flag set.\n- Custom handling of argument parsing errors.\n- Command lookup by name at app level.\n- `StringSliceFlag` type and supporting `StringSlice` type.\n- `IntSliceFlag` type and supporting `IntSlice` type.\n- Slice type flag lookups by name at context level.\n- Export of app and command help functions.\n- More tests &amp; docs.\n\n## 0.1.0 - 2013-07-22\n### Added\n- Initial implementation.\n\n[Unreleased]: https://github.com/urfave/cli/compare/v1.18.0...HEAD\n[1.18.0]: https://github.com/urfave/cli/compare/v1.17.0...v1.18.0\n[1.17.0]: https://github.com/urfave/cli/compare/v1.16.0...v1.17.0\n[1.16.0]: https://github.com/urfave/cli/compare/v1.15.0...v1.16.0\n[1.15.0]: https://github.com/urfave/cli/compare/v1.14.0...v1.15.0\n[1.14.0]: https://github.com/urfave/cli/compare/v1.13.0...v1.14.0\n[1.13.0]: https://github.com/urfave/cli/compare/v1.12.0...v1.13.0\n[1.12.0]: https://github.com/urfave/cli/compare/v1.11.1...v1.12.0\n[1.11.1]: https://github.com/urfave/cli/compare/v1.11.0...v1.11.1\n[1.11.0]: https://github.com/urfave/cli/compare/v1.10.2...v1.11.0\n[1.10.2]: https://github.com/urfave/cli/compare/v1.10.1...v1.10.2\n[1.10.1]: https://github.com/urfave/cli/compare/v1.10.0...v1.10.1\n[1.10.0]: https://github.com/urfave/cli/compare/v1.9.0...v1.10.0\n[1.9.0]: https://github.com/urfave/cli/compare/v1.8.0...v1.9.0\n[1.8.0]: https://github.com/urfave/cli/compare/v1.7.1...v1.8.0\n[1.7.1]: https://github.com/urfave/cli/compare/v1.7.0...v1.7.1\n[1.7.0]: https://github.com/urfave/cli/compare/v1.6.0...v1.7.0\n[1.6.0]: https://github.com/urfave/cli/compare/v1.5.0...v1.6.0\n[1.5.0]: https://github.com/urfave/cli/compare/v1.4.1...v1.5.0\n[1.4.1]: https://github.com/urfave/cli/compare/v1.4.0...v1.4.1\n[1.4.0]: https://github.com/urfave/cli/compare/v1.3.1...v1.4.0\n[1.3.1]: https://github.com/urfave/cli/compare/v1.3.0...v1.3.1\n[1.3.0]: https://github.com/urfave/cli/compare/v1.2.0...v1.3.0\n[1.2.0]: https://github.com/urfave/cli/compare/v1.1.0...v1.2.0\n[1.1.0]: https://github.com/urfave/cli/compare/v1.0.0...v1.1.0\n[1.0.0]: https://github.com/urfave/cli/compare/v0.1.0...v1.0.0\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/LICENSE",
    "content": "MIT License\n\nCopyright (c) 2016 Jeremy Saenz & Contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/README.md",
    "content": "cli\n===\n\n[![Build Status](https://travis-ci.org/urfave/cli.svg?branch=master)](https://travis-ci.org/urfave/cli)\n[![Windows Build Status](https://ci.appveyor.com/api/projects/status/rtgk5xufi932pb2v?svg=true)](https://ci.appveyor.com/project/urfave/cli)\n[![GoDoc](https://godoc.org/github.com/urfave/cli?status.svg)](https://godoc.org/github.com/urfave/cli)\n[![codebeat](https://codebeat.co/badges/0a8f30aa-f975-404b-b878-5fab3ae1cc5f)](https://codebeat.co/projects/github-com-urfave-cli)\n[![Go Report Card](https://goreportcard.com/badge/urfave/cli)](https://goreportcard.com/report/urfave/cli)\n[![top level coverage](https://gocover.io/_badge/github.com/urfave/cli?0 \"top level coverage\")](http://gocover.io/github.com/urfave/cli) /\n[![altsrc coverage](https://gocover.io/_badge/github.com/urfave/cli/altsrc?0 \"altsrc coverage\")](http://gocover.io/github.com/urfave/cli/altsrc)\n\n**Notice:** This is the library formerly known as\n`github.com/codegangsta/cli` -- Github will automatically redirect requests\nto this repository, but we recommend updating your references for clarity.\n\ncli is a simple, fast, and fun package for building command line apps in Go. The\ngoal is to enable developers to write fast and distributable command line\napplications in an expressive way.\n\n<!-- toc -->\n\n- [Overview](#overview)\n- [Installation](#installation)\n  * [Supported platforms](#supported-platforms)\n  * [Using the `v2` branch](#using-the-v2-branch)\n  * [Pinning to the `v1` releases](#pinning-to-the-v1-releases)\n- [Getting Started](#getting-started)\n- [Examples](#examples)\n  * [Arguments](#arguments)\n  * [Flags](#flags)\n    + [Placeholder Values](#placeholder-values)\n    + [Alternate Names](#alternate-names)\n    + [Ordering](#ordering)\n    + [Values from the Environment](#values-from-the-environment)\n    + [Values from alternate input sources (YAML, TOML, and others)](#values-from-alternate-input-sources-yaml-toml-and-others)\n  * [Subcommands](#subcommands)\n  * [Subcommands categories](#subcommands-categories)\n  * [Exit code](#exit-code)\n  * [Bash Completion](#bash-completion)\n    + [Enabling](#enabling)\n    + [Distribution](#distribution)\n    + [Customization](#customization)\n  * [Generated Help Text](#generated-help-text)\n    + [Customization](#customization-1)\n  * [Version Flag](#version-flag)\n    + [Customization](#customization-2)\n    + [Full API Example](#full-api-example)\n- [Contribution Guidelines](#contribution-guidelines)\n\n<!-- tocstop -->\n\n## Overview\n\nCommand line apps are usually so tiny that there is absolutely no reason why\nyour code should *not* be self-documenting. Things like generating help text and\nparsing command flags/options should not hinder productivity when writing a\ncommand line app.\n\n**This is where cli comes into play.** cli makes command line programming fun,\norganized, and expressive!\n\n## Installation\n\nMake sure you have a working Go environment.  Go version 1.2+ is supported.  [See\nthe install instructions for Go](http://golang.org/doc/install.html).\n\nTo install cli, simply run:\n```\n$ go get github.com/urfave/cli\n```\n\nMake sure your `PATH` includes the `$GOPATH/bin` directory so your commands can\nbe easily used:\n```\nexport PATH=$PATH:$GOPATH/bin\n```\n\n### Supported platforms\n\ncli is tested against multiple versions of Go on Linux, and against the latest\nreleased version of Go on OS X and Windows.  For full details, see\n[`./.travis.yml`](./.travis.yml) and [`./appveyor.yml`](./appveyor.yml).\n\n### Using the `v2` branch\n\n**Warning**: The `v2` branch is currently unreleased and considered unstable.\n\nThere is currently a long-lived branch named `v2` that is intended to land as\nthe new `master` branch once development there has settled down.  The current\n`master` branch (mirrored as `v1`) is being manually merged into `v2` on\nan irregular human-based schedule, but generally if one wants to \"upgrade\" to\n`v2` *now* and accept the volatility (read: \"awesomeness\") that comes along with\nthat, please use whatever version pinning of your preference, such as via\n`gopkg.in`:\n\n```\n$ go get gopkg.in/urfave/cli.v2\n```\n\n``` go\n...\nimport (\n  \"gopkg.in/urfave/cli.v2\" // imports as package \"cli\"\n)\n...\n```\n\n### Pinning to the `v1` releases\n\nSimilarly to the section above describing use of the `v2` branch, if one wants\nto avoid any unexpected compatibility pains once `v2` becomes `master`, then\npinning to `v1` is an acceptable option, e.g.:\n\n```\n$ go get gopkg.in/urfave/cli.v1\n```\n\n``` go\n...\nimport (\n  \"gopkg.in/urfave/cli.v1\" // imports as package \"cli\"\n)\n...\n```\n\nThis will pull the latest tagged `v1` release (e.g. `v1.18.1` at the time of writing).\n\n## Getting Started\n\nOne of the philosophies behind cli is that an API should be playful and full of\ndiscovery. So a cli app can be as little as one line of code in `main()`.\n\n<!-- {\n  \"args\": [\"&#45;&#45;help\"],\n  \"output\": \"A new cli application\"\n} -->\n``` go\npackage main\n\nimport (\n  \"os\"\n\n  \"github.com/urfave/cli\"\n)\n\nfunc main() {\n  cli.NewApp().Run(os.Args)\n}\n```\n\nThis app will run and show help text, but is not very useful. Let's give an\naction to execute and some help documentation:\n\n<!-- {\n  \"output\": \"boom! I say!\"\n} -->\n``` go\npackage main\n\nimport (\n  \"fmt\"\n  \"os\"\n\n  \"github.com/urfave/cli\"\n)\n\nfunc main() {\n  app := cli.NewApp()\n  app.Name = \"boom\"\n  app.Usage = \"make an explosive entrance\"\n  app.Action = func(c *cli.Context) error {\n    fmt.Println(\"boom! I say!\")\n    return nil\n  }\n\n  app.Run(os.Args)\n}\n```\n\nRunning this already gives you a ton of functionality, plus support for things\nlike subcommands and flags, which are covered below.\n\n## Examples\n\nBeing a programmer can be a lonely job. Thankfully by the power of automation\nthat is not the case! Let's create a greeter app to fend off our demons of\nloneliness!\n\nStart by creating a directory named `greet`, and within it, add a file,\n`greet.go` with the following code in it:\n\n<!-- {\n  \"output\": \"Hello friend!\"\n} -->\n``` go\npackage main\n\nimport (\n  \"fmt\"\n  \"os\"\n\n  \"github.com/urfave/cli\"\n)\n\nfunc main() {\n  app := cli.NewApp()\n  app.Name = \"greet\"\n  app.Usage = \"fight the loneliness!\"\n  app.Action = func(c *cli.Context) error {\n    fmt.Println(\"Hello friend!\")\n    return nil\n  }\n\n  app.Run(os.Args)\n}\n```\n\nInstall our command to the `$GOPATH/bin` directory:\n\n```\n$ go install\n```\n\nFinally run our new command:\n\n```\n$ greet\nHello friend!\n```\n\ncli also generates neat help text:\n\n```\n$ greet help\nNAME:\n    greet - fight the loneliness!\n\nUSAGE:\n    greet [global options] command [command options] [arguments...]\n\nVERSION:\n    0.0.0\n\nCOMMANDS:\n    help, h  Shows a list of commands or help for one command\n\nGLOBAL OPTIONS\n    --version Shows version information\n```\n\n### Arguments\n\nYou can lookup arguments by calling the `Args` function on `cli.Context`, e.g.:\n\n<!-- {\n  \"output\": \"Hello \\\"\"\n} -->\n``` go\npackage main\n\nimport (\n  \"fmt\"\n  \"os\"\n\n  \"github.com/urfave/cli\"\n)\n\nfunc main() {\n  app := cli.NewApp()\n\n  app.Action = func(c *cli.Context) error {\n    fmt.Printf(\"Hello %q\", c.Args().Get(0))\n    return nil\n  }\n\n  app.Run(os.Args)\n}\n```\n\n### Flags\n\nSetting and querying flags is simple.\n\n<!-- {\n  \"output\": \"Hello Nefertiti\"\n} -->\n``` go\npackage main\n\nimport (\n  \"fmt\"\n  \"os\"\n\n  \"github.com/urfave/cli\"\n)\n\nfunc main() {\n  app := cli.NewApp()\n\n  app.Flags = []cli.Flag {\n    cli.StringFlag{\n      Name: \"lang\",\n      Value: \"english\",\n      Usage: \"language for the greeting\",\n    },\n  }\n\n  app.Action = func(c *cli.Context) error {\n    name := \"Nefertiti\"\n    if c.NArg() > 0 {\n      name = c.Args().Get(0)\n    }\n    if c.String(\"lang\") == \"spanish\" {\n      fmt.Println(\"Hola\", name)\n    } else {\n      fmt.Println(\"Hello\", name)\n    }\n    return nil\n  }\n\n  app.Run(os.Args)\n}\n```\n\nYou can also set a destination variable for a flag, to which the content will be\nscanned.\n\n<!-- {\n  \"output\": \"Hello someone\"\n} -->\n``` go\npackage main\n\nimport (\n  \"os\"\n  \"fmt\"\n\n  \"github.com/urfave/cli\"\n)\n\nfunc main() {\n  var language string\n\n  app := cli.NewApp()\n\n  app.Flags = []cli.Flag {\n    cli.StringFlag{\n      Name:        \"lang\",\n      Value:       \"english\",\n      Usage:       \"language for the greeting\",\n      Destination: &language,\n    },\n  }\n\n  app.Action = func(c *cli.Context) error {\n    name := \"someone\"\n    if c.NArg() > 0 {\n      name = c.Args()[0]\n    }\n    if language == \"spanish\" {\n      fmt.Println(\"Hola\", name)\n    } else {\n      fmt.Println(\"Hello\", name)\n    }\n    return nil\n  }\n\n  app.Run(os.Args)\n}\n```\n\nSee full list of flags at http://godoc.org/github.com/urfave/cli\n\n#### Placeholder Values\n\nSometimes it's useful to specify a flag's value within the usage string itself.\nSuch placeholders are indicated with back quotes.\n\nFor example this:\n\n<!-- {\n  \"args\": [\"&#45;&#45;help\"],\n  \"output\": \"&#45;&#45;config FILE, &#45;c FILE\"\n} -->\n```go\npackage main\n\nimport (\n  \"os\"\n\n  \"github.com/urfave/cli\"\n)\n\nfunc main() {\n  app := cli.NewApp()\n\n  app.Flags = []cli.Flag{\n    cli.StringFlag{\n      Name:  \"config, c\",\n      Usage: \"Load configuration from `FILE`\",\n    },\n  }\n\n  app.Run(os.Args)\n}\n```\n\nWill result in help output like:\n\n```\n--config FILE, -c FILE   Load configuration from FILE\n```\n\nNote that only the first placeholder is used. Subsequent back-quoted words will\nbe left as-is.\n\n#### Alternate Names\n\nYou can set alternate (or short) names for flags by providing a comma-delimited\nlist for the `Name`. e.g.\n\n<!-- {\n  \"args\": [\"&#45;&#45;help\"],\n  \"output\": \"&#45;&#45;lang value, &#45;l value.*language for the greeting.*default: \\\"english\\\"\"\n} -->\n``` go\npackage main\n\nimport (\n  \"os\"\n\n  \"github.com/urfave/cli\"\n)\n\nfunc main() {\n  app := cli.NewApp()\n\n  app.Flags = []cli.Flag {\n    cli.StringFlag{\n      Name: \"lang, l\",\n      Value: \"english\",\n      Usage: \"language for the greeting\",\n    },\n  }\n\n  app.Run(os.Args)\n}\n```\n\nThat flag can then be set with `--lang spanish` or `-l spanish`. Note that\ngiving two different forms of the same flag in the same command invocation is an\nerror.\n\n#### Ordering\n\nFlags for the application and commands are shown in the order they are defined.\nHowever, it's possible to sort them from outside this library by using `FlagsByName`\nor `CommandsByName` with `sort`.\n\nFor example this:\n\n<!-- {\n  \"args\": [\"&#45;&#45;help\"],\n  \"output\": \"add a task to the list\\n.*complete a task on the list\\n.*\\n\\n.*\\n.*Load configuration from FILE\\n.*Language for the greeting.*\"\n} -->\n``` go\npackage main\n\nimport (\n  \"os\"\n  \"sort\"\n\n  \"github.com/urfave/cli\"\n)\n\nfunc main() {\n  app := cli.NewApp()\n\n  app.Flags = []cli.Flag {\n    cli.StringFlag{\n      Name: \"lang, l\",\n      Value: \"english\",\n      Usage: \"Language for the greeting\",\n    },\n    cli.StringFlag{\n      Name: \"config, c\",\n      Usage: \"Load configuration from `FILE`\",\n    },\n  }\n\n  app.Commands = []cli.Command{\n    {\n      Name:    \"complete\",\n      Aliases: []string{\"c\"},\n      Usage:   \"complete a task on the list\",\n      Action:  func(c *cli.Context) error {\n        return nil\n      },\n    },\n    {\n      Name:    \"add\",\n      Aliases: []string{\"a\"},\n      Usage:   \"add a task to the list\",\n      Action:  func(c *cli.Context) error {\n        return nil\n      },\n    },\n  }\n\n  sort.Sort(cli.FlagsByName(app.Flags))\n  sort.Sort(cli.CommandsByName(app.Commands))\n\n  app.Run(os.Args)\n}\n```\n\nWill result in help output like:\n\n```\n--config FILE, -c FILE  Load configuration from FILE\n--lang value, -l value  Language for the greeting (default: \"english\")\n```\n\n#### Values from the Environment\n\nYou can also have the default value set from the environment via `EnvVar`.  e.g.\n\n<!-- {\n  \"args\": [\"&#45;&#45;help\"],\n  \"output\": \"language for the greeting.*APP_LANG\"\n} -->\n``` go\npackage main\n\nimport (\n  \"os\"\n\n  \"github.com/urfave/cli\"\n)\n\nfunc main() {\n  app := cli.NewApp()\n\n  app.Flags = []cli.Flag {\n    cli.StringFlag{\n      Name: \"lang, l\",\n      Value: \"english\",\n      Usage: \"language for the greeting\",\n      EnvVar: \"APP_LANG\",\n    },\n  }\n\n  app.Run(os.Args)\n}\n```\n\nThe `EnvVar` may also be given as a comma-delimited \"cascade\", where the first\nenvironment variable that resolves is used as the default.\n\n<!-- {\n  \"args\": [\"&#45;&#45;help\"],\n  \"output\": \"language for the greeting.*LEGACY_COMPAT_LANG.*APP_LANG.*LANG\"\n} -->\n``` go\npackage main\n\nimport (\n  \"os\"\n\n  \"github.com/urfave/cli\"\n)\n\nfunc main() {\n  app := cli.NewApp()\n\n  app.Flags = []cli.Flag {\n    cli.StringFlag{\n      Name: \"lang, l\",\n      Value: \"english\",\n      Usage: \"language for the greeting\",\n      EnvVar: \"LEGACY_COMPAT_LANG,APP_LANG,LANG\",\n    },\n  }\n\n  app.Run(os.Args)\n}\n```\n\n#### Values from alternate input sources (YAML, TOML, and others)\n\nThere is a separate package altsrc that adds support for getting flag values\nfrom other file input sources.\n\nCurrently supported input source formats:\n* YAML\n* TOML\n\nIn order to get values for a flag from an alternate input source the following\ncode would be added to wrap an existing cli.Flag like below:\n\n``` go\n  altsrc.NewIntFlag(cli.IntFlag{Name: \"test\"})\n```\n\nInitialization must also occur for these flags. Below is an example initializing\ngetting data from a yaml file below.\n\n``` go\n  command.Before = altsrc.InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc(\"load\"))\n```\n\nThe code above will use the \"load\" string as a flag name to get the file name of\na yaml file from the cli.Context.  It will then use that file name to initialize\nthe yaml input source for any flags that are defined on that command.  As a note\nthe \"load\" flag used would also have to be defined on the command flags in order\nfor this code snipped to work.\n\nCurrently only the aboved specified formats are supported but developers can\nadd support for other input sources by implementing the\naltsrc.InputSourceContext for their given sources.\n\nHere is a more complete sample of a command using YAML support:\n\n<!-- {\n  \"args\": [\"test-cmd\", \"&#45;&#45;help\"],\n  \"output\": \"&#45&#45;test value.*default: 0\"\n} -->\n``` go\npackage notmain\n\nimport (\n  \"fmt\"\n  \"os\"\n\n  \"github.com/urfave/cli\"\n  \"github.com/urfave/cli/altsrc\"\n)\n\nfunc main() {\n  app := cli.NewApp()\n\n  flags := []cli.Flag{\n    altsrc.NewIntFlag(cli.IntFlag{Name: \"test\"}),\n    cli.StringFlag{Name: \"load\"},\n  }\n\n  app.Action = func(c *cli.Context) error {\n    fmt.Println(\"yaml ist rad\")\n    return nil\n  }\n\n  app.Before = altsrc.InitInputSourceWithContext(flags, altsrc.NewYamlSourceFromFlagFunc(\"load\"))\n  app.Flags = flags\n\n  app.Run(os.Args)\n}\n```\n\n### Subcommands\n\nSubcommands can be defined for a more git-like command line app.\n\n<!-- {\n  \"args\": [\"template\", \"add\"],\n  \"output\": \"new task template: .+\"\n} -->\n```go\npackage main\n\nimport (\n  \"fmt\"\n  \"os\"\n\n  \"github.com/urfave/cli\"\n)\n\nfunc main() {\n  app := cli.NewApp()\n\n  app.Commands = []cli.Command{\n    {\n      Name:    \"add\",\n      Aliases: []string{\"a\"},\n      Usage:   \"add a task to the list\",\n      Action:  func(c *cli.Context) error {\n        fmt.Println(\"added task: \", c.Args().First())\n        return nil\n      },\n    },\n    {\n      Name:    \"complete\",\n      Aliases: []string{\"c\"},\n      Usage:   \"complete a task on the list\",\n      Action:  func(c *cli.Context) error {\n        fmt.Println(\"completed task: \", c.Args().First())\n        return nil\n      },\n    },\n    {\n      Name:        \"template\",\n      Aliases:     []string{\"t\"},\n      Usage:       \"options for task templates\",\n      Subcommands: []cli.Command{\n        {\n          Name:  \"add\",\n          Usage: \"add a new template\",\n          Action: func(c *cli.Context) error {\n            fmt.Println(\"new task template: \", c.Args().First())\n            return nil\n          },\n        },\n        {\n          Name:  \"remove\",\n          Usage: \"remove an existing template\",\n          Action: func(c *cli.Context) error {\n            fmt.Println(\"removed task template: \", c.Args().First())\n            return nil\n          },\n        },\n      },\n    },\n  }\n\n  app.Run(os.Args)\n}\n```\n\n### Subcommands categories\n\nFor additional organization in apps that have many subcommands, you can\nassociate a category for each command to group them together in the help\noutput.\n\nE.g.\n\n```go\npackage main\n\nimport (\n  \"os\"\n\n  \"github.com/urfave/cli\"\n)\n\nfunc main() {\n  app := cli.NewApp()\n\n  app.Commands = []cli.Command{\n    {\n      Name: \"noop\",\n    },\n    {\n      Name:     \"add\",\n      Category: \"template\",\n    },\n    {\n      Name:     \"remove\",\n      Category: \"template\",\n    },\n  }\n\n  app.Run(os.Args)\n}\n```\n\nWill include:\n\n```\nCOMMANDS:\n    noop\n\n  Template actions:\n    add\n    remove\n```\n\n### Exit code\n\nCalling `App.Run` will not automatically call `os.Exit`, which means that by\ndefault the exit code will \"fall through\" to being `0`.  An explicit exit code\nmay be set by returning a non-nil error that fulfills `cli.ExitCoder`, *or* a\n`cli.MultiError` that includes an error that fulfills `cli.ExitCoder`, e.g.:\n\n``` go\npackage main\n\nimport (\n  \"os\"\n\n  \"github.com/urfave/cli\"\n)\n\nfunc main() {\n  app := cli.NewApp()\n  app.Flags = []cli.Flag{\n    cli.BoolTFlag{\n      Name:  \"ginger-crouton\",\n      Usage: \"is it in the soup?\",\n    },\n  }\n  app.Action = func(ctx *cli.Context) error {\n    if !ctx.Bool(\"ginger-crouton\") {\n      return cli.NewExitError(\"it is not in the soup\", 86)\n    }\n    return nil\n  }\n\n  app.Run(os.Args)\n}\n```\n\n### Bash Completion\n\nYou can enable completion commands by setting the `EnableBashCompletion`\nflag on the `App` object.  By default, this setting will only auto-complete to\nshow an app's subcommands, but you can write your own completion methods for\nthe App or its subcommands.\n\n<!-- {\n  \"args\": [\"complete\", \"&#45;&#45;generate&#45;bash&#45;completion\"],\n  \"output\": \"laundry\"\n} -->\n``` go\npackage main\n\nimport (\n  \"fmt\"\n  \"os\"\n\n  \"github.com/urfave/cli\"\n)\n\nfunc main() {\n  tasks := []string{\"cook\", \"clean\", \"laundry\", \"eat\", \"sleep\", \"code\"}\n\n  app := cli.NewApp()\n  app.EnableBashCompletion = true\n  app.Commands = []cli.Command{\n    {\n      Name:  \"complete\",\n      Aliases: []string{\"c\"},\n      Usage: \"complete a task on the list\",\n      Action: func(c *cli.Context) error {\n         fmt.Println(\"completed task: \", c.Args().First())\n         return nil\n      },\n      BashComplete: func(c *cli.Context) {\n        // This will complete if no args are passed\n        if c.NArg() > 0 {\n          return\n        }\n        for _, t := range tasks {\n          fmt.Println(t)\n        }\n      },\n    },\n  }\n\n  app.Run(os.Args)\n}\n```\n\n#### Enabling\n\nSource the `autocomplete/bash_autocomplete` file in your `.bashrc` file while\nsetting the `PROG` variable to the name of your program:\n\n`PROG=myprogram source /.../cli/autocomplete/bash_autocomplete`\n\n#### Distribution\n\nCopy `autocomplete/bash_autocomplete` into `/etc/bash_completion.d/` and rename\nit to the name of the program you wish to add autocomplete support for (or\nautomatically install it there if you are distributing a package). Don't forget\nto source the file to make it active in the current shell.\n\n```\nsudo cp src/bash_autocomplete /etc/bash_completion.d/<myprogram>\nsource /etc/bash_completion.d/<myprogram>\n```\n\nAlternatively, you can just document that users should source the generic\n`autocomplete/bash_autocomplete` in their bash configuration with `$PROG` set\nto the name of their program (as above).\n\n#### Customization\n\nThe default bash completion flag (`--generate-bash-completion`) is defined as\n`cli.BashCompletionFlag`, and may be redefined if desired, e.g.:\n\n<!-- {\n  \"args\": [\"&#45;&#45;compgen\"],\n  \"output\": \"wat\\nhelp\\nh\"\n} -->\n``` go\npackage main\n\nimport (\n  \"os\"\n\n  \"github.com/urfave/cli\"\n)\n\nfunc main() {\n  cli.BashCompletionFlag = cli.BoolFlag{\n    Name:   \"compgen\",\n    Hidden: true,\n  }\n\n  app := cli.NewApp()\n  app.EnableBashCompletion = true\n  app.Commands = []cli.Command{\n    {\n      Name: \"wat\",\n    },\n  }\n  app.Run(os.Args)\n}\n```\n\n### Generated Help Text\n\nThe default help flag (`-h/--help`) is defined as `cli.HelpFlag` and is checked\nby the cli internals in order to print generated help text for the app, command,\nor subcommand, and break execution.\n\n#### Customization\n\nAll of the help text generation may be customized, and at multiple levels.  The\ntemplates are exposed as variables `AppHelpTemplate`, `CommandHelpTemplate`, and\n`SubcommandHelpTemplate` which may be reassigned or augmented, and full override\nis possible by assigning a compatible func to the `cli.HelpPrinter` variable,\ne.g.:\n\n<!-- {\n  \"output\": \"Ha HA.  I pwnd the help!!1\"\n} -->\n``` go\npackage main\n\nimport (\n  \"fmt\"\n  \"io\"\n  \"os\"\n\n  \"github.com/urfave/cli\"\n)\n\nfunc main() {\n  // EXAMPLE: Append to an existing template\n  cli.AppHelpTemplate = fmt.Sprintf(`%s\n\nWEBSITE: http://awesometown.example.com\n\nSUPPORT: support@awesometown.example.com\n\n`, cli.AppHelpTemplate)\n\n  // EXAMPLE: Override a template\n  cli.AppHelpTemplate = `NAME:\n   {{.Name}} - {{.Usage}}\nUSAGE:\n   {{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}\n   {{if len .Authors}}\nAUTHOR:\n   {{range .Authors}}{{ . }}{{end}}\n   {{end}}{{if .Commands}}\nCOMMANDS:\n{{range .Commands}}{{if not .HideHelp}}   {{join .Names \", \"}}{{ \"\\t\"}}{{.Usage}}{{ \"\\n\" }}{{end}}{{end}}{{end}}{{if .VisibleFlags}}\nGLOBAL OPTIONS:\n   {{range .VisibleFlags}}{{.}}\n   {{end}}{{end}}{{if .Copyright }}\nCOPYRIGHT:\n   {{.Copyright}}\n   {{end}}{{if .Version}}\nVERSION:\n   {{.Version}}\n   {{end}}\n`\n\n  // EXAMPLE: Replace the `HelpPrinter` func\n  cli.HelpPrinter = func(w io.Writer, templ string, data interface{}) {\n    fmt.Println(\"Ha HA.  I pwnd the help!!1\")\n  }\n\n  cli.NewApp().Run(os.Args)\n}\n```\n\nThe default flag may be customized to something other than `-h/--help` by\nsetting `cli.HelpFlag`, e.g.:\n\n<!-- {\n  \"args\": [\"&#45;&#45halp\"],\n  \"output\": \"haaaaalp.*HALP\"\n} -->\n``` go\npackage main\n\nimport (\n  \"os\"\n\n  \"github.com/urfave/cli\"\n)\n\nfunc main() {\n  cli.HelpFlag = cli.BoolFlag{\n    Name: \"halp, haaaaalp\",\n    Usage: \"HALP\",\n    EnvVar: \"SHOW_HALP,HALPPLZ\",\n  }\n\n  cli.NewApp().Run(os.Args)\n}\n```\n\n### Version Flag\n\nThe default version flag (`-v/--version`) is defined as `cli.VersionFlag`, which\nis checked by the cli internals in order to print the `App.Version` via\n`cli.VersionPrinter` and break execution.\n\n#### Customization\n\nThe default flag may be customized to something other than `-v/--version` by\nsetting `cli.VersionFlag`, e.g.:\n\n<!-- {\n  \"args\": [\"&#45;&#45print-version\"],\n  \"output\": \"partay version 19\\\\.99\\\\.0\"\n} -->\n``` go\npackage main\n\nimport (\n  \"os\"\n\n  \"github.com/urfave/cli\"\n)\n\nfunc main() {\n  cli.VersionFlag = cli.BoolFlag{\n    Name: \"print-version, V\",\n    Usage: \"print only the version\",\n  }\n\n  app := cli.NewApp()\n  app.Name = \"partay\"\n  app.Version = \"19.99.0\"\n  app.Run(os.Args)\n}\n```\n\nAlternatively, the version printer at `cli.VersionPrinter` may be overridden, e.g.:\n\n<!-- {\n  \"args\": [\"&#45;&#45version\"],\n  \"output\": \"version=19\\\\.99\\\\.0 revision=fafafaf\"\n} -->\n``` go\npackage main\n\nimport (\n  \"fmt\"\n  \"os\"\n\n  \"github.com/urfave/cli\"\n)\n\nvar (\n  Revision = \"fafafaf\"\n)\n\nfunc main() {\n  cli.VersionPrinter = func(c *cli.Context) {\n    fmt.Printf(\"version=%s revision=%s\\n\", c.App.Version, Revision)\n  }\n\n  app := cli.NewApp()\n  app.Name = \"partay\"\n  app.Version = \"19.99.0\"\n  app.Run(os.Args)\n}\n```\n\n#### Full API Example\n\n**Notice**: This is a contrived (functioning) example meant strictly for API\ndemonstration purposes.  Use of one's imagination is encouraged.\n\n<!-- {\n  \"output\": \"made it!\\nPhew!\"\n} -->\n``` go\npackage main\n\nimport (\n  \"errors\"\n  \"flag\"\n  \"fmt\"\n  \"io\"\n  \"io/ioutil\"\n  \"os\"\n  \"time\"\n\n  \"github.com/urfave/cli\"\n)\n\nfunc init() {\n  cli.AppHelpTemplate += \"\\nCUSTOMIZED: you bet ur muffins\\n\"\n  cli.CommandHelpTemplate += \"\\nYMMV\\n\"\n  cli.SubcommandHelpTemplate += \"\\nor something\\n\"\n\n  cli.HelpFlag = cli.BoolFlag{Name: \"halp\"}\n  cli.BashCompletionFlag = cli.BoolFlag{Name: \"compgen\", Hidden: true}\n  cli.VersionFlag = cli.BoolFlag{Name: \"print-version, V\"}\n\n  cli.HelpPrinter = func(w io.Writer, templ string, data interface{}) {\n    fmt.Fprintf(w, \"best of luck to you\\n\")\n  }\n  cli.VersionPrinter = func(c *cli.Context) {\n    fmt.Fprintf(c.App.Writer, \"version=%s\\n\", c.App.Version)\n  }\n  cli.OsExiter = func(c int) {\n    fmt.Fprintf(cli.ErrWriter, \"refusing to exit %d\\n\", c)\n  }\n  cli.ErrWriter = ioutil.Discard\n  cli.FlagStringer = func(fl cli.Flag) string {\n    return fmt.Sprintf(\"\\t\\t%s\", fl.GetName())\n  }\n}\n\ntype hexWriter struct{}\n\nfunc (w *hexWriter) Write(p []byte) (int, error) {\n  for _, b := range p {\n    fmt.Printf(\"%x\", b)\n  }\n  fmt.Printf(\"\\n\")\n\n  return len(p), nil\n}\n\ntype genericType struct{\n  s string\n}\n\nfunc (g *genericType) Set(value string) error {\n  g.s = value\n  return nil\n}\n\nfunc (g *genericType) String() string {\n  return g.s\n}\n\nfunc main() {\n  app := cli.NewApp()\n  app.Name = \"kənˈtrīv\"\n  app.Version = \"19.99.0\"\n  app.Compiled = time.Now()\n  app.Authors = []cli.Author{\n    cli.Author{\n      Name:  \"Example Human\",\n      Email: \"human@example.com\",\n    },\n  }\n  app.Copyright = \"(c) 1999 Serious Enterprise\"\n  app.HelpName = \"contrive\"\n  app.Usage = \"demonstrate available API\"\n  app.UsageText = \"contrive - demonstrating the available API\"\n  app.ArgsUsage = \"[args and such]\"\n  app.Commands = []cli.Command{\n    cli.Command{\n      Name:        \"doo\",\n      Aliases:     []string{\"do\"},\n      Category:    \"motion\",\n      Usage:       \"do the doo\",\n      UsageText:   \"doo - does the dooing\",\n      Description: \"no really, there is a lot of dooing to be done\",\n      ArgsUsage:   \"[arrgh]\",\n      Flags: []cli.Flag{\n        cli.BoolFlag{Name: \"forever, forevvarr\"},\n      },\n      Subcommands: cli.Commands{\n        cli.Command{\n          Name:   \"wop\",\n          Action: wopAction,\n        },\n      },\n      SkipFlagParsing: false,\n      HideHelp:        false,\n      Hidden:          false,\n      HelpName:        \"doo!\",\n      BashComplete: func(c *cli.Context) {\n        fmt.Fprintf(c.App.Writer, \"--better\\n\")\n      },\n      Before: func(c *cli.Context) error {\n        fmt.Fprintf(c.App.Writer, \"brace for impact\\n\")\n        return nil\n      },\n      After: func(c *cli.Context) error {\n        fmt.Fprintf(c.App.Writer, \"did we lose anyone?\\n\")\n        return nil\n      },\n      Action: func(c *cli.Context) error {\n        c.Command.FullName()\n        c.Command.HasName(\"wop\")\n        c.Command.Names()\n        c.Command.VisibleFlags()\n        fmt.Fprintf(c.App.Writer, \"dodododododoodododddooooododododooo\\n\")\n        if c.Bool(\"forever\") {\n          c.Command.Run(c)\n        }\n        return nil\n      },\n      OnUsageError: func(c *cli.Context, err error, isSubcommand bool) error {\n        fmt.Fprintf(c.App.Writer, \"for shame\\n\")\n        return err\n      },\n    },\n  }\n  app.Flags = []cli.Flag{\n    cli.BoolFlag{Name: \"fancy\"},\n    cli.BoolTFlag{Name: \"fancier\"},\n    cli.DurationFlag{Name: \"howlong, H\", Value: time.Second * 3},\n    cli.Float64Flag{Name: \"howmuch\"},\n    cli.GenericFlag{Name: \"wat\", Value: &genericType{}},\n    cli.Int64Flag{Name: \"longdistance\"},\n    cli.Int64SliceFlag{Name: \"intervals\"},\n    cli.IntFlag{Name: \"distance\"},\n    cli.IntSliceFlag{Name: \"times\"},\n    cli.StringFlag{Name: \"dance-move, d\"},\n    cli.StringSliceFlag{Name: \"names, N\"},\n    cli.UintFlag{Name: \"age\"},\n    cli.Uint64Flag{Name: \"bigage\"},\n  }\n  app.EnableBashCompletion = true\n  app.HideHelp = false\n  app.HideVersion = false\n  app.BashComplete = func(c *cli.Context) {\n    fmt.Fprintf(c.App.Writer, \"lipstick\\nkiss\\nme\\nlipstick\\nringo\\n\")\n  }\n  app.Before = func(c *cli.Context) error {\n    fmt.Fprintf(c.App.Writer, \"HEEEERE GOES\\n\")\n    return nil\n  }\n  app.After = func(c *cli.Context) error {\n    fmt.Fprintf(c.App.Writer, \"Phew!\\n\")\n    return nil\n  }\n  app.CommandNotFound = func(c *cli.Context, command string) {\n    fmt.Fprintf(c.App.Writer, \"Thar be no %q here.\\n\", command)\n  }\n  app.OnUsageError = func(c *cli.Context, err error, isSubcommand bool) error {\n    if isSubcommand {\n      return err\n    }\n\n    fmt.Fprintf(c.App.Writer, \"WRONG: %#v\\n\", err)\n    return nil\n  }\n  app.Action = func(c *cli.Context) error {\n    cli.DefaultAppComplete(c)\n    cli.HandleExitCoder(errors.New(\"not an exit coder, though\"))\n    cli.ShowAppHelp(c)\n    cli.ShowCommandCompletions(c, \"nope\")\n    cli.ShowCommandHelp(c, \"also-nope\")\n    cli.ShowCompletions(c)\n    cli.ShowSubcommandHelp(c)\n    cli.ShowVersion(c)\n\n    categories := c.App.Categories()\n    categories.AddCommand(\"sounds\", cli.Command{\n      Name: \"bloop\",\n    })\n\n    for _, category := range c.App.Categories() {\n      fmt.Fprintf(c.App.Writer, \"%s\\n\", category.Name)\n      fmt.Fprintf(c.App.Writer, \"%#v\\n\", category.Commands)\n      fmt.Fprintf(c.App.Writer, \"%#v\\n\", category.VisibleCommands())\n    }\n\n    fmt.Printf(\"%#v\\n\", c.App.Command(\"doo\"))\n    if c.Bool(\"infinite\") {\n      c.App.Run([]string{\"app\", \"doo\", \"wop\"})\n    }\n\n    if c.Bool(\"forevar\") {\n      c.App.RunAsSubcommand(c)\n    }\n    c.App.Setup()\n    fmt.Printf(\"%#v\\n\", c.App.VisibleCategories())\n    fmt.Printf(\"%#v\\n\", c.App.VisibleCommands())\n    fmt.Printf(\"%#v\\n\", c.App.VisibleFlags())\n\n    fmt.Printf(\"%#v\\n\", c.Args().First())\n    if len(c.Args()) > 0 {\n      fmt.Printf(\"%#v\\n\", c.Args()[1])\n    }\n    fmt.Printf(\"%#v\\n\", c.Args().Present())\n    fmt.Printf(\"%#v\\n\", c.Args().Tail())\n\n    set := flag.NewFlagSet(\"contrive\", 0)\n    nc := cli.NewContext(c.App, set, c)\n\n    fmt.Printf(\"%#v\\n\", nc.Args())\n    fmt.Printf(\"%#v\\n\", nc.Bool(\"nope\"))\n    fmt.Printf(\"%#v\\n\", nc.BoolT(\"nerp\"))\n    fmt.Printf(\"%#v\\n\", nc.Duration(\"howlong\"))\n    fmt.Printf(\"%#v\\n\", nc.Float64(\"hay\"))\n    fmt.Printf(\"%#v\\n\", nc.Generic(\"bloop\"))\n    fmt.Printf(\"%#v\\n\", nc.Int64(\"bonk\"))\n    fmt.Printf(\"%#v\\n\", nc.Int64Slice(\"burnks\"))\n    fmt.Printf(\"%#v\\n\", nc.Int(\"bips\"))\n    fmt.Printf(\"%#v\\n\", nc.IntSlice(\"blups\"))\n    fmt.Printf(\"%#v\\n\", nc.String(\"snurt\"))\n    fmt.Printf(\"%#v\\n\", nc.StringSlice(\"snurkles\"))\n    fmt.Printf(\"%#v\\n\", nc.Uint(\"flub\"))\n    fmt.Printf(\"%#v\\n\", nc.Uint64(\"florb\"))\n    fmt.Printf(\"%#v\\n\", nc.GlobalBool(\"global-nope\"))\n    fmt.Printf(\"%#v\\n\", nc.GlobalBoolT(\"global-nerp\"))\n    fmt.Printf(\"%#v\\n\", nc.GlobalDuration(\"global-howlong\"))\n    fmt.Printf(\"%#v\\n\", nc.GlobalFloat64(\"global-hay\"))\n    fmt.Printf(\"%#v\\n\", nc.GlobalGeneric(\"global-bloop\"))\n    fmt.Printf(\"%#v\\n\", nc.GlobalInt(\"global-bips\"))\n    fmt.Printf(\"%#v\\n\", nc.GlobalIntSlice(\"global-blups\"))\n    fmt.Printf(\"%#v\\n\", nc.GlobalString(\"global-snurt\"))\n    fmt.Printf(\"%#v\\n\", nc.GlobalStringSlice(\"global-snurkles\"))\n\n    fmt.Printf(\"%#v\\n\", nc.FlagNames())\n    fmt.Printf(\"%#v\\n\", nc.GlobalFlagNames())\n    fmt.Printf(\"%#v\\n\", nc.GlobalIsSet(\"wat\"))\n    fmt.Printf(\"%#v\\n\", nc.GlobalSet(\"wat\", \"nope\"))\n    fmt.Printf(\"%#v\\n\", nc.NArg())\n    fmt.Printf(\"%#v\\n\", nc.NumFlags())\n    fmt.Printf(\"%#v\\n\", nc.Parent())\n\n    nc.Set(\"wat\", \"also-nope\")\n\n    ec := cli.NewExitError(\"ohwell\", 86)\n    fmt.Fprintf(c.App.Writer, \"%d\", ec.ExitCode())\n    fmt.Printf(\"made it!\\n\")\n    return ec\n  }\n\n  if os.Getenv(\"HEXY\") != \"\" {\n    app.Writer = &hexWriter{}\n    app.ErrWriter = &hexWriter{}\n  }\n\n  app.Metadata = map[string]interface{}{\n    \"layers\":     \"many\",\n    \"explicable\": false,\n    \"whatever-values\": 19.99,\n  }\n\n  app.Run(os.Args)\n}\n\nfunc wopAction(c *cli.Context) error {\n  fmt.Fprintf(c.App.Writer, \":wave: over here, eh\\n\")\n  return nil\n}\n```\n\n## Contribution Guidelines\n\nFeel free to put up a pull request to fix a bug or maybe add a feature. I will\ngive it a code review and make sure that it does not break backwards\ncompatibility. If I or any other collaborators agree that it is in line with\nthe vision of the project, we will work with you to get the code into\na mergeable state and merge it into the master branch.\n\nIf you have contributed something significant to the project, we will most\nlikely add you as a collaborator. As a collaborator you are given the ability\nto merge others pull requests. It is very important that new code does not\nbreak existing code, so be careful about what code you do choose to merge.\n\nIf you feel like you have contributed to the project but have not yet been\nadded as a collaborator, we probably forgot to add you, please open an issue.\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/altsrc/altsrc.go",
    "content": "package altsrc\n\n//go:generate python ../generate-flag-types altsrc -i ../flag-types.json -o flag_generated.go\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/altsrc/flag.go",
    "content": "package altsrc\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n\t\"syscall\"\n\n\t\"gopkg.in/urfave/cli.v1\"\n)\n\n// FlagInputSourceExtension is an extension interface of cli.Flag that\n// allows a value to be set on the existing parsed flags.\ntype FlagInputSourceExtension interface {\n\tcli.Flag\n\tApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error\n}\n\n// ApplyInputSourceValues iterates over all provided flags and\n// executes ApplyInputSourceValue on flags implementing the\n// FlagInputSourceExtension interface to initialize these flags\n// to an alternate input source.\nfunc ApplyInputSourceValues(context *cli.Context, inputSourceContext InputSourceContext, flags []cli.Flag) error {\n\tfor _, f := range flags {\n\t\tinputSourceExtendedFlag, isType := f.(FlagInputSourceExtension)\n\t\tif isType {\n\t\t\terr := inputSourceExtendedFlag.ApplyInputSourceValue(context, inputSourceContext)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// InitInputSource is used to to setup an InputSourceContext on a cli.Command Before method. It will create a new\n// input source based on the func provided. If there is no error it will then apply the new input source to any flags\n// that are supported by the input source\nfunc InitInputSource(flags []cli.Flag, createInputSource func() (InputSourceContext, error)) cli.BeforeFunc {\n\treturn func(context *cli.Context) error {\n\t\tinputSource, err := createInputSource()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Unable to create input source: inner error: \\n'%v'\", err.Error())\n\t\t}\n\n\t\treturn ApplyInputSourceValues(context, inputSource, flags)\n\t}\n}\n\n// InitInputSourceWithContext is used to to setup an InputSourceContext on a cli.Command Before method. It will create a new\n// input source based on the func provided with potentially using existing cli.Context values to initialize itself. If there is\n// no error it will then apply the new input source to any flags that are supported by the input source\nfunc InitInputSourceWithContext(flags []cli.Flag, createInputSource func(context *cli.Context) (InputSourceContext, error)) cli.BeforeFunc {\n\treturn func(context *cli.Context) error {\n\t\tinputSource, err := createInputSource(context)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Unable to create input source with context: inner error: \\n'%v'\", err.Error())\n\t\t}\n\n\t\treturn ApplyInputSourceValues(context, inputSource, flags)\n\t}\n}\n\n// ApplyInputSourceValue applies a generic value to the flagSet if required\nfunc (f *GenericFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error {\n\tif f.set != nil {\n\t\tif !context.IsSet(f.Name) && !isEnvVarSet(f.EnvVar) {\n\t\t\tvalue, err := isc.Generic(f.GenericFlag.Name)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif value != nil {\n\t\t\t\teachName(f.Name, func(name string) {\n\t\t\t\t\tf.set.Set(f.Name, value.String())\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// ApplyInputSourceValue applies a StringSlice value to the flagSet if required\nfunc (f *StringSliceFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error {\n\tif f.set != nil {\n\t\tif !context.IsSet(f.Name) && !isEnvVarSet(f.EnvVar) {\n\t\t\tvalue, err := isc.StringSlice(f.StringSliceFlag.Name)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif value != nil {\n\t\t\t\tvar sliceValue cli.StringSlice = value\n\t\t\t\teachName(f.Name, func(name string) {\n\t\t\t\t\tunderlyingFlag := f.set.Lookup(f.Name)\n\t\t\t\t\tif underlyingFlag != nil {\n\t\t\t\t\t\tunderlyingFlag.Value = &sliceValue\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\n// ApplyInputSourceValue applies a IntSlice value if required\nfunc (f *IntSliceFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error {\n\tif f.set != nil {\n\t\tif !context.IsSet(f.Name) && !isEnvVarSet(f.EnvVar) {\n\t\t\tvalue, err := isc.IntSlice(f.IntSliceFlag.Name)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif value != nil {\n\t\t\t\tvar sliceValue cli.IntSlice = value\n\t\t\t\teachName(f.Name, func(name string) {\n\t\t\t\t\tunderlyingFlag := f.set.Lookup(f.Name)\n\t\t\t\t\tif underlyingFlag != nil {\n\t\t\t\t\t\tunderlyingFlag.Value = &sliceValue\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\n// ApplyInputSourceValue applies a Bool value to the flagSet if required\nfunc (f *BoolFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error {\n\tif f.set != nil {\n\t\tif !context.IsSet(f.Name) && !isEnvVarSet(f.EnvVar) {\n\t\t\tvalue, err := isc.Bool(f.BoolFlag.Name)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif value {\n\t\t\t\teachName(f.Name, func(name string) {\n\t\t\t\t\tf.set.Set(f.Name, strconv.FormatBool(value))\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\n// ApplyInputSourceValue applies a BoolT value to the flagSet if required\nfunc (f *BoolTFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error {\n\tif f.set != nil {\n\t\tif !context.IsSet(f.Name) && !isEnvVarSet(f.EnvVar) {\n\t\t\tvalue, err := isc.BoolT(f.BoolTFlag.Name)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif !value {\n\t\t\t\teachName(f.Name, func(name string) {\n\t\t\t\t\tf.set.Set(f.Name, strconv.FormatBool(value))\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\n// ApplyInputSourceValue applies a String value to the flagSet if required\nfunc (f *StringFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error {\n\tif f.set != nil {\n\t\tif !(context.IsSet(f.Name) || isEnvVarSet(f.EnvVar)) {\n\t\t\tvalue, err := isc.String(f.StringFlag.Name)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif value != \"\" {\n\t\t\t\teachName(f.Name, func(name string) {\n\t\t\t\t\tf.set.Set(f.Name, value)\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\n// ApplyInputSourceValue applies a int value to the flagSet if required\nfunc (f *IntFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error {\n\tif f.set != nil {\n\t\tif !(context.IsSet(f.Name) || isEnvVarSet(f.EnvVar)) {\n\t\t\tvalue, err := isc.Int(f.IntFlag.Name)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif value > 0 {\n\t\t\t\teachName(f.Name, func(name string) {\n\t\t\t\t\tf.set.Set(f.Name, strconv.FormatInt(int64(value), 10))\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\n// ApplyInputSourceValue applies a Duration value to the flagSet if required\nfunc (f *DurationFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error {\n\tif f.set != nil {\n\t\tif !(context.IsSet(f.Name) || isEnvVarSet(f.EnvVar)) {\n\t\t\tvalue, err := isc.Duration(f.DurationFlag.Name)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif value > 0 {\n\t\t\t\teachName(f.Name, func(name string) {\n\t\t\t\t\tf.set.Set(f.Name, value.String())\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\n// ApplyInputSourceValue applies a Float64 value to the flagSet if required\nfunc (f *Float64Flag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error {\n\tif f.set != nil {\n\t\tif !(context.IsSet(f.Name) || isEnvVarSet(f.EnvVar)) {\n\t\t\tvalue, err := isc.Float64(f.Float64Flag.Name)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif value > 0 {\n\t\t\t\tfloatStr := float64ToString(value)\n\t\t\t\teachName(f.Name, func(name string) {\n\t\t\t\t\tf.set.Set(f.Name, floatStr)\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc isEnvVarSet(envVars string) bool {\n\tfor _, envVar := range strings.Split(envVars, \",\") {\n\t\tenvVar = strings.TrimSpace(envVar)\n\t\tif _, ok := syscall.Getenv(envVar); ok {\n\t\t\t// TODO: Can't use this for bools as\n\t\t\t// set means that it was true or false based on\n\t\t\t// Bool flag type, should work for other types\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\nfunc float64ToString(f float64) string {\n\treturn fmt.Sprintf(\"%v\", f)\n}\n\nfunc eachName(longName string, fn func(string)) {\n\tparts := strings.Split(longName, \",\")\n\tfor _, name := range parts {\n\t\tname = strings.Trim(name, \" \")\n\t\tfn(name)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/altsrc/flag_generated.go",
    "content": "package altsrc\n\nimport (\n\t\"flag\"\n\n\t\"gopkg.in/urfave/cli.v1\"\n)\n\n// WARNING: This file is generated!\n\n// BoolFlag is the flag type that wraps cli.BoolFlag to allow\n// for other values to be specified\ntype BoolFlag struct {\n\tcli.BoolFlag\n\tset *flag.FlagSet\n}\n\n// NewBoolFlag creates a new BoolFlag\nfunc NewBoolFlag(fl cli.BoolFlag) *BoolFlag {\n\treturn &BoolFlag{BoolFlag: fl, set: nil}\n}\n\n// Apply saves the flagSet for later usage calls, then calls the\n// wrapped BoolFlag.Apply\nfunc (f *BoolFlag) Apply(set *flag.FlagSet) {\n\tf.set = set\n\tf.BoolFlag.Apply(set)\n}\n\n// ApplyWithError saves the flagSet for later usage calls, then calls the\n// wrapped BoolFlag.ApplyWithError\nfunc (f *BoolFlag) ApplyWithError(set *flag.FlagSet) error {\n\tf.set = set\n\treturn f.BoolFlag.ApplyWithError(set)\n}\n\n// BoolTFlag is the flag type that wraps cli.BoolTFlag to allow\n// for other values to be specified\ntype BoolTFlag struct {\n\tcli.BoolTFlag\n\tset *flag.FlagSet\n}\n\n// NewBoolTFlag creates a new BoolTFlag\nfunc NewBoolTFlag(fl cli.BoolTFlag) *BoolTFlag {\n\treturn &BoolTFlag{BoolTFlag: fl, set: nil}\n}\n\n// Apply saves the flagSet for later usage calls, then calls the\n// wrapped BoolTFlag.Apply\nfunc (f *BoolTFlag) Apply(set *flag.FlagSet) {\n\tf.set = set\n\tf.BoolTFlag.Apply(set)\n}\n\n// ApplyWithError saves the flagSet for later usage calls, then calls the\n// wrapped BoolTFlag.ApplyWithError\nfunc (f *BoolTFlag) ApplyWithError(set *flag.FlagSet) error {\n\tf.set = set\n\treturn f.BoolTFlag.ApplyWithError(set)\n}\n\n// DurationFlag is the flag type that wraps cli.DurationFlag to allow\n// for other values to be specified\ntype DurationFlag struct {\n\tcli.DurationFlag\n\tset *flag.FlagSet\n}\n\n// NewDurationFlag creates a new DurationFlag\nfunc NewDurationFlag(fl cli.DurationFlag) *DurationFlag {\n\treturn &DurationFlag{DurationFlag: fl, set: nil}\n}\n\n// Apply saves the flagSet for later usage calls, then calls the\n// wrapped DurationFlag.Apply\nfunc (f *DurationFlag) Apply(set *flag.FlagSet) {\n\tf.set = set\n\tf.DurationFlag.Apply(set)\n}\n\n// ApplyWithError saves the flagSet for later usage calls, then calls the\n// wrapped DurationFlag.ApplyWithError\nfunc (f *DurationFlag) ApplyWithError(set *flag.FlagSet) error {\n\tf.set = set\n\treturn f.DurationFlag.ApplyWithError(set)\n}\n\n// Float64Flag is the flag type that wraps cli.Float64Flag to allow\n// for other values to be specified\ntype Float64Flag struct {\n\tcli.Float64Flag\n\tset *flag.FlagSet\n}\n\n// NewFloat64Flag creates a new Float64Flag\nfunc NewFloat64Flag(fl cli.Float64Flag) *Float64Flag {\n\treturn &Float64Flag{Float64Flag: fl, set: nil}\n}\n\n// Apply saves the flagSet for later usage calls, then calls the\n// wrapped Float64Flag.Apply\nfunc (f *Float64Flag) Apply(set *flag.FlagSet) {\n\tf.set = set\n\tf.Float64Flag.Apply(set)\n}\n\n// ApplyWithError saves the flagSet for later usage calls, then calls the\n// wrapped Float64Flag.ApplyWithError\nfunc (f *Float64Flag) ApplyWithError(set *flag.FlagSet) error {\n\tf.set = set\n\treturn f.Float64Flag.ApplyWithError(set)\n}\n\n// GenericFlag is the flag type that wraps cli.GenericFlag to allow\n// for other values to be specified\ntype GenericFlag struct {\n\tcli.GenericFlag\n\tset *flag.FlagSet\n}\n\n// NewGenericFlag creates a new GenericFlag\nfunc NewGenericFlag(fl cli.GenericFlag) *GenericFlag {\n\treturn &GenericFlag{GenericFlag: fl, set: nil}\n}\n\n// Apply saves the flagSet for later usage calls, then calls the\n// wrapped GenericFlag.Apply\nfunc (f *GenericFlag) Apply(set *flag.FlagSet) {\n\tf.set = set\n\tf.GenericFlag.Apply(set)\n}\n\n// ApplyWithError saves the flagSet for later usage calls, then calls the\n// wrapped GenericFlag.ApplyWithError\nfunc (f *GenericFlag) ApplyWithError(set *flag.FlagSet) error {\n\tf.set = set\n\treturn f.GenericFlag.ApplyWithError(set)\n}\n\n// Int64Flag is the flag type that wraps cli.Int64Flag to allow\n// for other values to be specified\ntype Int64Flag struct {\n\tcli.Int64Flag\n\tset *flag.FlagSet\n}\n\n// NewInt64Flag creates a new Int64Flag\nfunc NewInt64Flag(fl cli.Int64Flag) *Int64Flag {\n\treturn &Int64Flag{Int64Flag: fl, set: nil}\n}\n\n// Apply saves the flagSet for later usage calls, then calls the\n// wrapped Int64Flag.Apply\nfunc (f *Int64Flag) Apply(set *flag.FlagSet) {\n\tf.set = set\n\tf.Int64Flag.Apply(set)\n}\n\n// ApplyWithError saves the flagSet for later usage calls, then calls the\n// wrapped Int64Flag.ApplyWithError\nfunc (f *Int64Flag) ApplyWithError(set *flag.FlagSet) error {\n\tf.set = set\n\treturn f.Int64Flag.ApplyWithError(set)\n}\n\n// IntFlag is the flag type that wraps cli.IntFlag to allow\n// for other values to be specified\ntype IntFlag struct {\n\tcli.IntFlag\n\tset *flag.FlagSet\n}\n\n// NewIntFlag creates a new IntFlag\nfunc NewIntFlag(fl cli.IntFlag) *IntFlag {\n\treturn &IntFlag{IntFlag: fl, set: nil}\n}\n\n// Apply saves the flagSet for later usage calls, then calls the\n// wrapped IntFlag.Apply\nfunc (f *IntFlag) Apply(set *flag.FlagSet) {\n\tf.set = set\n\tf.IntFlag.Apply(set)\n}\n\n// ApplyWithError saves the flagSet for later usage calls, then calls the\n// wrapped IntFlag.ApplyWithError\nfunc (f *IntFlag) ApplyWithError(set *flag.FlagSet) error {\n\tf.set = set\n\treturn f.IntFlag.ApplyWithError(set)\n}\n\n// IntSliceFlag is the flag type that wraps cli.IntSliceFlag to allow\n// for other values to be specified\ntype IntSliceFlag struct {\n\tcli.IntSliceFlag\n\tset *flag.FlagSet\n}\n\n// NewIntSliceFlag creates a new IntSliceFlag\nfunc NewIntSliceFlag(fl cli.IntSliceFlag) *IntSliceFlag {\n\treturn &IntSliceFlag{IntSliceFlag: fl, set: nil}\n}\n\n// Apply saves the flagSet for later usage calls, then calls the\n// wrapped IntSliceFlag.Apply\nfunc (f *IntSliceFlag) Apply(set *flag.FlagSet) {\n\tf.set = set\n\tf.IntSliceFlag.Apply(set)\n}\n\n// ApplyWithError saves the flagSet for later usage calls, then calls the\n// wrapped IntSliceFlag.ApplyWithError\nfunc (f *IntSliceFlag) ApplyWithError(set *flag.FlagSet) error {\n\tf.set = set\n\treturn f.IntSliceFlag.ApplyWithError(set)\n}\n\n// Int64SliceFlag is the flag type that wraps cli.Int64SliceFlag to allow\n// for other values to be specified\ntype Int64SliceFlag struct {\n\tcli.Int64SliceFlag\n\tset *flag.FlagSet\n}\n\n// NewInt64SliceFlag creates a new Int64SliceFlag\nfunc NewInt64SliceFlag(fl cli.Int64SliceFlag) *Int64SliceFlag {\n\treturn &Int64SliceFlag{Int64SliceFlag: fl, set: nil}\n}\n\n// Apply saves the flagSet for later usage calls, then calls the\n// wrapped Int64SliceFlag.Apply\nfunc (f *Int64SliceFlag) Apply(set *flag.FlagSet) {\n\tf.set = set\n\tf.Int64SliceFlag.Apply(set)\n}\n\n// ApplyWithError saves the flagSet for later usage calls, then calls the\n// wrapped Int64SliceFlag.ApplyWithError\nfunc (f *Int64SliceFlag) ApplyWithError(set *flag.FlagSet) error {\n\tf.set = set\n\treturn f.Int64SliceFlag.ApplyWithError(set)\n}\n\n// StringFlag is the flag type that wraps cli.StringFlag to allow\n// for other values to be specified\ntype StringFlag struct {\n\tcli.StringFlag\n\tset *flag.FlagSet\n}\n\n// NewStringFlag creates a new StringFlag\nfunc NewStringFlag(fl cli.StringFlag) *StringFlag {\n\treturn &StringFlag{StringFlag: fl, set: nil}\n}\n\n// Apply saves the flagSet for later usage calls, then calls the\n// wrapped StringFlag.Apply\nfunc (f *StringFlag) Apply(set *flag.FlagSet) {\n\tf.set = set\n\tf.StringFlag.Apply(set)\n}\n\n// ApplyWithError saves the flagSet for later usage calls, then calls the\n// wrapped StringFlag.ApplyWithError\nfunc (f *StringFlag) ApplyWithError(set *flag.FlagSet) error {\n\tf.set = set\n\treturn f.StringFlag.ApplyWithError(set)\n}\n\n// StringSliceFlag is the flag type that wraps cli.StringSliceFlag to allow\n// for other values to be specified\ntype StringSliceFlag struct {\n\tcli.StringSliceFlag\n\tset *flag.FlagSet\n}\n\n// NewStringSliceFlag creates a new StringSliceFlag\nfunc NewStringSliceFlag(fl cli.StringSliceFlag) *StringSliceFlag {\n\treturn &StringSliceFlag{StringSliceFlag: fl, set: nil}\n}\n\n// Apply saves the flagSet for later usage calls, then calls the\n// wrapped StringSliceFlag.Apply\nfunc (f *StringSliceFlag) Apply(set *flag.FlagSet) {\n\tf.set = set\n\tf.StringSliceFlag.Apply(set)\n}\n\n// ApplyWithError saves the flagSet for later usage calls, then calls the\n// wrapped StringSliceFlag.ApplyWithError\nfunc (f *StringSliceFlag) ApplyWithError(set *flag.FlagSet) error {\n\tf.set = set\n\treturn f.StringSliceFlag.ApplyWithError(set)\n}\n\n// Uint64Flag is the flag type that wraps cli.Uint64Flag to allow\n// for other values to be specified\ntype Uint64Flag struct {\n\tcli.Uint64Flag\n\tset *flag.FlagSet\n}\n\n// NewUint64Flag creates a new Uint64Flag\nfunc NewUint64Flag(fl cli.Uint64Flag) *Uint64Flag {\n\treturn &Uint64Flag{Uint64Flag: fl, set: nil}\n}\n\n// Apply saves the flagSet for later usage calls, then calls the\n// wrapped Uint64Flag.Apply\nfunc (f *Uint64Flag) Apply(set *flag.FlagSet) {\n\tf.set = set\n\tf.Uint64Flag.Apply(set)\n}\n\n// ApplyWithError saves the flagSet for later usage calls, then calls the\n// wrapped Uint64Flag.ApplyWithError\nfunc (f *Uint64Flag) ApplyWithError(set *flag.FlagSet) error {\n\tf.set = set\n\treturn f.Uint64Flag.ApplyWithError(set)\n}\n\n// UintFlag is the flag type that wraps cli.UintFlag to allow\n// for other values to be specified\ntype UintFlag struct {\n\tcli.UintFlag\n\tset *flag.FlagSet\n}\n\n// NewUintFlag creates a new UintFlag\nfunc NewUintFlag(fl cli.UintFlag) *UintFlag {\n\treturn &UintFlag{UintFlag: fl, set: nil}\n}\n\n// Apply saves the flagSet for later usage calls, then calls the\n// wrapped UintFlag.Apply\nfunc (f *UintFlag) Apply(set *flag.FlagSet) {\n\tf.set = set\n\tf.UintFlag.Apply(set)\n}\n\n// ApplyWithError saves the flagSet for later usage calls, then calls the\n// wrapped UintFlag.ApplyWithError\nfunc (f *UintFlag) ApplyWithError(set *flag.FlagSet) error {\n\tf.set = set\n\treturn f.UintFlag.ApplyWithError(set)\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/altsrc/flag_test.go",
    "content": "package altsrc\n\nimport (\n\t\"flag\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n\t\"testing\"\n\t\"time\"\n\n\t\"gopkg.in/urfave/cli.v1\"\n)\n\ntype testApplyInputSource struct {\n\tFlag               FlagInputSourceExtension\n\tFlagName           string\n\tFlagSetName        string\n\tExpected           string\n\tContextValueString string\n\tContextValue       flag.Value\n\tEnvVarValue        string\n\tEnvVarName         string\n\tMapValue           interface{}\n}\n\nfunc TestGenericApplyInputSourceValue(t *testing.T) {\n\tv := &Parser{\"abc\", \"def\"}\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:     NewGenericFlag(cli.GenericFlag{Name: \"test\", Value: &Parser{}}),\n\t\tFlagName: \"test\",\n\t\tMapValue: v,\n\t})\n\texpect(t, v, c.Generic(\"test\"))\n}\n\nfunc TestGenericApplyInputSourceMethodContextSet(t *testing.T) {\n\tp := &Parser{\"abc\", \"def\"}\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:               NewGenericFlag(cli.GenericFlag{Name: \"test\", Value: &Parser{}}),\n\t\tFlagName:           \"test\",\n\t\tMapValue:           &Parser{\"efg\", \"hig\"},\n\t\tContextValueString: p.String(),\n\t})\n\texpect(t, p, c.Generic(\"test\"))\n}\n\nfunc TestGenericApplyInputSourceMethodEnvVarSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:        NewGenericFlag(cli.GenericFlag{Name: \"test\", Value: &Parser{}, EnvVar: \"TEST\"}),\n\t\tFlagName:    \"test\",\n\t\tMapValue:    &Parser{\"efg\", \"hij\"},\n\t\tEnvVarName:  \"TEST\",\n\t\tEnvVarValue: \"abc,def\",\n\t})\n\texpect(t, &Parser{\"abc\", \"def\"}, c.Generic(\"test\"))\n}\n\nfunc TestStringSliceApplyInputSourceValue(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:     NewStringSliceFlag(cli.StringSliceFlag{Name: \"test\"}),\n\t\tFlagName: \"test\",\n\t\tMapValue: []interface{}{\"hello\", \"world\"},\n\t})\n\texpect(t, c.StringSlice(\"test\"), []string{\"hello\", \"world\"})\n}\n\nfunc TestStringSliceApplyInputSourceMethodContextSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:               NewStringSliceFlag(cli.StringSliceFlag{Name: \"test\"}),\n\t\tFlagName:           \"test\",\n\t\tMapValue:           []interface{}{\"hello\", \"world\"},\n\t\tContextValueString: \"ohno\",\n\t})\n\texpect(t, c.StringSlice(\"test\"), []string{\"ohno\"})\n}\n\nfunc TestStringSliceApplyInputSourceMethodEnvVarSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:        NewStringSliceFlag(cli.StringSliceFlag{Name: \"test\", EnvVar: \"TEST\"}),\n\t\tFlagName:    \"test\",\n\t\tMapValue:    []interface{}{\"hello\", \"world\"},\n\t\tEnvVarName:  \"TEST\",\n\t\tEnvVarValue: \"oh,no\",\n\t})\n\texpect(t, c.StringSlice(\"test\"), []string{\"oh\", \"no\"})\n}\n\nfunc TestIntSliceApplyInputSourceValue(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:     NewIntSliceFlag(cli.IntSliceFlag{Name: \"test\"}),\n\t\tFlagName: \"test\",\n\t\tMapValue: []interface{}{1, 2},\n\t})\n\texpect(t, c.IntSlice(\"test\"), []int{1, 2})\n}\n\nfunc TestIntSliceApplyInputSourceMethodContextSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:               NewIntSliceFlag(cli.IntSliceFlag{Name: \"test\"}),\n\t\tFlagName:           \"test\",\n\t\tMapValue:           []interface{}{1, 2},\n\t\tContextValueString: \"3\",\n\t})\n\texpect(t, c.IntSlice(\"test\"), []int{3})\n}\n\nfunc TestIntSliceApplyInputSourceMethodEnvVarSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:        NewIntSliceFlag(cli.IntSliceFlag{Name: \"test\", EnvVar: \"TEST\"}),\n\t\tFlagName:    \"test\",\n\t\tMapValue:    []interface{}{1, 2},\n\t\tEnvVarName:  \"TEST\",\n\t\tEnvVarValue: \"3,4\",\n\t})\n\texpect(t, c.IntSlice(\"test\"), []int{3, 4})\n}\n\nfunc TestBoolApplyInputSourceMethodSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:     NewBoolFlag(cli.BoolFlag{Name: \"test\"}),\n\t\tFlagName: \"test\",\n\t\tMapValue: true,\n\t})\n\texpect(t, true, c.Bool(\"test\"))\n}\n\nfunc TestBoolApplyInputSourceMethodContextSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:               NewBoolFlag(cli.BoolFlag{Name: \"test\"}),\n\t\tFlagName:           \"test\",\n\t\tMapValue:           false,\n\t\tContextValueString: \"true\",\n\t})\n\texpect(t, true, c.Bool(\"test\"))\n}\n\nfunc TestBoolApplyInputSourceMethodEnvVarSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:        NewBoolFlag(cli.BoolFlag{Name: \"test\", EnvVar: \"TEST\"}),\n\t\tFlagName:    \"test\",\n\t\tMapValue:    false,\n\t\tEnvVarName:  \"TEST\",\n\t\tEnvVarValue: \"true\",\n\t})\n\texpect(t, true, c.Bool(\"test\"))\n}\n\nfunc TestBoolTApplyInputSourceMethodSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:     NewBoolTFlag(cli.BoolTFlag{Name: \"test\"}),\n\t\tFlagName: \"test\",\n\t\tMapValue: false,\n\t})\n\texpect(t, false, c.BoolT(\"test\"))\n}\n\nfunc TestBoolTApplyInputSourceMethodContextSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:               NewBoolTFlag(cli.BoolTFlag{Name: \"test\"}),\n\t\tFlagName:           \"test\",\n\t\tMapValue:           true,\n\t\tContextValueString: \"false\",\n\t})\n\texpect(t, false, c.BoolT(\"test\"))\n}\n\nfunc TestBoolTApplyInputSourceMethodEnvVarSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:        NewBoolTFlag(cli.BoolTFlag{Name: \"test\", EnvVar: \"TEST\"}),\n\t\tFlagName:    \"test\",\n\t\tMapValue:    true,\n\t\tEnvVarName:  \"TEST\",\n\t\tEnvVarValue: \"false\",\n\t})\n\texpect(t, false, c.BoolT(\"test\"))\n}\n\nfunc TestStringApplyInputSourceMethodSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:     NewStringFlag(cli.StringFlag{Name: \"test\"}),\n\t\tFlagName: \"test\",\n\t\tMapValue: \"hello\",\n\t})\n\texpect(t, \"hello\", c.String(\"test\"))\n}\n\nfunc TestStringApplyInputSourceMethodContextSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:               NewStringFlag(cli.StringFlag{Name: \"test\"}),\n\t\tFlagName:           \"test\",\n\t\tMapValue:           \"hello\",\n\t\tContextValueString: \"goodbye\",\n\t})\n\texpect(t, \"goodbye\", c.String(\"test\"))\n}\n\nfunc TestStringApplyInputSourceMethodEnvVarSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:        NewStringFlag(cli.StringFlag{Name: \"test\", EnvVar: \"TEST\"}),\n\t\tFlagName:    \"test\",\n\t\tMapValue:    \"hello\",\n\t\tEnvVarName:  \"TEST\",\n\t\tEnvVarValue: \"goodbye\",\n\t})\n\texpect(t, \"goodbye\", c.String(\"test\"))\n}\n\nfunc TestIntApplyInputSourceMethodSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:     NewIntFlag(cli.IntFlag{Name: \"test\"}),\n\t\tFlagName: \"test\",\n\t\tMapValue: 15,\n\t})\n\texpect(t, 15, c.Int(\"test\"))\n}\n\nfunc TestIntApplyInputSourceMethodContextSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:               NewIntFlag(cli.IntFlag{Name: \"test\"}),\n\t\tFlagName:           \"test\",\n\t\tMapValue:           15,\n\t\tContextValueString: \"7\",\n\t})\n\texpect(t, 7, c.Int(\"test\"))\n}\n\nfunc TestIntApplyInputSourceMethodEnvVarSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:        NewIntFlag(cli.IntFlag{Name: \"test\", EnvVar: \"TEST\"}),\n\t\tFlagName:    \"test\",\n\t\tMapValue:    15,\n\t\tEnvVarName:  \"TEST\",\n\t\tEnvVarValue: \"12\",\n\t})\n\texpect(t, 12, c.Int(\"test\"))\n}\n\nfunc TestDurationApplyInputSourceMethodSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:     NewDurationFlag(cli.DurationFlag{Name: \"test\"}),\n\t\tFlagName: \"test\",\n\t\tMapValue: time.Duration(30 * time.Second),\n\t})\n\texpect(t, time.Duration(30*time.Second), c.Duration(\"test\"))\n}\n\nfunc TestDurationApplyInputSourceMethodContextSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:               NewDurationFlag(cli.DurationFlag{Name: \"test\"}),\n\t\tFlagName:           \"test\",\n\t\tMapValue:           time.Duration(30 * time.Second),\n\t\tContextValueString: time.Duration(15 * time.Second).String(),\n\t})\n\texpect(t, time.Duration(15*time.Second), c.Duration(\"test\"))\n}\n\nfunc TestDurationApplyInputSourceMethodEnvVarSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:        NewDurationFlag(cli.DurationFlag{Name: \"test\", EnvVar: \"TEST\"}),\n\t\tFlagName:    \"test\",\n\t\tMapValue:    time.Duration(30 * time.Second),\n\t\tEnvVarName:  \"TEST\",\n\t\tEnvVarValue: time.Duration(15 * time.Second).String(),\n\t})\n\texpect(t, time.Duration(15*time.Second), c.Duration(\"test\"))\n}\n\nfunc TestFloat64ApplyInputSourceMethodSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:     NewFloat64Flag(cli.Float64Flag{Name: \"test\"}),\n\t\tFlagName: \"test\",\n\t\tMapValue: 1.3,\n\t})\n\texpect(t, 1.3, c.Float64(\"test\"))\n}\n\nfunc TestFloat64ApplyInputSourceMethodContextSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:               NewFloat64Flag(cli.Float64Flag{Name: \"test\"}),\n\t\tFlagName:           \"test\",\n\t\tMapValue:           1.3,\n\t\tContextValueString: fmt.Sprintf(\"%v\", 1.4),\n\t})\n\texpect(t, 1.4, c.Float64(\"test\"))\n}\n\nfunc TestFloat64ApplyInputSourceMethodEnvVarSet(t *testing.T) {\n\tc := runTest(t, testApplyInputSource{\n\t\tFlag:        NewFloat64Flag(cli.Float64Flag{Name: \"test\", EnvVar: \"TEST\"}),\n\t\tFlagName:    \"test\",\n\t\tMapValue:    1.3,\n\t\tEnvVarName:  \"TEST\",\n\t\tEnvVarValue: fmt.Sprintf(\"%v\", 1.4),\n\t})\n\texpect(t, 1.4, c.Float64(\"test\"))\n}\n\nfunc runTest(t *testing.T, test testApplyInputSource) *cli.Context {\n\tinputSource := &MapInputSource{valueMap: map[interface{}]interface{}{test.FlagName: test.MapValue}}\n\tset := flag.NewFlagSet(test.FlagSetName, flag.ContinueOnError)\n\tc := cli.NewContext(nil, set, nil)\n\tif test.EnvVarName != \"\" && test.EnvVarValue != \"\" {\n\t\tos.Setenv(test.EnvVarName, test.EnvVarValue)\n\t\tdefer os.Setenv(test.EnvVarName, \"\")\n\t}\n\n\ttest.Flag.Apply(set)\n\tif test.ContextValue != nil {\n\t\tflag := set.Lookup(test.FlagName)\n\t\tflag.Value = test.ContextValue\n\t}\n\tif test.ContextValueString != \"\" {\n\t\tset.Set(test.FlagName, test.ContextValueString)\n\t}\n\ttest.Flag.ApplyInputSourceValue(c, inputSource)\n\n\treturn c\n}\n\ntype Parser [2]string\n\nfunc (p *Parser) Set(value string) error {\n\tparts := strings.Split(value, \",\")\n\tif len(parts) != 2 {\n\t\treturn fmt.Errorf(\"invalid format\")\n\t}\n\n\t(*p)[0] = parts[0]\n\t(*p)[1] = parts[1]\n\n\treturn nil\n}\n\nfunc (p *Parser) String() string {\n\treturn fmt.Sprintf(\"%s,%s\", p[0], p[1])\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/altsrc/helpers_test.go",
    "content": "package altsrc\n\nimport (\n\t\"reflect\"\n\t\"testing\"\n)\n\nfunc expect(t *testing.T, a interface{}, b interface{}) {\n\tif !reflect.DeepEqual(b, a) {\n\t\tt.Errorf(\"Expected %#v (type %v) - Got %#v (type %v)\", b, reflect.TypeOf(b), a, reflect.TypeOf(a))\n\t}\n}\n\nfunc refute(t *testing.T, a interface{}, b interface{}) {\n\tif a == b {\n\t\tt.Errorf(\"Did not expect %v (type %v) - Got %v (type %v)\", b, reflect.TypeOf(b), a, reflect.TypeOf(a))\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/altsrc/input_source_context.go",
    "content": "package altsrc\n\nimport (\n\t\"time\"\n\n\t\"gopkg.in/urfave/cli.v1\"\n)\n\n// InputSourceContext is an interface used to allow\n// other input sources to be implemented as needed.\ntype InputSourceContext interface {\n\tInt(name string) (int, error)\n\tDuration(name string) (time.Duration, error)\n\tFloat64(name string) (float64, error)\n\tString(name string) (string, error)\n\tStringSlice(name string) ([]string, error)\n\tIntSlice(name string) ([]int, error)\n\tGeneric(name string) (cli.Generic, error)\n\tBool(name string) (bool, error)\n\tBoolT(name string) (bool, error)\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/altsrc/map_input_source.go",
    "content": "package altsrc\n\nimport (\n\t\"fmt\"\n\t\"reflect\"\n\t\"strings\"\n\t\"time\"\n\n\t\"gopkg.in/urfave/cli.v1\"\n)\n\n// MapInputSource implements InputSourceContext to return\n// data from the map that is loaded.\ntype MapInputSource struct {\n\tvalueMap map[interface{}]interface{}\n}\n\n// nestedVal checks if the name has '.' delimiters.\n// If so, it tries to traverse the tree by the '.' delimited sections to find\n// a nested value for the key.\nfunc nestedVal(name string, tree map[interface{}]interface{}) (interface{}, bool) {\n\tif sections := strings.Split(name, \".\"); len(sections) > 1 {\n\t\tnode := tree\n\t\tfor _, section := range sections[:len(sections)-1] {\n\t\t\tif child, ok := node[section]; !ok {\n\t\t\t\treturn nil, false\n\t\t\t} else {\n\t\t\t\tif ctype, ok := child.(map[interface{}]interface{}); !ok {\n\t\t\t\t\treturn nil, false\n\t\t\t\t} else {\n\t\t\t\t\tnode = ctype\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif val, ok := node[sections[len(sections)-1]]; ok {\n\t\t\treturn val, true\n\t\t}\n\t}\n\treturn nil, false\n}\n\n// Int returns an int from the map if it exists otherwise returns 0\nfunc (fsm *MapInputSource) Int(name string) (int, error) {\n\totherGenericValue, exists := fsm.valueMap[name]\n\tif exists {\n\t\totherValue, isType := otherGenericValue.(int)\n\t\tif !isType {\n\t\t\treturn 0, incorrectTypeForFlagError(name, \"int\", otherGenericValue)\n\t\t}\n\t\treturn otherValue, nil\n\t}\n\tnestedGenericValue, exists := nestedVal(name, fsm.valueMap)\n\tif exists {\n\t\totherValue, isType := nestedGenericValue.(int)\n\t\tif !isType {\n\t\t\treturn 0, incorrectTypeForFlagError(name, \"int\", nestedGenericValue)\n\t\t}\n\t\treturn otherValue, nil\n\t}\n\n\treturn 0, nil\n}\n\n// Duration returns a duration from the map if it exists otherwise returns 0\nfunc (fsm *MapInputSource) Duration(name string) (time.Duration, error) {\n\totherGenericValue, exists := fsm.valueMap[name]\n\tif exists {\n\t\totherValue, isType := otherGenericValue.(time.Duration)\n\t\tif !isType {\n\t\t\treturn 0, incorrectTypeForFlagError(name, \"duration\", otherGenericValue)\n\t\t}\n\t\treturn otherValue, nil\n\t}\n\tnestedGenericValue, exists := nestedVal(name, fsm.valueMap)\n\tif exists {\n\t\totherValue, isType := nestedGenericValue.(time.Duration)\n\t\tif !isType {\n\t\t\treturn 0, incorrectTypeForFlagError(name, \"duration\", nestedGenericValue)\n\t\t}\n\t\treturn otherValue, nil\n\t}\n\n\treturn 0, nil\n}\n\n// Float64 returns an float64 from the map if it exists otherwise returns 0\nfunc (fsm *MapInputSource) Float64(name string) (float64, error) {\n\totherGenericValue, exists := fsm.valueMap[name]\n\tif exists {\n\t\totherValue, isType := otherGenericValue.(float64)\n\t\tif !isType {\n\t\t\treturn 0, incorrectTypeForFlagError(name, \"float64\", otherGenericValue)\n\t\t}\n\t\treturn otherValue, nil\n\t}\n\tnestedGenericValue, exists := nestedVal(name, fsm.valueMap)\n\tif exists {\n\t\totherValue, isType := nestedGenericValue.(float64)\n\t\tif !isType {\n\t\t\treturn 0, incorrectTypeForFlagError(name, \"float64\", nestedGenericValue)\n\t\t}\n\t\treturn otherValue, nil\n\t}\n\n\treturn 0, nil\n}\n\n// String returns a string from the map if it exists otherwise returns an empty string\nfunc (fsm *MapInputSource) String(name string) (string, error) {\n\totherGenericValue, exists := fsm.valueMap[name]\n\tif exists {\n\t\totherValue, isType := otherGenericValue.(string)\n\t\tif !isType {\n\t\t\treturn \"\", incorrectTypeForFlagError(name, \"string\", otherGenericValue)\n\t\t}\n\t\treturn otherValue, nil\n\t}\n\tnestedGenericValue, exists := nestedVal(name, fsm.valueMap)\n\tif exists {\n\t\totherValue, isType := nestedGenericValue.(string)\n\t\tif !isType {\n\t\t\treturn \"\", incorrectTypeForFlagError(name, \"string\", nestedGenericValue)\n\t\t}\n\t\treturn otherValue, nil\n\t}\n\n\treturn \"\", nil\n}\n\n// StringSlice returns an []string from the map if it exists otherwise returns nil\nfunc (fsm *MapInputSource) StringSlice(name string) ([]string, error) {\n\totherGenericValue, exists := fsm.valueMap[name]\n\tif !exists {\n\t\totherGenericValue, exists = nestedVal(name, fsm.valueMap)\n\t\tif !exists {\n\t\t\treturn nil, nil\n\t\t}\n\t}\n\n\totherValue, isType := otherGenericValue.([]interface{})\n\tif !isType {\n\t\treturn nil, incorrectTypeForFlagError(name, \"[]interface{}\", otherGenericValue)\n\t}\n\n\tvar stringSlice = make([]string, 0, len(otherValue))\n\tfor i, v := range otherValue {\n\t\tstringValue, isType := v.(string)\n\n\t\tif !isType {\n\t\t\treturn nil, incorrectTypeForFlagError(fmt.Sprintf(\"%s[%d]\", name, i), \"string\", v)\n\t\t}\n\n\t\tstringSlice = append(stringSlice, stringValue)\n\t}\n\n\treturn stringSlice, nil\n}\n\n// IntSlice returns an []int from the map if it exists otherwise returns nil\nfunc (fsm *MapInputSource) IntSlice(name string) ([]int, error) {\n\totherGenericValue, exists := fsm.valueMap[name]\n\tif !exists {\n\t\totherGenericValue, exists = nestedVal(name, fsm.valueMap)\n\t\tif !exists {\n\t\t\treturn nil, nil\n\t\t}\n\t}\n\n\totherValue, isType := otherGenericValue.([]interface{})\n\tif !isType {\n\t\treturn nil, incorrectTypeForFlagError(name, \"[]interface{}\", otherGenericValue)\n\t}\n\n\tvar intSlice = make([]int, 0, len(otherValue))\n\tfor i, v := range otherValue {\n\t\tintValue, isType := v.(int)\n\n\t\tif !isType {\n\t\t\treturn nil, incorrectTypeForFlagError(fmt.Sprintf(\"%s[%d]\", name, i), \"int\", v)\n\t\t}\n\n\t\tintSlice = append(intSlice, intValue)\n\t}\n\n\treturn intSlice, nil\n}\n\n// Generic returns an cli.Generic from the map if it exists otherwise returns nil\nfunc (fsm *MapInputSource) Generic(name string) (cli.Generic, error) {\n\totherGenericValue, exists := fsm.valueMap[name]\n\tif exists {\n\t\totherValue, isType := otherGenericValue.(cli.Generic)\n\t\tif !isType {\n\t\t\treturn nil, incorrectTypeForFlagError(name, \"cli.Generic\", otherGenericValue)\n\t\t}\n\t\treturn otherValue, nil\n\t}\n\tnestedGenericValue, exists := nestedVal(name, fsm.valueMap)\n\tif exists {\n\t\totherValue, isType := nestedGenericValue.(cli.Generic)\n\t\tif !isType {\n\t\t\treturn nil, incorrectTypeForFlagError(name, \"cli.Generic\", nestedGenericValue)\n\t\t}\n\t\treturn otherValue, nil\n\t}\n\n\treturn nil, nil\n}\n\n// Bool returns an bool from the map otherwise returns false\nfunc (fsm *MapInputSource) Bool(name string) (bool, error) {\n\totherGenericValue, exists := fsm.valueMap[name]\n\tif exists {\n\t\totherValue, isType := otherGenericValue.(bool)\n\t\tif !isType {\n\t\t\treturn false, incorrectTypeForFlagError(name, \"bool\", otherGenericValue)\n\t\t}\n\t\treturn otherValue, nil\n\t}\n\tnestedGenericValue, exists := nestedVal(name, fsm.valueMap)\n\tif exists {\n\t\totherValue, isType := nestedGenericValue.(bool)\n\t\tif !isType {\n\t\t\treturn false, incorrectTypeForFlagError(name, \"bool\", nestedGenericValue)\n\t\t}\n\t\treturn otherValue, nil\n\t}\n\n\treturn false, nil\n}\n\n// BoolT returns an bool from the map otherwise returns true\nfunc (fsm *MapInputSource) BoolT(name string) (bool, error) {\n\totherGenericValue, exists := fsm.valueMap[name]\n\tif exists {\n\t\totherValue, isType := otherGenericValue.(bool)\n\t\tif !isType {\n\t\t\treturn true, incorrectTypeForFlagError(name, \"bool\", otherGenericValue)\n\t\t}\n\t\treturn otherValue, nil\n\t}\n\tnestedGenericValue, exists := nestedVal(name, fsm.valueMap)\n\tif exists {\n\t\totherValue, isType := nestedGenericValue.(bool)\n\t\tif !isType {\n\t\t\treturn true, incorrectTypeForFlagError(name, \"bool\", nestedGenericValue)\n\t\t}\n\t\treturn otherValue, nil\n\t}\n\n\treturn true, nil\n}\n\nfunc incorrectTypeForFlagError(name, expectedTypeName string, value interface{}) error {\n\tvalueType := reflect.TypeOf(value)\n\tvalueTypeName := \"\"\n\tif valueType != nil {\n\t\tvalueTypeName = valueType.Name()\n\t}\n\n\treturn fmt.Errorf(\"Mismatched type for flag '%s'. Expected '%s' but actual is '%s'\", name, expectedTypeName, valueTypeName)\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/altsrc/toml_command_test.go",
    "content": "// Disabling building of toml support in cases where golang is 1.0 or 1.1\n// as the encoding library is not implemented or supported.\n\n// +build go1.2\n\npackage altsrc\n\nimport (\n\t\"flag\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"testing\"\n\n\t\"gopkg.in/urfave/cli.v1\"\n)\n\nfunc TestCommandTomFileTest(t *testing.T) {\n\tapp := cli.NewApp()\n\tset := flag.NewFlagSet(\"test\", 0)\n\tioutil.WriteFile(\"current.toml\", []byte(\"test = 15\"), 0666)\n\tdefer os.Remove(\"current.toml\")\n\ttest := []string{\"test-cmd\", \"--load\", \"current.toml\"}\n\tset.Parse(test)\n\n\tc := cli.NewContext(app, set, nil)\n\n\tcommand := &cli.Command{\n\t\tName:        \"test-cmd\",\n\t\tAliases:     []string{\"tc\"},\n\t\tUsage:       \"this is for testing\",\n\t\tDescription: \"testing\",\n\t\tAction: func(c *cli.Context) error {\n\t\t\tval := c.Int(\"test\")\n\t\t\texpect(t, val, 15)\n\t\t\treturn nil\n\t\t},\n\t\tFlags: []cli.Flag{\n\t\t\tNewIntFlag(cli.IntFlag{Name: \"test\"}),\n\t\t\tcli.StringFlag{Name: \"load\"}},\n\t}\n\tcommand.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc(\"load\"))\n\terr := command.Run(c)\n\n\texpect(t, err, nil)\n}\n\nfunc TestCommandTomlFileTestGlobalEnvVarWins(t *testing.T) {\n\tapp := cli.NewApp()\n\tset := flag.NewFlagSet(\"test\", 0)\n\tioutil.WriteFile(\"current.toml\", []byte(\"test = 15\"), 0666)\n\tdefer os.Remove(\"current.toml\")\n\n\tos.Setenv(\"THE_TEST\", \"10\")\n\tdefer os.Setenv(\"THE_TEST\", \"\")\n\ttest := []string{\"test-cmd\", \"--load\", \"current.toml\"}\n\tset.Parse(test)\n\n\tc := cli.NewContext(app, set, nil)\n\n\tcommand := &cli.Command{\n\t\tName:        \"test-cmd\",\n\t\tAliases:     []string{\"tc\"},\n\t\tUsage:       \"this is for testing\",\n\t\tDescription: \"testing\",\n\t\tAction: func(c *cli.Context) error {\n\t\t\tval := c.Int(\"test\")\n\t\t\texpect(t, val, 10)\n\t\t\treturn nil\n\t\t},\n\t\tFlags: []cli.Flag{\n\t\t\tNewIntFlag(cli.IntFlag{Name: \"test\", EnvVar: \"THE_TEST\"}),\n\t\t\tcli.StringFlag{Name: \"load\"}},\n\t}\n\tcommand.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc(\"load\"))\n\n\terr := command.Run(c)\n\n\texpect(t, err, nil)\n}\n\nfunc TestCommandTomlFileTestGlobalEnvVarWinsNested(t *testing.T) {\n\tapp := cli.NewApp()\n\tset := flag.NewFlagSet(\"test\", 0)\n\tioutil.WriteFile(\"current.toml\", []byte(\"[top]\\ntest = 15\"), 0666)\n\tdefer os.Remove(\"current.toml\")\n\n\tos.Setenv(\"THE_TEST\", \"10\")\n\tdefer os.Setenv(\"THE_TEST\", \"\")\n\ttest := []string{\"test-cmd\", \"--load\", \"current.toml\"}\n\tset.Parse(test)\n\n\tc := cli.NewContext(app, set, nil)\n\n\tcommand := &cli.Command{\n\t\tName:        \"test-cmd\",\n\t\tAliases:     []string{\"tc\"},\n\t\tUsage:       \"this is for testing\",\n\t\tDescription: \"testing\",\n\t\tAction: func(c *cli.Context) error {\n\t\t\tval := c.Int(\"top.test\")\n\t\t\texpect(t, val, 10)\n\t\t\treturn nil\n\t\t},\n\t\tFlags: []cli.Flag{\n\t\t\tNewIntFlag(cli.IntFlag{Name: \"top.test\", EnvVar: \"THE_TEST\"}),\n\t\t\tcli.StringFlag{Name: \"load\"}},\n\t}\n\tcommand.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc(\"load\"))\n\n\terr := command.Run(c)\n\n\texpect(t, err, nil)\n}\n\nfunc TestCommandTomlFileTestSpecifiedFlagWins(t *testing.T) {\n\tapp := cli.NewApp()\n\tset := flag.NewFlagSet(\"test\", 0)\n\tioutil.WriteFile(\"current.toml\", []byte(\"test = 15\"), 0666)\n\tdefer os.Remove(\"current.toml\")\n\n\ttest := []string{\"test-cmd\", \"--load\", \"current.toml\", \"--test\", \"7\"}\n\tset.Parse(test)\n\n\tc := cli.NewContext(app, set, nil)\n\n\tcommand := &cli.Command{\n\t\tName:        \"test-cmd\",\n\t\tAliases:     []string{\"tc\"},\n\t\tUsage:       \"this is for testing\",\n\t\tDescription: \"testing\",\n\t\tAction: func(c *cli.Context) error {\n\t\t\tval := c.Int(\"test\")\n\t\t\texpect(t, val, 7)\n\t\t\treturn nil\n\t\t},\n\t\tFlags: []cli.Flag{\n\t\t\tNewIntFlag(cli.IntFlag{Name: \"test\"}),\n\t\t\tcli.StringFlag{Name: \"load\"}},\n\t}\n\tcommand.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc(\"load\"))\n\n\terr := command.Run(c)\n\n\texpect(t, err, nil)\n}\n\nfunc TestCommandTomlFileTestSpecifiedFlagWinsNested(t *testing.T) {\n\tapp := cli.NewApp()\n\tset := flag.NewFlagSet(\"test\", 0)\n\tioutil.WriteFile(\"current.toml\", []byte(`[top]\n  test = 15`), 0666)\n\tdefer os.Remove(\"current.toml\")\n\n\ttest := []string{\"test-cmd\", \"--load\", \"current.toml\", \"--top.test\", \"7\"}\n\tset.Parse(test)\n\n\tc := cli.NewContext(app, set, nil)\n\n\tcommand := &cli.Command{\n\t\tName:        \"test-cmd\",\n\t\tAliases:     []string{\"tc\"},\n\t\tUsage:       \"this is for testing\",\n\t\tDescription: \"testing\",\n\t\tAction: func(c *cli.Context) error {\n\t\t\tval := c.Int(\"top.test\")\n\t\t\texpect(t, val, 7)\n\t\t\treturn nil\n\t\t},\n\t\tFlags: []cli.Flag{\n\t\t\tNewIntFlag(cli.IntFlag{Name: \"top.test\"}),\n\t\t\tcli.StringFlag{Name: \"load\"}},\n\t}\n\tcommand.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc(\"load\"))\n\n\terr := command.Run(c)\n\n\texpect(t, err, nil)\n}\n\nfunc TestCommandTomlFileTestDefaultValueFileWins(t *testing.T) {\n\tapp := cli.NewApp()\n\tset := flag.NewFlagSet(\"test\", 0)\n\tioutil.WriteFile(\"current.toml\", []byte(\"test = 15\"), 0666)\n\tdefer os.Remove(\"current.toml\")\n\n\ttest := []string{\"test-cmd\", \"--load\", \"current.toml\"}\n\tset.Parse(test)\n\n\tc := cli.NewContext(app, set, nil)\n\n\tcommand := &cli.Command{\n\t\tName:        \"test-cmd\",\n\t\tAliases:     []string{\"tc\"},\n\t\tUsage:       \"this is for testing\",\n\t\tDescription: \"testing\",\n\t\tAction: func(c *cli.Context) error {\n\t\t\tval := c.Int(\"test\")\n\t\t\texpect(t, val, 15)\n\t\t\treturn nil\n\t\t},\n\t\tFlags: []cli.Flag{\n\t\t\tNewIntFlag(cli.IntFlag{Name: \"test\", Value: 7}),\n\t\t\tcli.StringFlag{Name: \"load\"}},\n\t}\n\tcommand.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc(\"load\"))\n\n\terr := command.Run(c)\n\n\texpect(t, err, nil)\n}\n\nfunc TestCommandTomlFileTestDefaultValueFileWinsNested(t *testing.T) {\n\tapp := cli.NewApp()\n\tset := flag.NewFlagSet(\"test\", 0)\n\tioutil.WriteFile(\"current.toml\", []byte(\"[top]\\ntest = 15\"), 0666)\n\tdefer os.Remove(\"current.toml\")\n\n\ttest := []string{\"test-cmd\", \"--load\", \"current.toml\"}\n\tset.Parse(test)\n\n\tc := cli.NewContext(app, set, nil)\n\n\tcommand := &cli.Command{\n\t\tName:        \"test-cmd\",\n\t\tAliases:     []string{\"tc\"},\n\t\tUsage:       \"this is for testing\",\n\t\tDescription: \"testing\",\n\t\tAction: func(c *cli.Context) error {\n\t\t\tval := c.Int(\"top.test\")\n\t\t\texpect(t, val, 15)\n\t\t\treturn nil\n\t\t},\n\t\tFlags: []cli.Flag{\n\t\t\tNewIntFlag(cli.IntFlag{Name: \"top.test\", Value: 7}),\n\t\t\tcli.StringFlag{Name: \"load\"}},\n\t}\n\tcommand.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc(\"load\"))\n\n\terr := command.Run(c)\n\n\texpect(t, err, nil)\n}\n\nfunc TestCommandTomlFileFlagHasDefaultGlobalEnvTomlSetGlobalEnvWins(t *testing.T) {\n\tapp := cli.NewApp()\n\tset := flag.NewFlagSet(\"test\", 0)\n\tioutil.WriteFile(\"current.toml\", []byte(\"test = 15\"), 0666)\n\tdefer os.Remove(\"current.toml\")\n\n\tos.Setenv(\"THE_TEST\", \"11\")\n\tdefer os.Setenv(\"THE_TEST\", \"\")\n\n\ttest := []string{\"test-cmd\", \"--load\", \"current.toml\"}\n\tset.Parse(test)\n\n\tc := cli.NewContext(app, set, nil)\n\n\tcommand := &cli.Command{\n\t\tName:        \"test-cmd\",\n\t\tAliases:     []string{\"tc\"},\n\t\tUsage:       \"this is for testing\",\n\t\tDescription: \"testing\",\n\t\tAction: func(c *cli.Context) error {\n\t\t\tval := c.Int(\"test\")\n\t\t\texpect(t, val, 11)\n\t\t\treturn nil\n\t\t},\n\t\tFlags: []cli.Flag{\n\t\t\tNewIntFlag(cli.IntFlag{Name: \"test\", Value: 7, EnvVar: \"THE_TEST\"}),\n\t\t\tcli.StringFlag{Name: \"load\"}},\n\t}\n\tcommand.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc(\"load\"))\n\terr := command.Run(c)\n\n\texpect(t, err, nil)\n}\n\nfunc TestCommandTomlFileFlagHasDefaultGlobalEnvTomlSetGlobalEnvWinsNested(t *testing.T) {\n\tapp := cli.NewApp()\n\tset := flag.NewFlagSet(\"test\", 0)\n\tioutil.WriteFile(\"current.toml\", []byte(\"[top]\\ntest = 15\"), 0666)\n\tdefer os.Remove(\"current.toml\")\n\n\tos.Setenv(\"THE_TEST\", \"11\")\n\tdefer os.Setenv(\"THE_TEST\", \"\")\n\n\ttest := []string{\"test-cmd\", \"--load\", \"current.toml\"}\n\tset.Parse(test)\n\n\tc := cli.NewContext(app, set, nil)\n\n\tcommand := &cli.Command{\n\t\tName:        \"test-cmd\",\n\t\tAliases:     []string{\"tc\"},\n\t\tUsage:       \"this is for testing\",\n\t\tDescription: \"testing\",\n\t\tAction: func(c *cli.Context) error {\n\t\t\tval := c.Int(\"top.test\")\n\t\t\texpect(t, val, 11)\n\t\t\treturn nil\n\t\t},\n\t\tFlags: []cli.Flag{\n\t\t\tNewIntFlag(cli.IntFlag{Name: \"top.test\", Value: 7, EnvVar: \"THE_TEST\"}),\n\t\t\tcli.StringFlag{Name: \"load\"}},\n\t}\n\tcommand.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc(\"load\"))\n\terr := command.Run(c)\n\n\texpect(t, err, nil)\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/altsrc/toml_file_loader.go",
    "content": "// Disabling building of toml support in cases where golang is 1.0 or 1.1\n// as the encoding library is not implemented or supported.\n\n// +build go1.2\n\npackage altsrc\n\nimport (\n\t\"fmt\"\n\t\"reflect\"\n\n\t\"github.com/BurntSushi/toml\"\n\t\"gopkg.in/urfave/cli.v1\"\n)\n\ntype tomlMap struct {\n\tMap map[interface{}]interface{}\n}\n\nfunc unmarshalMap(i interface{}) (ret map[interface{}]interface{}, err error) {\n\tret = make(map[interface{}]interface{})\n\tm := i.(map[string]interface{})\n\tfor key, val := range m {\n\t\tv := reflect.ValueOf(val)\n\t\tswitch v.Kind() {\n\t\tcase reflect.Bool:\n\t\t\tret[key] = val.(bool)\n\t\tcase reflect.String:\n\t\t\tret[key] = val.(string)\n\t\tcase reflect.Int:\n\t\t\tret[key] = int(val.(int))\n\t\tcase reflect.Int8:\n\t\t\tret[key] = int(val.(int8))\n\t\tcase reflect.Int16:\n\t\t\tret[key] = int(val.(int16))\n\t\tcase reflect.Int32:\n\t\t\tret[key] = int(val.(int32))\n\t\tcase reflect.Int64:\n\t\t\tret[key] = int(val.(int64))\n\t\tcase reflect.Uint:\n\t\t\tret[key] = int(val.(uint))\n\t\tcase reflect.Uint8:\n\t\t\tret[key] = int(val.(uint8))\n\t\tcase reflect.Uint16:\n\t\t\tret[key] = int(val.(uint16))\n\t\tcase reflect.Uint32:\n\t\t\tret[key] = int(val.(uint32))\n\t\tcase reflect.Uint64:\n\t\t\tret[key] = int(val.(uint64))\n\t\tcase reflect.Float32:\n\t\t\tret[key] = float64(val.(float32))\n\t\tcase reflect.Float64:\n\t\t\tret[key] = float64(val.(float64))\n\t\tcase reflect.Map:\n\t\t\tif tmp, err := unmarshalMap(val); err == nil {\n\t\t\t\tret[key] = tmp\n\t\t\t} else {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\tcase reflect.Array, reflect.Slice:\n\t\t\tret[key] = val.([]interface{})\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"Unsupported: type = %#v\", v.Kind())\n\t\t}\n\t}\n\treturn ret, nil\n}\n\nfunc (self *tomlMap) UnmarshalTOML(i interface{}) error {\n\tif tmp, err := unmarshalMap(i); err == nil {\n\t\tself.Map = tmp\n\t} else {\n\t\treturn err\n\t}\n\treturn nil\n}\n\ntype tomlSourceContext struct {\n\tFilePath string\n}\n\n// NewTomlSourceFromFile creates a new TOML InputSourceContext from a filepath.\nfunc NewTomlSourceFromFile(file string) (InputSourceContext, error) {\n\ttsc := &tomlSourceContext{FilePath: file}\n\tvar results tomlMap = tomlMap{}\n\tif err := readCommandToml(tsc.FilePath, &results); err != nil {\n\t\treturn nil, fmt.Errorf(\"Unable to load TOML file '%s': inner error: \\n'%v'\", tsc.FilePath, err.Error())\n\t}\n\treturn &MapInputSource{valueMap: results.Map}, nil\n}\n\n// NewTomlSourceFromFlagFunc creates a new TOML InputSourceContext from a provided flag name and source context.\nfunc NewTomlSourceFromFlagFunc(flagFileName string) func(context *cli.Context) (InputSourceContext, error) {\n\treturn func(context *cli.Context) (InputSourceContext, error) {\n\t\tfilePath := context.String(flagFileName)\n\t\treturn NewTomlSourceFromFile(filePath)\n\t}\n}\n\nfunc readCommandToml(filePath string, container interface{}) (err error) {\n\tb, err := loadDataFrom(filePath)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = toml.Unmarshal(b, container)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = nil\n\treturn\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/altsrc/yaml_command_test.go",
    "content": "// Disabling building of yaml support in cases where golang is 1.0 or 1.1\n// as the encoding library is not implemented or supported.\n\n// +build go1.2\n\npackage altsrc\n\nimport (\n\t\"flag\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"testing\"\n\n\t\"gopkg.in/urfave/cli.v1\"\n)\n\nfunc TestCommandYamlFileTest(t *testing.T) {\n\tapp := cli.NewApp()\n\tset := flag.NewFlagSet(\"test\", 0)\n\tioutil.WriteFile(\"current.yaml\", []byte(\"test: 15\"), 0666)\n\tdefer os.Remove(\"current.yaml\")\n\ttest := []string{\"test-cmd\", \"--load\", \"current.yaml\"}\n\tset.Parse(test)\n\n\tc := cli.NewContext(app, set, nil)\n\n\tcommand := &cli.Command{\n\t\tName:        \"test-cmd\",\n\t\tAliases:     []string{\"tc\"},\n\t\tUsage:       \"this is for testing\",\n\t\tDescription: \"testing\",\n\t\tAction: func(c *cli.Context) error {\n\t\t\tval := c.Int(\"test\")\n\t\t\texpect(t, val, 15)\n\t\t\treturn nil\n\t\t},\n\t\tFlags: []cli.Flag{\n\t\t\tNewIntFlag(cli.IntFlag{Name: \"test\"}),\n\t\t\tcli.StringFlag{Name: \"load\"}},\n\t}\n\tcommand.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc(\"load\"))\n\terr := command.Run(c)\n\n\texpect(t, err, nil)\n}\n\nfunc TestCommandYamlFileTestGlobalEnvVarWins(t *testing.T) {\n\tapp := cli.NewApp()\n\tset := flag.NewFlagSet(\"test\", 0)\n\tioutil.WriteFile(\"current.yaml\", []byte(\"test: 15\"), 0666)\n\tdefer os.Remove(\"current.yaml\")\n\n\tos.Setenv(\"THE_TEST\", \"10\")\n\tdefer os.Setenv(\"THE_TEST\", \"\")\n\ttest := []string{\"test-cmd\", \"--load\", \"current.yaml\"}\n\tset.Parse(test)\n\n\tc := cli.NewContext(app, set, nil)\n\n\tcommand := &cli.Command{\n\t\tName:        \"test-cmd\",\n\t\tAliases:     []string{\"tc\"},\n\t\tUsage:       \"this is for testing\",\n\t\tDescription: \"testing\",\n\t\tAction: func(c *cli.Context) error {\n\t\t\tval := c.Int(\"test\")\n\t\t\texpect(t, val, 10)\n\t\t\treturn nil\n\t\t},\n\t\tFlags: []cli.Flag{\n\t\t\tNewIntFlag(cli.IntFlag{Name: \"test\", EnvVar: \"THE_TEST\"}),\n\t\t\tcli.StringFlag{Name: \"load\"}},\n\t}\n\tcommand.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc(\"load\"))\n\n\terr := command.Run(c)\n\n\texpect(t, err, nil)\n}\n\nfunc TestCommandYamlFileTestGlobalEnvVarWinsNested(t *testing.T) {\n\tapp := cli.NewApp()\n\tset := flag.NewFlagSet(\"test\", 0)\n\tioutil.WriteFile(\"current.yaml\", []byte(`top:\n  test: 15`), 0666)\n\tdefer os.Remove(\"current.yaml\")\n\n\tos.Setenv(\"THE_TEST\", \"10\")\n\tdefer os.Setenv(\"THE_TEST\", \"\")\n\ttest := []string{\"test-cmd\", \"--load\", \"current.yaml\"}\n\tset.Parse(test)\n\n\tc := cli.NewContext(app, set, nil)\n\n\tcommand := &cli.Command{\n\t\tName:        \"test-cmd\",\n\t\tAliases:     []string{\"tc\"},\n\t\tUsage:       \"this is for testing\",\n\t\tDescription: \"testing\",\n\t\tAction: func(c *cli.Context) error {\n\t\t\tval := c.Int(\"top.test\")\n\t\t\texpect(t, val, 10)\n\t\t\treturn nil\n\t\t},\n\t\tFlags: []cli.Flag{\n\t\t\tNewIntFlag(cli.IntFlag{Name: \"top.test\", EnvVar: \"THE_TEST\"}),\n\t\t\tcli.StringFlag{Name: \"load\"}},\n\t}\n\tcommand.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc(\"load\"))\n\n\terr := command.Run(c)\n\n\texpect(t, err, nil)\n}\n\nfunc TestCommandYamlFileTestSpecifiedFlagWins(t *testing.T) {\n\tapp := cli.NewApp()\n\tset := flag.NewFlagSet(\"test\", 0)\n\tioutil.WriteFile(\"current.yaml\", []byte(\"test: 15\"), 0666)\n\tdefer os.Remove(\"current.yaml\")\n\n\ttest := []string{\"test-cmd\", \"--load\", \"current.yaml\", \"--test\", \"7\"}\n\tset.Parse(test)\n\n\tc := cli.NewContext(app, set, nil)\n\n\tcommand := &cli.Command{\n\t\tName:        \"test-cmd\",\n\t\tAliases:     []string{\"tc\"},\n\t\tUsage:       \"this is for testing\",\n\t\tDescription: \"testing\",\n\t\tAction: func(c *cli.Context) error {\n\t\t\tval := c.Int(\"test\")\n\t\t\texpect(t, val, 7)\n\t\t\treturn nil\n\t\t},\n\t\tFlags: []cli.Flag{\n\t\t\tNewIntFlag(cli.IntFlag{Name: \"test\"}),\n\t\t\tcli.StringFlag{Name: \"load\"}},\n\t}\n\tcommand.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc(\"load\"))\n\n\terr := command.Run(c)\n\n\texpect(t, err, nil)\n}\n\nfunc TestCommandYamlFileTestSpecifiedFlagWinsNested(t *testing.T) {\n\tapp := cli.NewApp()\n\tset := flag.NewFlagSet(\"test\", 0)\n\tioutil.WriteFile(\"current.yaml\", []byte(`top:\n  test: 15`), 0666)\n\tdefer os.Remove(\"current.yaml\")\n\n\ttest := []string{\"test-cmd\", \"--load\", \"current.yaml\", \"--top.test\", \"7\"}\n\tset.Parse(test)\n\n\tc := cli.NewContext(app, set, nil)\n\n\tcommand := &cli.Command{\n\t\tName:        \"test-cmd\",\n\t\tAliases:     []string{\"tc\"},\n\t\tUsage:       \"this is for testing\",\n\t\tDescription: \"testing\",\n\t\tAction: func(c *cli.Context) error {\n\t\t\tval := c.Int(\"top.test\")\n\t\t\texpect(t, val, 7)\n\t\t\treturn nil\n\t\t},\n\t\tFlags: []cli.Flag{\n\t\t\tNewIntFlag(cli.IntFlag{Name: \"top.test\"}),\n\t\t\tcli.StringFlag{Name: \"load\"}},\n\t}\n\tcommand.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc(\"load\"))\n\n\terr := command.Run(c)\n\n\texpect(t, err, nil)\n}\n\nfunc TestCommandYamlFileTestDefaultValueFileWins(t *testing.T) {\n\tapp := cli.NewApp()\n\tset := flag.NewFlagSet(\"test\", 0)\n\tioutil.WriteFile(\"current.yaml\", []byte(\"test: 15\"), 0666)\n\tdefer os.Remove(\"current.yaml\")\n\n\ttest := []string{\"test-cmd\", \"--load\", \"current.yaml\"}\n\tset.Parse(test)\n\n\tc := cli.NewContext(app, set, nil)\n\n\tcommand := &cli.Command{\n\t\tName:        \"test-cmd\",\n\t\tAliases:     []string{\"tc\"},\n\t\tUsage:       \"this is for testing\",\n\t\tDescription: \"testing\",\n\t\tAction: func(c *cli.Context) error {\n\t\t\tval := c.Int(\"test\")\n\t\t\texpect(t, val, 15)\n\t\t\treturn nil\n\t\t},\n\t\tFlags: []cli.Flag{\n\t\t\tNewIntFlag(cli.IntFlag{Name: \"test\", Value: 7}),\n\t\t\tcli.StringFlag{Name: \"load\"}},\n\t}\n\tcommand.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc(\"load\"))\n\n\terr := command.Run(c)\n\n\texpect(t, err, nil)\n}\n\nfunc TestCommandYamlFileTestDefaultValueFileWinsNested(t *testing.T) {\n\tapp := cli.NewApp()\n\tset := flag.NewFlagSet(\"test\", 0)\n\tioutil.WriteFile(\"current.yaml\", []byte(`top:\n  test: 15`), 0666)\n\tdefer os.Remove(\"current.yaml\")\n\n\ttest := []string{\"test-cmd\", \"--load\", \"current.yaml\"}\n\tset.Parse(test)\n\n\tc := cli.NewContext(app, set, nil)\n\n\tcommand := &cli.Command{\n\t\tName:        \"test-cmd\",\n\t\tAliases:     []string{\"tc\"},\n\t\tUsage:       \"this is for testing\",\n\t\tDescription: \"testing\",\n\t\tAction: func(c *cli.Context) error {\n\t\t\tval := c.Int(\"top.test\")\n\t\t\texpect(t, val, 15)\n\t\t\treturn nil\n\t\t},\n\t\tFlags: []cli.Flag{\n\t\t\tNewIntFlag(cli.IntFlag{Name: \"top.test\", Value: 7}),\n\t\t\tcli.StringFlag{Name: \"load\"}},\n\t}\n\tcommand.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc(\"load\"))\n\n\terr := command.Run(c)\n\n\texpect(t, err, nil)\n}\n\nfunc TestCommandYamlFileFlagHasDefaultGlobalEnvYamlSetGlobalEnvWins(t *testing.T) {\n\tapp := cli.NewApp()\n\tset := flag.NewFlagSet(\"test\", 0)\n\tioutil.WriteFile(\"current.yaml\", []byte(\"test: 15\"), 0666)\n\tdefer os.Remove(\"current.yaml\")\n\n\tos.Setenv(\"THE_TEST\", \"11\")\n\tdefer os.Setenv(\"THE_TEST\", \"\")\n\n\ttest := []string{\"test-cmd\", \"--load\", \"current.yaml\"}\n\tset.Parse(test)\n\n\tc := cli.NewContext(app, set, nil)\n\n\tcommand := &cli.Command{\n\t\tName:        \"test-cmd\",\n\t\tAliases:     []string{\"tc\"},\n\t\tUsage:       \"this is for testing\",\n\t\tDescription: \"testing\",\n\t\tAction: func(c *cli.Context) error {\n\t\t\tval := c.Int(\"test\")\n\t\t\texpect(t, val, 11)\n\t\t\treturn nil\n\t\t},\n\t\tFlags: []cli.Flag{\n\t\t\tNewIntFlag(cli.IntFlag{Name: \"test\", Value: 7, EnvVar: \"THE_TEST\"}),\n\t\t\tcli.StringFlag{Name: \"load\"}},\n\t}\n\tcommand.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc(\"load\"))\n\terr := command.Run(c)\n\n\texpect(t, err, nil)\n}\n\nfunc TestCommandYamlFileFlagHasDefaultGlobalEnvYamlSetGlobalEnvWinsNested(t *testing.T) {\n\tapp := cli.NewApp()\n\tset := flag.NewFlagSet(\"test\", 0)\n\tioutil.WriteFile(\"current.yaml\", []byte(`top:\n  test: 15`), 0666)\n\tdefer os.Remove(\"current.yaml\")\n\n\tos.Setenv(\"THE_TEST\", \"11\")\n\tdefer os.Setenv(\"THE_TEST\", \"\")\n\n\ttest := []string{\"test-cmd\", \"--load\", \"current.yaml\"}\n\tset.Parse(test)\n\n\tc := cli.NewContext(app, set, nil)\n\n\tcommand := &cli.Command{\n\t\tName:        \"test-cmd\",\n\t\tAliases:     []string{\"tc\"},\n\t\tUsage:       \"this is for testing\",\n\t\tDescription: \"testing\",\n\t\tAction: func(c *cli.Context) error {\n\t\t\tval := c.Int(\"top.test\")\n\t\t\texpect(t, val, 11)\n\t\t\treturn nil\n\t\t},\n\t\tFlags: []cli.Flag{\n\t\t\tNewIntFlag(cli.IntFlag{Name: \"top.test\", Value: 7, EnvVar: \"THE_TEST\"}),\n\t\t\tcli.StringFlag{Name: \"load\"}},\n\t}\n\tcommand.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc(\"load\"))\n\terr := command.Run(c)\n\n\texpect(t, err, nil)\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/altsrc/yaml_file_loader.go",
    "content": "// Disabling building of yaml support in cases where golang is 1.0 or 1.1\n// as the encoding library is not implemented or supported.\n\n// +build go1.2\n\npackage altsrc\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"os\"\n\t\"runtime\"\n\t\"strings\"\n\n\t\"gopkg.in/urfave/cli.v1\"\n\n\t\"gopkg.in/yaml.v2\"\n)\n\ntype yamlSourceContext struct {\n\tFilePath string\n}\n\n// NewYamlSourceFromFile creates a new Yaml InputSourceContext from a filepath.\nfunc NewYamlSourceFromFile(file string) (InputSourceContext, error) {\n\tysc := &yamlSourceContext{FilePath: file}\n\tvar results map[interface{}]interface{}\n\terr := readCommandYaml(ysc.FilePath, &results)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Unable to load Yaml file '%s': inner error: \\n'%v'\", ysc.FilePath, err.Error())\n\t}\n\n\treturn &MapInputSource{valueMap: results}, nil\n}\n\n// NewYamlSourceFromFlagFunc creates a new Yaml InputSourceContext from a provided flag name and source context.\nfunc NewYamlSourceFromFlagFunc(flagFileName string) func(context *cli.Context) (InputSourceContext, error) {\n\treturn func(context *cli.Context) (InputSourceContext, error) {\n\t\tfilePath := context.String(flagFileName)\n\t\treturn NewYamlSourceFromFile(filePath)\n\t}\n}\n\nfunc readCommandYaml(filePath string, container interface{}) (err error) {\n\tb, err := loadDataFrom(filePath)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = yaml.Unmarshal(b, container)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = nil\n\treturn\n}\n\nfunc loadDataFrom(filePath string) ([]byte, error) {\n\tu, err := url.Parse(filePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif u.Host != \"\" { // i have a host, now do i support the scheme?\n\t\tswitch u.Scheme {\n\t\tcase \"http\", \"https\":\n\t\t\tres, err := http.Get(filePath)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\treturn ioutil.ReadAll(res.Body)\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"scheme of %s is unsupported\", filePath)\n\t\t}\n\t} else if u.Path != \"\" { // i dont have a host, but I have a path. I am a local file.\n\t\tif _, notFoundFileErr := os.Stat(filePath); notFoundFileErr != nil {\n\t\t\treturn nil, fmt.Errorf(\"Cannot read from file: '%s' because it does not exist.\", filePath)\n\t\t}\n\t\treturn ioutil.ReadFile(filePath)\n\t} else if runtime.GOOS == \"windows\" && strings.Contains(u.String(), \"\\\\\") {\n\t\t// on Windows systems u.Path is always empty, so we need to check the string directly.\n\t\tif _, notFoundFileErr := os.Stat(filePath); notFoundFileErr != nil {\n\t\t\treturn nil, fmt.Errorf(\"Cannot read from file: '%s' because it does not exist.\", filePath)\n\t\t}\n\t\treturn ioutil.ReadFile(filePath)\n\t} else {\n\t\treturn nil, fmt.Errorf(\"unable to determine how to load from path %s\", filePath)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/app.go",
    "content": "package cli\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"sort\"\n\t\"time\"\n)\n\nvar (\n\tchangeLogURL                    = \"https://github.com/urfave/cli/blob/master/CHANGELOG.md\"\n\tappActionDeprecationURL         = fmt.Sprintf(\"%s#deprecated-cli-app-action-signature\", changeLogURL)\n\trunAndExitOnErrorDeprecationURL = fmt.Sprintf(\"%s#deprecated-cli-app-runandexitonerror\", changeLogURL)\n\n\tcontactSysadmin = \"This is an error in the application.  Please contact the distributor of this application if this is not you.\"\n\n\terrInvalidActionType = NewExitError(\"ERROR invalid Action type. \"+\n\t\tfmt.Sprintf(\"Must be `func(*Context`)` or `func(*Context) error).  %s\", contactSysadmin)+\n\t\tfmt.Sprintf(\"See %s\", appActionDeprecationURL), 2)\n)\n\n// App is the main structure of a cli application. It is recommended that\n// an app be created with the cli.NewApp() function\ntype App struct {\n\t// The name of the program. Defaults to path.Base(os.Args[0])\n\tName string\n\t// Full name of command for help, defaults to Name\n\tHelpName string\n\t// Description of the program.\n\tUsage string\n\t// Text to override the USAGE section of help\n\tUsageText string\n\t// Description of the program argument format.\n\tArgsUsage string\n\t// Version of the program\n\tVersion string\n\t// Description of the program\n\tDescription string\n\t// List of commands to execute\n\tCommands []Command\n\t// List of flags to parse\n\tFlags []Flag\n\t// Boolean to enable bash completion commands\n\tEnableBashCompletion bool\n\t// Boolean to hide built-in help command\n\tHideHelp bool\n\t// Boolean to hide built-in version flag and the VERSION section of help\n\tHideVersion bool\n\t// Populate on app startup, only gettable through method Categories()\n\tcategories CommandCategories\n\t// An action to execute when the bash-completion flag is set\n\tBashComplete BashCompleteFunc\n\t// An action to execute before any subcommands are run, but after the context is ready\n\t// If a non-nil error is returned, no subcommands are run\n\tBefore BeforeFunc\n\t// An action to execute after any subcommands are run, but after the subcommand has finished\n\t// It is run even if Action() panics\n\tAfter AfterFunc\n\n\t// The action to execute when no subcommands are specified\n\t// Expects a `cli.ActionFunc` but will accept the *deprecated* signature of `func(*cli.Context) {}`\n\t// *Note*: support for the deprecated `Action` signature will be removed in a future version\n\tAction interface{}\n\n\t// Execute this function if the proper command cannot be found\n\tCommandNotFound CommandNotFoundFunc\n\t// Execute this function if an usage error occurs\n\tOnUsageError OnUsageErrorFunc\n\t// Compilation date\n\tCompiled time.Time\n\t// List of all authors who contributed\n\tAuthors []Author\n\t// Copyright of the binary if any\n\tCopyright string\n\t// Name of Author (Note: Use App.Authors, this is deprecated)\n\tAuthor string\n\t// Email of Author (Note: Use App.Authors, this is deprecated)\n\tEmail string\n\t// Writer writer to write output to\n\tWriter io.Writer\n\t// ErrWriter writes error output\n\tErrWriter io.Writer\n\t// Other custom info\n\tMetadata map[string]interface{}\n\t// Carries a function which returns app specific info.\n\tExtraInfo func() map[string]string\n\t// CustomAppHelpTemplate the text template for app help topic.\n\t// cli.go uses text/template to render templates. You can\n\t// render custom help text by setting this variable.\n\tCustomAppHelpTemplate string\n\n\tdidSetup bool\n}\n\n// Tries to find out when this binary was compiled.\n// Returns the current time if it fails to find it.\nfunc compileTime() time.Time {\n\tinfo, err := os.Stat(os.Args[0])\n\tif err != nil {\n\t\treturn time.Now()\n\t}\n\treturn info.ModTime()\n}\n\n// NewApp creates a new cli Application with some reasonable defaults for Name,\n// Usage, Version and Action.\nfunc NewApp() *App {\n\treturn &App{\n\t\tName:         filepath.Base(os.Args[0]),\n\t\tHelpName:     filepath.Base(os.Args[0]),\n\t\tUsage:        \"A new cli application\",\n\t\tUsageText:    \"\",\n\t\tVersion:      \"0.0.0\",\n\t\tBashComplete: DefaultAppComplete,\n\t\tAction:       helpCommand.Action,\n\t\tCompiled:     compileTime(),\n\t\tWriter:       os.Stdout,\n\t}\n}\n\n// Setup runs initialization code to ensure all data structures are ready for\n// `Run` or inspection prior to `Run`.  It is internally called by `Run`, but\n// will return early if setup has already happened.\nfunc (a *App) Setup() {\n\tif a.didSetup {\n\t\treturn\n\t}\n\n\ta.didSetup = true\n\n\tif a.Author != \"\" || a.Email != \"\" {\n\t\ta.Authors = append(a.Authors, Author{Name: a.Author, Email: a.Email})\n\t}\n\n\tnewCmds := []Command{}\n\tfor _, c := range a.Commands {\n\t\tif c.HelpName == \"\" {\n\t\t\tc.HelpName = fmt.Sprintf(\"%s %s\", a.HelpName, c.Name)\n\t\t}\n\t\tnewCmds = append(newCmds, c)\n\t}\n\ta.Commands = newCmds\n\n\tif a.Command(helpCommand.Name) == nil && !a.HideHelp {\n\t\ta.Commands = append(a.Commands, helpCommand)\n\t\tif (HelpFlag != BoolFlag{}) {\n\t\t\ta.appendFlag(HelpFlag)\n\t\t}\n\t}\n\n\tif !a.HideVersion {\n\t\ta.appendFlag(VersionFlag)\n\t}\n\n\ta.categories = CommandCategories{}\n\tfor _, command := range a.Commands {\n\t\ta.categories = a.categories.AddCommand(command.Category, command)\n\t}\n\tsort.Sort(a.categories)\n\n\tif a.Metadata == nil {\n\t\ta.Metadata = make(map[string]interface{})\n\t}\n\n\tif a.Writer == nil {\n\t\ta.Writer = os.Stdout\n\t}\n}\n\n// Run is the entry point to the cli app. Parses the arguments slice and routes\n// to the proper flag/args combination\nfunc (a *App) Run(arguments []string) (err error) {\n\ta.Setup()\n\n\t// handle the completion flag separately from the flagset since\n\t// completion could be attempted after a flag, but before its value was put\n\t// on the command line. this causes the flagset to interpret the completion\n\t// flag name as the value of the flag before it which is undesirable\n\t// note that we can only do this because the shell autocomplete function\n\t// always appends the completion flag at the end of the command\n\tshellComplete, arguments := checkShellCompleteFlag(a, arguments)\n\n\t// parse flags\n\tset, err := flagSet(a.Name, a.Flags)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tset.SetOutput(ioutil.Discard)\n\terr = set.Parse(arguments[1:])\n\tnerr := normalizeFlags(a.Flags, set)\n\tcontext := NewContext(a, set, nil)\n\tif nerr != nil {\n\t\tfmt.Fprintln(a.Writer, nerr)\n\t\tShowAppHelp(context)\n\t\treturn nerr\n\t}\n\tcontext.shellComplete = shellComplete\n\n\tif checkCompletions(context) {\n\t\treturn nil\n\t}\n\n\tif err != nil {\n\t\tif a.OnUsageError != nil {\n\t\t\terr := a.OnUsageError(context, err, false)\n\t\t\tHandleExitCoder(err)\n\t\t\treturn err\n\t\t}\n\t\tfmt.Fprintf(a.Writer, \"%s %s\\n\\n\", \"Incorrect Usage.\", err.Error())\n\t\tShowAppHelp(context)\n\t\treturn err\n\t}\n\n\tif !a.HideHelp && checkHelp(context) {\n\t\tShowAppHelp(context)\n\t\treturn nil\n\t}\n\n\tif !a.HideVersion && checkVersion(context) {\n\t\tShowVersion(context)\n\t\treturn nil\n\t}\n\n\tif a.After != nil {\n\t\tdefer func() {\n\t\t\tif afterErr := a.After(context); afterErr != nil {\n\t\t\t\tif err != nil {\n\t\t\t\t\terr = NewMultiError(err, afterErr)\n\t\t\t\t} else {\n\t\t\t\t\terr = afterErr\n\t\t\t\t}\n\t\t\t}\n\t\t}()\n\t}\n\n\tif a.Before != nil {\n\t\tbeforeErr := a.Before(context)\n\t\tif beforeErr != nil {\n\t\t\tShowAppHelp(context)\n\t\t\tHandleExitCoder(beforeErr)\n\t\t\terr = beforeErr\n\t\t\treturn err\n\t\t}\n\t}\n\n\targs := context.Args()\n\tif args.Present() {\n\t\tname := args.First()\n\t\tc := a.Command(name)\n\t\tif c != nil {\n\t\t\treturn c.Run(context)\n\t\t}\n\t}\n\n\tif a.Action == nil {\n\t\ta.Action = helpCommand.Action\n\t}\n\n\t// Run default Action\n\terr = HandleAction(a.Action, context)\n\n\tHandleExitCoder(err)\n\treturn err\n}\n\n// RunAndExitOnError calls .Run() and exits non-zero if an error was returned\n//\n// Deprecated: instead you should return an error that fulfills cli.ExitCoder\n// to cli.App.Run. This will cause the application to exit with the given eror\n// code in the cli.ExitCoder\nfunc (a *App) RunAndExitOnError() {\n\tif err := a.Run(os.Args); err != nil {\n\t\tfmt.Fprintln(a.errWriter(), err)\n\t\tOsExiter(1)\n\t}\n}\n\n// RunAsSubcommand invokes the subcommand given the context, parses ctx.Args() to\n// generate command-specific flags\nfunc (a *App) RunAsSubcommand(ctx *Context) (err error) {\n\t// append help to commands\n\tif len(a.Commands) > 0 {\n\t\tif a.Command(helpCommand.Name) == nil && !a.HideHelp {\n\t\t\ta.Commands = append(a.Commands, helpCommand)\n\t\t\tif (HelpFlag != BoolFlag{}) {\n\t\t\t\ta.appendFlag(HelpFlag)\n\t\t\t}\n\t\t}\n\t}\n\n\tnewCmds := []Command{}\n\tfor _, c := range a.Commands {\n\t\tif c.HelpName == \"\" {\n\t\t\tc.HelpName = fmt.Sprintf(\"%s %s\", a.HelpName, c.Name)\n\t\t}\n\t\tnewCmds = append(newCmds, c)\n\t}\n\ta.Commands = newCmds\n\n\t// parse flags\n\tset, err := flagSet(a.Name, a.Flags)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tset.SetOutput(ioutil.Discard)\n\terr = set.Parse(ctx.Args().Tail())\n\tnerr := normalizeFlags(a.Flags, set)\n\tcontext := NewContext(a, set, ctx)\n\n\tif nerr != nil {\n\t\tfmt.Fprintln(a.Writer, nerr)\n\t\tfmt.Fprintln(a.Writer)\n\t\tif len(a.Commands) > 0 {\n\t\t\tShowSubcommandHelp(context)\n\t\t} else {\n\t\t\tShowCommandHelp(ctx, context.Args().First())\n\t\t}\n\t\treturn nerr\n\t}\n\n\tif checkCompletions(context) {\n\t\treturn nil\n\t}\n\n\tif err != nil {\n\t\tif a.OnUsageError != nil {\n\t\t\terr = a.OnUsageError(context, err, true)\n\t\t\tHandleExitCoder(err)\n\t\t\treturn err\n\t\t}\n\t\tfmt.Fprintf(a.Writer, \"%s %s\\n\\n\", \"Incorrect Usage.\", err.Error())\n\t\tShowSubcommandHelp(context)\n\t\treturn err\n\t}\n\n\tif len(a.Commands) > 0 {\n\t\tif checkSubcommandHelp(context) {\n\t\t\treturn nil\n\t\t}\n\t} else {\n\t\tif checkCommandHelp(ctx, context.Args().First()) {\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tif a.After != nil {\n\t\tdefer func() {\n\t\t\tafterErr := a.After(context)\n\t\t\tif afterErr != nil {\n\t\t\t\tHandleExitCoder(err)\n\t\t\t\tif err != nil {\n\t\t\t\t\terr = NewMultiError(err, afterErr)\n\t\t\t\t} else {\n\t\t\t\t\terr = afterErr\n\t\t\t\t}\n\t\t\t}\n\t\t}()\n\t}\n\n\tif a.Before != nil {\n\t\tbeforeErr := a.Before(context)\n\t\tif beforeErr != nil {\n\t\t\tHandleExitCoder(beforeErr)\n\t\t\terr = beforeErr\n\t\t\treturn err\n\t\t}\n\t}\n\n\targs := context.Args()\n\tif args.Present() {\n\t\tname := args.First()\n\t\tc := a.Command(name)\n\t\tif c != nil {\n\t\t\treturn c.Run(context)\n\t\t}\n\t}\n\n\t// Run default Action\n\terr = HandleAction(a.Action, context)\n\n\tHandleExitCoder(err)\n\treturn err\n}\n\n// Command returns the named command on App. Returns nil if the command does not exist\nfunc (a *App) Command(name string) *Command {\n\tfor _, c := range a.Commands {\n\t\tif c.HasName(name) {\n\t\t\treturn &c\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// Categories returns a slice containing all the categories with the commands they contain\nfunc (a *App) Categories() CommandCategories {\n\treturn a.categories\n}\n\n// VisibleCategories returns a slice of categories and commands that are\n// Hidden=false\nfunc (a *App) VisibleCategories() []*CommandCategory {\n\tret := []*CommandCategory{}\n\tfor _, category := range a.categories {\n\t\tif visible := func() *CommandCategory {\n\t\t\tfor _, command := range category.Commands {\n\t\t\t\tif !command.Hidden {\n\t\t\t\t\treturn category\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn nil\n\t\t}(); visible != nil {\n\t\t\tret = append(ret, visible)\n\t\t}\n\t}\n\treturn ret\n}\n\n// VisibleCommands returns a slice of the Commands with Hidden=false\nfunc (a *App) VisibleCommands() []Command {\n\tret := []Command{}\n\tfor _, command := range a.Commands {\n\t\tif !command.Hidden {\n\t\t\tret = append(ret, command)\n\t\t}\n\t}\n\treturn ret\n}\n\n// VisibleFlags returns a slice of the Flags with Hidden=false\nfunc (a *App) VisibleFlags() []Flag {\n\treturn visibleFlags(a.Flags)\n}\n\nfunc (a *App) hasFlag(flag Flag) bool {\n\tfor _, f := range a.Flags {\n\t\tif flag == f {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\nfunc (a *App) errWriter() io.Writer {\n\n\t// When the app ErrWriter is nil use the package level one.\n\tif a.ErrWriter == nil {\n\t\treturn ErrWriter\n\t}\n\n\treturn a.ErrWriter\n}\n\nfunc (a *App) appendFlag(flag Flag) {\n\tif !a.hasFlag(flag) {\n\t\ta.Flags = append(a.Flags, flag)\n\t}\n}\n\n// Author represents someone who has contributed to a cli project.\ntype Author struct {\n\tName  string // The Authors name\n\tEmail string // The Authors email\n}\n\n// String makes Author comply to the Stringer interface, to allow an easy print in the templating process\nfunc (a Author) String() string {\n\te := \"\"\n\tif a.Email != \"\" {\n\t\te = \" <\" + a.Email + \">\"\n\t}\n\n\treturn fmt.Sprintf(\"%v%v\", a.Name, e)\n}\n\n// HandleAction attempts to figure out which Action signature was used.  If\n// it's an ActionFunc or a func with the legacy signature for Action, the func\n// is run!\nfunc HandleAction(action interface{}, context *Context) (err error) {\n\tif a, ok := action.(ActionFunc); ok {\n\t\treturn a(context)\n\t} else if a, ok := action.(func(*Context) error); ok {\n\t\treturn a(context)\n\t} else if a, ok := action.(func(*Context)); ok { // deprecated function signature\n\t\ta(context)\n\t\treturn nil\n\t} else {\n\t\treturn errInvalidActionType\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/app_test.go",
    "content": "package cli\n\nimport (\n\t\"bytes\"\n\t\"errors\"\n\t\"flag\"\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"reflect\"\n\t\"strings\"\n\t\"testing\"\n)\n\nvar (\n\tlastExitCode = 0\n\tfakeOsExiter = func(rc int) {\n\t\tlastExitCode = rc\n\t}\n\tfakeErrWriter = &bytes.Buffer{}\n)\n\nfunc init() {\n\tOsExiter = fakeOsExiter\n\tErrWriter = fakeErrWriter\n}\n\ntype opCounts struct {\n\tTotal, BashComplete, OnUsageError, Before, CommandNotFound, Action, After, SubCommand int\n}\n\nfunc ExampleApp_Run() {\n\t// set args for examples sake\n\tos.Args = []string{\"greet\", \"--name\", \"Jeremy\"}\n\n\tapp := NewApp()\n\tapp.Name = \"greet\"\n\tapp.Flags = []Flag{\n\t\tStringFlag{Name: \"name\", Value: \"bob\", Usage: \"a name to say\"},\n\t}\n\tapp.Action = func(c *Context) error {\n\t\tfmt.Printf(\"Hello %v\\n\", c.String(\"name\"))\n\t\treturn nil\n\t}\n\tapp.UsageText = \"app [first_arg] [second_arg]\"\n\tapp.Author = \"Harrison\"\n\tapp.Email = \"harrison@lolwut.com\"\n\tapp.Authors = []Author{{Name: \"Oliver Allen\", Email: \"oliver@toyshop.com\"}}\n\tapp.Run(os.Args)\n\t// Output:\n\t// Hello Jeremy\n}\n\nfunc ExampleApp_Run_subcommand() {\n\t// set args for examples sake\n\tos.Args = []string{\"say\", \"hi\", \"english\", \"--name\", \"Jeremy\"}\n\tapp := NewApp()\n\tapp.Name = \"say\"\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName:        \"hello\",\n\t\t\tAliases:     []string{\"hi\"},\n\t\t\tUsage:       \"use it to see a description\",\n\t\t\tDescription: \"This is how we describe hello the function\",\n\t\t\tSubcommands: []Command{\n\t\t\t\t{\n\t\t\t\t\tName:        \"english\",\n\t\t\t\t\tAliases:     []string{\"en\"},\n\t\t\t\t\tUsage:       \"sends a greeting in english\",\n\t\t\t\t\tDescription: \"greets someone in english\",\n\t\t\t\t\tFlags: []Flag{\n\t\t\t\t\t\tStringFlag{\n\t\t\t\t\t\t\tName:  \"name\",\n\t\t\t\t\t\t\tValue: \"Bob\",\n\t\t\t\t\t\t\tUsage: \"Name of the person to greet\",\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tAction: func(c *Context) error {\n\t\t\t\t\t\tfmt.Println(\"Hello,\", c.String(\"name\"))\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\tapp.Run(os.Args)\n\t// Output:\n\t// Hello, Jeremy\n}\n\nfunc ExampleApp_Run_appHelp() {\n\t// set args for examples sake\n\tos.Args = []string{\"greet\", \"help\"}\n\n\tapp := NewApp()\n\tapp.Name = \"greet\"\n\tapp.Version = \"0.1.0\"\n\tapp.Description = \"This is how we describe greet the app\"\n\tapp.Authors = []Author{\n\t\t{Name: \"Harrison\", Email: \"harrison@lolwut.com\"},\n\t\t{Name: \"Oliver Allen\", Email: \"oliver@toyshop.com\"},\n\t}\n\tapp.Flags = []Flag{\n\t\tStringFlag{Name: \"name\", Value: \"bob\", Usage: \"a name to say\"},\n\t}\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName:        \"describeit\",\n\t\t\tAliases:     []string{\"d\"},\n\t\t\tUsage:       \"use it to see a description\",\n\t\t\tDescription: \"This is how we describe describeit the function\",\n\t\t\tAction: func(c *Context) error {\n\t\t\t\tfmt.Printf(\"i like to describe things\")\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t}\n\tapp.Run(os.Args)\n\t// Output:\n\t// NAME:\n\t//    greet - A new cli application\n\t//\n\t// USAGE:\n\t//    greet [global options] command [command options] [arguments...]\n\t//\n\t// VERSION:\n\t//    0.1.0\n\t//\n\t// DESCRIPTION:\n\t//    This is how we describe greet the app\n\t//\n\t// AUTHORS:\n\t//    Harrison <harrison@lolwut.com>\n\t//    Oliver Allen <oliver@toyshop.com>\n\t//\n\t// COMMANDS:\n\t//      describeit, d  use it to see a description\n\t//      help, h        Shows a list of commands or help for one command\n\t//\n\t// GLOBAL OPTIONS:\n\t//    --name value   a name to say (default: \"bob\")\n\t//    --help, -h     show help\n\t//    --version, -v  print the version\n}\n\nfunc ExampleApp_Run_commandHelp() {\n\t// set args for examples sake\n\tos.Args = []string{\"greet\", \"h\", \"describeit\"}\n\n\tapp := NewApp()\n\tapp.Name = \"greet\"\n\tapp.Flags = []Flag{\n\t\tStringFlag{Name: \"name\", Value: \"bob\", Usage: \"a name to say\"},\n\t}\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName:        \"describeit\",\n\t\t\tAliases:     []string{\"d\"},\n\t\t\tUsage:       \"use it to see a description\",\n\t\t\tDescription: \"This is how we describe describeit the function\",\n\t\t\tAction: func(c *Context) error {\n\t\t\t\tfmt.Printf(\"i like to describe things\")\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t}\n\tapp.Run(os.Args)\n\t// Output:\n\t// NAME:\n\t//    greet describeit - use it to see a description\n\t//\n\t// USAGE:\n\t//    greet describeit [arguments...]\n\t//\n\t// DESCRIPTION:\n\t//    This is how we describe describeit the function\n}\n\nfunc ExampleApp_Run_noAction() {\n\tapp := App{}\n\tapp.Name = \"greet\"\n\tapp.Run([]string{\"greet\"})\n\t// Output:\n\t// NAME:\n\t//    greet\n\t//\n\t// USAGE:\n\t//     [global options] command [command options] [arguments...]\n\t//\n\t// COMMANDS:\n\t//      help, h  Shows a list of commands or help for one command\n\t//\n\t// GLOBAL OPTIONS:\n\t//    --help, -h     show help\n\t//    --version, -v  print the version\n}\n\nfunc ExampleApp_Run_subcommandNoAction() {\n\tapp := App{}\n\tapp.Name = \"greet\"\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName:        \"describeit\",\n\t\t\tAliases:     []string{\"d\"},\n\t\t\tUsage:       \"use it to see a description\",\n\t\t\tDescription: \"This is how we describe describeit the function\",\n\t\t},\n\t}\n\tapp.Run([]string{\"greet\", \"describeit\"})\n\t// Output:\n\t// NAME:\n\t//     describeit - use it to see a description\n\t//\n\t// USAGE:\n\t//     describeit [arguments...]\n\t//\n\t// DESCRIPTION:\n\t//    This is how we describe describeit the function\n\n}\n\nfunc ExampleApp_Run_bashComplete() {\n\t// set args for examples sake\n\tos.Args = []string{\"greet\", \"--generate-bash-completion\"}\n\n\tapp := NewApp()\n\tapp.Name = \"greet\"\n\tapp.EnableBashCompletion = true\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName:        \"describeit\",\n\t\t\tAliases:     []string{\"d\"},\n\t\t\tUsage:       \"use it to see a description\",\n\t\t\tDescription: \"This is how we describe describeit the function\",\n\t\t\tAction: func(c *Context) error {\n\t\t\t\tfmt.Printf(\"i like to describe things\")\n\t\t\t\treturn nil\n\t\t\t},\n\t\t}, {\n\t\t\tName:        \"next\",\n\t\t\tUsage:       \"next example\",\n\t\t\tDescription: \"more stuff to see when generating bash completion\",\n\t\t\tAction: func(c *Context) error {\n\t\t\t\tfmt.Printf(\"the next example\")\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t}\n\n\tapp.Run(os.Args)\n\t// Output:\n\t// describeit\n\t// d\n\t// next\n\t// help\n\t// h\n}\n\nfunc TestApp_Run(t *testing.T) {\n\ts := \"\"\n\n\tapp := NewApp()\n\tapp.Action = func(c *Context) error {\n\t\ts = s + c.Args().First()\n\t\treturn nil\n\t}\n\n\terr := app.Run([]string{\"command\", \"foo\"})\n\texpect(t, err, nil)\n\terr = app.Run([]string{\"command\", \"bar\"})\n\texpect(t, err, nil)\n\texpect(t, s, \"foobar\")\n}\n\nvar commandAppTests = []struct {\n\tname     string\n\texpected bool\n}{\n\t{\"foobar\", true},\n\t{\"batbaz\", true},\n\t{\"b\", true},\n\t{\"f\", true},\n\t{\"bat\", false},\n\t{\"nothing\", false},\n}\n\nfunc TestApp_Command(t *testing.T) {\n\tapp := NewApp()\n\tfooCommand := Command{Name: \"foobar\", Aliases: []string{\"f\"}}\n\tbatCommand := Command{Name: \"batbaz\", Aliases: []string{\"b\"}}\n\tapp.Commands = []Command{\n\t\tfooCommand,\n\t\tbatCommand,\n\t}\n\n\tfor _, test := range commandAppTests {\n\t\texpect(t, app.Command(test.name) != nil, test.expected)\n\t}\n}\n\nfunc TestApp_Setup_defaultsWriter(t *testing.T) {\n\tapp := &App{}\n\tapp.Setup()\n\texpect(t, app.Writer, os.Stdout)\n}\n\nfunc TestApp_CommandWithArgBeforeFlags(t *testing.T) {\n\tvar parsedOption, firstArg string\n\n\tapp := NewApp()\n\tcommand := Command{\n\t\tName: \"cmd\",\n\t\tFlags: []Flag{\n\t\t\tStringFlag{Name: \"option\", Value: \"\", Usage: \"some option\"},\n\t\t},\n\t\tAction: func(c *Context) error {\n\t\t\tparsedOption = c.String(\"option\")\n\t\t\tfirstArg = c.Args().First()\n\t\t\treturn nil\n\t\t},\n\t}\n\tapp.Commands = []Command{command}\n\n\tapp.Run([]string{\"\", \"cmd\", \"my-arg\", \"--option\", \"my-option\"})\n\n\texpect(t, parsedOption, \"my-option\")\n\texpect(t, firstArg, \"my-arg\")\n}\n\nfunc TestApp_RunAsSubcommandParseFlags(t *testing.T) {\n\tvar context *Context\n\n\ta := NewApp()\n\ta.Commands = []Command{\n\t\t{\n\t\t\tName: \"foo\",\n\t\t\tAction: func(c *Context) error {\n\t\t\t\tcontext = c\n\t\t\t\treturn nil\n\t\t\t},\n\t\t\tFlags: []Flag{\n\t\t\t\tStringFlag{\n\t\t\t\t\tName:  \"lang\",\n\t\t\t\t\tValue: \"english\",\n\t\t\t\t\tUsage: \"language for the greeting\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tBefore: func(_ *Context) error { return nil },\n\t\t},\n\t}\n\ta.Run([]string{\"\", \"foo\", \"--lang\", \"spanish\", \"abcd\"})\n\n\texpect(t, context.Args().Get(0), \"abcd\")\n\texpect(t, context.String(\"lang\"), \"spanish\")\n}\n\nfunc TestApp_RunAsSubCommandIncorrectUsage(t *testing.T) {\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tStringFlag{Name: \"--foo\"},\n\t\t},\n\t\tWriter: bytes.NewBufferString(\"\"),\n\t}\n\n\tset := flag.NewFlagSet(\"\", flag.ContinueOnError)\n\tset.Parse([]string{\"\", \"---foo\"})\n\tc := &Context{flagSet: set}\n\n\terr := a.RunAsSubcommand(c)\n\n\texpect(t, err, errors.New(\"bad flag syntax: ---foo\"))\n}\n\nfunc TestApp_CommandWithFlagBeforeTerminator(t *testing.T) {\n\tvar parsedOption string\n\tvar args []string\n\n\tapp := NewApp()\n\tcommand := Command{\n\t\tName: \"cmd\",\n\t\tFlags: []Flag{\n\t\t\tStringFlag{Name: \"option\", Value: \"\", Usage: \"some option\"},\n\t\t},\n\t\tAction: func(c *Context) error {\n\t\t\tparsedOption = c.String(\"option\")\n\t\t\targs = c.Args()\n\t\t\treturn nil\n\t\t},\n\t}\n\tapp.Commands = []Command{command}\n\n\tapp.Run([]string{\"\", \"cmd\", \"my-arg\", \"--option\", \"my-option\", \"--\", \"--notARealFlag\"})\n\n\texpect(t, parsedOption, \"my-option\")\n\texpect(t, args[0], \"my-arg\")\n\texpect(t, args[1], \"--\")\n\texpect(t, args[2], \"--notARealFlag\")\n}\n\nfunc TestApp_CommandWithDash(t *testing.T) {\n\tvar args []string\n\n\tapp := NewApp()\n\tcommand := Command{\n\t\tName: \"cmd\",\n\t\tAction: func(c *Context) error {\n\t\t\targs = c.Args()\n\t\t\treturn nil\n\t\t},\n\t}\n\tapp.Commands = []Command{command}\n\n\tapp.Run([]string{\"\", \"cmd\", \"my-arg\", \"-\"})\n\n\texpect(t, args[0], \"my-arg\")\n\texpect(t, args[1], \"-\")\n}\n\nfunc TestApp_CommandWithNoFlagBeforeTerminator(t *testing.T) {\n\tvar args []string\n\n\tapp := NewApp()\n\tcommand := Command{\n\t\tName: \"cmd\",\n\t\tAction: func(c *Context) error {\n\t\t\targs = c.Args()\n\t\t\treturn nil\n\t\t},\n\t}\n\tapp.Commands = []Command{command}\n\n\tapp.Run([]string{\"\", \"cmd\", \"my-arg\", \"--\", \"notAFlagAtAll\"})\n\n\texpect(t, args[0], \"my-arg\")\n\texpect(t, args[1], \"--\")\n\texpect(t, args[2], \"notAFlagAtAll\")\n}\n\nfunc TestApp_VisibleCommands(t *testing.T) {\n\tapp := NewApp()\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName:     \"frob\",\n\t\t\tHelpName: \"foo frob\",\n\t\t\tAction:   func(_ *Context) error { return nil },\n\t\t},\n\t\t{\n\t\t\tName:     \"frib\",\n\t\t\tHelpName: \"foo frib\",\n\t\t\tHidden:   true,\n\t\t\tAction:   func(_ *Context) error { return nil },\n\t\t},\n\t}\n\n\tapp.Setup()\n\texpected := []Command{\n\t\tapp.Commands[0],\n\t\tapp.Commands[2], // help\n\t}\n\tactual := app.VisibleCommands()\n\texpect(t, len(expected), len(actual))\n\tfor i, actualCommand := range actual {\n\t\texpectedCommand := expected[i]\n\n\t\tif expectedCommand.Action != nil {\n\t\t\t// comparing func addresses is OK!\n\t\t\texpect(t, fmt.Sprintf(\"%p\", expectedCommand.Action), fmt.Sprintf(\"%p\", actualCommand.Action))\n\t\t}\n\n\t\t// nil out funcs, as they cannot be compared\n\t\t// (https://github.com/golang/go/issues/8554)\n\t\texpectedCommand.Action = nil\n\t\tactualCommand.Action = nil\n\n\t\tif !reflect.DeepEqual(expectedCommand, actualCommand) {\n\t\t\tt.Errorf(\"expected\\n%#v\\n!=\\n%#v\", expectedCommand, actualCommand)\n\t\t}\n\t}\n}\n\nfunc TestApp_Float64Flag(t *testing.T) {\n\tvar meters float64\n\n\tapp := NewApp()\n\tapp.Flags = []Flag{\n\t\tFloat64Flag{Name: \"height\", Value: 1.5, Usage: \"Set the height, in meters\"},\n\t}\n\tapp.Action = func(c *Context) error {\n\t\tmeters = c.Float64(\"height\")\n\t\treturn nil\n\t}\n\n\tapp.Run([]string{\"\", \"--height\", \"1.93\"})\n\texpect(t, meters, 1.93)\n}\n\nfunc TestApp_ParseSliceFlags(t *testing.T) {\n\tvar parsedOption, firstArg string\n\tvar parsedIntSlice []int\n\tvar parsedStringSlice []string\n\n\tapp := NewApp()\n\tcommand := Command{\n\t\tName: \"cmd\",\n\t\tFlags: []Flag{\n\t\t\tIntSliceFlag{Name: \"p\", Value: &IntSlice{}, Usage: \"set one or more ip addr\"},\n\t\t\tStringSliceFlag{Name: \"ip\", Value: &StringSlice{}, Usage: \"set one or more ports to open\"},\n\t\t},\n\t\tAction: func(c *Context) error {\n\t\t\tparsedIntSlice = c.IntSlice(\"p\")\n\t\t\tparsedStringSlice = c.StringSlice(\"ip\")\n\t\t\tparsedOption = c.String(\"option\")\n\t\t\tfirstArg = c.Args().First()\n\t\t\treturn nil\n\t\t},\n\t}\n\tapp.Commands = []Command{command}\n\n\tapp.Run([]string{\"\", \"cmd\", \"my-arg\", \"-p\", \"22\", \"-p\", \"80\", \"-ip\", \"8.8.8.8\", \"-ip\", \"8.8.4.4\"})\n\n\tIntsEquals := func(a, b []int) bool {\n\t\tif len(a) != len(b) {\n\t\t\treturn false\n\t\t}\n\t\tfor i, v := range a {\n\t\t\tif v != b[i] {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\n\tStrsEquals := func(a, b []string) bool {\n\t\tif len(a) != len(b) {\n\t\t\treturn false\n\t\t}\n\t\tfor i, v := range a {\n\t\t\tif v != b[i] {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\tvar expectedIntSlice = []int{22, 80}\n\tvar expectedStringSlice = []string{\"8.8.8.8\", \"8.8.4.4\"}\n\n\tif !IntsEquals(parsedIntSlice, expectedIntSlice) {\n\t\tt.Errorf(\"%v does not match %v\", parsedIntSlice, expectedIntSlice)\n\t}\n\n\tif !StrsEquals(parsedStringSlice, expectedStringSlice) {\n\t\tt.Errorf(\"%v does not match %v\", parsedStringSlice, expectedStringSlice)\n\t}\n}\n\nfunc TestApp_ParseSliceFlagsWithMissingValue(t *testing.T) {\n\tvar parsedIntSlice []int\n\tvar parsedStringSlice []string\n\n\tapp := NewApp()\n\tcommand := Command{\n\t\tName: \"cmd\",\n\t\tFlags: []Flag{\n\t\t\tIntSliceFlag{Name: \"a\", Usage: \"set numbers\"},\n\t\t\tStringSliceFlag{Name: \"str\", Usage: \"set strings\"},\n\t\t},\n\t\tAction: func(c *Context) error {\n\t\t\tparsedIntSlice = c.IntSlice(\"a\")\n\t\t\tparsedStringSlice = c.StringSlice(\"str\")\n\t\t\treturn nil\n\t\t},\n\t}\n\tapp.Commands = []Command{command}\n\n\tapp.Run([]string{\"\", \"cmd\", \"my-arg\", \"-a\", \"2\", \"-str\", \"A\"})\n\n\tvar expectedIntSlice = []int{2}\n\tvar expectedStringSlice = []string{\"A\"}\n\n\tif parsedIntSlice[0] != expectedIntSlice[0] {\n\t\tt.Errorf(\"%v does not match %v\", parsedIntSlice[0], expectedIntSlice[0])\n\t}\n\n\tif parsedStringSlice[0] != expectedStringSlice[0] {\n\t\tt.Errorf(\"%v does not match %v\", parsedIntSlice[0], expectedIntSlice[0])\n\t}\n}\n\nfunc TestApp_DefaultStdout(t *testing.T) {\n\tapp := NewApp()\n\n\tif app.Writer != os.Stdout {\n\t\tt.Error(\"Default output writer not set.\")\n\t}\n}\n\ntype mockWriter struct {\n\twritten []byte\n}\n\nfunc (fw *mockWriter) Write(p []byte) (n int, err error) {\n\tif fw.written == nil {\n\t\tfw.written = p\n\t} else {\n\t\tfw.written = append(fw.written, p...)\n\t}\n\n\treturn len(p), nil\n}\n\nfunc (fw *mockWriter) GetWritten() (b []byte) {\n\treturn fw.written\n}\n\nfunc TestApp_SetStdout(t *testing.T) {\n\tw := &mockWriter{}\n\n\tapp := NewApp()\n\tapp.Name = \"test\"\n\tapp.Writer = w\n\n\terr := app.Run([]string{\"help\"})\n\n\tif err != nil {\n\t\tt.Fatalf(\"Run error: %s\", err)\n\t}\n\n\tif len(w.written) == 0 {\n\t\tt.Error(\"App did not write output to desired writer.\")\n\t}\n}\n\nfunc TestApp_BeforeFunc(t *testing.T) {\n\tcounts := &opCounts{}\n\tbeforeError := fmt.Errorf(\"fail\")\n\tvar err error\n\n\tapp := NewApp()\n\n\tapp.Before = func(c *Context) error {\n\t\tcounts.Total++\n\t\tcounts.Before = counts.Total\n\t\ts := c.String(\"opt\")\n\t\tif s == \"fail\" {\n\t\t\treturn beforeError\n\t\t}\n\n\t\treturn nil\n\t}\n\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName: \"sub\",\n\t\t\tAction: func(c *Context) error {\n\t\t\t\tcounts.Total++\n\t\t\t\tcounts.SubCommand = counts.Total\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t}\n\n\tapp.Flags = []Flag{\n\t\tStringFlag{Name: \"opt\"},\n\t}\n\n\t// run with the Before() func succeeding\n\terr = app.Run([]string{\"command\", \"--opt\", \"succeed\", \"sub\"})\n\n\tif err != nil {\n\t\tt.Fatalf(\"Run error: %s\", err)\n\t}\n\n\tif counts.Before != 1 {\n\t\tt.Errorf(\"Before() not executed when expected\")\n\t}\n\n\tif counts.SubCommand != 2 {\n\t\tt.Errorf(\"Subcommand not executed when expected\")\n\t}\n\n\t// reset\n\tcounts = &opCounts{}\n\n\t// run with the Before() func failing\n\terr = app.Run([]string{\"command\", \"--opt\", \"fail\", \"sub\"})\n\n\t// should be the same error produced by the Before func\n\tif err != beforeError {\n\t\tt.Errorf(\"Run error expected, but not received\")\n\t}\n\n\tif counts.Before != 1 {\n\t\tt.Errorf(\"Before() not executed when expected\")\n\t}\n\n\tif counts.SubCommand != 0 {\n\t\tt.Errorf(\"Subcommand executed when NOT expected\")\n\t}\n\n\t// reset\n\tcounts = &opCounts{}\n\n\tafterError := errors.New(\"fail again\")\n\tapp.After = func(_ *Context) error {\n\t\treturn afterError\n\t}\n\n\t// run with the Before() func failing, wrapped by After()\n\terr = app.Run([]string{\"command\", \"--opt\", \"fail\", \"sub\"})\n\n\t// should be the same error produced by the Before func\n\tif _, ok := err.(MultiError); !ok {\n\t\tt.Errorf(\"MultiError expected, but not received\")\n\t}\n\n\tif counts.Before != 1 {\n\t\tt.Errorf(\"Before() not executed when expected\")\n\t}\n\n\tif counts.SubCommand != 0 {\n\t\tt.Errorf(\"Subcommand executed when NOT expected\")\n\t}\n}\n\nfunc TestApp_AfterFunc(t *testing.T) {\n\tcounts := &opCounts{}\n\tafterError := fmt.Errorf(\"fail\")\n\tvar err error\n\n\tapp := NewApp()\n\n\tapp.After = func(c *Context) error {\n\t\tcounts.Total++\n\t\tcounts.After = counts.Total\n\t\ts := c.String(\"opt\")\n\t\tif s == \"fail\" {\n\t\t\treturn afterError\n\t\t}\n\n\t\treturn nil\n\t}\n\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName: \"sub\",\n\t\t\tAction: func(c *Context) error {\n\t\t\t\tcounts.Total++\n\t\t\t\tcounts.SubCommand = counts.Total\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t}\n\n\tapp.Flags = []Flag{\n\t\tStringFlag{Name: \"opt\"},\n\t}\n\n\t// run with the After() func succeeding\n\terr = app.Run([]string{\"command\", \"--opt\", \"succeed\", \"sub\"})\n\n\tif err != nil {\n\t\tt.Fatalf(\"Run error: %s\", err)\n\t}\n\n\tif counts.After != 2 {\n\t\tt.Errorf(\"After() not executed when expected\")\n\t}\n\n\tif counts.SubCommand != 1 {\n\t\tt.Errorf(\"Subcommand not executed when expected\")\n\t}\n\n\t// reset\n\tcounts = &opCounts{}\n\n\t// run with the Before() func failing\n\terr = app.Run([]string{\"command\", \"--opt\", \"fail\", \"sub\"})\n\n\t// should be the same error produced by the Before func\n\tif err != afterError {\n\t\tt.Errorf(\"Run error expected, but not received\")\n\t}\n\n\tif counts.After != 2 {\n\t\tt.Errorf(\"After() not executed when expected\")\n\t}\n\n\tif counts.SubCommand != 1 {\n\t\tt.Errorf(\"Subcommand not executed when expected\")\n\t}\n}\n\nfunc TestAppNoHelpFlag(t *testing.T) {\n\toldFlag := HelpFlag\n\tdefer func() {\n\t\tHelpFlag = oldFlag\n\t}()\n\n\tHelpFlag = BoolFlag{}\n\n\tapp := NewApp()\n\tapp.Writer = ioutil.Discard\n\terr := app.Run([]string{\"test\", \"-h\"})\n\n\tif err != flag.ErrHelp {\n\t\tt.Errorf(\"expected error about missing help flag, but got: %s (%T)\", err, err)\n\t}\n}\n\nfunc TestAppHelpPrinter(t *testing.T) {\n\toldPrinter := HelpPrinter\n\tdefer func() {\n\t\tHelpPrinter = oldPrinter\n\t}()\n\n\tvar wasCalled = false\n\tHelpPrinter = func(w io.Writer, template string, data interface{}) {\n\t\twasCalled = true\n\t}\n\n\tapp := NewApp()\n\tapp.Run([]string{\"-h\"})\n\n\tif wasCalled == false {\n\t\tt.Errorf(\"Help printer expected to be called, but was not\")\n\t}\n}\n\nfunc TestApp_VersionPrinter(t *testing.T) {\n\toldPrinter := VersionPrinter\n\tdefer func() {\n\t\tVersionPrinter = oldPrinter\n\t}()\n\n\tvar wasCalled = false\n\tVersionPrinter = func(c *Context) {\n\t\twasCalled = true\n\t}\n\n\tapp := NewApp()\n\tctx := NewContext(app, nil, nil)\n\tShowVersion(ctx)\n\n\tif wasCalled == false {\n\t\tt.Errorf(\"Version printer expected to be called, but was not\")\n\t}\n}\n\nfunc TestApp_CommandNotFound(t *testing.T) {\n\tcounts := &opCounts{}\n\tapp := NewApp()\n\n\tapp.CommandNotFound = func(c *Context, command string) {\n\t\tcounts.Total++\n\t\tcounts.CommandNotFound = counts.Total\n\t}\n\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName: \"bar\",\n\t\t\tAction: func(c *Context) error {\n\t\t\t\tcounts.Total++\n\t\t\t\tcounts.SubCommand = counts.Total\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t}\n\n\tapp.Run([]string{\"command\", \"foo\"})\n\n\texpect(t, counts.CommandNotFound, 1)\n\texpect(t, counts.SubCommand, 0)\n\texpect(t, counts.Total, 1)\n}\n\nfunc TestApp_OrderOfOperations(t *testing.T) {\n\tcounts := &opCounts{}\n\n\tresetCounts := func() { counts = &opCounts{} }\n\n\tapp := NewApp()\n\tapp.EnableBashCompletion = true\n\tapp.BashComplete = func(c *Context) {\n\t\tcounts.Total++\n\t\tcounts.BashComplete = counts.Total\n\t}\n\n\tapp.OnUsageError = func(c *Context, err error, isSubcommand bool) error {\n\t\tcounts.Total++\n\t\tcounts.OnUsageError = counts.Total\n\t\treturn errors.New(\"hay OnUsageError\")\n\t}\n\n\tbeforeNoError := func(c *Context) error {\n\t\tcounts.Total++\n\t\tcounts.Before = counts.Total\n\t\treturn nil\n\t}\n\n\tbeforeError := func(c *Context) error {\n\t\tcounts.Total++\n\t\tcounts.Before = counts.Total\n\t\treturn errors.New(\"hay Before\")\n\t}\n\n\tapp.Before = beforeNoError\n\tapp.CommandNotFound = func(c *Context, command string) {\n\t\tcounts.Total++\n\t\tcounts.CommandNotFound = counts.Total\n\t}\n\n\tafterNoError := func(c *Context) error {\n\t\tcounts.Total++\n\t\tcounts.After = counts.Total\n\t\treturn nil\n\t}\n\n\tafterError := func(c *Context) error {\n\t\tcounts.Total++\n\t\tcounts.After = counts.Total\n\t\treturn errors.New(\"hay After\")\n\t}\n\n\tapp.After = afterNoError\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName: \"bar\",\n\t\t\tAction: func(c *Context) error {\n\t\t\t\tcounts.Total++\n\t\t\t\tcounts.SubCommand = counts.Total\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t}\n\n\tapp.Action = func(c *Context) error {\n\t\tcounts.Total++\n\t\tcounts.Action = counts.Total\n\t\treturn nil\n\t}\n\n\t_ = app.Run([]string{\"command\", \"--nope\"})\n\texpect(t, counts.OnUsageError, 1)\n\texpect(t, counts.Total, 1)\n\n\tresetCounts()\n\n\t_ = app.Run([]string{\"command\", \"--generate-bash-completion\"})\n\texpect(t, counts.BashComplete, 1)\n\texpect(t, counts.Total, 1)\n\n\tresetCounts()\n\n\toldOnUsageError := app.OnUsageError\n\tapp.OnUsageError = nil\n\t_ = app.Run([]string{\"command\", \"--nope\"})\n\texpect(t, counts.Total, 0)\n\tapp.OnUsageError = oldOnUsageError\n\n\tresetCounts()\n\n\t_ = app.Run([]string{\"command\", \"foo\"})\n\texpect(t, counts.OnUsageError, 0)\n\texpect(t, counts.Before, 1)\n\texpect(t, counts.CommandNotFound, 0)\n\texpect(t, counts.Action, 2)\n\texpect(t, counts.After, 3)\n\texpect(t, counts.Total, 3)\n\n\tresetCounts()\n\n\tapp.Before = beforeError\n\t_ = app.Run([]string{\"command\", \"bar\"})\n\texpect(t, counts.OnUsageError, 0)\n\texpect(t, counts.Before, 1)\n\texpect(t, counts.After, 2)\n\texpect(t, counts.Total, 2)\n\tapp.Before = beforeNoError\n\n\tresetCounts()\n\n\tapp.After = nil\n\t_ = app.Run([]string{\"command\", \"bar\"})\n\texpect(t, counts.OnUsageError, 0)\n\texpect(t, counts.Before, 1)\n\texpect(t, counts.SubCommand, 2)\n\texpect(t, counts.Total, 2)\n\tapp.After = afterNoError\n\n\tresetCounts()\n\n\tapp.After = afterError\n\terr := app.Run([]string{\"command\", \"bar\"})\n\tif err == nil {\n\t\tt.Fatalf(\"expected a non-nil error\")\n\t}\n\texpect(t, counts.OnUsageError, 0)\n\texpect(t, counts.Before, 1)\n\texpect(t, counts.SubCommand, 2)\n\texpect(t, counts.After, 3)\n\texpect(t, counts.Total, 3)\n\tapp.After = afterNoError\n\n\tresetCounts()\n\n\toldCommands := app.Commands\n\tapp.Commands = nil\n\t_ = app.Run([]string{\"command\"})\n\texpect(t, counts.OnUsageError, 0)\n\texpect(t, counts.Before, 1)\n\texpect(t, counts.Action, 2)\n\texpect(t, counts.After, 3)\n\texpect(t, counts.Total, 3)\n\tapp.Commands = oldCommands\n}\n\nfunc TestApp_Run_CommandWithSubcommandHasHelpTopic(t *testing.T) {\n\tvar subcommandHelpTopics = [][]string{\n\t\t{\"command\", \"foo\", \"--help\"},\n\t\t{\"command\", \"foo\", \"-h\"},\n\t\t{\"command\", \"foo\", \"help\"},\n\t}\n\n\tfor _, flagSet := range subcommandHelpTopics {\n\t\tt.Logf(\"==> checking with flags %v\", flagSet)\n\n\t\tapp := NewApp()\n\t\tbuf := new(bytes.Buffer)\n\t\tapp.Writer = buf\n\n\t\tsubCmdBar := Command{\n\t\t\tName:  \"bar\",\n\t\t\tUsage: \"does bar things\",\n\t\t}\n\t\tsubCmdBaz := Command{\n\t\t\tName:  \"baz\",\n\t\t\tUsage: \"does baz things\",\n\t\t}\n\t\tcmd := Command{\n\t\t\tName:        \"foo\",\n\t\t\tDescription: \"descriptive wall of text about how it does foo things\",\n\t\t\tSubcommands: []Command{subCmdBar, subCmdBaz},\n\t\t\tAction:      func(c *Context) error { return nil },\n\t\t}\n\n\t\tapp.Commands = []Command{cmd}\n\t\terr := app.Run(flagSet)\n\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\n\t\toutput := buf.String()\n\t\tt.Logf(\"output: %q\\n\", buf.Bytes())\n\n\t\tif strings.Contains(output, \"No help topic for\") {\n\t\t\tt.Errorf(\"expect a help topic, got none: \\n%q\", output)\n\t\t}\n\n\t\tfor _, shouldContain := range []string{\n\t\t\tcmd.Name, cmd.Description,\n\t\t\tsubCmdBar.Name, subCmdBar.Usage,\n\t\t\tsubCmdBaz.Name, subCmdBaz.Usage,\n\t\t} {\n\t\t\tif !strings.Contains(output, shouldContain) {\n\t\t\t\tt.Errorf(\"want help to contain %q, did not: \\n%q\", shouldContain, output)\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc TestApp_Run_SubcommandFullPath(t *testing.T) {\n\tapp := NewApp()\n\tbuf := new(bytes.Buffer)\n\tapp.Writer = buf\n\tapp.Name = \"command\"\n\tsubCmd := Command{\n\t\tName:  \"bar\",\n\t\tUsage: \"does bar things\",\n\t}\n\tcmd := Command{\n\t\tName:        \"foo\",\n\t\tDescription: \"foo commands\",\n\t\tSubcommands: []Command{subCmd},\n\t}\n\tapp.Commands = []Command{cmd}\n\n\terr := app.Run([]string{\"command\", \"foo\", \"bar\", \"--help\"})\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\toutput := buf.String()\n\tif !strings.Contains(output, \"command foo bar - does bar things\") {\n\t\tt.Errorf(\"expected full path to subcommand: %s\", output)\n\t}\n\tif !strings.Contains(output, \"command foo bar [arguments...]\") {\n\t\tt.Errorf(\"expected full path to subcommand: %s\", output)\n\t}\n}\n\nfunc TestApp_Run_SubcommandHelpName(t *testing.T) {\n\tapp := NewApp()\n\tbuf := new(bytes.Buffer)\n\tapp.Writer = buf\n\tapp.Name = \"command\"\n\tsubCmd := Command{\n\t\tName:     \"bar\",\n\t\tHelpName: \"custom\",\n\t\tUsage:    \"does bar things\",\n\t}\n\tcmd := Command{\n\t\tName:        \"foo\",\n\t\tDescription: \"foo commands\",\n\t\tSubcommands: []Command{subCmd},\n\t}\n\tapp.Commands = []Command{cmd}\n\n\terr := app.Run([]string{\"command\", \"foo\", \"bar\", \"--help\"})\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\toutput := buf.String()\n\tif !strings.Contains(output, \"custom - does bar things\") {\n\t\tt.Errorf(\"expected HelpName for subcommand: %s\", output)\n\t}\n\tif !strings.Contains(output, \"custom [arguments...]\") {\n\t\tt.Errorf(\"expected HelpName to subcommand: %s\", output)\n\t}\n}\n\nfunc TestApp_Run_CommandHelpName(t *testing.T) {\n\tapp := NewApp()\n\tbuf := new(bytes.Buffer)\n\tapp.Writer = buf\n\tapp.Name = \"command\"\n\tsubCmd := Command{\n\t\tName:  \"bar\",\n\t\tUsage: \"does bar things\",\n\t}\n\tcmd := Command{\n\t\tName:        \"foo\",\n\t\tHelpName:    \"custom\",\n\t\tDescription: \"foo commands\",\n\t\tSubcommands: []Command{subCmd},\n\t}\n\tapp.Commands = []Command{cmd}\n\n\terr := app.Run([]string{\"command\", \"foo\", \"bar\", \"--help\"})\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\toutput := buf.String()\n\tif !strings.Contains(output, \"command foo bar - does bar things\") {\n\t\tt.Errorf(\"expected full path to subcommand: %s\", output)\n\t}\n\tif !strings.Contains(output, \"command foo bar [arguments...]\") {\n\t\tt.Errorf(\"expected full path to subcommand: %s\", output)\n\t}\n}\n\nfunc TestApp_Run_CommandSubcommandHelpName(t *testing.T) {\n\tapp := NewApp()\n\tbuf := new(bytes.Buffer)\n\tapp.Writer = buf\n\tapp.Name = \"base\"\n\tsubCmd := Command{\n\t\tName:     \"bar\",\n\t\tHelpName: \"custom\",\n\t\tUsage:    \"does bar things\",\n\t}\n\tcmd := Command{\n\t\tName:        \"foo\",\n\t\tDescription: \"foo commands\",\n\t\tSubcommands: []Command{subCmd},\n\t}\n\tapp.Commands = []Command{cmd}\n\n\terr := app.Run([]string{\"command\", \"foo\", \"--help\"})\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\toutput := buf.String()\n\tif !strings.Contains(output, \"base foo - foo commands\") {\n\t\tt.Errorf(\"expected full path to subcommand: %s\", output)\n\t}\n\tif !strings.Contains(output, \"base foo command [command options] [arguments...]\") {\n\t\tt.Errorf(\"expected full path to subcommand: %s\", output)\n\t}\n}\n\nfunc TestApp_Run_Help(t *testing.T) {\n\tvar helpArguments = [][]string{{\"boom\", \"--help\"}, {\"boom\", \"-h\"}, {\"boom\", \"help\"}}\n\n\tfor _, args := range helpArguments {\n\t\tbuf := new(bytes.Buffer)\n\n\t\tt.Logf(\"==> checking with arguments %v\", args)\n\n\t\tapp := NewApp()\n\t\tapp.Name = \"boom\"\n\t\tapp.Usage = \"make an explosive entrance\"\n\t\tapp.Writer = buf\n\t\tapp.Action = func(c *Context) error {\n\t\t\tbuf.WriteString(\"boom I say!\")\n\t\t\treturn nil\n\t\t}\n\n\t\terr := app.Run(args)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\n\t\toutput := buf.String()\n\t\tt.Logf(\"output: %q\\n\", buf.Bytes())\n\n\t\tif !strings.Contains(output, \"boom - make an explosive entrance\") {\n\t\t\tt.Errorf(\"want help to contain %q, did not: \\n%q\", \"boom - make an explosive entrance\", output)\n\t\t}\n\t}\n}\n\nfunc TestApp_Run_Version(t *testing.T) {\n\tvar versionArguments = [][]string{{\"boom\", \"--version\"}, {\"boom\", \"-v\"}}\n\n\tfor _, args := range versionArguments {\n\t\tbuf := new(bytes.Buffer)\n\n\t\tt.Logf(\"==> checking with arguments %v\", args)\n\n\t\tapp := NewApp()\n\t\tapp.Name = \"boom\"\n\t\tapp.Usage = \"make an explosive entrance\"\n\t\tapp.Version = \"0.1.0\"\n\t\tapp.Writer = buf\n\t\tapp.Action = func(c *Context) error {\n\t\t\tbuf.WriteString(\"boom I say!\")\n\t\t\treturn nil\n\t\t}\n\n\t\terr := app.Run(args)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\n\t\toutput := buf.String()\n\t\tt.Logf(\"output: %q\\n\", buf.Bytes())\n\n\t\tif !strings.Contains(output, \"0.1.0\") {\n\t\t\tt.Errorf(\"want version to contain %q, did not: \\n%q\", \"0.1.0\", output)\n\t\t}\n\t}\n}\n\nfunc TestApp_Run_Categories(t *testing.T) {\n\tapp := NewApp()\n\tapp.Name = \"categories\"\n\tapp.HideHelp = true\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName:     \"command1\",\n\t\t\tCategory: \"1\",\n\t\t},\n\t\t{\n\t\t\tName:     \"command2\",\n\t\t\tCategory: \"1\",\n\t\t},\n\t\t{\n\t\t\tName:     \"command3\",\n\t\t\tCategory: \"2\",\n\t\t},\n\t}\n\tbuf := new(bytes.Buffer)\n\tapp.Writer = buf\n\n\tapp.Run([]string{\"categories\"})\n\n\texpect := CommandCategories{\n\t\t&CommandCategory{\n\t\t\tName: \"1\",\n\t\t\tCommands: []Command{\n\t\t\t\tapp.Commands[0],\n\t\t\t\tapp.Commands[1],\n\t\t\t},\n\t\t},\n\t\t&CommandCategory{\n\t\t\tName: \"2\",\n\t\t\tCommands: []Command{\n\t\t\t\tapp.Commands[2],\n\t\t\t},\n\t\t},\n\t}\n\tif !reflect.DeepEqual(app.Categories(), expect) {\n\t\tt.Fatalf(\"expected categories %#v, to equal %#v\", app.Categories(), expect)\n\t}\n\n\toutput := buf.String()\n\tt.Logf(\"output: %q\\n\", buf.Bytes())\n\n\tif !strings.Contains(output, \"1:\\n     command1\") {\n\t\tt.Errorf(\"want buffer to include category %q, did not: \\n%q\", \"1:\\n     command1\", output)\n\t}\n}\n\nfunc TestApp_VisibleCategories(t *testing.T) {\n\tapp := NewApp()\n\tapp.Name = \"visible-categories\"\n\tapp.HideHelp = true\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName:     \"command1\",\n\t\t\tCategory: \"1\",\n\t\t\tHelpName: \"foo command1\",\n\t\t\tHidden:   true,\n\t\t},\n\t\t{\n\t\t\tName:     \"command2\",\n\t\t\tCategory: \"2\",\n\t\t\tHelpName: \"foo command2\",\n\t\t},\n\t\t{\n\t\t\tName:     \"command3\",\n\t\t\tCategory: \"3\",\n\t\t\tHelpName: \"foo command3\",\n\t\t},\n\t}\n\n\texpected := []*CommandCategory{\n\t\t{\n\t\t\tName: \"2\",\n\t\t\tCommands: []Command{\n\t\t\t\tapp.Commands[1],\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName: \"3\",\n\t\t\tCommands: []Command{\n\t\t\t\tapp.Commands[2],\n\t\t\t},\n\t\t},\n\t}\n\n\tapp.Setup()\n\texpect(t, expected, app.VisibleCategories())\n\n\tapp = NewApp()\n\tapp.Name = \"visible-categories\"\n\tapp.HideHelp = true\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName:     \"command1\",\n\t\t\tCategory: \"1\",\n\t\t\tHelpName: \"foo command1\",\n\t\t\tHidden:   true,\n\t\t},\n\t\t{\n\t\t\tName:     \"command2\",\n\t\t\tCategory: \"2\",\n\t\t\tHelpName: \"foo command2\",\n\t\t\tHidden:   true,\n\t\t},\n\t\t{\n\t\t\tName:     \"command3\",\n\t\t\tCategory: \"3\",\n\t\t\tHelpName: \"foo command3\",\n\t\t},\n\t}\n\n\texpected = []*CommandCategory{\n\t\t{\n\t\t\tName: \"3\",\n\t\t\tCommands: []Command{\n\t\t\t\tapp.Commands[2],\n\t\t\t},\n\t\t},\n\t}\n\n\tapp.Setup()\n\texpect(t, expected, app.VisibleCategories())\n\n\tapp = NewApp()\n\tapp.Name = \"visible-categories\"\n\tapp.HideHelp = true\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName:     \"command1\",\n\t\t\tCategory: \"1\",\n\t\t\tHelpName: \"foo command1\",\n\t\t\tHidden:   true,\n\t\t},\n\t\t{\n\t\t\tName:     \"command2\",\n\t\t\tCategory: \"2\",\n\t\t\tHelpName: \"foo command2\",\n\t\t\tHidden:   true,\n\t\t},\n\t\t{\n\t\t\tName:     \"command3\",\n\t\t\tCategory: \"3\",\n\t\t\tHelpName: \"foo command3\",\n\t\t\tHidden:   true,\n\t\t},\n\t}\n\n\texpected = []*CommandCategory{}\n\n\tapp.Setup()\n\texpect(t, expected, app.VisibleCategories())\n}\n\nfunc TestApp_Run_DoesNotOverwriteErrorFromBefore(t *testing.T) {\n\tapp := NewApp()\n\tapp.Action = func(c *Context) error { return nil }\n\tapp.Before = func(c *Context) error { return fmt.Errorf(\"before error\") }\n\tapp.After = func(c *Context) error { return fmt.Errorf(\"after error\") }\n\n\terr := app.Run([]string{\"foo\"})\n\tif err == nil {\n\t\tt.Fatalf(\"expected to receive error from Run, got none\")\n\t}\n\n\tif !strings.Contains(err.Error(), \"before error\") {\n\t\tt.Errorf(\"expected text of error from Before method, but got none in \\\"%v\\\"\", err)\n\t}\n\tif !strings.Contains(err.Error(), \"after error\") {\n\t\tt.Errorf(\"expected text of error from After method, but got none in \\\"%v\\\"\", err)\n\t}\n}\n\nfunc TestApp_Run_SubcommandDoesNotOverwriteErrorFromBefore(t *testing.T) {\n\tapp := NewApp()\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tSubcommands: []Command{\n\t\t\t\t{\n\t\t\t\t\tName: \"sub\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tName:   \"bar\",\n\t\t\tBefore: func(c *Context) error { return fmt.Errorf(\"before error\") },\n\t\t\tAfter:  func(c *Context) error { return fmt.Errorf(\"after error\") },\n\t\t},\n\t}\n\n\terr := app.Run([]string{\"foo\", \"bar\"})\n\tif err == nil {\n\t\tt.Fatalf(\"expected to receive error from Run, got none\")\n\t}\n\n\tif !strings.Contains(err.Error(), \"before error\") {\n\t\tt.Errorf(\"expected text of error from Before method, but got none in \\\"%v\\\"\", err)\n\t}\n\tif !strings.Contains(err.Error(), \"after error\") {\n\t\tt.Errorf(\"expected text of error from After method, but got none in \\\"%v\\\"\", err)\n\t}\n}\n\nfunc TestApp_OnUsageError_WithWrongFlagValue(t *testing.T) {\n\tapp := NewApp()\n\tapp.Flags = []Flag{\n\t\tIntFlag{Name: \"flag\"},\n\t}\n\tapp.OnUsageError = func(c *Context, err error, isSubcommand bool) error {\n\t\tif isSubcommand {\n\t\t\tt.Errorf(\"Expect no subcommand\")\n\t\t}\n\t\tif !strings.HasPrefix(err.Error(), \"invalid value \\\"wrong\\\"\") {\n\t\t\tt.Errorf(\"Expect an invalid value error, but got \\\"%v\\\"\", err)\n\t\t}\n\t\treturn errors.New(\"intercepted: \" + err.Error())\n\t}\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName: \"bar\",\n\t\t},\n\t}\n\n\terr := app.Run([]string{\"foo\", \"--flag=wrong\"})\n\tif err == nil {\n\t\tt.Fatalf(\"expected to receive error from Run, got none\")\n\t}\n\n\tif !strings.HasPrefix(err.Error(), \"intercepted: invalid value\") {\n\t\tt.Errorf(\"Expect an intercepted error, but got \\\"%v\\\"\", err)\n\t}\n}\n\nfunc TestApp_OnUsageError_WithWrongFlagValue_ForSubcommand(t *testing.T) {\n\tapp := NewApp()\n\tapp.Flags = []Flag{\n\t\tIntFlag{Name: \"flag\"},\n\t}\n\tapp.OnUsageError = func(c *Context, err error, isSubcommand bool) error {\n\t\tif isSubcommand {\n\t\t\tt.Errorf(\"Expect subcommand\")\n\t\t}\n\t\tif !strings.HasPrefix(err.Error(), \"invalid value \\\"wrong\\\"\") {\n\t\t\tt.Errorf(\"Expect an invalid value error, but got \\\"%v\\\"\", err)\n\t\t}\n\t\treturn errors.New(\"intercepted: \" + err.Error())\n\t}\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName: \"bar\",\n\t\t},\n\t}\n\n\terr := app.Run([]string{\"foo\", \"--flag=wrong\", \"bar\"})\n\tif err == nil {\n\t\tt.Fatalf(\"expected to receive error from Run, got none\")\n\t}\n\n\tif !strings.HasPrefix(err.Error(), \"intercepted: invalid value\") {\n\t\tt.Errorf(\"Expect an intercepted error, but got \\\"%v\\\"\", err)\n\t}\n}\n\n// A custom flag that conforms to the relevant interfaces, but has none of the\n// fields that the other flag types do.\ntype customBoolFlag struct {\n\tNombre string\n}\n\n// Don't use the normal FlagStringer\nfunc (c *customBoolFlag) String() string {\n\treturn \"***\" + c.Nombre + \"***\"\n}\n\nfunc (c *customBoolFlag) GetName() string {\n\treturn c.Nombre\n}\n\nfunc (c *customBoolFlag) Apply(set *flag.FlagSet) {\n\tset.String(c.Nombre, c.Nombre, \"\")\n}\n\nfunc TestCustomFlagsUnused(t *testing.T) {\n\tapp := NewApp()\n\tapp.Flags = []Flag{&customBoolFlag{\"custom\"}}\n\n\terr := app.Run([]string{\"foo\"})\n\tif err != nil {\n\t\tt.Errorf(\"Run returned unexpected error: %v\", err)\n\t}\n}\n\nfunc TestCustomFlagsUsed(t *testing.T) {\n\tapp := NewApp()\n\tapp.Flags = []Flag{&customBoolFlag{\"custom\"}}\n\n\terr := app.Run([]string{\"foo\", \"--custom=bar\"})\n\tif err != nil {\n\t\tt.Errorf(\"Run returned unexpected error: %v\", err)\n\t}\n}\n\nfunc TestCustomHelpVersionFlags(t *testing.T) {\n\tapp := NewApp()\n\n\t// Be sure to reset the global flags\n\tdefer func(helpFlag Flag, versionFlag Flag) {\n\t\tHelpFlag = helpFlag\n\t\tVersionFlag = versionFlag\n\t}(HelpFlag, VersionFlag)\n\n\tHelpFlag = &customBoolFlag{\"help-custom\"}\n\tVersionFlag = &customBoolFlag{\"version-custom\"}\n\n\terr := app.Run([]string{\"foo\", \"--help-custom=bar\"})\n\tif err != nil {\n\t\tt.Errorf(\"Run returned unexpected error: %v\", err)\n\t}\n}\n\nfunc TestHandleAction_WithNonFuncAction(t *testing.T) {\n\tapp := NewApp()\n\tapp.Action = 42\n\tfs, err := flagSet(app.Name, app.Flags)\n\tif err != nil {\n\t\tt.Errorf(\"error creating FlagSet: %s\", err)\n\t}\n\terr = HandleAction(app.Action, NewContext(app, fs, nil))\n\n\tif err == nil {\n\t\tt.Fatalf(\"expected to receive error from Run, got none\")\n\t}\n\n\texitErr, ok := err.(*ExitError)\n\n\tif !ok {\n\t\tt.Fatalf(\"expected to receive a *ExitError\")\n\t}\n\n\tif !strings.HasPrefix(exitErr.Error(), \"ERROR invalid Action type.\") {\n\t\tt.Fatalf(\"expected an unknown Action error, but got: %v\", exitErr.Error())\n\t}\n\n\tif exitErr.ExitCode() != 2 {\n\t\tt.Fatalf(\"expected error exit code to be 2, but got: %v\", exitErr.ExitCode())\n\t}\n}\n\nfunc TestHandleAction_WithInvalidFuncSignature(t *testing.T) {\n\tapp := NewApp()\n\tapp.Action = func() string { return \"\" }\n\tfs, err := flagSet(app.Name, app.Flags)\n\tif err != nil {\n\t\tt.Errorf(\"error creating FlagSet: %s\", err)\n\t}\n\terr = HandleAction(app.Action, NewContext(app, fs, nil))\n\n\tif err == nil {\n\t\tt.Fatalf(\"expected to receive error from Run, got none\")\n\t}\n\n\texitErr, ok := err.(*ExitError)\n\n\tif !ok {\n\t\tt.Fatalf(\"expected to receive a *ExitError\")\n\t}\n\n\tif !strings.HasPrefix(exitErr.Error(), \"ERROR invalid Action type\") {\n\t\tt.Fatalf(\"expected an unknown Action error, but got: %v\", exitErr.Error())\n\t}\n\n\tif exitErr.ExitCode() != 2 {\n\t\tt.Fatalf(\"expected error exit code to be 2, but got: %v\", exitErr.ExitCode())\n\t}\n}\n\nfunc TestHandleAction_WithInvalidFuncReturnSignature(t *testing.T) {\n\tapp := NewApp()\n\tapp.Action = func(_ *Context) (int, error) { return 0, nil }\n\tfs, err := flagSet(app.Name, app.Flags)\n\tif err != nil {\n\t\tt.Errorf(\"error creating FlagSet: %s\", err)\n\t}\n\terr = HandleAction(app.Action, NewContext(app, fs, nil))\n\n\tif err == nil {\n\t\tt.Fatalf(\"expected to receive error from Run, got none\")\n\t}\n\n\texitErr, ok := err.(*ExitError)\n\n\tif !ok {\n\t\tt.Fatalf(\"expected to receive a *ExitError\")\n\t}\n\n\tif !strings.HasPrefix(exitErr.Error(), \"ERROR invalid Action type\") {\n\t\tt.Fatalf(\"expected an invalid Action signature error, but got: %v\", exitErr.Error())\n\t}\n\n\tif exitErr.ExitCode() != 2 {\n\t\tt.Fatalf(\"expected error exit code to be 2, but got: %v\", exitErr.ExitCode())\n\t}\n}\n\nfunc TestHandleAction_WithUnknownPanic(t *testing.T) {\n\tdefer func() { refute(t, recover(), nil) }()\n\n\tvar fn ActionFunc\n\n\tapp := NewApp()\n\tapp.Action = func(ctx *Context) error {\n\t\tfn(ctx)\n\t\treturn nil\n\t}\n\tfs, err := flagSet(app.Name, app.Flags)\n\tif err != nil {\n\t\tt.Errorf(\"error creating FlagSet: %s\", err)\n\t}\n\tHandleAction(app.Action, NewContext(app, fs, nil))\n}\n\nfunc TestShellCompletionForIncompleteFlags(t *testing.T) {\n\tapp := NewApp()\n\tapp.Flags = []Flag{\n\t\tIntFlag{\n\t\t\tName: \"test-completion\",\n\t\t},\n\t}\n\tapp.EnableBashCompletion = true\n\tapp.BashComplete = func(ctx *Context) {\n\t\tfor _, command := range ctx.App.Commands {\n\t\t\tif command.Hidden {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tfor _, name := range command.Names() {\n\t\t\t\tfmt.Fprintln(ctx.App.Writer, name)\n\t\t\t}\n\t\t}\n\n\t\tfor _, flag := range ctx.App.Flags {\n\t\t\tfor _, name := range strings.Split(flag.GetName(), \",\") {\n\t\t\t\tif name == BashCompletionFlag.GetName() {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tswitch name = strings.TrimSpace(name); len(name) {\n\t\t\t\tcase 0:\n\t\t\t\tcase 1:\n\t\t\t\t\tfmt.Fprintln(ctx.App.Writer, \"-\"+name)\n\t\t\t\tdefault:\n\t\t\t\t\tfmt.Fprintln(ctx.App.Writer, \"--\"+name)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tapp.Action = func(ctx *Context) error {\n\t\treturn fmt.Errorf(\"should not get here\")\n\t}\n\terr := app.Run([]string{\"\", \"--test-completion\", \"--\" + BashCompletionFlag.GetName()})\n\tif err != nil {\n\t\tt.Errorf(\"app should not return an error: %s\", err)\n\t}\n}\n\nfunc TestHandleActionActuallyWorksWithActions(t *testing.T) {\n\tvar f ActionFunc\n\tcalled := false\n\tf = func(c *Context) error {\n\t\tcalled = true\n\t\treturn nil\n\t}\n\n\terr := HandleAction(f, nil)\n\n\tif err != nil {\n\t\tt.Errorf(\"Should not have errored: %v\", err)\n\t}\n\n\tif !called {\n\t\tt.Errorf(\"Function was not called\")\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/appveyor.yml",
    "content": "version: \"{build}\"\n\nos: Windows Server 2016\n\nimage: Visual Studio 2017\n\nclone_folder: c:\\gopath\\src\\github.com\\urfave\\cli\n\nenvironment:\n  GOPATH: C:\\gopath\n  GOVERSION: 1.8.x\n  PYTHON: C:\\Python36-x64\n  PYTHON_VERSION: 3.6.x\n  PYTHON_ARCH: 64\n\ninstall:\n- set PATH=%GOPATH%\\bin;C:\\go\\bin;%PATH%\n- go version\n- go env\n- go get github.com/urfave/gfmrun/...\n- go get -v -t ./...\n\nbuild_script:\n- python runtests vet\n- python runtests test\n- python runtests gfmrun\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/autocomplete/bash_autocomplete",
    "content": "#! /bin/bash\n\n: ${PROG:=$(basename ${BASH_SOURCE})}\n\n_cli_bash_autocomplete() {\n    local cur opts base\n    COMPREPLY=()\n    cur=\"${COMP_WORDS[COMP_CWORD]}\"\n    opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )\n    COMPREPLY=( $(compgen -W \"${opts}\" -- ${cur}) )\n    return 0\n}\n\ncomplete -F _cli_bash_autocomplete $PROG\n\nunset PROG\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/autocomplete/zsh_autocomplete",
    "content": "autoload -U compinit && compinit\nautoload -U bashcompinit && bashcompinit\n\nscript_dir=$(dirname $0)\nsource ${script_dir}/bash_autocomplete\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/category.go",
    "content": "package cli\n\n// CommandCategories is a slice of *CommandCategory.\ntype CommandCategories []*CommandCategory\n\n// CommandCategory is a category containing commands.\ntype CommandCategory struct {\n\tName     string\n\tCommands Commands\n}\n\nfunc (c CommandCategories) Less(i, j int) bool {\n\treturn c[i].Name < c[j].Name\n}\n\nfunc (c CommandCategories) Len() int {\n\treturn len(c)\n}\n\nfunc (c CommandCategories) Swap(i, j int) {\n\tc[i], c[j] = c[j], c[i]\n}\n\n// AddCommand adds a command to a category.\nfunc (c CommandCategories) AddCommand(category string, command Command) CommandCategories {\n\tfor _, commandCategory := range c {\n\t\tif commandCategory.Name == category {\n\t\t\tcommandCategory.Commands = append(commandCategory.Commands, command)\n\t\t\treturn c\n\t\t}\n\t}\n\treturn append(c, &CommandCategory{Name: category, Commands: []Command{command}})\n}\n\n// VisibleCommands returns a slice of the Commands with Hidden=false\nfunc (c *CommandCategory) VisibleCommands() []Command {\n\tret := []Command{}\n\tfor _, command := range c.Commands {\n\t\tif !command.Hidden {\n\t\t\tret = append(ret, command)\n\t\t}\n\t}\n\treturn ret\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/cli.go",
    "content": "// Package cli provides a minimal framework for creating and organizing command line\n// Go applications. cli is designed to be easy to understand and write, the most simple\n// cli application can be written as follows:\n//   func main() {\n//     cli.NewApp().Run(os.Args)\n//   }\n//\n// Of course this application does not do much, so let's make this an actual application:\n//   func main() {\n//     app := cli.NewApp()\n//     app.Name = \"greet\"\n//     app.Usage = \"say a greeting\"\n//     app.Action = func(c *cli.Context) error {\n//       println(\"Greetings\")\n//       return nil\n//     }\n//\n//     app.Run(os.Args)\n//   }\npackage cli\n\n//go:generate python ./generate-flag-types cli -i flag-types.json -o flag_generated.go\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/command.go",
    "content": "package cli\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"sort\"\n\t\"strings\"\n)\n\n// Command is a subcommand for a cli.App.\ntype Command struct {\n\t// The name of the command\n\tName string\n\t// short name of the command. Typically one character (deprecated, use `Aliases`)\n\tShortName string\n\t// A list of aliases for the command\n\tAliases []string\n\t// A short description of the usage of this command\n\tUsage string\n\t// Custom text to show on USAGE section of help\n\tUsageText string\n\t// A longer explanation of how the command works\n\tDescription string\n\t// A short description of the arguments of this command\n\tArgsUsage string\n\t// The category the command is part of\n\tCategory string\n\t// The function to call when checking for bash command completions\n\tBashComplete BashCompleteFunc\n\t// An action to execute before any sub-subcommands are run, but after the context is ready\n\t// If a non-nil error is returned, no sub-subcommands are run\n\tBefore BeforeFunc\n\t// An action to execute after any subcommands are run, but after the subcommand has finished\n\t// It is run even if Action() panics\n\tAfter AfterFunc\n\t// The function to call when this command is invoked\n\tAction interface{}\n\t// TODO: replace `Action: interface{}` with `Action: ActionFunc` once some kind\n\t// of deprecation period has passed, maybe?\n\n\t// Execute this function if a usage error occurs.\n\tOnUsageError OnUsageErrorFunc\n\t// List of child commands\n\tSubcommands Commands\n\t// List of flags to parse\n\tFlags []Flag\n\t// Treat all flags as normal arguments if true\n\tSkipFlagParsing bool\n\t// Skip argument reordering which attempts to move flags before arguments,\n\t// but only works if all flags appear after all arguments. This behavior was\n\t// removed n version 2 since it only works under specific conditions so we\n\t// backport here by exposing it as an option for compatibility.\n\tSkipArgReorder bool\n\t// Boolean to hide built-in help command\n\tHideHelp bool\n\t// Boolean to hide this command from help or completion\n\tHidden bool\n\n\t// Full name of command for help, defaults to full command name, including parent commands.\n\tHelpName        string\n\tcommandNamePath []string\n\n\t// CustomHelpTemplate the text template for the command help topic.\n\t// cli.go uses text/template to render templates. You can\n\t// render custom help text by setting this variable.\n\tCustomHelpTemplate string\n}\n\ntype CommandsByName []Command\n\nfunc (c CommandsByName) Len() int {\n\treturn len(c)\n}\n\nfunc (c CommandsByName) Less(i, j int) bool {\n\treturn c[i].Name < c[j].Name\n}\n\nfunc (c CommandsByName) Swap(i, j int) {\n\tc[i], c[j] = c[j], c[i]\n}\n\n// FullName returns the full name of the command.\n// For subcommands this ensures that parent commands are part of the command path\nfunc (c Command) FullName() string {\n\tif c.commandNamePath == nil {\n\t\treturn c.Name\n\t}\n\treturn strings.Join(c.commandNamePath, \" \")\n}\n\n// Commands is a slice of Command\ntype Commands []Command\n\n// Run invokes the command given the context, parses ctx.Args() to generate command-specific flags\nfunc (c Command) Run(ctx *Context) (err error) {\n\tif len(c.Subcommands) > 0 {\n\t\treturn c.startApp(ctx)\n\t}\n\n\tif !c.HideHelp && (HelpFlag != BoolFlag{}) {\n\t\t// append help to flags\n\t\tc.Flags = append(\n\t\t\tc.Flags,\n\t\t\tHelpFlag,\n\t\t)\n\t}\n\n\tset, err := flagSet(c.Name, c.Flags)\n\tif err != nil {\n\t\treturn err\n\t}\n\tset.SetOutput(ioutil.Discard)\n\n\tif c.SkipFlagParsing {\n\t\terr = set.Parse(append([]string{\"--\"}, ctx.Args().Tail()...))\n\t} else if !c.SkipArgReorder {\n\t\tfirstFlagIndex := -1\n\t\tterminatorIndex := -1\n\t\tfor index, arg := range ctx.Args() {\n\t\t\tif arg == \"--\" {\n\t\t\t\tterminatorIndex = index\n\t\t\t\tbreak\n\t\t\t} else if arg == \"-\" {\n\t\t\t\t// Do nothing. A dash alone is not really a flag.\n\t\t\t\tcontinue\n\t\t\t} else if strings.HasPrefix(arg, \"-\") && firstFlagIndex == -1 {\n\t\t\t\tfirstFlagIndex = index\n\t\t\t}\n\t\t}\n\n\t\tif firstFlagIndex > -1 {\n\t\t\targs := ctx.Args()\n\t\t\tregularArgs := make([]string, len(args[1:firstFlagIndex]))\n\t\t\tcopy(regularArgs, args[1:firstFlagIndex])\n\n\t\t\tvar flagArgs []string\n\t\t\tif terminatorIndex > -1 {\n\t\t\t\tflagArgs = args[firstFlagIndex:terminatorIndex]\n\t\t\t\tregularArgs = append(regularArgs, args[terminatorIndex:]...)\n\t\t\t} else {\n\t\t\t\tflagArgs = args[firstFlagIndex:]\n\t\t\t}\n\n\t\t\terr = set.Parse(append(flagArgs, regularArgs...))\n\t\t} else {\n\t\t\terr = set.Parse(ctx.Args().Tail())\n\t\t}\n\t} else {\n\t\terr = set.Parse(ctx.Args().Tail())\n\t}\n\n\tnerr := normalizeFlags(c.Flags, set)\n\tif nerr != nil {\n\t\tfmt.Fprintln(ctx.App.Writer, nerr)\n\t\tfmt.Fprintln(ctx.App.Writer)\n\t\tShowCommandHelp(ctx, c.Name)\n\t\treturn nerr\n\t}\n\n\tcontext := NewContext(ctx.App, set, ctx)\n\tcontext.Command = c\n\tif checkCommandCompletions(context, c.Name) {\n\t\treturn nil\n\t}\n\n\tif err != nil {\n\t\tif c.OnUsageError != nil {\n\t\t\terr := c.OnUsageError(context, err, false)\n\t\t\tHandleExitCoder(err)\n\t\t\treturn err\n\t\t}\n\t\tfmt.Fprintln(context.App.Writer, \"Incorrect Usage:\", err.Error())\n\t\tfmt.Fprintln(context.App.Writer)\n\t\tShowCommandHelp(context, c.Name)\n\t\treturn err\n\t}\n\n\tif checkCommandHelp(context, c.Name) {\n\t\treturn nil\n\t}\n\n\tif c.After != nil {\n\t\tdefer func() {\n\t\t\tafterErr := c.After(context)\n\t\t\tif afterErr != nil {\n\t\t\t\tHandleExitCoder(err)\n\t\t\t\tif err != nil {\n\t\t\t\t\terr = NewMultiError(err, afterErr)\n\t\t\t\t} else {\n\t\t\t\t\terr = afterErr\n\t\t\t\t}\n\t\t\t}\n\t\t}()\n\t}\n\n\tif c.Before != nil {\n\t\terr = c.Before(context)\n\t\tif err != nil {\n\t\t\tShowCommandHelp(context, c.Name)\n\t\t\tHandleExitCoder(err)\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif c.Action == nil {\n\t\tc.Action = helpSubcommand.Action\n\t}\n\n\terr = HandleAction(c.Action, context)\n\n\tif err != nil {\n\t\tHandleExitCoder(err)\n\t}\n\treturn err\n}\n\n// Names returns the names including short names and aliases.\nfunc (c Command) Names() []string {\n\tnames := []string{c.Name}\n\n\tif c.ShortName != \"\" {\n\t\tnames = append(names, c.ShortName)\n\t}\n\n\treturn append(names, c.Aliases...)\n}\n\n// HasName returns true if Command.Name or Command.ShortName matches given name\nfunc (c Command) HasName(name string) bool {\n\tfor _, n := range c.Names() {\n\t\tif n == name {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc (c Command) startApp(ctx *Context) error {\n\tapp := NewApp()\n\tapp.Metadata = ctx.App.Metadata\n\t// set the name and usage\n\tapp.Name = fmt.Sprintf(\"%s %s\", ctx.App.Name, c.Name)\n\tif c.HelpName == \"\" {\n\t\tapp.HelpName = c.HelpName\n\t} else {\n\t\tapp.HelpName = app.Name\n\t}\n\n\tapp.Usage = c.Usage\n\tapp.Description = c.Description\n\tapp.ArgsUsage = c.ArgsUsage\n\n\t// set CommandNotFound\n\tapp.CommandNotFound = ctx.App.CommandNotFound\n\tapp.CustomAppHelpTemplate = c.CustomHelpTemplate\n\n\t// set the flags and commands\n\tapp.Commands = c.Subcommands\n\tapp.Flags = c.Flags\n\tapp.HideHelp = c.HideHelp\n\n\tapp.Version = ctx.App.Version\n\tapp.HideVersion = ctx.App.HideVersion\n\tapp.Compiled = ctx.App.Compiled\n\tapp.Author = ctx.App.Author\n\tapp.Email = ctx.App.Email\n\tapp.Writer = ctx.App.Writer\n\tapp.ErrWriter = ctx.App.ErrWriter\n\n\tapp.categories = CommandCategories{}\n\tfor _, command := range c.Subcommands {\n\t\tapp.categories = app.categories.AddCommand(command.Category, command)\n\t}\n\n\tsort.Sort(app.categories)\n\n\t// bash completion\n\tapp.EnableBashCompletion = ctx.App.EnableBashCompletion\n\tif c.BashComplete != nil {\n\t\tapp.BashComplete = c.BashComplete\n\t}\n\n\t// set the actions\n\tapp.Before = c.Before\n\tapp.After = c.After\n\tif c.Action != nil {\n\t\tapp.Action = c.Action\n\t} else {\n\t\tapp.Action = helpSubcommand.Action\n\t}\n\tapp.OnUsageError = c.OnUsageError\n\n\tfor index, cc := range app.Commands {\n\t\tapp.Commands[index].commandNamePath = []string{c.Name, cc.Name}\n\t}\n\n\treturn app.RunAsSubcommand(ctx)\n}\n\n// VisibleFlags returns a slice of the Flags with Hidden=false\nfunc (c Command) VisibleFlags() []Flag {\n\treturn visibleFlags(c.Flags)\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/command_test.go",
    "content": "package cli\n\nimport (\n\t\"errors\"\n\t\"flag\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"strings\"\n\t\"testing\"\n)\n\nfunc TestCommandFlagParsing(t *testing.T) {\n\tcases := []struct {\n\t\ttestArgs        []string\n\t\tskipFlagParsing bool\n\t\tskipArgReorder  bool\n\t\texpectedErr     error\n\t}{\n\t\t// Test normal \"not ignoring flags\" flow\n\t\t{[]string{\"test-cmd\", \"blah\", \"blah\", \"-break\"}, false, false, errors.New(\"flag provided but not defined: -break\")},\n\n\t\t// Test no arg reorder\n\t\t{[]string{\"test-cmd\", \"blah\", \"blah\", \"-break\"}, false, true, nil},\n\n\t\t{[]string{\"test-cmd\", \"blah\", \"blah\"}, true, false, nil},   // Test SkipFlagParsing without any args that look like flags\n\t\t{[]string{\"test-cmd\", \"blah\", \"-break\"}, true, false, nil}, // Test SkipFlagParsing with random flag arg\n\t\t{[]string{\"test-cmd\", \"blah\", \"-help\"}, true, false, nil},  // Test SkipFlagParsing with \"special\" help flag arg\n\t}\n\n\tfor _, c := range cases {\n\t\tapp := NewApp()\n\t\tapp.Writer = ioutil.Discard\n\t\tset := flag.NewFlagSet(\"test\", 0)\n\t\tset.Parse(c.testArgs)\n\n\t\tcontext := NewContext(app, set, nil)\n\n\t\tcommand := Command{\n\t\t\tName:            \"test-cmd\",\n\t\t\tAliases:         []string{\"tc\"},\n\t\t\tUsage:           \"this is for testing\",\n\t\t\tDescription:     \"testing\",\n\t\t\tAction:          func(_ *Context) error { return nil },\n\t\t\tSkipFlagParsing: c.skipFlagParsing,\n\t\t\tSkipArgReorder:  c.skipArgReorder,\n\t\t}\n\n\t\terr := command.Run(context)\n\n\t\texpect(t, err, c.expectedErr)\n\t\texpect(t, []string(context.Args()), c.testArgs)\n\t}\n}\n\nfunc TestCommand_Run_DoesNotOverwriteErrorFromBefore(t *testing.T) {\n\tapp := NewApp()\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName: \"bar\",\n\t\t\tBefore: func(c *Context) error {\n\t\t\t\treturn fmt.Errorf(\"before error\")\n\t\t\t},\n\t\t\tAfter: func(c *Context) error {\n\t\t\t\treturn fmt.Errorf(\"after error\")\n\t\t\t},\n\t\t},\n\t}\n\n\terr := app.Run([]string{\"foo\", \"bar\"})\n\tif err == nil {\n\t\tt.Fatalf(\"expected to receive error from Run, got none\")\n\t}\n\n\tif !strings.Contains(err.Error(), \"before error\") {\n\t\tt.Errorf(\"expected text of error from Before method, but got none in \\\"%v\\\"\", err)\n\t}\n\tif !strings.Contains(err.Error(), \"after error\") {\n\t\tt.Errorf(\"expected text of error from After method, but got none in \\\"%v\\\"\", err)\n\t}\n}\n\nfunc TestCommand_Run_BeforeSavesMetadata(t *testing.T) {\n\tvar receivedMsgFromAction string\n\tvar receivedMsgFromAfter string\n\n\tapp := NewApp()\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName: \"bar\",\n\t\t\tBefore: func(c *Context) error {\n\t\t\t\tc.App.Metadata[\"msg\"] = \"hello world\"\n\t\t\t\treturn nil\n\t\t\t},\n\t\t\tAction: func(c *Context) error {\n\t\t\t\tmsg, ok := c.App.Metadata[\"msg\"]\n\t\t\t\tif !ok {\n\t\t\t\t\treturn errors.New(\"msg not found\")\n\t\t\t\t}\n\t\t\t\treceivedMsgFromAction = msg.(string)\n\t\t\t\treturn nil\n\t\t\t},\n\t\t\tAfter: func(c *Context) error {\n\t\t\t\tmsg, ok := c.App.Metadata[\"msg\"]\n\t\t\t\tif !ok {\n\t\t\t\t\treturn errors.New(\"msg not found\")\n\t\t\t\t}\n\t\t\t\treceivedMsgFromAfter = msg.(string)\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t}\n\n\terr := app.Run([]string{\"foo\", \"bar\"})\n\tif err != nil {\n\t\tt.Fatalf(\"expected no error from Run, got %s\", err)\n\t}\n\n\texpectedMsg := \"hello world\"\n\n\tif receivedMsgFromAction != expectedMsg {\n\t\tt.Fatalf(\"expected msg from Action to match. Given: %q\\nExpected: %q\",\n\t\t\treceivedMsgFromAction, expectedMsg)\n\t}\n\tif receivedMsgFromAfter != expectedMsg {\n\t\tt.Fatalf(\"expected msg from After to match. Given: %q\\nExpected: %q\",\n\t\t\treceivedMsgFromAction, expectedMsg)\n\t}\n}\n\nfunc TestCommand_OnUsageError_hasCommandContext(t *testing.T) {\n\tapp := NewApp()\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName: \"bar\",\n\t\t\tFlags: []Flag{\n\t\t\t\tIntFlag{Name: \"flag\"},\n\t\t\t},\n\t\t\tOnUsageError: func(c *Context, err error, _ bool) error {\n\t\t\t\treturn fmt.Errorf(\"intercepted in %s: %s\", c.Command.Name, err.Error())\n\t\t\t},\n\t\t},\n\t}\n\n\terr := app.Run([]string{\"foo\", \"bar\", \"--flag=wrong\"})\n\tif err == nil {\n\t\tt.Fatalf(\"expected to receive error from Run, got none\")\n\t}\n\n\tif !strings.HasPrefix(err.Error(), \"intercepted in bar\") {\n\t\tt.Errorf(\"Expect an intercepted error, but got \\\"%v\\\"\", err)\n\t}\n}\n\nfunc TestCommand_OnUsageError_WithWrongFlagValue(t *testing.T) {\n\tapp := NewApp()\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName: \"bar\",\n\t\t\tFlags: []Flag{\n\t\t\t\tIntFlag{Name: \"flag\"},\n\t\t\t},\n\t\t\tOnUsageError: func(c *Context, err error, _ bool) error {\n\t\t\t\tif !strings.HasPrefix(err.Error(), \"invalid value \\\"wrong\\\"\") {\n\t\t\t\t\tt.Errorf(\"Expect an invalid value error, but got \\\"%v\\\"\", err)\n\t\t\t\t}\n\t\t\t\treturn errors.New(\"intercepted: \" + err.Error())\n\t\t\t},\n\t\t},\n\t}\n\n\terr := app.Run([]string{\"foo\", \"bar\", \"--flag=wrong\"})\n\tif err == nil {\n\t\tt.Fatalf(\"expected to receive error from Run, got none\")\n\t}\n\n\tif !strings.HasPrefix(err.Error(), \"intercepted: invalid value\") {\n\t\tt.Errorf(\"Expect an intercepted error, but got \\\"%v\\\"\", err)\n\t}\n}\n\nfunc TestCommand_OnUsageError_WithSubcommand(t *testing.T) {\n\tapp := NewApp()\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName: \"bar\",\n\t\t\tSubcommands: []Command{\n\t\t\t\t{\n\t\t\t\t\tName: \"baz\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tFlags: []Flag{\n\t\t\t\tIntFlag{Name: \"flag\"},\n\t\t\t},\n\t\t\tOnUsageError: func(c *Context, err error, _ bool) error {\n\t\t\t\tif !strings.HasPrefix(err.Error(), \"invalid value \\\"wrong\\\"\") {\n\t\t\t\t\tt.Errorf(\"Expect an invalid value error, but got \\\"%v\\\"\", err)\n\t\t\t\t}\n\t\t\t\treturn errors.New(\"intercepted: \" + err.Error())\n\t\t\t},\n\t\t},\n\t}\n\n\terr := app.Run([]string{\"foo\", \"bar\", \"--flag=wrong\"})\n\tif err == nil {\n\t\tt.Fatalf(\"expected to receive error from Run, got none\")\n\t}\n\n\tif !strings.HasPrefix(err.Error(), \"intercepted: invalid value\") {\n\t\tt.Errorf(\"Expect an intercepted error, but got \\\"%v\\\"\", err)\n\t}\n}\n\nfunc TestCommand_Run_SubcommandsCanUseErrWriter(t *testing.T) {\n\tapp := NewApp()\n\tapp.ErrWriter = ioutil.Discard\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName:  \"bar\",\n\t\t\tUsage: \"this is for testing\",\n\t\t\tSubcommands: []Command{\n\t\t\t\t{\n\t\t\t\t\tName:  \"baz\",\n\t\t\t\t\tUsage: \"this is for testing\",\n\t\t\t\t\tAction: func(c *Context) error {\n\t\t\t\t\t\tif c.App.ErrWriter != ioutil.Discard {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"ErrWriter not passed\")\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\terr := app.Run([]string{\"foo\", \"bar\", \"baz\"})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/context.go",
    "content": "package cli\n\nimport (\n\t\"errors\"\n\t\"flag\"\n\t\"reflect\"\n\t\"strings\"\n\t\"syscall\"\n)\n\n// Context is a type that is passed through to\n// each Handler action in a cli application. Context\n// can be used to retrieve context-specific Args and\n// parsed command-line options.\ntype Context struct {\n\tApp           *App\n\tCommand       Command\n\tshellComplete bool\n\tflagSet       *flag.FlagSet\n\tsetFlags      map[string]bool\n\tparentContext *Context\n}\n\n// NewContext creates a new context. For use in when invoking an App or Command action.\nfunc NewContext(app *App, set *flag.FlagSet, parentCtx *Context) *Context {\n\tc := &Context{App: app, flagSet: set, parentContext: parentCtx}\n\n\tif parentCtx != nil {\n\t\tc.shellComplete = parentCtx.shellComplete\n\t}\n\n\treturn c\n}\n\n// NumFlags returns the number of flags set\nfunc (c *Context) NumFlags() int {\n\treturn c.flagSet.NFlag()\n}\n\n// Set sets a context flag to a value.\nfunc (c *Context) Set(name, value string) error {\n\tc.setFlags = nil\n\treturn c.flagSet.Set(name, value)\n}\n\n// GlobalSet sets a context flag to a value on the global flagset\nfunc (c *Context) GlobalSet(name, value string) error {\n\tglobalContext(c).setFlags = nil\n\treturn globalContext(c).flagSet.Set(name, value)\n}\n\n// IsSet determines if the flag was actually set\nfunc (c *Context) IsSet(name string) bool {\n\tif c.setFlags == nil {\n\t\tc.setFlags = make(map[string]bool)\n\n\t\tc.flagSet.Visit(func(f *flag.Flag) {\n\t\t\tc.setFlags[f.Name] = true\n\t\t})\n\n\t\tc.flagSet.VisitAll(func(f *flag.Flag) {\n\t\t\tif _, ok := c.setFlags[f.Name]; ok {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tc.setFlags[f.Name] = false\n\t\t})\n\n\t\t// XXX hack to support IsSet for flags with EnvVar\n\t\t//\n\t\t// There isn't an easy way to do this with the current implementation since\n\t\t// whether a flag was set via an environment variable is very difficult to\n\t\t// determine here. Instead, we intend to introduce a backwards incompatible\n\t\t// change in version 2 to add `IsSet` to the Flag interface to push the\n\t\t// responsibility closer to where the information required to determine\n\t\t// whether a flag is set by non-standard means such as environment\n\t\t// variables is avaliable.\n\t\t//\n\t\t// See https://github.com/urfave/cli/issues/294 for additional discussion\n\t\tflags := c.Command.Flags\n\t\tif c.Command.Name == \"\" { // cannot == Command{} since it contains slice types\n\t\t\tif c.App != nil {\n\t\t\t\tflags = c.App.Flags\n\t\t\t}\n\t\t}\n\t\tfor _, f := range flags {\n\t\t\teachName(f.GetName(), func(name string) {\n\t\t\t\tif isSet, ok := c.setFlags[name]; isSet || !ok {\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tval := reflect.ValueOf(f)\n\t\t\t\tif val.Kind() == reflect.Ptr {\n\t\t\t\t\tval = val.Elem()\n\t\t\t\t}\n\n\t\t\t\tenvVarValue := val.FieldByName(\"EnvVar\")\n\t\t\t\tif !envVarValue.IsValid() {\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\teachName(envVarValue.String(), func(envVar string) {\n\t\t\t\t\tenvVar = strings.TrimSpace(envVar)\n\t\t\t\t\tif _, ok := syscall.Getenv(envVar); ok {\n\t\t\t\t\t\tc.setFlags[name] = true\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t})\n\t\t}\n\t}\n\n\treturn c.setFlags[name]\n}\n\n// GlobalIsSet determines if the global flag was actually set\nfunc (c *Context) GlobalIsSet(name string) bool {\n\tctx := c\n\tif ctx.parentContext != nil {\n\t\tctx = ctx.parentContext\n\t}\n\n\tfor ; ctx != nil; ctx = ctx.parentContext {\n\t\tif ctx.IsSet(name) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\n// FlagNames returns a slice of flag names used in this context.\nfunc (c *Context) FlagNames() (names []string) {\n\tfor _, flag := range c.Command.Flags {\n\t\tname := strings.Split(flag.GetName(), \",\")[0]\n\t\tif name == \"help\" {\n\t\t\tcontinue\n\t\t}\n\t\tnames = append(names, name)\n\t}\n\treturn\n}\n\n// GlobalFlagNames returns a slice of global flag names used by the app.\nfunc (c *Context) GlobalFlagNames() (names []string) {\n\tfor _, flag := range c.App.Flags {\n\t\tname := strings.Split(flag.GetName(), \",\")[0]\n\t\tif name == \"help\" || name == \"version\" {\n\t\t\tcontinue\n\t\t}\n\t\tnames = append(names, name)\n\t}\n\treturn\n}\n\n// Parent returns the parent context, if any\nfunc (c *Context) Parent() *Context {\n\treturn c.parentContext\n}\n\n// value returns the value of the flag coressponding to `name`\nfunc (c *Context) value(name string) interface{} {\n\treturn c.flagSet.Lookup(name).Value.(flag.Getter).Get()\n}\n\n// Args contains apps console arguments\ntype Args []string\n\n// Args returns the command line arguments associated with the context.\nfunc (c *Context) Args() Args {\n\targs := Args(c.flagSet.Args())\n\treturn args\n}\n\n// NArg returns the number of the command line arguments.\nfunc (c *Context) NArg() int {\n\treturn len(c.Args())\n}\n\n// Get returns the nth argument, or else a blank string\nfunc (a Args) Get(n int) string {\n\tif len(a) > n {\n\t\treturn a[n]\n\t}\n\treturn \"\"\n}\n\n// First returns the first argument, or else a blank string\nfunc (a Args) First() string {\n\treturn a.Get(0)\n}\n\n// Tail returns the rest of the arguments (not the first one)\n// or else an empty string slice\nfunc (a Args) Tail() []string {\n\tif len(a) >= 2 {\n\t\treturn []string(a)[1:]\n\t}\n\treturn []string{}\n}\n\n// Present checks if there are any arguments present\nfunc (a Args) Present() bool {\n\treturn len(a) != 0\n}\n\n// Swap swaps arguments at the given indexes\nfunc (a Args) Swap(from, to int) error {\n\tif from >= len(a) || to >= len(a) {\n\t\treturn errors.New(\"index out of range\")\n\t}\n\ta[from], a[to] = a[to], a[from]\n\treturn nil\n}\n\nfunc globalContext(ctx *Context) *Context {\n\tif ctx == nil {\n\t\treturn nil\n\t}\n\n\tfor {\n\t\tif ctx.parentContext == nil {\n\t\t\treturn ctx\n\t\t}\n\t\tctx = ctx.parentContext\n\t}\n}\n\nfunc lookupGlobalFlagSet(name string, ctx *Context) *flag.FlagSet {\n\tif ctx.parentContext != nil {\n\t\tctx = ctx.parentContext\n\t}\n\tfor ; ctx != nil; ctx = ctx.parentContext {\n\t\tif f := ctx.flagSet.Lookup(name); f != nil {\n\t\t\treturn ctx.flagSet\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc copyFlag(name string, ff *flag.Flag, set *flag.FlagSet) {\n\tswitch ff.Value.(type) {\n\tcase *StringSlice:\n\tdefault:\n\t\tset.Set(name, ff.Value.String())\n\t}\n}\n\nfunc normalizeFlags(flags []Flag, set *flag.FlagSet) error {\n\tvisited := make(map[string]bool)\n\tset.Visit(func(f *flag.Flag) {\n\t\tvisited[f.Name] = true\n\t})\n\tfor _, f := range flags {\n\t\tparts := strings.Split(f.GetName(), \",\")\n\t\tif len(parts) == 1 {\n\t\t\tcontinue\n\t\t}\n\t\tvar ff *flag.Flag\n\t\tfor _, name := range parts {\n\t\t\tname = strings.Trim(name, \" \")\n\t\t\tif visited[name] {\n\t\t\t\tif ff != nil {\n\t\t\t\t\treturn errors.New(\"Cannot use two forms of the same flag: \" + name + \" \" + ff.Name)\n\t\t\t\t}\n\t\t\t\tff = set.Lookup(name)\n\t\t\t}\n\t\t}\n\t\tif ff == nil {\n\t\t\tcontinue\n\t\t}\n\t\tfor _, name := range parts {\n\t\t\tname = strings.Trim(name, \" \")\n\t\t\tif !visited[name] {\n\t\t\t\tcopyFlag(name, ff, set)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/context_test.go",
    "content": "package cli\n\nimport (\n\t\"flag\"\n\t\"os\"\n\t\"testing\"\n\t\"time\"\n)\n\nfunc TestNewContext(t *testing.T) {\n\tset := flag.NewFlagSet(\"test\", 0)\n\tset.Int(\"myflag\", 12, \"doc\")\n\tset.Int64(\"myflagInt64\", int64(12), \"doc\")\n\tset.Uint(\"myflagUint\", uint(93), \"doc\")\n\tset.Uint64(\"myflagUint64\", uint64(93), \"doc\")\n\tset.Float64(\"myflag64\", float64(17), \"doc\")\n\tglobalSet := flag.NewFlagSet(\"test\", 0)\n\tglobalSet.Int(\"myflag\", 42, \"doc\")\n\tglobalSet.Int64(\"myflagInt64\", int64(42), \"doc\")\n\tglobalSet.Uint(\"myflagUint\", uint(33), \"doc\")\n\tglobalSet.Uint64(\"myflagUint64\", uint64(33), \"doc\")\n\tglobalSet.Float64(\"myflag64\", float64(47), \"doc\")\n\tglobalCtx := NewContext(nil, globalSet, nil)\n\tcommand := Command{Name: \"mycommand\"}\n\tc := NewContext(nil, set, globalCtx)\n\tc.Command = command\n\texpect(t, c.Int(\"myflag\"), 12)\n\texpect(t, c.Int64(\"myflagInt64\"), int64(12))\n\texpect(t, c.Uint(\"myflagUint\"), uint(93))\n\texpect(t, c.Uint64(\"myflagUint64\"), uint64(93))\n\texpect(t, c.Float64(\"myflag64\"), float64(17))\n\texpect(t, c.GlobalInt(\"myflag\"), 42)\n\texpect(t, c.GlobalInt64(\"myflagInt64\"), int64(42))\n\texpect(t, c.GlobalUint(\"myflagUint\"), uint(33))\n\texpect(t, c.GlobalUint64(\"myflagUint64\"), uint64(33))\n\texpect(t, c.GlobalFloat64(\"myflag64\"), float64(47))\n\texpect(t, c.Command.Name, \"mycommand\")\n}\n\nfunc TestContext_Int(t *testing.T) {\n\tset := flag.NewFlagSet(\"test\", 0)\n\tset.Int(\"myflag\", 12, \"doc\")\n\tc := NewContext(nil, set, nil)\n\texpect(t, c.Int(\"myflag\"), 12)\n}\n\nfunc TestContext_Int64(t *testing.T) {\n\tset := flag.NewFlagSet(\"test\", 0)\n\tset.Int64(\"myflagInt64\", 12, \"doc\")\n\tc := NewContext(nil, set, nil)\n\texpect(t, c.Int64(\"myflagInt64\"), int64(12))\n}\n\nfunc TestContext_Uint(t *testing.T) {\n\tset := flag.NewFlagSet(\"test\", 0)\n\tset.Uint(\"myflagUint\", uint(13), \"doc\")\n\tc := NewContext(nil, set, nil)\n\texpect(t, c.Uint(\"myflagUint\"), uint(13))\n}\n\nfunc TestContext_Uint64(t *testing.T) {\n\tset := flag.NewFlagSet(\"test\", 0)\n\tset.Uint64(\"myflagUint64\", uint64(9), \"doc\")\n\tc := NewContext(nil, set, nil)\n\texpect(t, c.Uint64(\"myflagUint64\"), uint64(9))\n}\n\nfunc TestContext_GlobalInt(t *testing.T) {\n\tset := flag.NewFlagSet(\"test\", 0)\n\tset.Int(\"myflag\", 12, \"doc\")\n\tc := NewContext(nil, set, nil)\n\texpect(t, c.GlobalInt(\"myflag\"), 12)\n\texpect(t, c.GlobalInt(\"nope\"), 0)\n}\n\nfunc TestContext_GlobalInt64(t *testing.T) {\n\tset := flag.NewFlagSet(\"test\", 0)\n\tset.Int64(\"myflagInt64\", 12, \"doc\")\n\tc := NewContext(nil, set, nil)\n\texpect(t, c.GlobalInt64(\"myflagInt64\"), int64(12))\n\texpect(t, c.GlobalInt64(\"nope\"), int64(0))\n}\n\nfunc TestContext_Float64(t *testing.T) {\n\tset := flag.NewFlagSet(\"test\", 0)\n\tset.Float64(\"myflag\", float64(17), \"doc\")\n\tc := NewContext(nil, set, nil)\n\texpect(t, c.Float64(\"myflag\"), float64(17))\n}\n\nfunc TestContext_GlobalFloat64(t *testing.T) {\n\tset := flag.NewFlagSet(\"test\", 0)\n\tset.Float64(\"myflag\", float64(17), \"doc\")\n\tc := NewContext(nil, set, nil)\n\texpect(t, c.GlobalFloat64(\"myflag\"), float64(17))\n\texpect(t, c.GlobalFloat64(\"nope\"), float64(0))\n}\n\nfunc TestContext_Duration(t *testing.T) {\n\tset := flag.NewFlagSet(\"test\", 0)\n\tset.Duration(\"myflag\", time.Duration(12*time.Second), \"doc\")\n\tc := NewContext(nil, set, nil)\n\texpect(t, c.Duration(\"myflag\"), time.Duration(12*time.Second))\n}\n\nfunc TestContext_String(t *testing.T) {\n\tset := flag.NewFlagSet(\"test\", 0)\n\tset.String(\"myflag\", \"hello world\", \"doc\")\n\tc := NewContext(nil, set, nil)\n\texpect(t, c.String(\"myflag\"), \"hello world\")\n}\n\nfunc TestContext_Bool(t *testing.T) {\n\tset := flag.NewFlagSet(\"test\", 0)\n\tset.Bool(\"myflag\", false, \"doc\")\n\tc := NewContext(nil, set, nil)\n\texpect(t, c.Bool(\"myflag\"), false)\n}\n\nfunc TestContext_BoolT(t *testing.T) {\n\tset := flag.NewFlagSet(\"test\", 0)\n\tset.Bool(\"myflag\", true, \"doc\")\n\tc := NewContext(nil, set, nil)\n\texpect(t, c.BoolT(\"myflag\"), true)\n}\n\nfunc TestContext_GlobalBool(t *testing.T) {\n\tset := flag.NewFlagSet(\"test\", 0)\n\n\tglobalSet := flag.NewFlagSet(\"test-global\", 0)\n\tglobalSet.Bool(\"myflag\", false, \"doc\")\n\tglobalCtx := NewContext(nil, globalSet, nil)\n\n\tc := NewContext(nil, set, globalCtx)\n\texpect(t, c.GlobalBool(\"myflag\"), false)\n\texpect(t, c.GlobalBool(\"nope\"), false)\n}\n\nfunc TestContext_GlobalBoolT(t *testing.T) {\n\tset := flag.NewFlagSet(\"test\", 0)\n\n\tglobalSet := flag.NewFlagSet(\"test-global\", 0)\n\tglobalSet.Bool(\"myflag\", true, \"doc\")\n\tglobalCtx := NewContext(nil, globalSet, nil)\n\n\tc := NewContext(nil, set, globalCtx)\n\texpect(t, c.GlobalBoolT(\"myflag\"), true)\n\texpect(t, c.GlobalBoolT(\"nope\"), false)\n}\n\nfunc TestContext_Args(t *testing.T) {\n\tset := flag.NewFlagSet(\"test\", 0)\n\tset.Bool(\"myflag\", false, \"doc\")\n\tc := NewContext(nil, set, nil)\n\tset.Parse([]string{\"--myflag\", \"bat\", \"baz\"})\n\texpect(t, len(c.Args()), 2)\n\texpect(t, c.Bool(\"myflag\"), true)\n}\n\nfunc TestContext_NArg(t *testing.T) {\n\tset := flag.NewFlagSet(\"test\", 0)\n\tset.Bool(\"myflag\", false, \"doc\")\n\tc := NewContext(nil, set, nil)\n\tset.Parse([]string{\"--myflag\", \"bat\", \"baz\"})\n\texpect(t, c.NArg(), 2)\n}\n\nfunc TestContext_IsSet(t *testing.T) {\n\tset := flag.NewFlagSet(\"test\", 0)\n\tset.Bool(\"myflag\", false, \"doc\")\n\tset.String(\"otherflag\", \"hello world\", \"doc\")\n\tglobalSet := flag.NewFlagSet(\"test\", 0)\n\tglobalSet.Bool(\"myflagGlobal\", true, \"doc\")\n\tglobalCtx := NewContext(nil, globalSet, nil)\n\tc := NewContext(nil, set, globalCtx)\n\tset.Parse([]string{\"--myflag\", \"bat\", \"baz\"})\n\tglobalSet.Parse([]string{\"--myflagGlobal\", \"bat\", \"baz\"})\n\texpect(t, c.IsSet(\"myflag\"), true)\n\texpect(t, c.IsSet(\"otherflag\"), false)\n\texpect(t, c.IsSet(\"bogusflag\"), false)\n\texpect(t, c.IsSet(\"myflagGlobal\"), false)\n}\n\n// XXX Corresponds to hack in context.IsSet for flags with EnvVar field\n// Should be moved to `flag_test` in v2\nfunc TestContext_IsSet_fromEnv(t *testing.T) {\n\tvar (\n\t\ttimeoutIsSet, tIsSet    bool\n\t\tnoEnvVarIsSet, nIsSet   bool\n\t\tpasswordIsSet, pIsSet   bool\n\t\tunparsableIsSet, uIsSet bool\n\t)\n\n\tclearenv()\n\tos.Setenv(\"APP_TIMEOUT_SECONDS\", \"15.5\")\n\tos.Setenv(\"APP_PASSWORD\", \"\")\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tFloat64Flag{Name: \"timeout, t\", EnvVar: \"APP_TIMEOUT_SECONDS\"},\n\t\t\tStringFlag{Name: \"password, p\", EnvVar: \"APP_PASSWORD\"},\n\t\t\tFloat64Flag{Name: \"unparsable, u\", EnvVar: \"APP_UNPARSABLE\"},\n\t\t\tFloat64Flag{Name: \"no-env-var, n\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\ttimeoutIsSet = ctx.IsSet(\"timeout\")\n\t\t\ttIsSet = ctx.IsSet(\"t\")\n\t\t\tpasswordIsSet = ctx.IsSet(\"password\")\n\t\t\tpIsSet = ctx.IsSet(\"p\")\n\t\t\tunparsableIsSet = ctx.IsSet(\"unparsable\")\n\t\t\tuIsSet = ctx.IsSet(\"u\")\n\t\t\tnoEnvVarIsSet = ctx.IsSet(\"no-env-var\")\n\t\t\tnIsSet = ctx.IsSet(\"n\")\n\t\t\treturn nil\n\t\t},\n\t}\n\ta.Run([]string{\"run\"})\n\texpect(t, timeoutIsSet, true)\n\texpect(t, tIsSet, true)\n\texpect(t, passwordIsSet, true)\n\texpect(t, pIsSet, true)\n\texpect(t, noEnvVarIsSet, false)\n\texpect(t, nIsSet, false)\n\n\tos.Setenv(\"APP_UNPARSABLE\", \"foobar\")\n\ta.Run([]string{\"run\"})\n\texpect(t, unparsableIsSet, false)\n\texpect(t, uIsSet, false)\n}\n\nfunc TestContext_GlobalIsSet(t *testing.T) {\n\tset := flag.NewFlagSet(\"test\", 0)\n\tset.Bool(\"myflag\", false, \"doc\")\n\tset.String(\"otherflag\", \"hello world\", \"doc\")\n\tglobalSet := flag.NewFlagSet(\"test\", 0)\n\tglobalSet.Bool(\"myflagGlobal\", true, \"doc\")\n\tglobalSet.Bool(\"myflagGlobalUnset\", true, \"doc\")\n\tglobalCtx := NewContext(nil, globalSet, nil)\n\tc := NewContext(nil, set, globalCtx)\n\tset.Parse([]string{\"--myflag\", \"bat\", \"baz\"})\n\tglobalSet.Parse([]string{\"--myflagGlobal\", \"bat\", \"baz\"})\n\texpect(t, c.GlobalIsSet(\"myflag\"), false)\n\texpect(t, c.GlobalIsSet(\"otherflag\"), false)\n\texpect(t, c.GlobalIsSet(\"bogusflag\"), false)\n\texpect(t, c.GlobalIsSet(\"myflagGlobal\"), true)\n\texpect(t, c.GlobalIsSet(\"myflagGlobalUnset\"), false)\n\texpect(t, c.GlobalIsSet(\"bogusGlobal\"), false)\n}\n\n// XXX Corresponds to hack in context.IsSet for flags with EnvVar field\n// Should be moved to `flag_test` in v2\nfunc TestContext_GlobalIsSet_fromEnv(t *testing.T) {\n\tvar (\n\t\ttimeoutIsSet, tIsSet    bool\n\t\tnoEnvVarIsSet, nIsSet   bool\n\t\tpasswordIsSet, pIsSet   bool\n\t\tunparsableIsSet, uIsSet bool\n\t)\n\n\tclearenv()\n\tos.Setenv(\"APP_TIMEOUT_SECONDS\", \"15.5\")\n\tos.Setenv(\"APP_PASSWORD\", \"\")\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tFloat64Flag{Name: \"timeout, t\", EnvVar: \"APP_TIMEOUT_SECONDS\"},\n\t\t\tStringFlag{Name: \"password, p\", EnvVar: \"APP_PASSWORD\"},\n\t\t\tFloat64Flag{Name: \"no-env-var, n\"},\n\t\t\tFloat64Flag{Name: \"unparsable, u\", EnvVar: \"APP_UNPARSABLE\"},\n\t\t},\n\t\tCommands: []Command{\n\t\t\t{\n\t\t\t\tName: \"hello\",\n\t\t\t\tAction: func(ctx *Context) error {\n\t\t\t\t\ttimeoutIsSet = ctx.GlobalIsSet(\"timeout\")\n\t\t\t\t\ttIsSet = ctx.GlobalIsSet(\"t\")\n\t\t\t\t\tpasswordIsSet = ctx.GlobalIsSet(\"password\")\n\t\t\t\t\tpIsSet = ctx.GlobalIsSet(\"p\")\n\t\t\t\t\tunparsableIsSet = ctx.GlobalIsSet(\"unparsable\")\n\t\t\t\t\tuIsSet = ctx.GlobalIsSet(\"u\")\n\t\t\t\t\tnoEnvVarIsSet = ctx.GlobalIsSet(\"no-env-var\")\n\t\t\t\t\tnIsSet = ctx.GlobalIsSet(\"n\")\n\t\t\t\t\treturn nil\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\tif err := a.Run([]string{\"run\", \"hello\"}); err != nil {\n\t\tt.Logf(\"error running Run(): %+v\", err)\n\t}\n\texpect(t, timeoutIsSet, true)\n\texpect(t, tIsSet, true)\n\texpect(t, passwordIsSet, true)\n\texpect(t, pIsSet, true)\n\texpect(t, noEnvVarIsSet, false)\n\texpect(t, nIsSet, false)\n\n\tos.Setenv(\"APP_UNPARSABLE\", \"foobar\")\n\tif err := a.Run([]string{\"run\"}); err != nil {\n\t\tt.Logf(\"error running Run(): %+v\", err)\n\t}\n\texpect(t, unparsableIsSet, false)\n\texpect(t, uIsSet, false)\n}\n\nfunc TestContext_NumFlags(t *testing.T) {\n\tset := flag.NewFlagSet(\"test\", 0)\n\tset.Bool(\"myflag\", false, \"doc\")\n\tset.String(\"otherflag\", \"hello world\", \"doc\")\n\tglobalSet := flag.NewFlagSet(\"test\", 0)\n\tglobalSet.Bool(\"myflagGlobal\", true, \"doc\")\n\tglobalCtx := NewContext(nil, globalSet, nil)\n\tc := NewContext(nil, set, globalCtx)\n\tset.Parse([]string{\"--myflag\", \"--otherflag=foo\"})\n\tglobalSet.Parse([]string{\"--myflagGlobal\"})\n\texpect(t, c.NumFlags(), 2)\n}\n\nfunc TestContext_GlobalFlag(t *testing.T) {\n\tvar globalFlag string\n\tvar globalFlagSet bool\n\tapp := NewApp()\n\tapp.Flags = []Flag{\n\t\tStringFlag{Name: \"global, g\", Usage: \"global\"},\n\t}\n\tapp.Action = func(c *Context) error {\n\t\tglobalFlag = c.GlobalString(\"global\")\n\t\tglobalFlagSet = c.GlobalIsSet(\"global\")\n\t\treturn nil\n\t}\n\tapp.Run([]string{\"command\", \"-g\", \"foo\"})\n\texpect(t, globalFlag, \"foo\")\n\texpect(t, globalFlagSet, true)\n\n}\n\nfunc TestContext_GlobalFlagsInSubcommands(t *testing.T) {\n\tsubcommandRun := false\n\tparentFlag := false\n\tapp := NewApp()\n\n\tapp.Flags = []Flag{\n\t\tBoolFlag{Name: \"debug, d\", Usage: \"Enable debugging\"},\n\t}\n\n\tapp.Commands = []Command{\n\t\t{\n\t\t\tName: \"foo\",\n\t\t\tFlags: []Flag{\n\t\t\t\tBoolFlag{Name: \"parent, p\", Usage: \"Parent flag\"},\n\t\t\t},\n\t\t\tSubcommands: []Command{\n\t\t\t\t{\n\t\t\t\t\tName: \"bar\",\n\t\t\t\t\tAction: func(c *Context) error {\n\t\t\t\t\t\tif c.GlobalBool(\"debug\") {\n\t\t\t\t\t\t\tsubcommandRun = true\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif c.GlobalBool(\"parent\") {\n\t\t\t\t\t\t\tparentFlag = true\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\tapp.Run([]string{\"command\", \"-d\", \"foo\", \"-p\", \"bar\"})\n\n\texpect(t, subcommandRun, true)\n\texpect(t, parentFlag, true)\n}\n\nfunc TestContext_Set(t *testing.T) {\n\tset := flag.NewFlagSet(\"test\", 0)\n\tset.Int(\"int\", 5, \"an int\")\n\tc := NewContext(nil, set, nil)\n\n\texpect(t, c.IsSet(\"int\"), false)\n\tc.Set(\"int\", \"1\")\n\texpect(t, c.Int(\"int\"), 1)\n\texpect(t, c.IsSet(\"int\"), true)\n}\n\nfunc TestContext_GlobalSet(t *testing.T) {\n\tgSet := flag.NewFlagSet(\"test\", 0)\n\tgSet.Int(\"int\", 5, \"an int\")\n\n\tset := flag.NewFlagSet(\"sub\", 0)\n\tset.Int(\"int\", 3, \"an int\")\n\n\tpc := NewContext(nil, gSet, nil)\n\tc := NewContext(nil, set, pc)\n\n\tc.Set(\"int\", \"1\")\n\texpect(t, c.Int(\"int\"), 1)\n\texpect(t, c.GlobalInt(\"int\"), 5)\n\n\texpect(t, c.GlobalIsSet(\"int\"), false)\n\tc.GlobalSet(\"int\", \"1\")\n\texpect(t, c.Int(\"int\"), 1)\n\texpect(t, c.GlobalInt(\"int\"), 1)\n\texpect(t, c.GlobalIsSet(\"int\"), true)\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/errors.go",
    "content": "package cli\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strings\"\n)\n\n// OsExiter is the function used when the app exits. If not set defaults to os.Exit.\nvar OsExiter = os.Exit\n\n// ErrWriter is used to write errors to the user. This can be anything\n// implementing the io.Writer interface and defaults to os.Stderr.\nvar ErrWriter io.Writer = os.Stderr\n\n// MultiError is an error that wraps multiple errors.\ntype MultiError struct {\n\tErrors []error\n}\n\n// NewMultiError creates a new MultiError. Pass in one or more errors.\nfunc NewMultiError(err ...error) MultiError {\n\treturn MultiError{Errors: err}\n}\n\n// Error implements the error interface.\nfunc (m MultiError) Error() string {\n\terrs := make([]string, len(m.Errors))\n\tfor i, err := range m.Errors {\n\t\terrs[i] = err.Error()\n\t}\n\n\treturn strings.Join(errs, \"\\n\")\n}\n\ntype ErrorFormatter interface {\n\tFormat(s fmt.State, verb rune)\n}\n\n// ExitCoder is the interface checked by `App` and `Command` for a custom exit\n// code\ntype ExitCoder interface {\n\terror\n\tExitCode() int\n}\n\n// ExitError fulfills both the builtin `error` interface and `ExitCoder`\ntype ExitError struct {\n\texitCode int\n\tmessage  interface{}\n}\n\n// NewExitError makes a new *ExitError\nfunc NewExitError(message interface{}, exitCode int) *ExitError {\n\treturn &ExitError{\n\t\texitCode: exitCode,\n\t\tmessage:  message,\n\t}\n}\n\n// Error returns the string message, fulfilling the interface required by\n// `error`\nfunc (ee *ExitError) Error() string {\n\treturn fmt.Sprintf(\"%v\", ee.message)\n}\n\n// ExitCode returns the exit code, fulfilling the interface required by\n// `ExitCoder`\nfunc (ee *ExitError) ExitCode() int {\n\treturn ee.exitCode\n}\n\n// HandleExitCoder checks if the error fulfills the ExitCoder interface, and if\n// so prints the error to stderr (if it is non-empty) and calls OsExiter with the\n// given exit code.  If the given error is a MultiError, then this func is\n// called on all members of the Errors slice and calls OsExiter with the last exit code.\nfunc HandleExitCoder(err error) {\n\tif err == nil {\n\t\treturn\n\t}\n\n\tif exitErr, ok := err.(ExitCoder); ok {\n\t\tif err.Error() != \"\" {\n\t\t\tif _, ok := exitErr.(ErrorFormatter); ok {\n\t\t\t\tfmt.Fprintf(ErrWriter, \"%+v\\n\", err)\n\t\t\t} else {\n\t\t\t\tfmt.Fprintln(ErrWriter, err)\n\t\t\t}\n\t\t}\n\t\tOsExiter(exitErr.ExitCode())\n\t\treturn\n\t}\n\n\tif multiErr, ok := err.(MultiError); ok {\n\t\tcode := handleMultiError(multiErr)\n\t\tOsExiter(code)\n\t\treturn\n\t}\n}\n\nfunc handleMultiError(multiErr MultiError) int {\n\tcode := 1\n\tfor _, merr := range multiErr.Errors {\n\t\tif multiErr2, ok := merr.(MultiError); ok {\n\t\t\tcode = handleMultiError(multiErr2)\n\t\t} else {\n\t\t\tfmt.Fprintln(ErrWriter, merr)\n\t\t\tif exitErr, ok := merr.(ExitCoder); ok {\n\t\t\t\tcode = exitErr.ExitCode()\n\t\t\t}\n\t\t}\n\t}\n\treturn code\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/errors_test.go",
    "content": "package cli\n\nimport (\n\t\"bytes\"\n\t\"errors\"\n\t\"fmt\"\n\t\"testing\"\n)\n\nfunc TestHandleExitCoder_nil(t *testing.T) {\n\texitCode := 0\n\tcalled := false\n\n\tOsExiter = func(rc int) {\n\t\tif !called {\n\t\t\texitCode = rc\n\t\t\tcalled = true\n\t\t}\n\t}\n\n\tdefer func() { OsExiter = fakeOsExiter }()\n\n\tHandleExitCoder(nil)\n\n\texpect(t, exitCode, 0)\n\texpect(t, called, false)\n}\n\nfunc TestHandleExitCoder_ExitCoder(t *testing.T) {\n\texitCode := 0\n\tcalled := false\n\n\tOsExiter = func(rc int) {\n\t\tif !called {\n\t\t\texitCode = rc\n\t\t\tcalled = true\n\t\t}\n\t}\n\n\tdefer func() { OsExiter = fakeOsExiter }()\n\n\tHandleExitCoder(NewExitError(\"galactic perimeter breach\", 9))\n\n\texpect(t, exitCode, 9)\n\texpect(t, called, true)\n}\n\nfunc TestHandleExitCoder_MultiErrorWithExitCoder(t *testing.T) {\n\texitCode := 0\n\tcalled := false\n\n\tOsExiter = func(rc int) {\n\t\tif !called {\n\t\t\texitCode = rc\n\t\t\tcalled = true\n\t\t}\n\t}\n\n\tdefer func() { OsExiter = fakeOsExiter }()\n\n\texitErr := NewExitError(\"galactic perimeter breach\", 9)\n\texitErr2 := NewExitError(\"last ExitCoder\", 11)\n\terr := NewMultiError(errors.New(\"wowsa\"), errors.New(\"egad\"), exitErr, exitErr2)\n\tHandleExitCoder(err)\n\n\texpect(t, exitCode, 11)\n\texpect(t, called, true)\n}\n\n// make a stub to not import pkg/errors\ntype ErrorWithFormat struct {\n\terror\n}\n\nfunc NewErrorWithFormat(m string) *ErrorWithFormat {\n\treturn &ErrorWithFormat{error: errors.New(m)}\n}\n\nfunc (f *ErrorWithFormat) Format(s fmt.State, verb rune) {\n\tfmt.Fprintf(s, \"This the format: %v\", f.error)\n}\n\nfunc TestHandleExitCoder_ErrorWithFormat(t *testing.T) {\n\tcalled := false\n\n\tOsExiter = func(rc int) {\n\t\tif !called {\n\t\t\tcalled = true\n\t\t}\n\t}\n\tErrWriter = &bytes.Buffer{}\n\n\tdefer func() {\n\t\tOsExiter = fakeOsExiter\n\t\tErrWriter = fakeErrWriter\n\t}()\n\n\terr := NewExitError(NewErrorWithFormat(\"I am formatted\"), 1)\n\tHandleExitCoder(err)\n\n\texpect(t, called, true)\n\texpect(t, ErrWriter.(*bytes.Buffer).String(), \"This the format: I am formatted\\n\")\n}\n\nfunc TestHandleExitCoder_MultiErrorWithFormat(t *testing.T) {\n\tcalled := false\n\n\tOsExiter = func(rc int) {\n\t\tif !called {\n\t\t\tcalled = true\n\t\t}\n\t}\n\tErrWriter = &bytes.Buffer{}\n\n\tdefer func() { OsExiter = fakeOsExiter }()\n\n\terr := NewMultiError(NewErrorWithFormat(\"err1\"), NewErrorWithFormat(\"err2\"))\n\tHandleExitCoder(err)\n\n\texpect(t, called, true)\n\texpect(t, ErrWriter.(*bytes.Buffer).String(), \"This the format: err1\\nThis the format: err2\\n\")\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/flag-types.json",
    "content": "[\n  {\n    \"name\": \"Bool\",\n    \"type\": \"bool\",\n    \"value\": false,\n    \"context_default\": \"false\",\n    \"parser\": \"strconv.ParseBool(f.Value.String())\"\n  },\n  {\n    \"name\": \"BoolT\",\n    \"type\": \"bool\",\n    \"value\": false,\n    \"doctail\": \" that is true by default\",\n    \"context_default\": \"false\",\n    \"parser\": \"strconv.ParseBool(f.Value.String())\"\n  },\n  {\n    \"name\": \"Duration\",\n    \"type\": \"time.Duration\",\n    \"doctail\": \" (see https://golang.org/pkg/time/#ParseDuration)\",\n    \"context_default\": \"0\",\n    \"parser\": \"time.ParseDuration(f.Value.String())\"\n  },\n  {\n    \"name\": \"Float64\",\n    \"type\": \"float64\",\n    \"context_default\": \"0\",\n    \"parser\": \"strconv.ParseFloat(f.Value.String(), 64)\"\n  },\n  {\n    \"name\": \"Generic\",\n    \"type\": \"Generic\",\n    \"dest\": false,\n    \"context_default\": \"nil\",\n    \"context_type\": \"interface{}\"\n  },\n  {\n    \"name\": \"Int64\",\n    \"type\": \"int64\",\n    \"context_default\": \"0\",\n    \"parser\": \"strconv.ParseInt(f.Value.String(), 0, 64)\"\n  },\n  {\n    \"name\": \"Int\",\n    \"type\": \"int\",\n    \"context_default\": \"0\",\n    \"parser\": \"strconv.ParseInt(f.Value.String(), 0, 64)\",\n    \"parser_cast\": \"int(parsed)\"\n  },\n  {\n    \"name\": \"IntSlice\",\n    \"type\": \"*IntSlice\",\n    \"dest\": false,\n    \"context_default\": \"nil\",\n    \"context_type\": \"[]int\",\n    \"parser\": \"(f.Value.(*IntSlice)).Value(), error(nil)\"\n  },\n  {\n    \"name\": \"Int64Slice\",\n    \"type\": \"*Int64Slice\",\n    \"dest\": false,\n    \"context_default\": \"nil\",\n    \"context_type\": \"[]int64\",\n    \"parser\": \"(f.Value.(*Int64Slice)).Value(), error(nil)\"\n  },\n  {\n    \"name\": \"String\",\n    \"type\": \"string\",\n    \"context_default\": \"\\\"\\\"\",\n    \"parser\": \"f.Value.String(), error(nil)\"\n  },\n  {\n    \"name\": \"StringSlice\",\n    \"type\": \"*StringSlice\",\n    \"dest\": false,\n    \"context_default\": \"nil\",\n    \"context_type\": \"[]string\",\n    \"parser\": \"(f.Value.(*StringSlice)).Value(), error(nil)\"\n  },\n  {\n    \"name\": \"Uint64\",\n    \"type\": \"uint64\",\n    \"context_default\": \"0\",\n    \"parser\": \"strconv.ParseUint(f.Value.String(), 0, 64)\"\n  },\n  {\n    \"name\": \"Uint\",\n    \"type\": \"uint\",\n    \"context_default\": \"0\",\n    \"parser\": \"strconv.ParseUint(f.Value.String(), 0, 64)\",\n    \"parser_cast\": \"uint(parsed)\"\n  }\n]\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/flag.go",
    "content": "package cli\n\nimport (\n\t\"flag\"\n\t\"fmt\"\n\t\"reflect\"\n\t\"runtime\"\n\t\"strconv\"\n\t\"strings\"\n\t\"syscall\"\n\t\"time\"\n)\n\nconst defaultPlaceholder = \"value\"\n\n// BashCompletionFlag enables bash-completion for all commands and subcommands\nvar BashCompletionFlag Flag = BoolFlag{\n\tName:   \"generate-bash-completion\",\n\tHidden: true,\n}\n\n// VersionFlag prints the version for the application\nvar VersionFlag Flag = BoolFlag{\n\tName:  \"version, v\",\n\tUsage: \"print the version\",\n}\n\n// HelpFlag prints the help for all commands and subcommands\n// Set to the zero value (BoolFlag{}) to disable flag -- keeps subcommand\n// unless HideHelp is set to true)\nvar HelpFlag Flag = BoolFlag{\n\tName:  \"help, h\",\n\tUsage: \"show help\",\n}\n\n// FlagStringer converts a flag definition to a string. This is used by help\n// to display a flag.\nvar FlagStringer FlagStringFunc = stringifyFlag\n\n// FlagsByName is a slice of Flag.\ntype FlagsByName []Flag\n\nfunc (f FlagsByName) Len() int {\n\treturn len(f)\n}\n\nfunc (f FlagsByName) Less(i, j int) bool {\n\treturn f[i].GetName() < f[j].GetName()\n}\n\nfunc (f FlagsByName) Swap(i, j int) {\n\tf[i], f[j] = f[j], f[i]\n}\n\n// Flag is a common interface related to parsing flags in cli.\n// For more advanced flag parsing techniques, it is recommended that\n// this interface be implemented.\ntype Flag interface {\n\tfmt.Stringer\n\t// Apply Flag settings to the given flag set\n\tApply(*flag.FlagSet)\n\tGetName() string\n}\n\n// errorableFlag is an interface that allows us to return errors during apply\n// it allows flags defined in this library to return errors in a fashion backwards compatible\n// TODO remove in v2 and modify the existing Flag interface to return errors\ntype errorableFlag interface {\n\tFlag\n\n\tApplyWithError(*flag.FlagSet) error\n}\n\nfunc flagSet(name string, flags []Flag) (*flag.FlagSet, error) {\n\tset := flag.NewFlagSet(name, flag.ContinueOnError)\n\n\tfor _, f := range flags {\n\t\t//TODO remove in v2 when errorableFlag is removed\n\t\tif ef, ok := f.(errorableFlag); ok {\n\t\t\tif err := ef.ApplyWithError(set); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t} else {\n\t\t\tf.Apply(set)\n\t\t}\n\t}\n\treturn set, nil\n}\n\nfunc eachName(longName string, fn func(string)) {\n\tparts := strings.Split(longName, \",\")\n\tfor _, name := range parts {\n\t\tname = strings.Trim(name, \" \")\n\t\tfn(name)\n\t}\n}\n\n// Generic is a generic parseable type identified by a specific flag\ntype Generic interface {\n\tSet(value string) error\n\tString() string\n}\n\n// Apply takes the flagset and calls Set on the generic flag with the value\n// provided by the user for parsing by the flag\n// Ignores parsing errors\nfunc (f GenericFlag) Apply(set *flag.FlagSet) {\n\tf.ApplyWithError(set)\n}\n\n// ApplyWithError takes the flagset and calls Set on the generic flag with the value\n// provided by the user for parsing by the flag\nfunc (f GenericFlag) ApplyWithError(set *flag.FlagSet) error {\n\tval := f.Value\n\tif f.EnvVar != \"\" {\n\t\tfor _, envVar := range strings.Split(f.EnvVar, \",\") {\n\t\t\tenvVar = strings.TrimSpace(envVar)\n\t\t\tif envVal, ok := syscall.Getenv(envVar); ok {\n\t\t\t\tif err := val.Set(envVal); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"could not parse %s as value for flag %s: %s\", envVal, f.Name, err)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\teachName(f.Name, func(name string) {\n\t\tset.Var(f.Value, name, f.Usage)\n\t})\n\n\treturn nil\n}\n\n// StringSlice is an opaque type for []string to satisfy flag.Value and flag.Getter\ntype StringSlice []string\n\n// Set appends the string value to the list of values\nfunc (f *StringSlice) Set(value string) error {\n\t*f = append(*f, value)\n\treturn nil\n}\n\n// String returns a readable representation of this value (for usage defaults)\nfunc (f *StringSlice) String() string {\n\treturn fmt.Sprintf(\"%s\", *f)\n}\n\n// Value returns the slice of strings set by this flag\nfunc (f *StringSlice) Value() []string {\n\treturn *f\n}\n\n// Get returns the slice of strings set by this flag\nfunc (f *StringSlice) Get() interface{} {\n\treturn *f\n}\n\n// Apply populates the flag given the flag set and environment\n// Ignores errors\nfunc (f StringSliceFlag) Apply(set *flag.FlagSet) {\n\tf.ApplyWithError(set)\n}\n\n// ApplyWithError populates the flag given the flag set and environment\nfunc (f StringSliceFlag) ApplyWithError(set *flag.FlagSet) error {\n\tif f.EnvVar != \"\" {\n\t\tfor _, envVar := range strings.Split(f.EnvVar, \",\") {\n\t\t\tenvVar = strings.TrimSpace(envVar)\n\t\t\tif envVal, ok := syscall.Getenv(envVar); ok {\n\t\t\t\tnewVal := &StringSlice{}\n\t\t\t\tfor _, s := range strings.Split(envVal, \",\") {\n\t\t\t\t\ts = strings.TrimSpace(s)\n\t\t\t\t\tif err := newVal.Set(s); err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"could not parse %s as string value for flag %s: %s\", envVal, f.Name, err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tf.Value = newVal\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\teachName(f.Name, func(name string) {\n\t\tif f.Value == nil {\n\t\t\tf.Value = &StringSlice{}\n\t\t}\n\t\tset.Var(f.Value, name, f.Usage)\n\t})\n\n\treturn nil\n}\n\n// IntSlice is an opaque type for []int to satisfy flag.Value and flag.Getter\ntype IntSlice []int\n\n// Set parses the value into an integer and appends it to the list of values\nfunc (f *IntSlice) Set(value string) error {\n\ttmp, err := strconv.Atoi(value)\n\tif err != nil {\n\t\treturn err\n\t}\n\t*f = append(*f, tmp)\n\treturn nil\n}\n\n// String returns a readable representation of this value (for usage defaults)\nfunc (f *IntSlice) String() string {\n\treturn fmt.Sprintf(\"%#v\", *f)\n}\n\n// Value returns the slice of ints set by this flag\nfunc (f *IntSlice) Value() []int {\n\treturn *f\n}\n\n// Get returns the slice of ints set by this flag\nfunc (f *IntSlice) Get() interface{} {\n\treturn *f\n}\n\n// Apply populates the flag given the flag set and environment\n// Ignores errors\nfunc (f IntSliceFlag) Apply(set *flag.FlagSet) {\n\tf.ApplyWithError(set)\n}\n\n// ApplyWithError populates the flag given the flag set and environment\nfunc (f IntSliceFlag) ApplyWithError(set *flag.FlagSet) error {\n\tif f.EnvVar != \"\" {\n\t\tfor _, envVar := range strings.Split(f.EnvVar, \",\") {\n\t\t\tenvVar = strings.TrimSpace(envVar)\n\t\t\tif envVal, ok := syscall.Getenv(envVar); ok {\n\t\t\t\tnewVal := &IntSlice{}\n\t\t\t\tfor _, s := range strings.Split(envVal, \",\") {\n\t\t\t\t\ts = strings.TrimSpace(s)\n\t\t\t\t\tif err := newVal.Set(s); err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"could not parse %s as int slice value for flag %s: %s\", envVal, f.Name, err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tf.Value = newVal\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\teachName(f.Name, func(name string) {\n\t\tif f.Value == nil {\n\t\t\tf.Value = &IntSlice{}\n\t\t}\n\t\tset.Var(f.Value, name, f.Usage)\n\t})\n\n\treturn nil\n}\n\n// Int64Slice is an opaque type for []int to satisfy flag.Value and flag.Getter\ntype Int64Slice []int64\n\n// Set parses the value into an integer and appends it to the list of values\nfunc (f *Int64Slice) Set(value string) error {\n\ttmp, err := strconv.ParseInt(value, 10, 64)\n\tif err != nil {\n\t\treturn err\n\t}\n\t*f = append(*f, tmp)\n\treturn nil\n}\n\n// String returns a readable representation of this value (for usage defaults)\nfunc (f *Int64Slice) String() string {\n\treturn fmt.Sprintf(\"%#v\", *f)\n}\n\n// Value returns the slice of ints set by this flag\nfunc (f *Int64Slice) Value() []int64 {\n\treturn *f\n}\n\n// Get returns the slice of ints set by this flag\nfunc (f *Int64Slice) Get() interface{} {\n\treturn *f\n}\n\n// Apply populates the flag given the flag set and environment\n// Ignores errors\nfunc (f Int64SliceFlag) Apply(set *flag.FlagSet) {\n\tf.ApplyWithError(set)\n}\n\n// ApplyWithError populates the flag given the flag set and environment\nfunc (f Int64SliceFlag) ApplyWithError(set *flag.FlagSet) error {\n\tif f.EnvVar != \"\" {\n\t\tfor _, envVar := range strings.Split(f.EnvVar, \",\") {\n\t\t\tenvVar = strings.TrimSpace(envVar)\n\t\t\tif envVal, ok := syscall.Getenv(envVar); ok {\n\t\t\t\tnewVal := &Int64Slice{}\n\t\t\t\tfor _, s := range strings.Split(envVal, \",\") {\n\t\t\t\t\ts = strings.TrimSpace(s)\n\t\t\t\t\tif err := newVal.Set(s); err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"could not parse %s as int64 slice value for flag %s: %s\", envVal, f.Name, err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tf.Value = newVal\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\teachName(f.Name, func(name string) {\n\t\tif f.Value == nil {\n\t\t\tf.Value = &Int64Slice{}\n\t\t}\n\t\tset.Var(f.Value, name, f.Usage)\n\t})\n\treturn nil\n}\n\n// Apply populates the flag given the flag set and environment\n// Ignores errors\nfunc (f BoolFlag) Apply(set *flag.FlagSet) {\n\tf.ApplyWithError(set)\n}\n\n// ApplyWithError populates the flag given the flag set and environment\nfunc (f BoolFlag) ApplyWithError(set *flag.FlagSet) error {\n\tval := false\n\tif f.EnvVar != \"\" {\n\t\tfor _, envVar := range strings.Split(f.EnvVar, \",\") {\n\t\t\tenvVar = strings.TrimSpace(envVar)\n\t\t\tif envVal, ok := syscall.Getenv(envVar); ok {\n\t\t\t\tif envVal == \"\" {\n\t\t\t\t\tval = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tenvValBool, err := strconv.ParseBool(envVal)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"could not parse %s as bool value for flag %s: %s\", envVal, f.Name, err)\n\t\t\t\t}\n\n\t\t\t\tval = envValBool\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\teachName(f.Name, func(name string) {\n\t\tif f.Destination != nil {\n\t\t\tset.BoolVar(f.Destination, name, val, f.Usage)\n\t\t\treturn\n\t\t}\n\t\tset.Bool(name, val, f.Usage)\n\t})\n\n\treturn nil\n}\n\n// Apply populates the flag given the flag set and environment\n// Ignores errors\nfunc (f BoolTFlag) Apply(set *flag.FlagSet) {\n\tf.ApplyWithError(set)\n}\n\n// ApplyWithError populates the flag given the flag set and environment\nfunc (f BoolTFlag) ApplyWithError(set *flag.FlagSet) error {\n\tval := true\n\tif f.EnvVar != \"\" {\n\t\tfor _, envVar := range strings.Split(f.EnvVar, \",\") {\n\t\t\tenvVar = strings.TrimSpace(envVar)\n\t\t\tif envVal, ok := syscall.Getenv(envVar); ok {\n\t\t\t\tif envVal == \"\" {\n\t\t\t\t\tval = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tenvValBool, err := strconv.ParseBool(envVal)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"could not parse %s as bool value for flag %s: %s\", envVal, f.Name, err)\n\t\t\t\t}\n\n\t\t\t\tval = envValBool\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\teachName(f.Name, func(name string) {\n\t\tif f.Destination != nil {\n\t\t\tset.BoolVar(f.Destination, name, val, f.Usage)\n\t\t\treturn\n\t\t}\n\t\tset.Bool(name, val, f.Usage)\n\t})\n\n\treturn nil\n}\n\n// Apply populates the flag given the flag set and environment\n// Ignores errors\nfunc (f StringFlag) Apply(set *flag.FlagSet) {\n\tf.ApplyWithError(set)\n}\n\n// ApplyWithError populates the flag given the flag set and environment\nfunc (f StringFlag) ApplyWithError(set *flag.FlagSet) error {\n\tif f.EnvVar != \"\" {\n\t\tfor _, envVar := range strings.Split(f.EnvVar, \",\") {\n\t\t\tenvVar = strings.TrimSpace(envVar)\n\t\t\tif envVal, ok := syscall.Getenv(envVar); ok {\n\t\t\t\tf.Value = envVal\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\teachName(f.Name, func(name string) {\n\t\tif f.Destination != nil {\n\t\t\tset.StringVar(f.Destination, name, f.Value, f.Usage)\n\t\t\treturn\n\t\t}\n\t\tset.String(name, f.Value, f.Usage)\n\t})\n\n\treturn nil\n}\n\n// Apply populates the flag given the flag set and environment\n// Ignores errors\nfunc (f IntFlag) Apply(set *flag.FlagSet) {\n\tf.ApplyWithError(set)\n}\n\n// ApplyWithError populates the flag given the flag set and environment\nfunc (f IntFlag) ApplyWithError(set *flag.FlagSet) error {\n\tif f.EnvVar != \"\" {\n\t\tfor _, envVar := range strings.Split(f.EnvVar, \",\") {\n\t\t\tenvVar = strings.TrimSpace(envVar)\n\t\t\tif envVal, ok := syscall.Getenv(envVar); ok {\n\t\t\t\tenvValInt, err := strconv.ParseInt(envVal, 0, 64)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"could not parse %s as int value for flag %s: %s\", envVal, f.Name, err)\n\t\t\t\t}\n\t\t\t\tf.Value = int(envValInt)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\teachName(f.Name, func(name string) {\n\t\tif f.Destination != nil {\n\t\t\tset.IntVar(f.Destination, name, f.Value, f.Usage)\n\t\t\treturn\n\t\t}\n\t\tset.Int(name, f.Value, f.Usage)\n\t})\n\n\treturn nil\n}\n\n// Apply populates the flag given the flag set and environment\n// Ignores errors\nfunc (f Int64Flag) Apply(set *flag.FlagSet) {\n\tf.ApplyWithError(set)\n}\n\n// ApplyWithError populates the flag given the flag set and environment\nfunc (f Int64Flag) ApplyWithError(set *flag.FlagSet) error {\n\tif f.EnvVar != \"\" {\n\t\tfor _, envVar := range strings.Split(f.EnvVar, \",\") {\n\t\t\tenvVar = strings.TrimSpace(envVar)\n\t\t\tif envVal, ok := syscall.Getenv(envVar); ok {\n\t\t\t\tenvValInt, err := strconv.ParseInt(envVal, 0, 64)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"could not parse %s as int value for flag %s: %s\", envVal, f.Name, err)\n\t\t\t\t}\n\n\t\t\t\tf.Value = envValInt\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\teachName(f.Name, func(name string) {\n\t\tif f.Destination != nil {\n\t\t\tset.Int64Var(f.Destination, name, f.Value, f.Usage)\n\t\t\treturn\n\t\t}\n\t\tset.Int64(name, f.Value, f.Usage)\n\t})\n\n\treturn nil\n}\n\n// Apply populates the flag given the flag set and environment\n// Ignores errors\nfunc (f UintFlag) Apply(set *flag.FlagSet) {\n\tf.ApplyWithError(set)\n}\n\n// ApplyWithError populates the flag given the flag set and environment\nfunc (f UintFlag) ApplyWithError(set *flag.FlagSet) error {\n\tif f.EnvVar != \"\" {\n\t\tfor _, envVar := range strings.Split(f.EnvVar, \",\") {\n\t\t\tenvVar = strings.TrimSpace(envVar)\n\t\t\tif envVal, ok := syscall.Getenv(envVar); ok {\n\t\t\t\tenvValInt, err := strconv.ParseUint(envVal, 0, 64)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"could not parse %s as uint value for flag %s: %s\", envVal, f.Name, err)\n\t\t\t\t}\n\n\t\t\t\tf.Value = uint(envValInt)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\teachName(f.Name, func(name string) {\n\t\tif f.Destination != nil {\n\t\t\tset.UintVar(f.Destination, name, f.Value, f.Usage)\n\t\t\treturn\n\t\t}\n\t\tset.Uint(name, f.Value, f.Usage)\n\t})\n\n\treturn nil\n}\n\n// Apply populates the flag given the flag set and environment\n// Ignores errors\nfunc (f Uint64Flag) Apply(set *flag.FlagSet) {\n\tf.ApplyWithError(set)\n}\n\n// ApplyWithError populates the flag given the flag set and environment\nfunc (f Uint64Flag) ApplyWithError(set *flag.FlagSet) error {\n\tif f.EnvVar != \"\" {\n\t\tfor _, envVar := range strings.Split(f.EnvVar, \",\") {\n\t\t\tenvVar = strings.TrimSpace(envVar)\n\t\t\tif envVal, ok := syscall.Getenv(envVar); ok {\n\t\t\t\tenvValInt, err := strconv.ParseUint(envVal, 0, 64)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"could not parse %s as uint64 value for flag %s: %s\", envVal, f.Name, err)\n\t\t\t\t}\n\n\t\t\t\tf.Value = uint64(envValInt)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\teachName(f.Name, func(name string) {\n\t\tif f.Destination != nil {\n\t\t\tset.Uint64Var(f.Destination, name, f.Value, f.Usage)\n\t\t\treturn\n\t\t}\n\t\tset.Uint64(name, f.Value, f.Usage)\n\t})\n\n\treturn nil\n}\n\n// Apply populates the flag given the flag set and environment\n// Ignores errors\nfunc (f DurationFlag) Apply(set *flag.FlagSet) {\n\tf.ApplyWithError(set)\n}\n\n// ApplyWithError populates the flag given the flag set and environment\nfunc (f DurationFlag) ApplyWithError(set *flag.FlagSet) error {\n\tif f.EnvVar != \"\" {\n\t\tfor _, envVar := range strings.Split(f.EnvVar, \",\") {\n\t\t\tenvVar = strings.TrimSpace(envVar)\n\t\t\tif envVal, ok := syscall.Getenv(envVar); ok {\n\t\t\t\tenvValDuration, err := time.ParseDuration(envVal)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"could not parse %s as duration for flag %s: %s\", envVal, f.Name, err)\n\t\t\t\t}\n\n\t\t\t\tf.Value = envValDuration\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\teachName(f.Name, func(name string) {\n\t\tif f.Destination != nil {\n\t\t\tset.DurationVar(f.Destination, name, f.Value, f.Usage)\n\t\t\treturn\n\t\t}\n\t\tset.Duration(name, f.Value, f.Usage)\n\t})\n\n\treturn nil\n}\n\n// Apply populates the flag given the flag set and environment\n// Ignores errors\nfunc (f Float64Flag) Apply(set *flag.FlagSet) {\n\tf.ApplyWithError(set)\n}\n\n// ApplyWithError populates the flag given the flag set and environment\nfunc (f Float64Flag) ApplyWithError(set *flag.FlagSet) error {\n\tif f.EnvVar != \"\" {\n\t\tfor _, envVar := range strings.Split(f.EnvVar, \",\") {\n\t\t\tenvVar = strings.TrimSpace(envVar)\n\t\t\tif envVal, ok := syscall.Getenv(envVar); ok {\n\t\t\t\tenvValFloat, err := strconv.ParseFloat(envVal, 10)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"could not parse %s as float64 value for flag %s: %s\", envVal, f.Name, err)\n\t\t\t\t}\n\n\t\t\t\tf.Value = float64(envValFloat)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\teachName(f.Name, func(name string) {\n\t\tif f.Destination != nil {\n\t\t\tset.Float64Var(f.Destination, name, f.Value, f.Usage)\n\t\t\treturn\n\t\t}\n\t\tset.Float64(name, f.Value, f.Usage)\n\t})\n\n\treturn nil\n}\n\nfunc visibleFlags(fl []Flag) []Flag {\n\tvisible := []Flag{}\n\tfor _, flag := range fl {\n\t\tfield := flagValue(flag).FieldByName(\"Hidden\")\n\t\tif !field.IsValid() || !field.Bool() {\n\t\t\tvisible = append(visible, flag)\n\t\t}\n\t}\n\treturn visible\n}\n\nfunc prefixFor(name string) (prefix string) {\n\tif len(name) == 1 {\n\t\tprefix = \"-\"\n\t} else {\n\t\tprefix = \"--\"\n\t}\n\n\treturn\n}\n\n// Returns the placeholder, if any, and the unquoted usage string.\nfunc unquoteUsage(usage string) (string, string) {\n\tfor i := 0; i < len(usage); i++ {\n\t\tif usage[i] == '`' {\n\t\t\tfor j := i + 1; j < len(usage); j++ {\n\t\t\t\tif usage[j] == '`' {\n\t\t\t\t\tname := usage[i+1 : j]\n\t\t\t\t\tusage = usage[:i] + name + usage[j+1:]\n\t\t\t\t\treturn name, usage\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\treturn \"\", usage\n}\n\nfunc prefixedNames(fullName, placeholder string) string {\n\tvar prefixed string\n\tparts := strings.Split(fullName, \",\")\n\tfor i, name := range parts {\n\t\tname = strings.Trim(name, \" \")\n\t\tprefixed += prefixFor(name) + name\n\t\tif placeholder != \"\" {\n\t\t\tprefixed += \" \" + placeholder\n\t\t}\n\t\tif i < len(parts)-1 {\n\t\t\tprefixed += \", \"\n\t\t}\n\t}\n\treturn prefixed\n}\n\nfunc withEnvHint(envVar, str string) string {\n\tenvText := \"\"\n\tif envVar != \"\" {\n\t\tprefix := \"$\"\n\t\tsuffix := \"\"\n\t\tsep := \", $\"\n\t\tif runtime.GOOS == \"windows\" {\n\t\t\tprefix = \"%\"\n\t\t\tsuffix = \"%\"\n\t\t\tsep = \"%, %\"\n\t\t}\n\t\tenvText = fmt.Sprintf(\" [%s%s%s]\", prefix, strings.Join(strings.Split(envVar, \",\"), sep), suffix)\n\t}\n\treturn str + envText\n}\n\nfunc flagValue(f Flag) reflect.Value {\n\tfv := reflect.ValueOf(f)\n\tfor fv.Kind() == reflect.Ptr {\n\t\tfv = reflect.Indirect(fv)\n\t}\n\treturn fv\n}\n\nfunc stringifyFlag(f Flag) string {\n\tfv := flagValue(f)\n\n\tswitch f.(type) {\n\tcase IntSliceFlag:\n\t\treturn withEnvHint(fv.FieldByName(\"EnvVar\").String(),\n\t\t\tstringifyIntSliceFlag(f.(IntSliceFlag)))\n\tcase Int64SliceFlag:\n\t\treturn withEnvHint(fv.FieldByName(\"EnvVar\").String(),\n\t\t\tstringifyInt64SliceFlag(f.(Int64SliceFlag)))\n\tcase StringSliceFlag:\n\t\treturn withEnvHint(fv.FieldByName(\"EnvVar\").String(),\n\t\t\tstringifyStringSliceFlag(f.(StringSliceFlag)))\n\t}\n\n\tplaceholder, usage := unquoteUsage(fv.FieldByName(\"Usage\").String())\n\n\tneedsPlaceholder := false\n\tdefaultValueString := \"\"\n\n\tif val := fv.FieldByName(\"Value\"); val.IsValid() {\n\t\tneedsPlaceholder = true\n\t\tdefaultValueString = fmt.Sprintf(\" (default: %v)\", val.Interface())\n\n\t\tif val.Kind() == reflect.String && val.String() != \"\" {\n\t\t\tdefaultValueString = fmt.Sprintf(\" (default: %q)\", val.String())\n\t\t}\n\t}\n\n\tif defaultValueString == \" (default: )\" {\n\t\tdefaultValueString = \"\"\n\t}\n\n\tif needsPlaceholder && placeholder == \"\" {\n\t\tplaceholder = defaultPlaceholder\n\t}\n\n\tusageWithDefault := strings.TrimSpace(fmt.Sprintf(\"%s%s\", usage, defaultValueString))\n\n\treturn withEnvHint(fv.FieldByName(\"EnvVar\").String(),\n\t\tfmt.Sprintf(\"%s\\t%s\", prefixedNames(fv.FieldByName(\"Name\").String(), placeholder), usageWithDefault))\n}\n\nfunc stringifyIntSliceFlag(f IntSliceFlag) string {\n\tdefaultVals := []string{}\n\tif f.Value != nil && len(f.Value.Value()) > 0 {\n\t\tfor _, i := range f.Value.Value() {\n\t\t\tdefaultVals = append(defaultVals, fmt.Sprintf(\"%d\", i))\n\t\t}\n\t}\n\n\treturn stringifySliceFlag(f.Usage, f.Name, defaultVals)\n}\n\nfunc stringifyInt64SliceFlag(f Int64SliceFlag) string {\n\tdefaultVals := []string{}\n\tif f.Value != nil && len(f.Value.Value()) > 0 {\n\t\tfor _, i := range f.Value.Value() {\n\t\t\tdefaultVals = append(defaultVals, fmt.Sprintf(\"%d\", i))\n\t\t}\n\t}\n\n\treturn stringifySliceFlag(f.Usage, f.Name, defaultVals)\n}\n\nfunc stringifyStringSliceFlag(f StringSliceFlag) string {\n\tdefaultVals := []string{}\n\tif f.Value != nil && len(f.Value.Value()) > 0 {\n\t\tfor _, s := range f.Value.Value() {\n\t\t\tif len(s) > 0 {\n\t\t\t\tdefaultVals = append(defaultVals, fmt.Sprintf(\"%q\", s))\n\t\t\t}\n\t\t}\n\t}\n\n\treturn stringifySliceFlag(f.Usage, f.Name, defaultVals)\n}\n\nfunc stringifySliceFlag(usage, name string, defaultVals []string) string {\n\tplaceholder, usage := unquoteUsage(usage)\n\tif placeholder == \"\" {\n\t\tplaceholder = defaultPlaceholder\n\t}\n\n\tdefaultVal := \"\"\n\tif len(defaultVals) > 0 {\n\t\tdefaultVal = fmt.Sprintf(\" (default: %s)\", strings.Join(defaultVals, \", \"))\n\t}\n\n\tusageWithDefault := strings.TrimSpace(fmt.Sprintf(\"%s%s\", usage, defaultVal))\n\treturn fmt.Sprintf(\"%s\\t%s\", prefixedNames(name, placeholder), usageWithDefault)\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/flag_generated.go",
    "content": "package cli\n\nimport (\n\t\"flag\"\n\t\"strconv\"\n\t\"time\"\n)\n\n// WARNING: This file is generated!\n\n// BoolFlag is a flag with type bool\ntype BoolFlag struct {\n\tName        string\n\tUsage       string\n\tEnvVar      string\n\tHidden      bool\n\tDestination *bool\n}\n\n// String returns a readable representation of this value\n// (for usage defaults)\nfunc (f BoolFlag) String() string {\n\treturn FlagStringer(f)\n}\n\n// GetName returns the name of the flag\nfunc (f BoolFlag) GetName() string {\n\treturn f.Name\n}\n\n// Bool looks up the value of a local BoolFlag, returns\n// false if not found\nfunc (c *Context) Bool(name string) bool {\n\treturn lookupBool(name, c.flagSet)\n}\n\n// GlobalBool looks up the value of a global BoolFlag, returns\n// false if not found\nfunc (c *Context) GlobalBool(name string) bool {\n\tif fs := lookupGlobalFlagSet(name, c); fs != nil {\n\t\treturn lookupBool(name, fs)\n\t}\n\treturn false\n}\n\nfunc lookupBool(name string, set *flag.FlagSet) bool {\n\tf := set.Lookup(name)\n\tif f != nil {\n\t\tparsed, err := strconv.ParseBool(f.Value.String())\n\t\tif err != nil {\n\t\t\treturn false\n\t\t}\n\t\treturn parsed\n\t}\n\treturn false\n}\n\n// BoolTFlag is a flag with type bool that is true by default\ntype BoolTFlag struct {\n\tName        string\n\tUsage       string\n\tEnvVar      string\n\tHidden      bool\n\tDestination *bool\n}\n\n// String returns a readable representation of this value\n// (for usage defaults)\nfunc (f BoolTFlag) String() string {\n\treturn FlagStringer(f)\n}\n\n// GetName returns the name of the flag\nfunc (f BoolTFlag) GetName() string {\n\treturn f.Name\n}\n\n// BoolT looks up the value of a local BoolTFlag, returns\n// false if not found\nfunc (c *Context) BoolT(name string) bool {\n\treturn lookupBoolT(name, c.flagSet)\n}\n\n// GlobalBoolT looks up the value of a global BoolTFlag, returns\n// false if not found\nfunc (c *Context) GlobalBoolT(name string) bool {\n\tif fs := lookupGlobalFlagSet(name, c); fs != nil {\n\t\treturn lookupBoolT(name, fs)\n\t}\n\treturn false\n}\n\nfunc lookupBoolT(name string, set *flag.FlagSet) bool {\n\tf := set.Lookup(name)\n\tif f != nil {\n\t\tparsed, err := strconv.ParseBool(f.Value.String())\n\t\tif err != nil {\n\t\t\treturn false\n\t\t}\n\t\treturn parsed\n\t}\n\treturn false\n}\n\n// DurationFlag is a flag with type time.Duration (see https://golang.org/pkg/time/#ParseDuration)\ntype DurationFlag struct {\n\tName        string\n\tUsage       string\n\tEnvVar      string\n\tHidden      bool\n\tValue       time.Duration\n\tDestination *time.Duration\n}\n\n// String returns a readable representation of this value\n// (for usage defaults)\nfunc (f DurationFlag) String() string {\n\treturn FlagStringer(f)\n}\n\n// GetName returns the name of the flag\nfunc (f DurationFlag) GetName() string {\n\treturn f.Name\n}\n\n// Duration looks up the value of a local DurationFlag, returns\n// 0 if not found\nfunc (c *Context) Duration(name string) time.Duration {\n\treturn lookupDuration(name, c.flagSet)\n}\n\n// GlobalDuration looks up the value of a global DurationFlag, returns\n// 0 if not found\nfunc (c *Context) GlobalDuration(name string) time.Duration {\n\tif fs := lookupGlobalFlagSet(name, c); fs != nil {\n\t\treturn lookupDuration(name, fs)\n\t}\n\treturn 0\n}\n\nfunc lookupDuration(name string, set *flag.FlagSet) time.Duration {\n\tf := set.Lookup(name)\n\tif f != nil {\n\t\tparsed, err := time.ParseDuration(f.Value.String())\n\t\tif err != nil {\n\t\t\treturn 0\n\t\t}\n\t\treturn parsed\n\t}\n\treturn 0\n}\n\n// Float64Flag is a flag with type float64\ntype Float64Flag struct {\n\tName        string\n\tUsage       string\n\tEnvVar      string\n\tHidden      bool\n\tValue       float64\n\tDestination *float64\n}\n\n// String returns a readable representation of this value\n// (for usage defaults)\nfunc (f Float64Flag) String() string {\n\treturn FlagStringer(f)\n}\n\n// GetName returns the name of the flag\nfunc (f Float64Flag) GetName() string {\n\treturn f.Name\n}\n\n// Float64 looks up the value of a local Float64Flag, returns\n// 0 if not found\nfunc (c *Context) Float64(name string) float64 {\n\treturn lookupFloat64(name, c.flagSet)\n}\n\n// GlobalFloat64 looks up the value of a global Float64Flag, returns\n// 0 if not found\nfunc (c *Context) GlobalFloat64(name string) float64 {\n\tif fs := lookupGlobalFlagSet(name, c); fs != nil {\n\t\treturn lookupFloat64(name, fs)\n\t}\n\treturn 0\n}\n\nfunc lookupFloat64(name string, set *flag.FlagSet) float64 {\n\tf := set.Lookup(name)\n\tif f != nil {\n\t\tparsed, err := strconv.ParseFloat(f.Value.String(), 64)\n\t\tif err != nil {\n\t\t\treturn 0\n\t\t}\n\t\treturn parsed\n\t}\n\treturn 0\n}\n\n// GenericFlag is a flag with type Generic\ntype GenericFlag struct {\n\tName   string\n\tUsage  string\n\tEnvVar string\n\tHidden bool\n\tValue  Generic\n}\n\n// String returns a readable representation of this value\n// (for usage defaults)\nfunc (f GenericFlag) String() string {\n\treturn FlagStringer(f)\n}\n\n// GetName returns the name of the flag\nfunc (f GenericFlag) GetName() string {\n\treturn f.Name\n}\n\n// Generic looks up the value of a local GenericFlag, returns\n// nil if not found\nfunc (c *Context) Generic(name string) interface{} {\n\treturn lookupGeneric(name, c.flagSet)\n}\n\n// GlobalGeneric looks up the value of a global GenericFlag, returns\n// nil if not found\nfunc (c *Context) GlobalGeneric(name string) interface{} {\n\tif fs := lookupGlobalFlagSet(name, c); fs != nil {\n\t\treturn lookupGeneric(name, fs)\n\t}\n\treturn nil\n}\n\nfunc lookupGeneric(name string, set *flag.FlagSet) interface{} {\n\tf := set.Lookup(name)\n\tif f != nil {\n\t\tparsed, err := f.Value, error(nil)\n\t\tif err != nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn parsed\n\t}\n\treturn nil\n}\n\n// Int64Flag is a flag with type int64\ntype Int64Flag struct {\n\tName        string\n\tUsage       string\n\tEnvVar      string\n\tHidden      bool\n\tValue       int64\n\tDestination *int64\n}\n\n// String returns a readable representation of this value\n// (for usage defaults)\nfunc (f Int64Flag) String() string {\n\treturn FlagStringer(f)\n}\n\n// GetName returns the name of the flag\nfunc (f Int64Flag) GetName() string {\n\treturn f.Name\n}\n\n// Int64 looks up the value of a local Int64Flag, returns\n// 0 if not found\nfunc (c *Context) Int64(name string) int64 {\n\treturn lookupInt64(name, c.flagSet)\n}\n\n// GlobalInt64 looks up the value of a global Int64Flag, returns\n// 0 if not found\nfunc (c *Context) GlobalInt64(name string) int64 {\n\tif fs := lookupGlobalFlagSet(name, c); fs != nil {\n\t\treturn lookupInt64(name, fs)\n\t}\n\treturn 0\n}\n\nfunc lookupInt64(name string, set *flag.FlagSet) int64 {\n\tf := set.Lookup(name)\n\tif f != nil {\n\t\tparsed, err := strconv.ParseInt(f.Value.String(), 0, 64)\n\t\tif err != nil {\n\t\t\treturn 0\n\t\t}\n\t\treturn parsed\n\t}\n\treturn 0\n}\n\n// IntFlag is a flag with type int\ntype IntFlag struct {\n\tName        string\n\tUsage       string\n\tEnvVar      string\n\tHidden      bool\n\tValue       int\n\tDestination *int\n}\n\n// String returns a readable representation of this value\n// (for usage defaults)\nfunc (f IntFlag) String() string {\n\treturn FlagStringer(f)\n}\n\n// GetName returns the name of the flag\nfunc (f IntFlag) GetName() string {\n\treturn f.Name\n}\n\n// Int looks up the value of a local IntFlag, returns\n// 0 if not found\nfunc (c *Context) Int(name string) int {\n\treturn lookupInt(name, c.flagSet)\n}\n\n// GlobalInt looks up the value of a global IntFlag, returns\n// 0 if not found\nfunc (c *Context) GlobalInt(name string) int {\n\tif fs := lookupGlobalFlagSet(name, c); fs != nil {\n\t\treturn lookupInt(name, fs)\n\t}\n\treturn 0\n}\n\nfunc lookupInt(name string, set *flag.FlagSet) int {\n\tf := set.Lookup(name)\n\tif f != nil {\n\t\tparsed, err := strconv.ParseInt(f.Value.String(), 0, 64)\n\t\tif err != nil {\n\t\t\treturn 0\n\t\t}\n\t\treturn int(parsed)\n\t}\n\treturn 0\n}\n\n// IntSliceFlag is a flag with type *IntSlice\ntype IntSliceFlag struct {\n\tName   string\n\tUsage  string\n\tEnvVar string\n\tHidden bool\n\tValue  *IntSlice\n}\n\n// String returns a readable representation of this value\n// (for usage defaults)\nfunc (f IntSliceFlag) String() string {\n\treturn FlagStringer(f)\n}\n\n// GetName returns the name of the flag\nfunc (f IntSliceFlag) GetName() string {\n\treturn f.Name\n}\n\n// IntSlice looks up the value of a local IntSliceFlag, returns\n// nil if not found\nfunc (c *Context) IntSlice(name string) []int {\n\treturn lookupIntSlice(name, c.flagSet)\n}\n\n// GlobalIntSlice looks up the value of a global IntSliceFlag, returns\n// nil if not found\nfunc (c *Context) GlobalIntSlice(name string) []int {\n\tif fs := lookupGlobalFlagSet(name, c); fs != nil {\n\t\treturn lookupIntSlice(name, fs)\n\t}\n\treturn nil\n}\n\nfunc lookupIntSlice(name string, set *flag.FlagSet) []int {\n\tf := set.Lookup(name)\n\tif f != nil {\n\t\tparsed, err := (f.Value.(*IntSlice)).Value(), error(nil)\n\t\tif err != nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn parsed\n\t}\n\treturn nil\n}\n\n// Int64SliceFlag is a flag with type *Int64Slice\ntype Int64SliceFlag struct {\n\tName   string\n\tUsage  string\n\tEnvVar string\n\tHidden bool\n\tValue  *Int64Slice\n}\n\n// String returns a readable representation of this value\n// (for usage defaults)\nfunc (f Int64SliceFlag) String() string {\n\treturn FlagStringer(f)\n}\n\n// GetName returns the name of the flag\nfunc (f Int64SliceFlag) GetName() string {\n\treturn f.Name\n}\n\n// Int64Slice looks up the value of a local Int64SliceFlag, returns\n// nil if not found\nfunc (c *Context) Int64Slice(name string) []int64 {\n\treturn lookupInt64Slice(name, c.flagSet)\n}\n\n// GlobalInt64Slice looks up the value of a global Int64SliceFlag, returns\n// nil if not found\nfunc (c *Context) GlobalInt64Slice(name string) []int64 {\n\tif fs := lookupGlobalFlagSet(name, c); fs != nil {\n\t\treturn lookupInt64Slice(name, fs)\n\t}\n\treturn nil\n}\n\nfunc lookupInt64Slice(name string, set *flag.FlagSet) []int64 {\n\tf := set.Lookup(name)\n\tif f != nil {\n\t\tparsed, err := (f.Value.(*Int64Slice)).Value(), error(nil)\n\t\tif err != nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn parsed\n\t}\n\treturn nil\n}\n\n// StringFlag is a flag with type string\ntype StringFlag struct {\n\tName        string\n\tUsage       string\n\tEnvVar      string\n\tHidden      bool\n\tValue       string\n\tDestination *string\n}\n\n// String returns a readable representation of this value\n// (for usage defaults)\nfunc (f StringFlag) String() string {\n\treturn FlagStringer(f)\n}\n\n// GetName returns the name of the flag\nfunc (f StringFlag) GetName() string {\n\treturn f.Name\n}\n\n// String looks up the value of a local StringFlag, returns\n// \"\" if not found\nfunc (c *Context) String(name string) string {\n\treturn lookupString(name, c.flagSet)\n}\n\n// GlobalString looks up the value of a global StringFlag, returns\n// \"\" if not found\nfunc (c *Context) GlobalString(name string) string {\n\tif fs := lookupGlobalFlagSet(name, c); fs != nil {\n\t\treturn lookupString(name, fs)\n\t}\n\treturn \"\"\n}\n\nfunc lookupString(name string, set *flag.FlagSet) string {\n\tf := set.Lookup(name)\n\tif f != nil {\n\t\tparsed, err := f.Value.String(), error(nil)\n\t\tif err != nil {\n\t\t\treturn \"\"\n\t\t}\n\t\treturn parsed\n\t}\n\treturn \"\"\n}\n\n// StringSliceFlag is a flag with type *StringSlice\ntype StringSliceFlag struct {\n\tName   string\n\tUsage  string\n\tEnvVar string\n\tHidden bool\n\tValue  *StringSlice\n}\n\n// String returns a readable representation of this value\n// (for usage defaults)\nfunc (f StringSliceFlag) String() string {\n\treturn FlagStringer(f)\n}\n\n// GetName returns the name of the flag\nfunc (f StringSliceFlag) GetName() string {\n\treturn f.Name\n}\n\n// StringSlice looks up the value of a local StringSliceFlag, returns\n// nil if not found\nfunc (c *Context) StringSlice(name string) []string {\n\treturn lookupStringSlice(name, c.flagSet)\n}\n\n// GlobalStringSlice looks up the value of a global StringSliceFlag, returns\n// nil if not found\nfunc (c *Context) GlobalStringSlice(name string) []string {\n\tif fs := lookupGlobalFlagSet(name, c); fs != nil {\n\t\treturn lookupStringSlice(name, fs)\n\t}\n\treturn nil\n}\n\nfunc lookupStringSlice(name string, set *flag.FlagSet) []string {\n\tf := set.Lookup(name)\n\tif f != nil {\n\t\tparsed, err := (f.Value.(*StringSlice)).Value(), error(nil)\n\t\tif err != nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn parsed\n\t}\n\treturn nil\n}\n\n// Uint64Flag is a flag with type uint64\ntype Uint64Flag struct {\n\tName        string\n\tUsage       string\n\tEnvVar      string\n\tHidden      bool\n\tValue       uint64\n\tDestination *uint64\n}\n\n// String returns a readable representation of this value\n// (for usage defaults)\nfunc (f Uint64Flag) String() string {\n\treturn FlagStringer(f)\n}\n\n// GetName returns the name of the flag\nfunc (f Uint64Flag) GetName() string {\n\treturn f.Name\n}\n\n// Uint64 looks up the value of a local Uint64Flag, returns\n// 0 if not found\nfunc (c *Context) Uint64(name string) uint64 {\n\treturn lookupUint64(name, c.flagSet)\n}\n\n// GlobalUint64 looks up the value of a global Uint64Flag, returns\n// 0 if not found\nfunc (c *Context) GlobalUint64(name string) uint64 {\n\tif fs := lookupGlobalFlagSet(name, c); fs != nil {\n\t\treturn lookupUint64(name, fs)\n\t}\n\treturn 0\n}\n\nfunc lookupUint64(name string, set *flag.FlagSet) uint64 {\n\tf := set.Lookup(name)\n\tif f != nil {\n\t\tparsed, err := strconv.ParseUint(f.Value.String(), 0, 64)\n\t\tif err != nil {\n\t\t\treturn 0\n\t\t}\n\t\treturn parsed\n\t}\n\treturn 0\n}\n\n// UintFlag is a flag with type uint\ntype UintFlag struct {\n\tName        string\n\tUsage       string\n\tEnvVar      string\n\tHidden      bool\n\tValue       uint\n\tDestination *uint\n}\n\n// String returns a readable representation of this value\n// (for usage defaults)\nfunc (f UintFlag) String() string {\n\treturn FlagStringer(f)\n}\n\n// GetName returns the name of the flag\nfunc (f UintFlag) GetName() string {\n\treturn f.Name\n}\n\n// Uint looks up the value of a local UintFlag, returns\n// 0 if not found\nfunc (c *Context) Uint(name string) uint {\n\treturn lookupUint(name, c.flagSet)\n}\n\n// GlobalUint looks up the value of a global UintFlag, returns\n// 0 if not found\nfunc (c *Context) GlobalUint(name string) uint {\n\tif fs := lookupGlobalFlagSet(name, c); fs != nil {\n\t\treturn lookupUint(name, fs)\n\t}\n\treturn 0\n}\n\nfunc lookupUint(name string, set *flag.FlagSet) uint {\n\tf := set.Lookup(name)\n\tif f != nil {\n\t\tparsed, err := strconv.ParseUint(f.Value.String(), 0, 64)\n\t\tif err != nil {\n\t\t\treturn 0\n\t\t}\n\t\treturn uint(parsed)\n\t}\n\treturn 0\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/flag_test.go",
    "content": "package cli\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"reflect\"\n\t\"regexp\"\n\t\"runtime\"\n\t\"strings\"\n\t\"testing\"\n\t\"time\"\n)\n\nvar boolFlagTests = []struct {\n\tname     string\n\texpected string\n}{\n\t{\"help\", \"--help\\t\"},\n\t{\"h\", \"-h\\t\"},\n}\n\nfunc TestBoolFlagHelpOutput(t *testing.T) {\n\tfor _, test := range boolFlagTests {\n\t\tflag := BoolFlag{Name: test.name}\n\t\toutput := flag.String()\n\n\t\tif output != test.expected {\n\t\t\tt.Errorf(\"%q does not match %q\", output, test.expected)\n\t\t}\n\t}\n}\n\nfunc TestFlagsFromEnv(t *testing.T) {\n\tvar flagTests = []struct {\n\t\tinput     string\n\t\toutput    interface{}\n\t\tflag      Flag\n\t\terrRegexp string\n\t}{\n\t\t{\"\", false, BoolFlag{Name: \"debug\", EnvVar: \"DEBUG\"}, \"\"},\n\t\t{\"1\", true, BoolFlag{Name: \"debug\", EnvVar: \"DEBUG\"}, \"\"},\n\t\t{\"false\", false, BoolFlag{Name: \"debug\", EnvVar: \"DEBUG\"}, \"\"},\n\t\t{\"foobar\", true, BoolFlag{Name: \"debug\", EnvVar: \"DEBUG\"}, fmt.Sprintf(`could not parse foobar as bool value for flag debug: .*`)},\n\n\t\t{\"\", false, BoolTFlag{Name: \"debug\", EnvVar: \"DEBUG\"}, \"\"},\n\t\t{\"1\", true, BoolTFlag{Name: \"debug\", EnvVar: \"DEBUG\"}, \"\"},\n\t\t{\"false\", false, BoolTFlag{Name: \"debug\", EnvVar: \"DEBUG\"}, \"\"},\n\t\t{\"foobar\", true, BoolTFlag{Name: \"debug\", EnvVar: \"DEBUG\"}, fmt.Sprintf(`could not parse foobar as bool value for flag debug: .*`)},\n\n\t\t{\"1s\", 1 * time.Second, DurationFlag{Name: \"time\", EnvVar: \"TIME\"}, \"\"},\n\t\t{\"foobar\", false, DurationFlag{Name: \"time\", EnvVar: \"TIME\"}, fmt.Sprintf(`could not parse foobar as duration for flag time: .*`)},\n\n\t\t{\"1.2\", 1.2, Float64Flag{Name: \"seconds\", EnvVar: \"SECONDS\"}, \"\"},\n\t\t{\"1\", 1.0, Float64Flag{Name: \"seconds\", EnvVar: \"SECONDS\"}, \"\"},\n\t\t{\"foobar\", 0, Float64Flag{Name: \"seconds\", EnvVar: \"SECONDS\"}, fmt.Sprintf(`could not parse foobar as float64 value for flag seconds: .*`)},\n\n\t\t{\"1\", int64(1), Int64Flag{Name: \"seconds\", EnvVar: \"SECONDS\"}, \"\"},\n\t\t{\"1.2\", 0, Int64Flag{Name: \"seconds\", EnvVar: \"SECONDS\"}, fmt.Sprintf(`could not parse 1.2 as int value for flag seconds: .*`)},\n\t\t{\"foobar\", 0, Int64Flag{Name: \"seconds\", EnvVar: \"SECONDS\"}, fmt.Sprintf(`could not parse foobar as int value for flag seconds: .*`)},\n\n\t\t{\"1\", 1, IntFlag{Name: \"seconds\", EnvVar: \"SECONDS\"}, \"\"},\n\t\t{\"1.2\", 0, IntFlag{Name: \"seconds\", EnvVar: \"SECONDS\"}, fmt.Sprintf(`could not parse 1.2 as int value for flag seconds: .*`)},\n\t\t{\"foobar\", 0, IntFlag{Name: \"seconds\", EnvVar: \"SECONDS\"}, fmt.Sprintf(`could not parse foobar as int value for flag seconds: .*`)},\n\n\t\t{\"1,2\", IntSlice{1, 2}, IntSliceFlag{Name: \"seconds\", EnvVar: \"SECONDS\"}, \"\"},\n\t\t{\"1.2,2\", IntSlice{}, IntSliceFlag{Name: \"seconds\", EnvVar: \"SECONDS\"}, fmt.Sprintf(`could not parse 1.2,2 as int slice value for flag seconds: .*`)},\n\t\t{\"foobar\", IntSlice{}, IntSliceFlag{Name: \"seconds\", EnvVar: \"SECONDS\"}, fmt.Sprintf(`could not parse foobar as int slice value for flag seconds: .*`)},\n\n\t\t{\"1,2\", Int64Slice{1, 2}, Int64SliceFlag{Name: \"seconds\", EnvVar: \"SECONDS\"}, \"\"},\n\t\t{\"1.2,2\", Int64Slice{}, Int64SliceFlag{Name: \"seconds\", EnvVar: \"SECONDS\"}, fmt.Sprintf(`could not parse 1.2,2 as int64 slice value for flag seconds: .*`)},\n\t\t{\"foobar\", Int64Slice{}, Int64SliceFlag{Name: \"seconds\", EnvVar: \"SECONDS\"}, fmt.Sprintf(`could not parse foobar as int64 slice value for flag seconds: .*`)},\n\n\t\t{\"foo\", \"foo\", StringFlag{Name: \"name\", EnvVar: \"NAME\"}, \"\"},\n\n\t\t{\"foo,bar\", StringSlice{\"foo\", \"bar\"}, StringSliceFlag{Name: \"names\", EnvVar: \"NAMES\"}, \"\"},\n\n\t\t{\"1\", uint(1), UintFlag{Name: \"seconds\", EnvVar: \"SECONDS\"}, \"\"},\n\t\t{\"1.2\", 0, UintFlag{Name: \"seconds\", EnvVar: \"SECONDS\"}, fmt.Sprintf(`could not parse 1.2 as uint value for flag seconds: .*`)},\n\t\t{\"foobar\", 0, UintFlag{Name: \"seconds\", EnvVar: \"SECONDS\"}, fmt.Sprintf(`could not parse foobar as uint value for flag seconds: .*`)},\n\n\t\t{\"1\", uint64(1), Uint64Flag{Name: \"seconds\", EnvVar: \"SECONDS\"}, \"\"},\n\t\t{\"1.2\", 0, Uint64Flag{Name: \"seconds\", EnvVar: \"SECONDS\"}, fmt.Sprintf(`could not parse 1.2 as uint64 value for flag seconds: .*`)},\n\t\t{\"foobar\", 0, Uint64Flag{Name: \"seconds\", EnvVar: \"SECONDS\"}, fmt.Sprintf(`could not parse foobar as uint64 value for flag seconds: .*`)},\n\n\t\t{\"foo,bar\", &Parser{\"foo\", \"bar\"}, GenericFlag{Name: \"names\", Value: &Parser{}, EnvVar: \"NAMES\"}, \"\"},\n\t}\n\n\tfor _, test := range flagTests {\n\t\tos.Clearenv()\n\t\tos.Setenv(reflect.ValueOf(test.flag).FieldByName(\"EnvVar\").String(), test.input)\n\t\ta := App{\n\t\t\tFlags: []Flag{test.flag},\n\t\t\tAction: func(ctx *Context) error {\n\t\t\t\tif !reflect.DeepEqual(ctx.value(test.flag.GetName()), test.output) {\n\t\t\t\t\tt.Errorf(\"expected %+v to be parsed as %+v, instead was %+v\", test.input, test.output, ctx.value(test.flag.GetName()))\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t},\n\t\t}\n\n\t\terr := a.Run([]string{\"run\"})\n\n\t\tif test.errRegexp != \"\" {\n\t\t\tif err == nil {\n\t\t\t\tt.Errorf(\"expected error to match %s, got none\", test.errRegexp)\n\t\t\t} else {\n\t\t\t\tif matched, _ := regexp.MatchString(test.errRegexp, err.Error()); !matched {\n\t\t\t\t\tt.Errorf(\"expected error to match %s, got error %s\", test.errRegexp, err)\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif err != nil && test.errRegexp == \"\" {\n\t\t\t\tt.Errorf(\"expected no error got %s\", err)\n\t\t\t}\n\t\t}\n\t}\n}\n\nvar stringFlagTests = []struct {\n\tname     string\n\tusage    string\n\tvalue    string\n\texpected string\n}{\n\t{\"foo\", \"\", \"\", \"--foo value\\t\"},\n\t{\"f\", \"\", \"\", \"-f value\\t\"},\n\t{\"f\", \"The total `foo` desired\", \"all\", \"-f foo\\tThe total foo desired (default: \\\"all\\\")\"},\n\t{\"test\", \"\", \"Something\", \"--test value\\t(default: \\\"Something\\\")\"},\n\t{\"config,c\", \"Load configuration from `FILE`\", \"\", \"--config FILE, -c FILE\\tLoad configuration from FILE\"},\n\t{\"config,c\", \"Load configuration from `CONFIG`\", \"config.json\", \"--config CONFIG, -c CONFIG\\tLoad configuration from CONFIG (default: \\\"config.json\\\")\"},\n}\n\nfunc TestStringFlagHelpOutput(t *testing.T) {\n\tfor _, test := range stringFlagTests {\n\t\tflag := StringFlag{Name: test.name, Usage: test.usage, Value: test.value}\n\t\toutput := flag.String()\n\n\t\tif output != test.expected {\n\t\t\tt.Errorf(\"%q does not match %q\", output, test.expected)\n\t\t}\n\t}\n}\n\nfunc TestStringFlagWithEnvVarHelpOutput(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_FOO\", \"derp\")\n\tfor _, test := range stringFlagTests {\n\t\tflag := StringFlag{Name: test.name, Value: test.value, EnvVar: \"APP_FOO\"}\n\t\toutput := flag.String()\n\n\t\texpectedSuffix := \" [$APP_FOO]\"\n\t\tif runtime.GOOS == \"windows\" {\n\t\t\texpectedSuffix = \" [%APP_FOO%]\"\n\t\t}\n\t\tif !strings.HasSuffix(output, expectedSuffix) {\n\t\t\tt.Errorf(\"%s does not end with\"+expectedSuffix, output)\n\t\t}\n\t}\n}\n\nvar stringSliceFlagTests = []struct {\n\tname     string\n\tvalue    *StringSlice\n\texpected string\n}{\n\t{\"foo\", func() *StringSlice {\n\t\ts := &StringSlice{}\n\t\ts.Set(\"\")\n\t\treturn s\n\t}(), \"--foo value\\t\"},\n\t{\"f\", func() *StringSlice {\n\t\ts := &StringSlice{}\n\t\ts.Set(\"\")\n\t\treturn s\n\t}(), \"-f value\\t\"},\n\t{\"f\", func() *StringSlice {\n\t\ts := &StringSlice{}\n\t\ts.Set(\"Lipstick\")\n\t\treturn s\n\t}(), \"-f value\\t(default: \\\"Lipstick\\\")\"},\n\t{\"test\", func() *StringSlice {\n\t\ts := &StringSlice{}\n\t\ts.Set(\"Something\")\n\t\treturn s\n\t}(), \"--test value\\t(default: \\\"Something\\\")\"},\n}\n\nfunc TestStringSliceFlagHelpOutput(t *testing.T) {\n\tfor _, test := range stringSliceFlagTests {\n\t\tflag := StringSliceFlag{Name: test.name, Value: test.value}\n\t\toutput := flag.String()\n\n\t\tif output != test.expected {\n\t\t\tt.Errorf(\"%q does not match %q\", output, test.expected)\n\t\t}\n\t}\n}\n\nfunc TestStringSliceFlagWithEnvVarHelpOutput(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_QWWX\", \"11,4\")\n\tfor _, test := range stringSliceFlagTests {\n\t\tflag := StringSliceFlag{Name: test.name, Value: test.value, EnvVar: \"APP_QWWX\"}\n\t\toutput := flag.String()\n\n\t\texpectedSuffix := \" [$APP_QWWX]\"\n\t\tif runtime.GOOS == \"windows\" {\n\t\t\texpectedSuffix = \" [%APP_QWWX%]\"\n\t\t}\n\t\tif !strings.HasSuffix(output, expectedSuffix) {\n\t\t\tt.Errorf(\"%q does not end with\"+expectedSuffix, output)\n\t\t}\n\t}\n}\n\nvar intFlagTests = []struct {\n\tname     string\n\texpected string\n}{\n\t{\"hats\", \"--hats value\\t(default: 9)\"},\n\t{\"H\", \"-H value\\t(default: 9)\"},\n}\n\nfunc TestIntFlagHelpOutput(t *testing.T) {\n\tfor _, test := range intFlagTests {\n\t\tflag := IntFlag{Name: test.name, Value: 9}\n\t\toutput := flag.String()\n\n\t\tif output != test.expected {\n\t\t\tt.Errorf(\"%s does not match %s\", output, test.expected)\n\t\t}\n\t}\n}\n\nfunc TestIntFlagWithEnvVarHelpOutput(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_BAR\", \"2\")\n\tfor _, test := range intFlagTests {\n\t\tflag := IntFlag{Name: test.name, EnvVar: \"APP_BAR\"}\n\t\toutput := flag.String()\n\n\t\texpectedSuffix := \" [$APP_BAR]\"\n\t\tif runtime.GOOS == \"windows\" {\n\t\t\texpectedSuffix = \" [%APP_BAR%]\"\n\t\t}\n\t\tif !strings.HasSuffix(output, expectedSuffix) {\n\t\t\tt.Errorf(\"%s does not end with\"+expectedSuffix, output)\n\t\t}\n\t}\n}\n\nvar int64FlagTests = []struct {\n\tname     string\n\texpected string\n}{\n\t{\"hats\", \"--hats value\\t(default: 8589934592)\"},\n\t{\"H\", \"-H value\\t(default: 8589934592)\"},\n}\n\nfunc TestInt64FlagHelpOutput(t *testing.T) {\n\tfor _, test := range int64FlagTests {\n\t\tflag := Int64Flag{Name: test.name, Value: 8589934592}\n\t\toutput := flag.String()\n\n\t\tif output != test.expected {\n\t\t\tt.Errorf(\"%s does not match %s\", output, test.expected)\n\t\t}\n\t}\n}\n\nfunc TestInt64FlagWithEnvVarHelpOutput(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_BAR\", \"2\")\n\tfor _, test := range int64FlagTests {\n\t\tflag := IntFlag{Name: test.name, EnvVar: \"APP_BAR\"}\n\t\toutput := flag.String()\n\n\t\texpectedSuffix := \" [$APP_BAR]\"\n\t\tif runtime.GOOS == \"windows\" {\n\t\t\texpectedSuffix = \" [%APP_BAR%]\"\n\t\t}\n\t\tif !strings.HasSuffix(output, expectedSuffix) {\n\t\t\tt.Errorf(\"%s does not end with\"+expectedSuffix, output)\n\t\t}\n\t}\n}\n\nvar uintFlagTests = []struct {\n\tname     string\n\texpected string\n}{\n\t{\"nerfs\", \"--nerfs value\\t(default: 41)\"},\n\t{\"N\", \"-N value\\t(default: 41)\"},\n}\n\nfunc TestUintFlagHelpOutput(t *testing.T) {\n\tfor _, test := range uintFlagTests {\n\t\tflag := UintFlag{Name: test.name, Value: 41}\n\t\toutput := flag.String()\n\n\t\tif output != test.expected {\n\t\t\tt.Errorf(\"%s does not match %s\", output, test.expected)\n\t\t}\n\t}\n}\n\nfunc TestUintFlagWithEnvVarHelpOutput(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_BAR\", \"2\")\n\tfor _, test := range uintFlagTests {\n\t\tflag := UintFlag{Name: test.name, EnvVar: \"APP_BAR\"}\n\t\toutput := flag.String()\n\n\t\texpectedSuffix := \" [$APP_BAR]\"\n\t\tif runtime.GOOS == \"windows\" {\n\t\t\texpectedSuffix = \" [%APP_BAR%]\"\n\t\t}\n\t\tif !strings.HasSuffix(output, expectedSuffix) {\n\t\t\tt.Errorf(\"%s does not end with\"+expectedSuffix, output)\n\t\t}\n\t}\n}\n\nvar uint64FlagTests = []struct {\n\tname     string\n\texpected string\n}{\n\t{\"gerfs\", \"--gerfs value\\t(default: 8589934582)\"},\n\t{\"G\", \"-G value\\t(default: 8589934582)\"},\n}\n\nfunc TestUint64FlagHelpOutput(t *testing.T) {\n\tfor _, test := range uint64FlagTests {\n\t\tflag := Uint64Flag{Name: test.name, Value: 8589934582}\n\t\toutput := flag.String()\n\n\t\tif output != test.expected {\n\t\t\tt.Errorf(\"%s does not match %s\", output, test.expected)\n\t\t}\n\t}\n}\n\nfunc TestUint64FlagWithEnvVarHelpOutput(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_BAR\", \"2\")\n\tfor _, test := range uint64FlagTests {\n\t\tflag := UintFlag{Name: test.name, EnvVar: \"APP_BAR\"}\n\t\toutput := flag.String()\n\n\t\texpectedSuffix := \" [$APP_BAR]\"\n\t\tif runtime.GOOS == \"windows\" {\n\t\t\texpectedSuffix = \" [%APP_BAR%]\"\n\t\t}\n\t\tif !strings.HasSuffix(output, expectedSuffix) {\n\t\t\tt.Errorf(\"%s does not end with\"+expectedSuffix, output)\n\t\t}\n\t}\n}\n\nvar durationFlagTests = []struct {\n\tname     string\n\texpected string\n}{\n\t{\"hooting\", \"--hooting value\\t(default: 1s)\"},\n\t{\"H\", \"-H value\\t(default: 1s)\"},\n}\n\nfunc TestDurationFlagHelpOutput(t *testing.T) {\n\tfor _, test := range durationFlagTests {\n\t\tflag := DurationFlag{Name: test.name, Value: 1 * time.Second}\n\t\toutput := flag.String()\n\n\t\tif output != test.expected {\n\t\t\tt.Errorf(\"%q does not match %q\", output, test.expected)\n\t\t}\n\t}\n}\n\nfunc TestDurationFlagWithEnvVarHelpOutput(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_BAR\", \"2h3m6s\")\n\tfor _, test := range durationFlagTests {\n\t\tflag := DurationFlag{Name: test.name, EnvVar: \"APP_BAR\"}\n\t\toutput := flag.String()\n\n\t\texpectedSuffix := \" [$APP_BAR]\"\n\t\tif runtime.GOOS == \"windows\" {\n\t\t\texpectedSuffix = \" [%APP_BAR%]\"\n\t\t}\n\t\tif !strings.HasSuffix(output, expectedSuffix) {\n\t\t\tt.Errorf(\"%s does not end with\"+expectedSuffix, output)\n\t\t}\n\t}\n}\n\nvar intSliceFlagTests = []struct {\n\tname     string\n\tvalue    *IntSlice\n\texpected string\n}{\n\t{\"heads\", &IntSlice{}, \"--heads value\\t\"},\n\t{\"H\", &IntSlice{}, \"-H value\\t\"},\n\t{\"H, heads\", func() *IntSlice {\n\t\ti := &IntSlice{}\n\t\ti.Set(\"9\")\n\t\ti.Set(\"3\")\n\t\treturn i\n\t}(), \"-H value, --heads value\\t(default: 9, 3)\"},\n}\n\nfunc TestIntSliceFlagHelpOutput(t *testing.T) {\n\tfor _, test := range intSliceFlagTests {\n\t\tflag := IntSliceFlag{Name: test.name, Value: test.value}\n\t\toutput := flag.String()\n\n\t\tif output != test.expected {\n\t\t\tt.Errorf(\"%q does not match %q\", output, test.expected)\n\t\t}\n\t}\n}\n\nfunc TestIntSliceFlagWithEnvVarHelpOutput(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_SMURF\", \"42,3\")\n\tfor _, test := range intSliceFlagTests {\n\t\tflag := IntSliceFlag{Name: test.name, Value: test.value, EnvVar: \"APP_SMURF\"}\n\t\toutput := flag.String()\n\n\t\texpectedSuffix := \" [$APP_SMURF]\"\n\t\tif runtime.GOOS == \"windows\" {\n\t\t\texpectedSuffix = \" [%APP_SMURF%]\"\n\t\t}\n\t\tif !strings.HasSuffix(output, expectedSuffix) {\n\t\t\tt.Errorf(\"%q does not end with\"+expectedSuffix, output)\n\t\t}\n\t}\n}\n\nvar int64SliceFlagTests = []struct {\n\tname     string\n\tvalue    *Int64Slice\n\texpected string\n}{\n\t{\"heads\", &Int64Slice{}, \"--heads value\\t\"},\n\t{\"H\", &Int64Slice{}, \"-H value\\t\"},\n\t{\"H, heads\", func() *Int64Slice {\n\t\ti := &Int64Slice{}\n\t\ti.Set(\"2\")\n\t\ti.Set(\"17179869184\")\n\t\treturn i\n\t}(), \"-H value, --heads value\\t(default: 2, 17179869184)\"},\n}\n\nfunc TestInt64SliceFlagHelpOutput(t *testing.T) {\n\tfor _, test := range int64SliceFlagTests {\n\t\tflag := Int64SliceFlag{Name: test.name, Value: test.value}\n\t\toutput := flag.String()\n\n\t\tif output != test.expected {\n\t\t\tt.Errorf(\"%q does not match %q\", output, test.expected)\n\t\t}\n\t}\n}\n\nfunc TestInt64SliceFlagWithEnvVarHelpOutput(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_SMURF\", \"42,17179869184\")\n\tfor _, test := range int64SliceFlagTests {\n\t\tflag := Int64SliceFlag{Name: test.name, Value: test.value, EnvVar: \"APP_SMURF\"}\n\t\toutput := flag.String()\n\n\t\texpectedSuffix := \" [$APP_SMURF]\"\n\t\tif runtime.GOOS == \"windows\" {\n\t\t\texpectedSuffix = \" [%APP_SMURF%]\"\n\t\t}\n\t\tif !strings.HasSuffix(output, expectedSuffix) {\n\t\t\tt.Errorf(\"%q does not end with\"+expectedSuffix, output)\n\t\t}\n\t}\n}\n\nvar float64FlagTests = []struct {\n\tname     string\n\texpected string\n}{\n\t{\"hooting\", \"--hooting value\\t(default: 0.1)\"},\n\t{\"H\", \"-H value\\t(default: 0.1)\"},\n}\n\nfunc TestFloat64FlagHelpOutput(t *testing.T) {\n\tfor _, test := range float64FlagTests {\n\t\tflag := Float64Flag{Name: test.name, Value: float64(0.1)}\n\t\toutput := flag.String()\n\n\t\tif output != test.expected {\n\t\t\tt.Errorf(\"%q does not match %q\", output, test.expected)\n\t\t}\n\t}\n}\n\nfunc TestFloat64FlagWithEnvVarHelpOutput(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_BAZ\", \"99.4\")\n\tfor _, test := range float64FlagTests {\n\t\tflag := Float64Flag{Name: test.name, EnvVar: \"APP_BAZ\"}\n\t\toutput := flag.String()\n\n\t\texpectedSuffix := \" [$APP_BAZ]\"\n\t\tif runtime.GOOS == \"windows\" {\n\t\t\texpectedSuffix = \" [%APP_BAZ%]\"\n\t\t}\n\t\tif !strings.HasSuffix(output, expectedSuffix) {\n\t\t\tt.Errorf(\"%s does not end with\"+expectedSuffix, output)\n\t\t}\n\t}\n}\n\nvar genericFlagTests = []struct {\n\tname     string\n\tvalue    Generic\n\texpected string\n}{\n\t{\"toads\", &Parser{\"abc\", \"def\"}, \"--toads value\\ttest flag (default: abc,def)\"},\n\t{\"t\", &Parser{\"abc\", \"def\"}, \"-t value\\ttest flag (default: abc,def)\"},\n}\n\nfunc TestGenericFlagHelpOutput(t *testing.T) {\n\tfor _, test := range genericFlagTests {\n\t\tflag := GenericFlag{Name: test.name, Value: test.value, Usage: \"test flag\"}\n\t\toutput := flag.String()\n\n\t\tif output != test.expected {\n\t\t\tt.Errorf(\"%q does not match %q\", output, test.expected)\n\t\t}\n\t}\n}\n\nfunc TestGenericFlagWithEnvVarHelpOutput(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_ZAP\", \"3\")\n\tfor _, test := range genericFlagTests {\n\t\tflag := GenericFlag{Name: test.name, EnvVar: \"APP_ZAP\"}\n\t\toutput := flag.String()\n\n\t\texpectedSuffix := \" [$APP_ZAP]\"\n\t\tif runtime.GOOS == \"windows\" {\n\t\t\texpectedSuffix = \" [%APP_ZAP%]\"\n\t\t}\n\t\tif !strings.HasSuffix(output, expectedSuffix) {\n\t\t\tt.Errorf(\"%s does not end with\"+expectedSuffix, output)\n\t\t}\n\t}\n}\n\nfunc TestParseMultiString(t *testing.T) {\n\t(&App{\n\t\tFlags: []Flag{\n\t\t\tStringFlag{Name: \"serve, s\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif ctx.String(\"serve\") != \"10\" {\n\t\t\t\tt.Errorf(\"main name not set\")\n\t\t\t}\n\t\t\tif ctx.String(\"s\") != \"10\" {\n\t\t\t\tt.Errorf(\"short name not set\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}).Run([]string{\"run\", \"-s\", \"10\"})\n}\n\nfunc TestParseDestinationString(t *testing.T) {\n\tvar dest string\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tStringFlag{\n\t\t\t\tName:        \"dest\",\n\t\t\t\tDestination: &dest,\n\t\t\t},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif dest != \"10\" {\n\t\t\t\tt.Errorf(\"expected destination String 10\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\ta.Run([]string{\"run\", \"--dest\", \"10\"})\n}\n\nfunc TestParseMultiStringFromEnv(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_COUNT\", \"20\")\n\t(&App{\n\t\tFlags: []Flag{\n\t\t\tStringFlag{Name: \"count, c\", EnvVar: \"APP_COUNT\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif ctx.String(\"count\") != \"20\" {\n\t\t\t\tt.Errorf(\"main name not set\")\n\t\t\t}\n\t\t\tif ctx.String(\"c\") != \"20\" {\n\t\t\t\tt.Errorf(\"short name not set\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}).Run([]string{\"run\"})\n}\n\nfunc TestParseMultiStringFromEnvCascade(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_COUNT\", \"20\")\n\t(&App{\n\t\tFlags: []Flag{\n\t\t\tStringFlag{Name: \"count, c\", EnvVar: \"COMPAT_COUNT,APP_COUNT\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif ctx.String(\"count\") != \"20\" {\n\t\t\t\tt.Errorf(\"main name not set\")\n\t\t\t}\n\t\t\tif ctx.String(\"c\") != \"20\" {\n\t\t\t\tt.Errorf(\"short name not set\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}).Run([]string{\"run\"})\n}\n\nfunc TestParseMultiStringSlice(t *testing.T) {\n\t(&App{\n\t\tFlags: []Flag{\n\t\t\tStringSliceFlag{Name: \"serve, s\", Value: &StringSlice{}},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif !reflect.DeepEqual(ctx.StringSlice(\"serve\"), []string{\"10\", \"20\"}) {\n\t\t\t\tt.Errorf(\"main name not set\")\n\t\t\t}\n\t\t\tif !reflect.DeepEqual(ctx.StringSlice(\"s\"), []string{\"10\", \"20\"}) {\n\t\t\t\tt.Errorf(\"short name not set\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}).Run([]string{\"run\", \"-s\", \"10\", \"-s\", \"20\"})\n}\n\nfunc TestParseMultiStringSliceFromEnv(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_INTERVALS\", \"20,30,40\")\n\n\t(&App{\n\t\tFlags: []Flag{\n\t\t\tStringSliceFlag{Name: \"intervals, i\", Value: &StringSlice{}, EnvVar: \"APP_INTERVALS\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif !reflect.DeepEqual(ctx.StringSlice(\"intervals\"), []string{\"20\", \"30\", \"40\"}) {\n\t\t\t\tt.Errorf(\"main name not set from env\")\n\t\t\t}\n\t\t\tif !reflect.DeepEqual(ctx.StringSlice(\"i\"), []string{\"20\", \"30\", \"40\"}) {\n\t\t\t\tt.Errorf(\"short name not set from env\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}).Run([]string{\"run\"})\n}\n\nfunc TestParseMultiStringSliceFromEnvCascade(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_INTERVALS\", \"20,30,40\")\n\n\t(&App{\n\t\tFlags: []Flag{\n\t\t\tStringSliceFlag{Name: \"intervals, i\", Value: &StringSlice{}, EnvVar: \"COMPAT_INTERVALS,APP_INTERVALS\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif !reflect.DeepEqual(ctx.StringSlice(\"intervals\"), []string{\"20\", \"30\", \"40\"}) {\n\t\t\t\tt.Errorf(\"main name not set from env\")\n\t\t\t}\n\t\t\tif !reflect.DeepEqual(ctx.StringSlice(\"i\"), []string{\"20\", \"30\", \"40\"}) {\n\t\t\t\tt.Errorf(\"short name not set from env\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}).Run([]string{\"run\"})\n}\n\nfunc TestParseMultiInt(t *testing.T) {\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tIntFlag{Name: \"serve, s\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif ctx.Int(\"serve\") != 10 {\n\t\t\t\tt.Errorf(\"main name not set\")\n\t\t\t}\n\t\t\tif ctx.Int(\"s\") != 10 {\n\t\t\t\tt.Errorf(\"short name not set\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\ta.Run([]string{\"run\", \"-s\", \"10\"})\n}\n\nfunc TestParseDestinationInt(t *testing.T) {\n\tvar dest int\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tIntFlag{\n\t\t\t\tName:        \"dest\",\n\t\t\t\tDestination: &dest,\n\t\t\t},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif dest != 10 {\n\t\t\t\tt.Errorf(\"expected destination Int 10\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\ta.Run([]string{\"run\", \"--dest\", \"10\"})\n}\n\nfunc TestParseMultiIntFromEnv(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_TIMEOUT_SECONDS\", \"10\")\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tIntFlag{Name: \"timeout, t\", EnvVar: \"APP_TIMEOUT_SECONDS\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif ctx.Int(\"timeout\") != 10 {\n\t\t\t\tt.Errorf(\"main name not set\")\n\t\t\t}\n\t\t\tif ctx.Int(\"t\") != 10 {\n\t\t\t\tt.Errorf(\"short name not set\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\ta.Run([]string{\"run\"})\n}\n\nfunc TestParseMultiIntFromEnvCascade(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_TIMEOUT_SECONDS\", \"10\")\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tIntFlag{Name: \"timeout, t\", EnvVar: \"COMPAT_TIMEOUT_SECONDS,APP_TIMEOUT_SECONDS\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif ctx.Int(\"timeout\") != 10 {\n\t\t\t\tt.Errorf(\"main name not set\")\n\t\t\t}\n\t\t\tif ctx.Int(\"t\") != 10 {\n\t\t\t\tt.Errorf(\"short name not set\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\ta.Run([]string{\"run\"})\n}\n\nfunc TestParseMultiIntSlice(t *testing.T) {\n\t(&App{\n\t\tFlags: []Flag{\n\t\t\tIntSliceFlag{Name: \"serve, s\", Value: &IntSlice{}},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif !reflect.DeepEqual(ctx.IntSlice(\"serve\"), []int{10, 20}) {\n\t\t\t\tt.Errorf(\"main name not set\")\n\t\t\t}\n\t\t\tif !reflect.DeepEqual(ctx.IntSlice(\"s\"), []int{10, 20}) {\n\t\t\t\tt.Errorf(\"short name not set\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}).Run([]string{\"run\", \"-s\", \"10\", \"-s\", \"20\"})\n}\n\nfunc TestParseMultiIntSliceFromEnv(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_INTERVALS\", \"20,30,40\")\n\n\t(&App{\n\t\tFlags: []Flag{\n\t\t\tIntSliceFlag{Name: \"intervals, i\", Value: &IntSlice{}, EnvVar: \"APP_INTERVALS\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif !reflect.DeepEqual(ctx.IntSlice(\"intervals\"), []int{20, 30, 40}) {\n\t\t\t\tt.Errorf(\"main name not set from env\")\n\t\t\t}\n\t\t\tif !reflect.DeepEqual(ctx.IntSlice(\"i\"), []int{20, 30, 40}) {\n\t\t\t\tt.Errorf(\"short name not set from env\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}).Run([]string{\"run\"})\n}\n\nfunc TestParseMultiIntSliceFromEnvCascade(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_INTERVALS\", \"20,30,40\")\n\n\t(&App{\n\t\tFlags: []Flag{\n\t\t\tIntSliceFlag{Name: \"intervals, i\", Value: &IntSlice{}, EnvVar: \"COMPAT_INTERVALS,APP_INTERVALS\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif !reflect.DeepEqual(ctx.IntSlice(\"intervals\"), []int{20, 30, 40}) {\n\t\t\t\tt.Errorf(\"main name not set from env\")\n\t\t\t}\n\t\t\tif !reflect.DeepEqual(ctx.IntSlice(\"i\"), []int{20, 30, 40}) {\n\t\t\t\tt.Errorf(\"short name not set from env\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}).Run([]string{\"run\"})\n}\n\nfunc TestParseMultiInt64Slice(t *testing.T) {\n\t(&App{\n\t\tFlags: []Flag{\n\t\t\tInt64SliceFlag{Name: \"serve, s\", Value: &Int64Slice{}},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif !reflect.DeepEqual(ctx.Int64Slice(\"serve\"), []int64{10, 17179869184}) {\n\t\t\t\tt.Errorf(\"main name not set\")\n\t\t\t}\n\t\t\tif !reflect.DeepEqual(ctx.Int64Slice(\"s\"), []int64{10, 17179869184}) {\n\t\t\t\tt.Errorf(\"short name not set\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}).Run([]string{\"run\", \"-s\", \"10\", \"-s\", \"17179869184\"})\n}\n\nfunc TestParseMultiInt64SliceFromEnv(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_INTERVALS\", \"20,30,17179869184\")\n\n\t(&App{\n\t\tFlags: []Flag{\n\t\t\tInt64SliceFlag{Name: \"intervals, i\", Value: &Int64Slice{}, EnvVar: \"APP_INTERVALS\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif !reflect.DeepEqual(ctx.Int64Slice(\"intervals\"), []int64{20, 30, 17179869184}) {\n\t\t\t\tt.Errorf(\"main name not set from env\")\n\t\t\t}\n\t\t\tif !reflect.DeepEqual(ctx.Int64Slice(\"i\"), []int64{20, 30, 17179869184}) {\n\t\t\t\tt.Errorf(\"short name not set from env\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}).Run([]string{\"run\"})\n}\n\nfunc TestParseMultiInt64SliceFromEnvCascade(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_INTERVALS\", \"20,30,17179869184\")\n\n\t(&App{\n\t\tFlags: []Flag{\n\t\t\tInt64SliceFlag{Name: \"intervals, i\", Value: &Int64Slice{}, EnvVar: \"COMPAT_INTERVALS,APP_INTERVALS\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif !reflect.DeepEqual(ctx.Int64Slice(\"intervals\"), []int64{20, 30, 17179869184}) {\n\t\t\t\tt.Errorf(\"main name not set from env\")\n\t\t\t}\n\t\t\tif !reflect.DeepEqual(ctx.Int64Slice(\"i\"), []int64{20, 30, 17179869184}) {\n\t\t\t\tt.Errorf(\"short name not set from env\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}).Run([]string{\"run\"})\n}\n\nfunc TestParseMultiFloat64(t *testing.T) {\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tFloat64Flag{Name: \"serve, s\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif ctx.Float64(\"serve\") != 10.2 {\n\t\t\t\tt.Errorf(\"main name not set\")\n\t\t\t}\n\t\t\tif ctx.Float64(\"s\") != 10.2 {\n\t\t\t\tt.Errorf(\"short name not set\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\ta.Run([]string{\"run\", \"-s\", \"10.2\"})\n}\n\nfunc TestParseDestinationFloat64(t *testing.T) {\n\tvar dest float64\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tFloat64Flag{\n\t\t\t\tName:        \"dest\",\n\t\t\t\tDestination: &dest,\n\t\t\t},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif dest != 10.2 {\n\t\t\t\tt.Errorf(\"expected destination Float64 10.2\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\ta.Run([]string{\"run\", \"--dest\", \"10.2\"})\n}\n\nfunc TestParseMultiFloat64FromEnv(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_TIMEOUT_SECONDS\", \"15.5\")\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tFloat64Flag{Name: \"timeout, t\", EnvVar: \"APP_TIMEOUT_SECONDS\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif ctx.Float64(\"timeout\") != 15.5 {\n\t\t\t\tt.Errorf(\"main name not set\")\n\t\t\t}\n\t\t\tif ctx.Float64(\"t\") != 15.5 {\n\t\t\t\tt.Errorf(\"short name not set\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\ta.Run([]string{\"run\"})\n}\n\nfunc TestParseMultiFloat64FromEnvCascade(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_TIMEOUT_SECONDS\", \"15.5\")\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tFloat64Flag{Name: \"timeout, t\", EnvVar: \"COMPAT_TIMEOUT_SECONDS,APP_TIMEOUT_SECONDS\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif ctx.Float64(\"timeout\") != 15.5 {\n\t\t\t\tt.Errorf(\"main name not set\")\n\t\t\t}\n\t\t\tif ctx.Float64(\"t\") != 15.5 {\n\t\t\t\tt.Errorf(\"short name not set\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\ta.Run([]string{\"run\"})\n}\n\nfunc TestParseMultiBool(t *testing.T) {\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tBoolFlag{Name: \"serve, s\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif ctx.Bool(\"serve\") != true {\n\t\t\t\tt.Errorf(\"main name not set\")\n\t\t\t}\n\t\t\tif ctx.Bool(\"s\") != true {\n\t\t\t\tt.Errorf(\"short name not set\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\ta.Run([]string{\"run\", \"--serve\"})\n}\n\nfunc TestParseDestinationBool(t *testing.T) {\n\tvar dest bool\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tBoolFlag{\n\t\t\t\tName:        \"dest\",\n\t\t\t\tDestination: &dest,\n\t\t\t},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif dest != true {\n\t\t\t\tt.Errorf(\"expected destination Bool true\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\ta.Run([]string{\"run\", \"--dest\"})\n}\n\nfunc TestParseMultiBoolFromEnv(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_DEBUG\", \"1\")\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tBoolFlag{Name: \"debug, d\", EnvVar: \"APP_DEBUG\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif ctx.Bool(\"debug\") != true {\n\t\t\t\tt.Errorf(\"main name not set from env\")\n\t\t\t}\n\t\t\tif ctx.Bool(\"d\") != true {\n\t\t\t\tt.Errorf(\"short name not set from env\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\ta.Run([]string{\"run\"})\n}\n\nfunc TestParseMultiBoolFromEnvCascade(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_DEBUG\", \"1\")\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tBoolFlag{Name: \"debug, d\", EnvVar: \"COMPAT_DEBUG,APP_DEBUG\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif ctx.Bool(\"debug\") != true {\n\t\t\t\tt.Errorf(\"main name not set from env\")\n\t\t\t}\n\t\t\tif ctx.Bool(\"d\") != true {\n\t\t\t\tt.Errorf(\"short name not set from env\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\ta.Run([]string{\"run\"})\n}\n\nfunc TestParseBoolTFromEnv(t *testing.T) {\n\tvar boolTFlagTests = []struct {\n\t\tinput  string\n\t\toutput bool\n\t}{\n\t\t{\"\", false},\n\t\t{\"1\", true},\n\t\t{\"false\", false},\n\t\t{\"true\", true},\n\t}\n\n\tfor _, test := range boolTFlagTests {\n\t\tos.Clearenv()\n\t\tos.Setenv(\"DEBUG\", test.input)\n\t\ta := App{\n\t\t\tFlags: []Flag{\n\t\t\t\tBoolTFlag{Name: \"debug, d\", EnvVar: \"DEBUG\"},\n\t\t\t},\n\t\t\tAction: func(ctx *Context) error {\n\t\t\t\tif ctx.Bool(\"debug\") != test.output {\n\t\t\t\t\tt.Errorf(\"expected %+v to be parsed as %+v, instead was %+v\", test.input, test.output, ctx.Bool(\"debug\"))\n\t\t\t\t}\n\t\t\t\tif ctx.Bool(\"d\") != test.output {\n\t\t\t\t\tt.Errorf(\"expected %+v to be parsed as %+v, instead was %+v\", test.input, test.output, ctx.Bool(\"d\"))\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t},\n\t\t}\n\t\ta.Run([]string{\"run\"})\n\t}\n}\n\nfunc TestParseMultiBoolT(t *testing.T) {\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tBoolTFlag{Name: \"serve, s\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif ctx.BoolT(\"serve\") != true {\n\t\t\t\tt.Errorf(\"main name not set\")\n\t\t\t}\n\t\t\tif ctx.BoolT(\"s\") != true {\n\t\t\t\tt.Errorf(\"short name not set\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\ta.Run([]string{\"run\", \"--serve\"})\n}\n\nfunc TestParseDestinationBoolT(t *testing.T) {\n\tvar dest bool\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tBoolTFlag{\n\t\t\t\tName:        \"dest\",\n\t\t\t\tDestination: &dest,\n\t\t\t},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif dest != true {\n\t\t\t\tt.Errorf(\"expected destination BoolT true\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\ta.Run([]string{\"run\", \"--dest\"})\n}\n\nfunc TestParseMultiBoolTFromEnv(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_DEBUG\", \"0\")\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tBoolTFlag{Name: \"debug, d\", EnvVar: \"APP_DEBUG\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif ctx.BoolT(\"debug\") != false {\n\t\t\t\tt.Errorf(\"main name not set from env\")\n\t\t\t}\n\t\t\tif ctx.BoolT(\"d\") != false {\n\t\t\t\tt.Errorf(\"short name not set from env\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\ta.Run([]string{\"run\"})\n}\n\nfunc TestParseMultiBoolTFromEnvCascade(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_DEBUG\", \"0\")\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tBoolTFlag{Name: \"debug, d\", EnvVar: \"COMPAT_DEBUG,APP_DEBUG\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif ctx.BoolT(\"debug\") != false {\n\t\t\t\tt.Errorf(\"main name not set from env\")\n\t\t\t}\n\t\t\tif ctx.BoolT(\"d\") != false {\n\t\t\t\tt.Errorf(\"short name not set from env\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\ta.Run([]string{\"run\"})\n}\n\ntype Parser [2]string\n\nfunc (p *Parser) Set(value string) error {\n\tparts := strings.Split(value, \",\")\n\tif len(parts) != 2 {\n\t\treturn fmt.Errorf(\"invalid format\")\n\t}\n\n\t(*p)[0] = parts[0]\n\t(*p)[1] = parts[1]\n\n\treturn nil\n}\n\nfunc (p *Parser) String() string {\n\treturn fmt.Sprintf(\"%s,%s\", p[0], p[1])\n}\n\nfunc (p *Parser) Get() interface{} {\n\treturn p\n}\n\nfunc TestParseGeneric(t *testing.T) {\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tGenericFlag{Name: \"serve, s\", Value: &Parser{}},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif !reflect.DeepEqual(ctx.Generic(\"serve\"), &Parser{\"10\", \"20\"}) {\n\t\t\t\tt.Errorf(\"main name not set\")\n\t\t\t}\n\t\t\tif !reflect.DeepEqual(ctx.Generic(\"s\"), &Parser{\"10\", \"20\"}) {\n\t\t\t\tt.Errorf(\"short name not set\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\ta.Run([]string{\"run\", \"-s\", \"10,20\"})\n}\n\nfunc TestParseGenericFromEnv(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_SERVE\", \"20,30\")\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tGenericFlag{Name: \"serve, s\", Value: &Parser{}, EnvVar: \"APP_SERVE\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif !reflect.DeepEqual(ctx.Generic(\"serve\"), &Parser{\"20\", \"30\"}) {\n\t\t\t\tt.Errorf(\"main name not set from env\")\n\t\t\t}\n\t\t\tif !reflect.DeepEqual(ctx.Generic(\"s\"), &Parser{\"20\", \"30\"}) {\n\t\t\t\tt.Errorf(\"short name not set from env\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\ta.Run([]string{\"run\"})\n}\n\nfunc TestParseGenericFromEnvCascade(t *testing.T) {\n\tos.Clearenv()\n\tos.Setenv(\"APP_FOO\", \"99,2000\")\n\ta := App{\n\t\tFlags: []Flag{\n\t\t\tGenericFlag{Name: \"foos\", Value: &Parser{}, EnvVar: \"COMPAT_FOO,APP_FOO\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif !reflect.DeepEqual(ctx.Generic(\"foos\"), &Parser{\"99\", \"2000\"}) {\n\t\t\t\tt.Errorf(\"value not set from env\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\ta.Run([]string{\"run\"})\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/funcs.go",
    "content": "package cli\n\n// BashCompleteFunc is an action to execute when the bash-completion flag is set\ntype BashCompleteFunc func(*Context)\n\n// BeforeFunc is an action to execute before any subcommands are run, but after\n// the context is ready if a non-nil error is returned, no subcommands are run\ntype BeforeFunc func(*Context) error\n\n// AfterFunc is an action to execute after any subcommands are run, but after the\n// subcommand has finished it is run even if Action() panics\ntype AfterFunc func(*Context) error\n\n// ActionFunc is the action to execute when no subcommands are specified\ntype ActionFunc func(*Context) error\n\n// CommandNotFoundFunc is executed if the proper command cannot be found\ntype CommandNotFoundFunc func(*Context, string)\n\n// OnUsageErrorFunc is executed if an usage error occurs. This is useful for displaying\n// customized usage error messages.  This function is able to replace the\n// original error messages.  If this function is not set, the \"Incorrect usage\"\n// is displayed and the execution is interrupted.\ntype OnUsageErrorFunc func(context *Context, err error, isSubcommand bool) error\n\n// FlagStringFunc is used by the help generation to display a flag, which is\n// expected to be a single line.\ntype FlagStringFunc func(Flag) string\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/generate-flag-types",
    "content": "#!/usr/bin/env python\n\"\"\"\nThe flag types that ship with the cli library have many things in common, and\nso we can take advantage of the `go generate` command to create much of the\nsource code from a list of definitions.  These definitions attempt to cover\nthe parts that vary between flag types, and should evolve as needed.\n\nAn example of the minimum definition needed is:\n\n    {\n      \"name\": \"SomeType\",\n      \"type\": \"sometype\",\n      \"context_default\": \"nil\"\n    }\n\nIn this example, the code generated for the `cli` package will include a type\nnamed `SomeTypeFlag` that is expected to wrap a value of type `sometype`.\nFetching values by name via `*cli.Context` will default to a value of `nil`.\n\nA more complete, albeit somewhat redundant, example showing all available\ndefinition keys is:\n\n    {\n      \"name\": \"VeryMuchType\",\n      \"type\": \"*VeryMuchType\",\n      \"value\": true,\n      \"dest\": false,\n      \"doctail\": \" which really only wraps a []float64, oh well!\",\n      \"context_type\": \"[]float64\",\n      \"context_default\": \"nil\",\n      \"parser\": \"parseVeryMuchType(f.Value.String())\",\n      \"parser_cast\": \"[]float64(parsed)\"\n    }\n\nThe meaning of each field is as follows:\n\n               name (string) - The type \"name\", which will be suffixed with\n                               `Flag` when generating the type definition\n                               for `cli` and the wrapper type for `altsrc`\n               type (string) - The type that the generated `Flag` type for `cli`\n                               is expected to \"contain\" as its `.Value` member\n                value (bool) - Should the generated `cli` type have a `Value`\n                               member?\n                 dest (bool) - Should the generated `cli` type support a\n                               destination pointer?\n            doctail (string) - Additional docs for the `cli` flag type comment\n       context_type (string) - The literal type used in the `*cli.Context`\n                               reader func signature\n    context_default (string) - The literal value used as the default by the\n                               `*cli.Context` reader funcs when no value is\n                               present\n             parser (string) - Literal code used to parse the flag `f`,\n                               expected to have a return signature of\n                               (value, error)\n        parser_cast (string) - Literal code used to cast the `parsed` value\n                               returned from the `parser` code\n\"\"\"\n\nfrom __future__ import print_function, unicode_literals\n\nimport argparse\nimport json\nimport os\nimport subprocess\nimport sys\nimport tempfile\nimport textwrap\n\n\nclass _FancyFormatter(argparse.ArgumentDefaultsHelpFormatter,\n                      argparse.RawDescriptionHelpFormatter):\n    pass\n\n\ndef main(sysargs=sys.argv[:]):\n    parser = argparse.ArgumentParser(\n        description='Generate flag type code!',\n        formatter_class=_FancyFormatter)\n    parser.add_argument(\n        'package',\n        type=str, default='cli', choices=_WRITEFUNCS.keys(),\n        help='Package for which flag types will be generated'\n    )\n    parser.add_argument(\n        '-i', '--in-json',\n        type=argparse.FileType('r'),\n        default=sys.stdin,\n        help='Input JSON file which defines each type to be generated'\n    )\n    parser.add_argument(\n        '-o', '--out-go',\n        type=argparse.FileType('w'),\n        default=sys.stdout,\n        help='Output file/stream to which generated source will be written'\n    )\n    parser.epilog = __doc__\n\n    args = parser.parse_args(sysargs[1:])\n    _generate_flag_types(_WRITEFUNCS[args.package], args.out_go, args.in_json)\n    return 0\n\n\ndef _generate_flag_types(writefunc, output_go, input_json):\n    types = json.load(input_json)\n\n    tmp = tempfile.NamedTemporaryFile(suffix='.go', delete=False)\n    writefunc(tmp, types)\n    tmp.close()\n\n    new_content = subprocess.check_output(\n        ['goimports', tmp.name]\n    ).decode('utf-8')\n\n    print(new_content, file=output_go, end='')\n    output_go.flush()\n    os.remove(tmp.name)\n\n\ndef _set_typedef_defaults(typedef):\n    typedef.setdefault('doctail', '')\n    typedef.setdefault('context_type', typedef['type'])\n    typedef.setdefault('dest', True)\n    typedef.setdefault('value', True)\n    typedef.setdefault('parser', 'f.Value, error(nil)')\n    typedef.setdefault('parser_cast', 'parsed')\n\n\ndef _write_cli_flag_types(outfile, types):\n    _fwrite(outfile, \"\"\"\\\n        package cli\n\n        // WARNING: This file is generated!\n\n        \"\"\")\n\n    for typedef in types:\n        _set_typedef_defaults(typedef)\n\n        _fwrite(outfile, \"\"\"\\\n        // {name}Flag is a flag with type {type}{doctail}\n        type {name}Flag struct {{\n            Name string\n            Usage string\n            EnvVar string\n            Hidden bool\n        \"\"\".format(**typedef))\n\n        if typedef['value']:\n            _fwrite(outfile, \"\"\"\\\n            Value {type}\n            \"\"\".format(**typedef))\n\n        if typedef['dest']:\n            _fwrite(outfile, \"\"\"\\\n            Destination *{type}\n            \"\"\".format(**typedef))\n\n        _fwrite(outfile, \"\\n}\\n\\n\")\n\n        _fwrite(outfile, \"\"\"\\\n            // String returns a readable representation of this value\n            // (for usage defaults)\n            func (f {name}Flag) String() string {{\n                return FlagStringer(f)\n            }}\n\n            // GetName returns the name of the flag\n            func (f {name}Flag) GetName() string {{\n                return f.Name\n            }}\n\n            // {name} looks up the value of a local {name}Flag, returns\n            // {context_default} if not found\n            func (c *Context) {name}(name string) {context_type} {{\n                return lookup{name}(name, c.flagSet)\n            }}\n\n            // Global{name} looks up the value of a global {name}Flag, returns\n            // {context_default} if not found\n            func (c *Context) Global{name}(name string) {context_type} {{\n                if fs := lookupGlobalFlagSet(name, c); fs != nil {{\n                    return lookup{name}(name, fs)\n                }}\n                return {context_default}\n            }}\n\n            func lookup{name}(name string, set *flag.FlagSet) {context_type} {{\n                f := set.Lookup(name)\n                if f != nil {{\n                    parsed, err := {parser}\n                    if err != nil {{\n                        return {context_default}\n                    }}\n                    return {parser_cast}\n                }}\n                return {context_default}\n            }}\n            \"\"\".format(**typedef))\n\n\ndef _write_altsrc_flag_types(outfile, types):\n    _fwrite(outfile, \"\"\"\\\n        package altsrc\n\n        import (\n            \"gopkg.in/urfave/cli.v1\"\n        )\n\n        // WARNING: This file is generated!\n\n        \"\"\")\n\n    for typedef in types:\n        _set_typedef_defaults(typedef)\n\n        _fwrite(outfile, \"\"\"\\\n        // {name}Flag is the flag type that wraps cli.{name}Flag to allow\n        // for other values to be specified\n        type {name}Flag struct {{\n            cli.{name}Flag\n            set *flag.FlagSet\n        }}\n\n        // New{name}Flag creates a new {name}Flag\n        func New{name}Flag(fl cli.{name}Flag) *{name}Flag {{\n            return &{name}Flag{{{name}Flag: fl, set: nil}}\n        }}\n\n        // Apply saves the flagSet for later usage calls, then calls the\n        // wrapped {name}Flag.Apply\n        func (f *{name}Flag) Apply(set *flag.FlagSet) {{\n            f.set = set\n            f.{name}Flag.Apply(set)\n        }}\n\n        // ApplyWithError saves the flagSet for later usage calls, then calls the\n        // wrapped {name}Flag.ApplyWithError\n        func (f *{name}Flag) ApplyWithError(set *flag.FlagSet) error {{\n            f.set = set\n            return f.{name}Flag.ApplyWithError(set)\n        }}\n        \"\"\".format(**typedef))\n\n\ndef _fwrite(outfile, text):\n    print(textwrap.dedent(text), end='', file=outfile)\n\n\n_WRITEFUNCS = {\n    'cli': _write_cli_flag_types,\n    'altsrc': _write_altsrc_flag_types\n}\n\nif __name__ == '__main__':\n    sys.exit(main())\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/help.go",
    "content": "package cli\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strings\"\n\t\"text/tabwriter\"\n\t\"text/template\"\n)\n\n// AppHelpTemplate is the text template for the Default help topic.\n// cli.go uses text/template to render templates. You can\n// render custom help text by setting this variable.\nvar AppHelpTemplate = `NAME:\n   {{.Name}}{{if .Usage}} - {{.Usage}}{{end}}\n\nUSAGE:\n   {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Version}}{{if not .HideVersion}}\n\nVERSION:\n   {{.Version}}{{end}}{{end}}{{if .Description}}\n\nDESCRIPTION:\n   {{.Description}}{{end}}{{if len .Authors}}\n\nAUTHOR{{with $length := len .Authors}}{{if ne 1 $length}}S{{end}}{{end}}:\n   {{range $index, $author := .Authors}}{{if $index}}\n   {{end}}{{$author}}{{end}}{{end}}{{if .VisibleCommands}}\n\nCOMMANDS:{{range .VisibleCategories}}{{if .Name}}\n   {{.Name}}:{{end}}{{range .VisibleCommands}}\n     {{join .Names \", \"}}{{\"\\t\"}}{{.Usage}}{{end}}{{end}}{{end}}{{if .VisibleFlags}}\n\nGLOBAL OPTIONS:\n   {{range $index, $option := .VisibleFlags}}{{if $index}}\n   {{end}}{{$option}}{{end}}{{end}}{{if .Copyright}}\n\nCOPYRIGHT:\n   {{.Copyright}}{{end}}\n`\n\n// CommandHelpTemplate is the text template for the command help topic.\n// cli.go uses text/template to render templates. You can\n// render custom help text by setting this variable.\nvar CommandHelpTemplate = `NAME:\n   {{.HelpName}} - {{.Usage}}\n\nUSAGE:\n   {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}}{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Category}}\n\nCATEGORY:\n   {{.Category}}{{end}}{{if .Description}}\n\nDESCRIPTION:\n   {{.Description}}{{end}}{{if .VisibleFlags}}\n\nOPTIONS:\n   {{range .VisibleFlags}}{{.}}\n   {{end}}{{end}}\n`\n\n// SubcommandHelpTemplate is the text template for the subcommand help topic.\n// cli.go uses text/template to render templates. You can\n// render custom help text by setting this variable.\nvar SubcommandHelpTemplate = `NAME:\n   {{.HelpName}} - {{if .Description}}{{.Description}}{{else}}{{.Usage}}{{end}}\n\nUSAGE:\n   {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} command{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}\n\nCOMMANDS:{{range .VisibleCategories}}{{if .Name}}\n   {{.Name}}:{{end}}{{range .VisibleCommands}}\n     {{join .Names \", \"}}{{\"\\t\"}}{{.Usage}}{{end}}\n{{end}}{{if .VisibleFlags}}\nOPTIONS:\n   {{range .VisibleFlags}}{{.}}\n   {{end}}{{end}}\n`\n\nvar helpCommand = Command{\n\tName:      \"help\",\n\tAliases:   []string{\"h\"},\n\tUsage:     \"Shows a list of commands or help for one command\",\n\tArgsUsage: \"[command]\",\n\tAction: func(c *Context) error {\n\t\targs := c.Args()\n\t\tif args.Present() {\n\t\t\treturn ShowCommandHelp(c, args.First())\n\t\t}\n\n\t\tShowAppHelp(c)\n\t\treturn nil\n\t},\n}\n\nvar helpSubcommand = Command{\n\tName:      \"help\",\n\tAliases:   []string{\"h\"},\n\tUsage:     \"Shows a list of commands or help for one command\",\n\tArgsUsage: \"[command]\",\n\tAction: func(c *Context) error {\n\t\targs := c.Args()\n\t\tif args.Present() {\n\t\t\treturn ShowCommandHelp(c, args.First())\n\t\t}\n\n\t\treturn ShowSubcommandHelp(c)\n\t},\n}\n\n// Prints help for the App or Command\ntype helpPrinter func(w io.Writer, templ string, data interface{})\n\n// Prints help for the App or Command with custom template function.\ntype helpPrinterCustom func(w io.Writer, templ string, data interface{}, customFunc map[string]interface{})\n\n// HelpPrinter is a function that writes the help output. If not set a default\n// is used. The function signature is:\n// func(w io.Writer, templ string, data interface{})\nvar HelpPrinter helpPrinter = printHelp\n\n// HelpPrinterCustom is same as HelpPrinter but\n// takes a custom function for template function map.\nvar HelpPrinterCustom helpPrinterCustom = printHelpCustom\n\n// VersionPrinter prints the version for the App\nvar VersionPrinter = printVersion\n\n// ShowAppHelpAndExit - Prints the list of subcommands for the app and exits with exit code.\nfunc ShowAppHelpAndExit(c *Context, exitCode int) {\n\tShowAppHelp(c)\n\tos.Exit(exitCode)\n}\n\n// ShowAppHelp is an action that displays the help.\nfunc ShowAppHelp(c *Context) (err error) {\n\tif c.App.CustomAppHelpTemplate == \"\" {\n\t\tHelpPrinter(c.App.Writer, AppHelpTemplate, c.App)\n\t\treturn\n\t}\n\tcustomAppData := func() map[string]interface{} {\n\t\tif c.App.ExtraInfo == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn map[string]interface{}{\n\t\t\t\"ExtraInfo\": c.App.ExtraInfo,\n\t\t}\n\t}\n\tHelpPrinterCustom(c.App.Writer, c.App.CustomAppHelpTemplate, c.App, customAppData())\n\treturn nil\n}\n\n// DefaultAppComplete prints the list of subcommands as the default app completion method\nfunc DefaultAppComplete(c *Context) {\n\tfor _, command := range c.App.Commands {\n\t\tif command.Hidden {\n\t\t\tcontinue\n\t\t}\n\t\tfor _, name := range command.Names() {\n\t\t\tfmt.Fprintln(c.App.Writer, name)\n\t\t}\n\t}\n}\n\n// ShowCommandHelpAndExit - exits with code after showing help\nfunc ShowCommandHelpAndExit(c *Context, command string, code int) {\n\tShowCommandHelp(c, command)\n\tos.Exit(code)\n}\n\n// ShowCommandHelp prints help for the given command\nfunc ShowCommandHelp(ctx *Context, command string) error {\n\t// show the subcommand help for a command with subcommands\n\tif command == \"\" {\n\t\tHelpPrinter(ctx.App.Writer, SubcommandHelpTemplate, ctx.App)\n\t\treturn nil\n\t}\n\n\tfor _, c := range ctx.App.Commands {\n\t\tif c.HasName(command) {\n\t\t\tif c.CustomHelpTemplate != \"\" {\n\t\t\t\tHelpPrinterCustom(ctx.App.Writer, c.CustomHelpTemplate, c, nil)\n\t\t\t} else {\n\t\t\t\tHelpPrinter(ctx.App.Writer, CommandHelpTemplate, c)\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tif ctx.App.CommandNotFound == nil {\n\t\treturn NewExitError(fmt.Sprintf(\"No help topic for '%v'\", command), 3)\n\t}\n\n\tctx.App.CommandNotFound(ctx, command)\n\treturn nil\n}\n\n// ShowSubcommandHelp prints help for the given subcommand\nfunc ShowSubcommandHelp(c *Context) error {\n\treturn ShowCommandHelp(c, c.Command.Name)\n}\n\n// ShowVersion prints the version number of the App\nfunc ShowVersion(c *Context) {\n\tVersionPrinter(c)\n}\n\nfunc printVersion(c *Context) {\n\tfmt.Fprintf(c.App.Writer, \"%v version %v\\n\", c.App.Name, c.App.Version)\n}\n\n// ShowCompletions prints the lists of commands within a given context\nfunc ShowCompletions(c *Context) {\n\ta := c.App\n\tif a != nil && a.BashComplete != nil {\n\t\ta.BashComplete(c)\n\t}\n}\n\n// ShowCommandCompletions prints the custom completions for a given command\nfunc ShowCommandCompletions(ctx *Context, command string) {\n\tc := ctx.App.Command(command)\n\tif c != nil && c.BashComplete != nil {\n\t\tc.BashComplete(ctx)\n\t}\n}\n\nfunc printHelpCustom(out io.Writer, templ string, data interface{}, customFunc map[string]interface{}) {\n\tfuncMap := template.FuncMap{\n\t\t\"join\": strings.Join,\n\t}\n\tif customFunc != nil {\n\t\tfor key, value := range customFunc {\n\t\t\tfuncMap[key] = value\n\t\t}\n\t}\n\n\tw := tabwriter.NewWriter(out, 1, 8, 2, ' ', 0)\n\tt := template.Must(template.New(\"help\").Funcs(funcMap).Parse(templ))\n\terr := t.Execute(w, data)\n\tif err != nil {\n\t\t// If the writer is closed, t.Execute will fail, and there's nothing\n\t\t// we can do to recover.\n\t\tif os.Getenv(\"CLI_TEMPLATE_ERROR_DEBUG\") != \"\" {\n\t\t\tfmt.Fprintf(ErrWriter, \"CLI TEMPLATE ERROR: %#v\\n\", err)\n\t\t}\n\t\treturn\n\t}\n\tw.Flush()\n}\n\nfunc printHelp(out io.Writer, templ string, data interface{}) {\n\tprintHelpCustom(out, templ, data, nil)\n}\n\nfunc checkVersion(c *Context) bool {\n\tfound := false\n\tif VersionFlag.GetName() != \"\" {\n\t\teachName(VersionFlag.GetName(), func(name string) {\n\t\t\tif c.GlobalBool(name) || c.Bool(name) {\n\t\t\t\tfound = true\n\t\t\t}\n\t\t})\n\t}\n\treturn found\n}\n\nfunc checkHelp(c *Context) bool {\n\tfound := false\n\tif HelpFlag.GetName() != \"\" {\n\t\teachName(HelpFlag.GetName(), func(name string) {\n\t\t\tif c.GlobalBool(name) || c.Bool(name) {\n\t\t\t\tfound = true\n\t\t\t}\n\t\t})\n\t}\n\treturn found\n}\n\nfunc checkCommandHelp(c *Context, name string) bool {\n\tif c.Bool(\"h\") || c.Bool(\"help\") {\n\t\tShowCommandHelp(c, name)\n\t\treturn true\n\t}\n\n\treturn false\n}\n\nfunc checkSubcommandHelp(c *Context) bool {\n\tif c.Bool(\"h\") || c.Bool(\"help\") {\n\t\tShowSubcommandHelp(c)\n\t\treturn true\n\t}\n\n\treturn false\n}\n\nfunc checkShellCompleteFlag(a *App, arguments []string) (bool, []string) {\n\tif !a.EnableBashCompletion {\n\t\treturn false, arguments\n\t}\n\n\tpos := len(arguments) - 1\n\tlastArg := arguments[pos]\n\n\tif lastArg != \"--\"+BashCompletionFlag.GetName() {\n\t\treturn false, arguments\n\t}\n\n\treturn true, arguments[:pos]\n}\n\nfunc checkCompletions(c *Context) bool {\n\tif !c.shellComplete {\n\t\treturn false\n\t}\n\n\tif args := c.Args(); args.Present() {\n\t\tname := args.First()\n\t\tif cmd := c.App.Command(name); cmd != nil {\n\t\t\t// let the command handle the completion\n\t\t\treturn false\n\t\t}\n\t}\n\n\tShowCompletions(c)\n\treturn true\n}\n\nfunc checkCommandCompletions(c *Context, name string) bool {\n\tif !c.shellComplete {\n\t\treturn false\n\t}\n\n\tShowCommandCompletions(c, name)\n\treturn true\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/help_test.go",
    "content": "package cli\n\nimport (\n\t\"bytes\"\n\t\"flag\"\n\t\"fmt\"\n\t\"runtime\"\n\t\"strings\"\n\t\"testing\"\n)\n\nfunc Test_ShowAppHelp_NoAuthor(t *testing.T) {\n\toutput := new(bytes.Buffer)\n\tapp := NewApp()\n\tapp.Writer = output\n\n\tc := NewContext(app, nil, nil)\n\n\tShowAppHelp(c)\n\n\tif bytes.Index(output.Bytes(), []byte(\"AUTHOR(S):\")) != -1 {\n\t\tt.Errorf(\"expected\\n%snot to include %s\", output.String(), \"AUTHOR(S):\")\n\t}\n}\n\nfunc Test_ShowAppHelp_NoVersion(t *testing.T) {\n\toutput := new(bytes.Buffer)\n\tapp := NewApp()\n\tapp.Writer = output\n\n\tapp.Version = \"\"\n\n\tc := NewContext(app, nil, nil)\n\n\tShowAppHelp(c)\n\n\tif bytes.Index(output.Bytes(), []byte(\"VERSION:\")) != -1 {\n\t\tt.Errorf(\"expected\\n%snot to include %s\", output.String(), \"VERSION:\")\n\t}\n}\n\nfunc Test_ShowAppHelp_HideVersion(t *testing.T) {\n\toutput := new(bytes.Buffer)\n\tapp := NewApp()\n\tapp.Writer = output\n\n\tapp.HideVersion = true\n\n\tc := NewContext(app, nil, nil)\n\n\tShowAppHelp(c)\n\n\tif bytes.Index(output.Bytes(), []byte(\"VERSION:\")) != -1 {\n\t\tt.Errorf(\"expected\\n%snot to include %s\", output.String(), \"VERSION:\")\n\t}\n}\n\nfunc Test_Help_Custom_Flags(t *testing.T) {\n\toldFlag := HelpFlag\n\tdefer func() {\n\t\tHelpFlag = oldFlag\n\t}()\n\n\tHelpFlag = BoolFlag{\n\t\tName:  \"help, x\",\n\t\tUsage: \"show help\",\n\t}\n\n\tapp := App{\n\t\tFlags: []Flag{\n\t\t\tBoolFlag{Name: \"foo, h\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif ctx.Bool(\"h\") != true {\n\t\t\t\tt.Errorf(\"custom help flag not set\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\toutput := new(bytes.Buffer)\n\tapp.Writer = output\n\tapp.Run([]string{\"test\", \"-h\"})\n\tif output.Len() > 0 {\n\t\tt.Errorf(\"unexpected output: %s\", output.String())\n\t}\n}\n\nfunc Test_Version_Custom_Flags(t *testing.T) {\n\toldFlag := VersionFlag\n\tdefer func() {\n\t\tVersionFlag = oldFlag\n\t}()\n\n\tVersionFlag = BoolFlag{\n\t\tName:  \"version, V\",\n\t\tUsage: \"show version\",\n\t}\n\n\tapp := App{\n\t\tFlags: []Flag{\n\t\t\tBoolFlag{Name: \"foo, v\"},\n\t\t},\n\t\tAction: func(ctx *Context) error {\n\t\t\tif ctx.Bool(\"v\") != true {\n\t\t\t\tt.Errorf(\"custom version flag not set\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\toutput := new(bytes.Buffer)\n\tapp.Writer = output\n\tapp.Run([]string{\"test\", \"-v\"})\n\tif output.Len() > 0 {\n\t\tt.Errorf(\"unexpected output: %s\", output.String())\n\t}\n}\n\nfunc Test_helpCommand_Action_ErrorIfNoTopic(t *testing.T) {\n\tapp := NewApp()\n\n\tset := flag.NewFlagSet(\"test\", 0)\n\tset.Parse([]string{\"foo\"})\n\n\tc := NewContext(app, set, nil)\n\n\terr := helpCommand.Action.(func(*Context) error)(c)\n\n\tif err == nil {\n\t\tt.Fatalf(\"expected error from helpCommand.Action(), but got nil\")\n\t}\n\n\texitErr, ok := err.(*ExitError)\n\tif !ok {\n\t\tt.Fatalf(\"expected ExitError from helpCommand.Action(), but instead got: %v\", err.Error())\n\t}\n\n\tif !strings.HasPrefix(exitErr.Error(), \"No help topic for\") {\n\t\tt.Fatalf(\"expected an unknown help topic error, but got: %v\", exitErr.Error())\n\t}\n\n\tif exitErr.exitCode != 3 {\n\t\tt.Fatalf(\"expected exit value = 3, got %d instead\", exitErr.exitCode)\n\t}\n}\n\nfunc Test_helpCommand_InHelpOutput(t *testing.T) {\n\tapp := NewApp()\n\toutput := &bytes.Buffer{}\n\tapp.Writer = output\n\tapp.Run([]string{\"test\", \"--help\"})\n\n\ts := output.String()\n\n\tif strings.Contains(s, \"\\nCOMMANDS:\\nGLOBAL OPTIONS:\\n\") {\n\t\tt.Fatalf(\"empty COMMANDS section detected: %q\", s)\n\t}\n\n\tif !strings.Contains(s, \"help, h\") {\n\t\tt.Fatalf(\"missing \\\"help, h\\\": %q\", s)\n\t}\n}\n\nfunc Test_helpSubcommand_Action_ErrorIfNoTopic(t *testing.T) {\n\tapp := NewApp()\n\n\tset := flag.NewFlagSet(\"test\", 0)\n\tset.Parse([]string{\"foo\"})\n\n\tc := NewContext(app, set, nil)\n\n\terr := helpSubcommand.Action.(func(*Context) error)(c)\n\n\tif err == nil {\n\t\tt.Fatalf(\"expected error from helpCommand.Action(), but got nil\")\n\t}\n\n\texitErr, ok := err.(*ExitError)\n\tif !ok {\n\t\tt.Fatalf(\"expected ExitError from helpCommand.Action(), but instead got: %v\", err.Error())\n\t}\n\n\tif !strings.HasPrefix(exitErr.Error(), \"No help topic for\") {\n\t\tt.Fatalf(\"expected an unknown help topic error, but got: %v\", exitErr.Error())\n\t}\n\n\tif exitErr.exitCode != 3 {\n\t\tt.Fatalf(\"expected exit value = 3, got %d instead\", exitErr.exitCode)\n\t}\n}\n\nfunc TestShowAppHelp_CommandAliases(t *testing.T) {\n\tapp := &App{\n\t\tCommands: []Command{\n\t\t\t{\n\t\t\t\tName:    \"frobbly\",\n\t\t\t\tAliases: []string{\"fr\", \"frob\"},\n\t\t\t\tAction: func(ctx *Context) error {\n\t\t\t\t\treturn nil\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\toutput := &bytes.Buffer{}\n\tapp.Writer = output\n\tapp.Run([]string{\"foo\", \"--help\"})\n\n\tif !strings.Contains(output.String(), \"frobbly, fr, frob\") {\n\t\tt.Errorf(\"expected output to include all command aliases; got: %q\", output.String())\n\t}\n}\n\nfunc TestShowCommandHelp_CommandAliases(t *testing.T) {\n\tapp := &App{\n\t\tCommands: []Command{\n\t\t\t{\n\t\t\t\tName:    \"frobbly\",\n\t\t\t\tAliases: []string{\"fr\", \"frob\", \"bork\"},\n\t\t\t\tAction: func(ctx *Context) error {\n\t\t\t\t\treturn nil\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\toutput := &bytes.Buffer{}\n\tapp.Writer = output\n\tapp.Run([]string{\"foo\", \"help\", \"fr\"})\n\n\tif !strings.Contains(output.String(), \"frobbly\") {\n\t\tt.Errorf(\"expected output to include command name; got: %q\", output.String())\n\t}\n\n\tif strings.Contains(output.String(), \"bork\") {\n\t\tt.Errorf(\"expected output to exclude command aliases; got: %q\", output.String())\n\t}\n}\n\nfunc TestShowSubcommandHelp_CommandAliases(t *testing.T) {\n\tapp := &App{\n\t\tCommands: []Command{\n\t\t\t{\n\t\t\t\tName:    \"frobbly\",\n\t\t\t\tAliases: []string{\"fr\", \"frob\", \"bork\"},\n\t\t\t\tAction: func(ctx *Context) error {\n\t\t\t\t\treturn nil\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\toutput := &bytes.Buffer{}\n\tapp.Writer = output\n\tapp.Run([]string{\"foo\", \"help\"})\n\n\tif !strings.Contains(output.String(), \"frobbly, fr, frob, bork\") {\n\t\tt.Errorf(\"expected output to include all command aliases; got: %q\", output.String())\n\t}\n}\n\nfunc TestShowCommandHelp_Customtemplate(t *testing.T) {\n\tapp := &App{\n\t\tCommands: []Command{\n\t\t\t{\n\t\t\t\tName: \"frobbly\",\n\t\t\t\tAction: func(ctx *Context) error {\n\t\t\t\t\treturn nil\n\t\t\t\t},\n\t\t\t\tHelpName: \"foo frobbly\",\n\t\t\t\tCustomHelpTemplate: `NAME:\n   {{.HelpName}} - {{.Usage}}\n\nUSAGE:\n   {{.HelpName}} [FLAGS] TARGET [TARGET ...]\n\nFLAGS:\n  {{range .VisibleFlags}}{{.}}\n  {{end}}\nEXAMPLES:\n   1. Frobbly runs with this param locally.\n      $ {{.HelpName}} wobbly\n`,\n\t\t\t},\n\t\t},\n\t}\n\toutput := &bytes.Buffer{}\n\tapp.Writer = output\n\tapp.Run([]string{\"foo\", \"help\", \"frobbly\"})\n\n\tif strings.Contains(output.String(), \"2. Frobbly runs without this param locally.\") {\n\t\tt.Errorf(\"expected output to exclude \\\"2. Frobbly runs without this param locally.\\\"; got: %q\", output.String())\n\t}\n\n\tif !strings.Contains(output.String(), \"1. Frobbly runs with this param locally.\") {\n\t\tt.Errorf(\"expected output to include \\\"1. Frobbly runs with this param locally.\\\"; got: %q\", output.String())\n\t}\n\n\tif !strings.Contains(output.String(), \"$ foo frobbly wobbly\") {\n\t\tt.Errorf(\"expected output to include \\\"$ foo frobbly wobbly\\\"; got: %q\", output.String())\n\t}\n}\n\nfunc TestShowSubcommandHelp_CommandUsageText(t *testing.T) {\n\tapp := &App{\n\t\tCommands: []Command{\n\t\t\t{\n\t\t\t\tName:      \"frobbly\",\n\t\t\t\tUsageText: \"this is usage text\",\n\t\t\t},\n\t\t},\n\t}\n\n\toutput := &bytes.Buffer{}\n\tapp.Writer = output\n\n\tapp.Run([]string{\"foo\", \"frobbly\", \"--help\"})\n\n\tif !strings.Contains(output.String(), \"this is usage text\") {\n\t\tt.Errorf(\"expected output to include usage text; got: %q\", output.String())\n\t}\n}\n\nfunc TestShowSubcommandHelp_SubcommandUsageText(t *testing.T) {\n\tapp := &App{\n\t\tCommands: []Command{\n\t\t\t{\n\t\t\t\tName: \"frobbly\",\n\t\t\t\tSubcommands: []Command{\n\t\t\t\t\t{\n\t\t\t\t\t\tName:      \"bobbly\",\n\t\t\t\t\t\tUsageText: \"this is usage text\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\toutput := &bytes.Buffer{}\n\tapp.Writer = output\n\tapp.Run([]string{\"foo\", \"frobbly\", \"bobbly\", \"--help\"})\n\n\tif !strings.Contains(output.String(), \"this is usage text\") {\n\t\tt.Errorf(\"expected output to include usage text; got: %q\", output.String())\n\t}\n}\n\nfunc TestShowAppHelp_HiddenCommand(t *testing.T) {\n\tapp := &App{\n\t\tCommands: []Command{\n\t\t\t{\n\t\t\t\tName: \"frobbly\",\n\t\t\t\tAction: func(ctx *Context) error {\n\t\t\t\t\treturn nil\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tName:   \"secretfrob\",\n\t\t\t\tHidden: true,\n\t\t\t\tAction: func(ctx *Context) error {\n\t\t\t\t\treturn nil\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\toutput := &bytes.Buffer{}\n\tapp.Writer = output\n\tapp.Run([]string{\"app\", \"--help\"})\n\n\tif strings.Contains(output.String(), \"secretfrob\") {\n\t\tt.Errorf(\"expected output to exclude \\\"secretfrob\\\"; got: %q\", output.String())\n\t}\n\n\tif !strings.Contains(output.String(), \"frobbly\") {\n\t\tt.Errorf(\"expected output to include \\\"frobbly\\\"; got: %q\", output.String())\n\t}\n}\n\nfunc TestShowAppHelp_CustomAppTemplate(t *testing.T) {\n\tapp := &App{\n\t\tCommands: []Command{\n\t\t\t{\n\t\t\t\tName: \"frobbly\",\n\t\t\t\tAction: func(ctx *Context) error {\n\t\t\t\t\treturn nil\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tName:   \"secretfrob\",\n\t\t\t\tHidden: true,\n\t\t\t\tAction: func(ctx *Context) error {\n\t\t\t\t\treturn nil\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tExtraInfo: func() map[string]string {\n\t\t\tplatform := fmt.Sprintf(\"OS: %s | Arch: %s\", runtime.GOOS, runtime.GOARCH)\n\t\t\tgoruntime := fmt.Sprintf(\"Version: %s | CPUs: %d\", runtime.Version(), runtime.NumCPU())\n\t\t\treturn map[string]string{\n\t\t\t\t\"PLATFORM\": platform,\n\t\t\t\t\"RUNTIME\":  goruntime,\n\t\t\t}\n\t\t},\n\t\tCustomAppHelpTemplate: `NAME:\n  {{.Name}} - {{.Usage}}\n\nUSAGE:\n  {{.Name}} {{if .VisibleFlags}}[FLAGS] {{end}}COMMAND{{if .VisibleFlags}} [COMMAND FLAGS | -h]{{end}} [ARGUMENTS...]\n\nCOMMANDS:\n  {{range .VisibleCommands}}{{join .Names \", \"}}{{ \"\\t\" }}{{.Usage}}\n  {{end}}{{if .VisibleFlags}}\nGLOBAL FLAGS:\n  {{range .VisibleFlags}}{{.}}\n  {{end}}{{end}}\nVERSION:\n  2.0.0\n{{\"\\n\"}}{{range $key, $value := ExtraInfo}}\n{{$key}}:\n  {{$value}}\n{{end}}`,\n\t}\n\n\toutput := &bytes.Buffer{}\n\tapp.Writer = output\n\tapp.Run([]string{\"app\", \"--help\"})\n\n\tif strings.Contains(output.String(), \"secretfrob\") {\n\t\tt.Errorf(\"expected output to exclude \\\"secretfrob\\\"; got: %q\", output.String())\n\t}\n\n\tif !strings.Contains(output.String(), \"frobbly\") {\n\t\tt.Errorf(\"expected output to include \\\"frobbly\\\"; got: %q\", output.String())\n\t}\n\n\tif !strings.Contains(output.String(), \"PLATFORM:\") ||\n\t\t!strings.Contains(output.String(), \"OS:\") ||\n\t\t!strings.Contains(output.String(), \"Arch:\") {\n\t\tt.Errorf(\"expected output to include \\\"PLATFORM:, OS: and Arch:\\\"; got: %q\", output.String())\n\t}\n\n\tif !strings.Contains(output.String(), \"RUNTIME:\") ||\n\t\t!strings.Contains(output.String(), \"Version:\") ||\n\t\t!strings.Contains(output.String(), \"CPUs:\") {\n\t\tt.Errorf(\"expected output to include \\\"RUNTIME:, Version: and CPUs:\\\"; got: %q\", output.String())\n\t}\n\n\tif !strings.Contains(output.String(), \"VERSION:\") ||\n\t\t!strings.Contains(output.String(), \"2.0.0\") {\n\t\tt.Errorf(\"expected output to include \\\"VERSION:, 2.0.0\\\"; got: %q\", output.String())\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/helpers_test.go",
    "content": "package cli\n\nimport (\n\t\"os\"\n\t\"reflect\"\n\t\"runtime\"\n\t\"strings\"\n\t\"testing\"\n)\n\nvar (\n\twd, _ = os.Getwd()\n)\n\nfunc expect(t *testing.T, a interface{}, b interface{}) {\n\t_, fn, line, _ := runtime.Caller(1)\n\tfn = strings.Replace(fn, wd+\"/\", \"\", -1)\n\n\tif !reflect.DeepEqual(a, b) {\n\t\tt.Errorf(\"(%s:%d) Expected %v (type %v) - Got %v (type %v)\", fn, line, b, reflect.TypeOf(b), a, reflect.TypeOf(a))\n\t}\n}\n\nfunc refute(t *testing.T, a interface{}, b interface{}) {\n\tif reflect.DeepEqual(a, b) {\n\t\tt.Errorf(\"Did not expect %v (type %v) - Got %v (type %v)\", b, reflect.TypeOf(b), a, reflect.TypeOf(a))\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/helpers_unix_test.go",
    "content": "// +build darwin dragonfly freebsd linux netbsd openbsd solaris\n\npackage cli\n\nimport \"os\"\n\nfunc clearenv() {\n\tos.Clearenv()\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/helpers_windows_test.go",
    "content": "package cli\n\nimport (\n\t\"os\"\n\t\"syscall\"\n)\n\n// os.Clearenv() doesn't actually unset variables on Windows\n// See: https://github.com/golang/go/issues/17902\nfunc clearenv() {\n\tfor _, s := range os.Environ() {\n\t\tfor j := 1; j < len(s); j++ {\n\t\t\tif s[j] == '=' {\n\t\t\t\tkeyp, _ := syscall.UTF16PtrFromString(s[0:j])\n\t\t\t\tsyscall.SetEnvironmentVariable(keyp, nil)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/codegangsta/cli/runtests",
    "content": "#!/usr/bin/env python\nfrom __future__ import print_function\n\nimport argparse\nimport os\nimport sys\nimport tempfile\n\nfrom subprocess import check_call, check_output\n\n\nPACKAGE_NAME = os.environ.get(\n    'CLI_PACKAGE_NAME', 'github.com/urfave/cli'\n)\n\n\ndef main(sysargs=sys.argv[:]):\n    targets = {\n        'vet': _vet,\n        'test': _test,\n        'gfmrun': _gfmrun,\n        'toc': _toc,\n        'gen': _gen,\n    }\n\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\n        'target', nargs='?', choices=tuple(targets.keys()), default='test'\n    )\n    args = parser.parse_args(sysargs[1:])\n\n    targets[args.target]()\n    return 0\n\n\ndef _test():\n    if check_output('go version'.split()).split()[2] < 'go1.2':\n        _run('go test -v .')\n        return\n\n    coverprofiles = []\n    for subpackage in ['', 'altsrc']:\n        coverprofile = 'cli.coverprofile'\n        if subpackage != '':\n            coverprofile = '{}.coverprofile'.format(subpackage)\n\n        coverprofiles.append(coverprofile)\n\n        _run('go test -v'.split() + [\n            '-coverprofile={}'.format(coverprofile),\n            ('{}/{}'.format(PACKAGE_NAME, subpackage)).rstrip('/')\n        ])\n\n    combined_name = _combine_coverprofiles(coverprofiles)\n    _run('go tool cover -func={}'.format(combined_name))\n    os.remove(combined_name)\n\n\ndef _gfmrun():\n    go_version = check_output('go version'.split()).split()[2]\n    if go_version < 'go1.3':\n        print('runtests: skip on {}'.format(go_version), file=sys.stderr)\n        return\n    _run(['gfmrun', '-c', str(_gfmrun_count()), '-s', 'README.md'])\n\n\ndef _vet():\n    _run('go vet ./...')\n\n\ndef _toc():\n    _run('node_modules/.bin/markdown-toc -i README.md')\n    _run('git diff --exit-code')\n\n\ndef _gen():\n    go_version = check_output('go version'.split()).split()[2]\n    if go_version < 'go1.5':\n        print('runtests: skip on {}'.format(go_version), file=sys.stderr)\n        return\n\n    _run('go generate ./...')\n    _run('git diff --exit-code')\n\n\ndef _run(command):\n    if hasattr(command, 'split'):\n        command = command.split()\n    print('runtests: {}'.format(' '.join(command)), file=sys.stderr)\n    check_call(command)\n\n\ndef _gfmrun_count():\n    with open('README.md') as infile:\n        lines = infile.read().splitlines()\n        return len(filter(_is_go_runnable, lines))\n\n\ndef _is_go_runnable(line):\n    return line.startswith('package main')\n\n\ndef _combine_coverprofiles(coverprofiles):\n    combined = tempfile.NamedTemporaryFile(\n        suffix='.coverprofile', delete=False\n    )\n    combined.write('mode: set\\n')\n\n    for coverprofile in coverprofiles:\n        with open(coverprofile, 'r') as infile:\n            for line in infile.readlines():\n                if not line.startswith('mode: '):\n                    combined.write(line)\n\n    combined.flush()\n    name = combined.name\n    combined.close()\n    return name\n\n\nif __name__ == '__main__':\n    sys.exit(main())\n"
  },
  {
    "path": "vendor/github.com/mitchellh/go-homedir/LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2013 Mitchell Hashimoto\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "vendor/github.com/mitchellh/go-homedir/README.md",
    "content": "# go-homedir\n\nThis is a Go library for detecting the user's home directory without\nthe use of cgo, so the library can be used in cross-compilation environments.\n\nUsage is incredibly simple, just call `homedir.Dir()` to get the home directory\nfor a user, and `homedir.Expand()` to expand the `~` in a path to the home\ndirectory.\n\n**Why not just use `os/user`?** The built-in `os/user` package requires\ncgo on Darwin systems. This means that any Go code that uses that package\ncannot cross compile. But 99% of the time the use for `os/user` is just to\nretrieve the home directory, which we can do for the current user without\ncgo. This library does that, enabling cross-compilation.\n"
  },
  {
    "path": "vendor/github.com/mitchellh/go-homedir/homedir.go",
    "content": "package homedir\n\nimport (\n\t\"bytes\"\n\t\"errors\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n\t\"runtime\"\n\t\"strconv\"\n\t\"strings\"\n\t\"sync\"\n)\n\n// DisableCache will disable caching of the home directory. Caching is enabled\n// by default.\nvar DisableCache bool\n\nvar homedirCache string\nvar cacheLock sync.RWMutex\n\n// Dir returns the home directory for the executing user.\n//\n// This uses an OS-specific method for discovering the home directory.\n// An error is returned if a home directory cannot be detected.\nfunc Dir() (string, error) {\n\tif !DisableCache {\n\t\tcacheLock.RLock()\n\t\tcached := homedirCache\n\t\tcacheLock.RUnlock()\n\t\tif cached != \"\" {\n\t\t\treturn cached, nil\n\t\t}\n\t}\n\n\tcacheLock.Lock()\n\tdefer cacheLock.Unlock()\n\n\tvar result string\n\tvar err error\n\tif runtime.GOOS == \"windows\" {\n\t\tresult, err = dirWindows()\n\t} else {\n\t\t// Unix-like system, so just assume Unix\n\t\tresult, err = dirUnix()\n\t}\n\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\thomedirCache = result\n\treturn result, nil\n}\n\n// Expand expands the path to include the home directory if the path\n// is prefixed with `~`. If it isn't prefixed with `~`, the path is\n// returned as-is.\nfunc Expand(path string) (string, error) {\n\tif len(path) == 0 {\n\t\treturn path, nil\n\t}\n\n\tif path[0] != '~' {\n\t\treturn path, nil\n\t}\n\n\tif len(path) > 1 && path[1] != '/' && path[1] != '\\\\' {\n\t\treturn \"\", errors.New(\"cannot expand user-specific home dir\")\n\t}\n\n\tdir, err := Dir()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn filepath.Join(dir, path[1:]), nil\n}\n\nfunc dirUnix() (string, error) {\n\t// First prefer the HOME environmental variable\n\tif home := os.Getenv(\"HOME\"); home != \"\" {\n\t\treturn home, nil\n\t}\n\n\t// If that fails, try getent\n\tvar stdout bytes.Buffer\n\tcmd := exec.Command(\"getent\", \"passwd\", strconv.Itoa(os.Getuid()))\n\tcmd.Stdout = &stdout\n\tif err := cmd.Run(); err != nil {\n\t\t// If the error is ErrNotFound, we ignore it. Otherwise, return it.\n\t\tif err != exec.ErrNotFound {\n\t\t\treturn \"\", err\n\t\t}\n\t} else {\n\t\tif passwd := strings.TrimSpace(stdout.String()); passwd != \"\" {\n\t\t\t// username:password:uid:gid:gecos:home:shell\n\t\t\tpasswdParts := strings.SplitN(passwd, \":\", 7)\n\t\t\tif len(passwdParts) > 5 {\n\t\t\t\treturn passwdParts[5], nil\n\t\t\t}\n\t\t}\n\t}\n\n\t// If all else fails, try the shell\n\tstdout.Reset()\n\tcmd = exec.Command(\"sh\", \"-c\", \"cd && pwd\")\n\tcmd.Stdout = &stdout\n\tif err := cmd.Run(); err != nil {\n\t\treturn \"\", err\n\t}\n\n\tresult := strings.TrimSpace(stdout.String())\n\tif result == \"\" {\n\t\treturn \"\", errors.New(\"blank output when reading home directory\")\n\t}\n\n\treturn result, nil\n}\n\nfunc dirWindows() (string, error) {\n\t// First prefer the HOME environmental variable\n\tif home := os.Getenv(\"HOME\"); home != \"\" {\n\t\treturn home, nil\n\t}\n\n\tdrive := os.Getenv(\"HOMEDRIVE\")\n\tpath := os.Getenv(\"HOMEPATH\")\n\thome := drive + path\n\tif drive == \"\" || path == \"\" {\n\t\thome = os.Getenv(\"USERPROFILE\")\n\t}\n\tif home == \"\" {\n\t\treturn \"\", errors.New(\"HOMEDRIVE, HOMEPATH, and USERPROFILE are blank\")\n\t}\n\n\treturn home, nil\n}\n"
  },
  {
    "path": "vendor/github.com/mitchellh/go-homedir/homedir_test.go",
    "content": "package homedir\n\nimport (\n\t\"os\"\n\t\"os/user\"\n\t\"path/filepath\"\n\t\"testing\"\n)\n\nfunc patchEnv(key, value string) func() {\n\tbck := os.Getenv(key)\n\tdeferFunc := func() {\n\t\tos.Setenv(key, bck)\n\t}\n\n\tos.Setenv(key, value)\n\treturn deferFunc\n}\n\nfunc BenchmarkDir(b *testing.B) {\n\t// We do this for any \"warmups\"\n\tfor i := 0; i < 10; i++ {\n\t\tDir()\n\t}\n\n\tb.ResetTimer()\n\tfor i := 0; i < b.N; i++ {\n\t\tDir()\n\t}\n}\n\nfunc TestDir(t *testing.T) {\n\tu, err := user.Current()\n\tif err != nil {\n\t\tt.Fatalf(\"err: %s\", err)\n\t}\n\n\tdir, err := Dir()\n\tif err != nil {\n\t\tt.Fatalf(\"err: %s\", err)\n\t}\n\n\tif u.HomeDir != dir {\n\t\tt.Fatalf(\"%#v != %#v\", u.HomeDir, dir)\n\t}\n}\n\nfunc TestExpand(t *testing.T) {\n\tu, err := user.Current()\n\tif err != nil {\n\t\tt.Fatalf(\"err: %s\", err)\n\t}\n\n\tcases := []struct {\n\t\tInput  string\n\t\tOutput string\n\t\tErr    bool\n\t}{\n\t\t{\n\t\t\t\"/foo\",\n\t\t\t\"/foo\",\n\t\t\tfalse,\n\t\t},\n\n\t\t{\n\t\t\t\"~/foo\",\n\t\t\tfilepath.Join(u.HomeDir, \"foo\"),\n\t\t\tfalse,\n\t\t},\n\n\t\t{\n\t\t\t\"\",\n\t\t\t\"\",\n\t\t\tfalse,\n\t\t},\n\n\t\t{\n\t\t\t\"~\",\n\t\t\tu.HomeDir,\n\t\t\tfalse,\n\t\t},\n\n\t\t{\n\t\t\t\"~foo/foo\",\n\t\t\t\"\",\n\t\t\ttrue,\n\t\t},\n\t}\n\n\tfor _, tc := range cases {\n\t\tactual, err := Expand(tc.Input)\n\t\tif (err != nil) != tc.Err {\n\t\t\tt.Fatalf(\"Input: %#v\\n\\nErr: %s\", tc.Input, err)\n\t\t}\n\n\t\tif actual != tc.Output {\n\t\t\tt.Fatalf(\"Input: %#v\\n\\nOutput: %#v\", tc.Input, actual)\n\t\t}\n\t}\n\n\tDisableCache = true\n\tdefer func() { DisableCache = false }()\n\tdefer patchEnv(\"HOME\", \"/custom/path/\")()\n\texpected := filepath.Join(\"/\", \"custom\", \"path\", \"foo/bar\")\n\tactual, err := Expand(\"~/foo/bar\")\n\n\tif err != nil {\n\t\tt.Errorf(\"No error is expected, got: %v\", err)\n\t} else if actual != expected {\n\t\tt.Errorf(\"Expected: %v; actual: %v\", expected, actual)\n\t}\n}\n"
  },
  {
    "path": "vendor/gopkg.in/yaml.v2/.travis.yml",
    "content": "language: go\n\ngo:\n    - 1.4\n    - 1.5\n    - 1.6\n    - tip\n\ngo_import_path: gopkg.in/yaml.v2\n"
  },
  {
    "path": "vendor/gopkg.in/yaml.v2/LICENSE",
    "content": "Copyright 2011-2016 Canonical Ltd.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n"
  },
  {
    "path": "vendor/gopkg.in/yaml.v2/LICENSE.libyaml",
    "content": "The following files were ported to Go from C files of libyaml, and thus\nare still covered by their original copyright and license:\n\n    apic.go\n    emitterc.go\n    parserc.go\n    readerc.go\n    scannerc.go\n    writerc.go\n    yamlh.go\n    yamlprivateh.go\n\nCopyright (c) 2006 Kirill Simonov\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "vendor/gopkg.in/yaml.v2/README.md",
    "content": "# YAML support for the Go language\n\nIntroduction\n------------\n\nThe yaml package enables Go programs to comfortably encode and decode YAML\nvalues. It was developed within [Canonical](https://www.canonical.com) as\npart of the [juju](https://juju.ubuntu.com) project, and is based on a\npure Go port of the well-known [libyaml](http://pyyaml.org/wiki/LibYAML)\nC library to parse and generate YAML data quickly and reliably.\n\nCompatibility\n-------------\n\nThe yaml package supports most of YAML 1.1 and 1.2, including support for\nanchors, tags, map merging, etc. Multi-document unmarshalling is not yet\nimplemented, and base-60 floats from YAML 1.1 are purposefully not\nsupported since they're a poor design and are gone in YAML 1.2.\n\nInstallation and usage\n----------------------\n\nThe import path for the package is *gopkg.in/yaml.v2*.\n\nTo install it, run:\n\n    go get gopkg.in/yaml.v2\n\nAPI documentation\n-----------------\n\nIf opened in a browser, the import path itself leads to the API documentation:\n\n  * [https://gopkg.in/yaml.v2](https://gopkg.in/yaml.v2)\n\nAPI stability\n-------------\n\nThe package API for yaml v2 will remain stable as described in [gopkg.in](https://gopkg.in).\n\n\nLicense\n-------\n\nThe yaml package is licensed under the Apache License 2.0. Please see the LICENSE file for details.\n\n\nExample\n-------\n\nSome more examples can be found in the \"examples\" folder.\n\n```Go\npackage main\n\nimport (\n        \"fmt\"\n        \"log\"\n\n        \"gopkg.in/yaml.v2\"\n)\n\nvar data = `\na: Easy!\nb:\n  c: 2\n  d: [3, 4]\n`\n\ntype T struct {\n        A string\n        B struct {\n                RenamedC int   `yaml:\"c\"`\n                D        []int `yaml:\",flow\"`\n        }\n}\n\nfunc main() {\n        t := T{}\n    \n        err := yaml.Unmarshal([]byte(data), &t)\n        if err != nil {\n                log.Fatalf(\"error: %v\", err)\n        }\n        fmt.Printf(\"--- t:\\n%v\\n\\n\", t)\n    \n        d, err := yaml.Marshal(&t)\n        if err != nil {\n                log.Fatalf(\"error: %v\", err)\n        }\n        fmt.Printf(\"--- t dump:\\n%s\\n\\n\", string(d))\n    \n        m := make(map[interface{}]interface{})\n    \n        err = yaml.Unmarshal([]byte(data), &m)\n        if err != nil {\n                log.Fatalf(\"error: %v\", err)\n        }\n        fmt.Printf(\"--- m:\\n%v\\n\\n\", m)\n    \n        d, err = yaml.Marshal(&m)\n        if err != nil {\n                log.Fatalf(\"error: %v\", err)\n        }\n        fmt.Printf(\"--- m dump:\\n%s\\n\\n\", string(d))\n}\n```\n\nThis example will generate the following output:\n\n```\n--- t:\n{Easy! {2 [3 4]}}\n\n--- t dump:\na: Easy!\nb:\n  c: 2\n  d: [3, 4]\n\n\n--- m:\nmap[a:Easy! b:map[c:2 d:[3 4]]]\n\n--- m dump:\na: Easy!\nb:\n  c: 2\n  d:\n  - 3\n  - 4\n```\n\n"
  },
  {
    "path": "vendor/gopkg.in/yaml.v2/apic.go",
    "content": "package yaml\n\nimport (\n\t\"io\"\n\t\"os\"\n)\n\nfunc yaml_insert_token(parser *yaml_parser_t, pos int, token *yaml_token_t) {\n\t//fmt.Println(\"yaml_insert_token\", \"pos:\", pos, \"typ:\", token.typ, \"head:\", parser.tokens_head, \"len:\", len(parser.tokens))\n\n\t// Check if we can move the queue at the beginning of the buffer.\n\tif parser.tokens_head > 0 && len(parser.tokens) == cap(parser.tokens) {\n\t\tif parser.tokens_head != len(parser.tokens) {\n\t\t\tcopy(parser.tokens, parser.tokens[parser.tokens_head:])\n\t\t}\n\t\tparser.tokens = parser.tokens[:len(parser.tokens)-parser.tokens_head]\n\t\tparser.tokens_head = 0\n\t}\n\tparser.tokens = append(parser.tokens, *token)\n\tif pos < 0 {\n\t\treturn\n\t}\n\tcopy(parser.tokens[parser.tokens_head+pos+1:], parser.tokens[parser.tokens_head+pos:])\n\tparser.tokens[parser.tokens_head+pos] = *token\n}\n\n// Create a new parser object.\nfunc yaml_parser_initialize(parser *yaml_parser_t) bool {\n\t*parser = yaml_parser_t{\n\t\traw_buffer: make([]byte, 0, input_raw_buffer_size),\n\t\tbuffer:     make([]byte, 0, input_buffer_size),\n\t}\n\treturn true\n}\n\n// Destroy a parser object.\nfunc yaml_parser_delete(parser *yaml_parser_t) {\n\t*parser = yaml_parser_t{}\n}\n\n// String read handler.\nfunc yaml_string_read_handler(parser *yaml_parser_t, buffer []byte) (n int, err error) {\n\tif parser.input_pos == len(parser.input) {\n\t\treturn 0, io.EOF\n\t}\n\tn = copy(buffer, parser.input[parser.input_pos:])\n\tparser.input_pos += n\n\treturn n, nil\n}\n\n// File read handler.\nfunc yaml_file_read_handler(parser *yaml_parser_t, buffer []byte) (n int, err error) {\n\treturn parser.input_file.Read(buffer)\n}\n\n// Set a string input.\nfunc yaml_parser_set_input_string(parser *yaml_parser_t, input []byte) {\n\tif parser.read_handler != nil {\n\t\tpanic(\"must set the input source only once\")\n\t}\n\tparser.read_handler = yaml_string_read_handler\n\tparser.input = input\n\tparser.input_pos = 0\n}\n\n// Set a file input.\nfunc yaml_parser_set_input_file(parser *yaml_parser_t, file *os.File) {\n\tif parser.read_handler != nil {\n\t\tpanic(\"must set the input source only once\")\n\t}\n\tparser.read_handler = yaml_file_read_handler\n\tparser.input_file = file\n}\n\n// Set the source encoding.\nfunc yaml_parser_set_encoding(parser *yaml_parser_t, encoding yaml_encoding_t) {\n\tif parser.encoding != yaml_ANY_ENCODING {\n\t\tpanic(\"must set the encoding only once\")\n\t}\n\tparser.encoding = encoding\n}\n\n// Create a new emitter object.\nfunc yaml_emitter_initialize(emitter *yaml_emitter_t) bool {\n\t*emitter = yaml_emitter_t{\n\t\tbuffer:     make([]byte, output_buffer_size),\n\t\traw_buffer: make([]byte, 0, output_raw_buffer_size),\n\t\tstates:     make([]yaml_emitter_state_t, 0, initial_stack_size),\n\t\tevents:     make([]yaml_event_t, 0, initial_queue_size),\n\t}\n\treturn true\n}\n\n// Destroy an emitter object.\nfunc yaml_emitter_delete(emitter *yaml_emitter_t) {\n\t*emitter = yaml_emitter_t{}\n}\n\n// String write handler.\nfunc yaml_string_write_handler(emitter *yaml_emitter_t, buffer []byte) error {\n\t*emitter.output_buffer = append(*emitter.output_buffer, buffer...)\n\treturn nil\n}\n\n// File write handler.\nfunc yaml_file_write_handler(emitter *yaml_emitter_t, buffer []byte) error {\n\t_, err := emitter.output_file.Write(buffer)\n\treturn err\n}\n\n// Set a string output.\nfunc yaml_emitter_set_output_string(emitter *yaml_emitter_t, output_buffer *[]byte) {\n\tif emitter.write_handler != nil {\n\t\tpanic(\"must set the output target only once\")\n\t}\n\temitter.write_handler = yaml_string_write_handler\n\temitter.output_buffer = output_buffer\n}\n\n// Set a file output.\nfunc yaml_emitter_set_output_file(emitter *yaml_emitter_t, file io.Writer) {\n\tif emitter.write_handler != nil {\n\t\tpanic(\"must set the output target only once\")\n\t}\n\temitter.write_handler = yaml_file_write_handler\n\temitter.output_file = file\n}\n\n// Set the output encoding.\nfunc yaml_emitter_set_encoding(emitter *yaml_emitter_t, encoding yaml_encoding_t) {\n\tif emitter.encoding != yaml_ANY_ENCODING {\n\t\tpanic(\"must set the output encoding only once\")\n\t}\n\temitter.encoding = encoding\n}\n\n// Set the canonical output style.\nfunc yaml_emitter_set_canonical(emitter *yaml_emitter_t, canonical bool) {\n\temitter.canonical = canonical\n}\n\n//// Set the indentation increment.\nfunc yaml_emitter_set_indent(emitter *yaml_emitter_t, indent int) {\n\tif indent < 2 || indent > 9 {\n\t\tindent = 2\n\t}\n\temitter.best_indent = indent\n}\n\n// Set the preferred line width.\nfunc yaml_emitter_set_width(emitter *yaml_emitter_t, width int) {\n\tif width < 0 {\n\t\twidth = -1\n\t}\n\temitter.best_width = width\n}\n\n// Set if unescaped non-ASCII characters are allowed.\nfunc yaml_emitter_set_unicode(emitter *yaml_emitter_t, unicode bool) {\n\temitter.unicode = unicode\n}\n\n// Set the preferred line break character.\nfunc yaml_emitter_set_break(emitter *yaml_emitter_t, line_break yaml_break_t) {\n\temitter.line_break = line_break\n}\n\n///*\n// * Destroy a token object.\n// */\n//\n//YAML_DECLARE(void)\n//yaml_token_delete(yaml_token_t *token)\n//{\n//    assert(token);  // Non-NULL token object expected.\n//\n//    switch (token.type)\n//    {\n//        case YAML_TAG_DIRECTIVE_TOKEN:\n//            yaml_free(token.data.tag_directive.handle);\n//            yaml_free(token.data.tag_directive.prefix);\n//            break;\n//\n//        case YAML_ALIAS_TOKEN:\n//            yaml_free(token.data.alias.value);\n//            break;\n//\n//        case YAML_ANCHOR_TOKEN:\n//            yaml_free(token.data.anchor.value);\n//            break;\n//\n//        case YAML_TAG_TOKEN:\n//            yaml_free(token.data.tag.handle);\n//            yaml_free(token.data.tag.suffix);\n//            break;\n//\n//        case YAML_SCALAR_TOKEN:\n//            yaml_free(token.data.scalar.value);\n//            break;\n//\n//        default:\n//            break;\n//    }\n//\n//    memset(token, 0, sizeof(yaml_token_t));\n//}\n//\n///*\n// * Check if a string is a valid UTF-8 sequence.\n// *\n// * Check 'reader.c' for more details on UTF-8 encoding.\n// */\n//\n//static int\n//yaml_check_utf8(yaml_char_t *start, size_t length)\n//{\n//    yaml_char_t *end = start+length;\n//    yaml_char_t *pointer = start;\n//\n//    while (pointer < end) {\n//        unsigned char octet;\n//        unsigned int width;\n//        unsigned int value;\n//        size_t k;\n//\n//        octet = pointer[0];\n//        width = (octet & 0x80) == 0x00 ? 1 :\n//                (octet & 0xE0) == 0xC0 ? 2 :\n//                (octet & 0xF0) == 0xE0 ? 3 :\n//                (octet & 0xF8) == 0xF0 ? 4 : 0;\n//        value = (octet & 0x80) == 0x00 ? octet & 0x7F :\n//                (octet & 0xE0) == 0xC0 ? octet & 0x1F :\n//                (octet & 0xF0) == 0xE0 ? octet & 0x0F :\n//                (octet & 0xF8) == 0xF0 ? octet & 0x07 : 0;\n//        if (!width) return 0;\n//        if (pointer+width > end) return 0;\n//        for (k = 1; k < width; k ++) {\n//            octet = pointer[k];\n//            if ((octet & 0xC0) != 0x80) return 0;\n//            value = (value << 6) + (octet & 0x3F);\n//        }\n//        if (!((width == 1) ||\n//            (width == 2 && value >= 0x80) ||\n//            (width == 3 && value >= 0x800) ||\n//            (width == 4 && value >= 0x10000))) return 0;\n//\n//        pointer += width;\n//    }\n//\n//    return 1;\n//}\n//\n\n// Create STREAM-START.\nfunc yaml_stream_start_event_initialize(event *yaml_event_t, encoding yaml_encoding_t) bool {\n\t*event = yaml_event_t{\n\t\ttyp:      yaml_STREAM_START_EVENT,\n\t\tencoding: encoding,\n\t}\n\treturn true\n}\n\n// Create STREAM-END.\nfunc yaml_stream_end_event_initialize(event *yaml_event_t) bool {\n\t*event = yaml_event_t{\n\t\ttyp: yaml_STREAM_END_EVENT,\n\t}\n\treturn true\n}\n\n// Create DOCUMENT-START.\nfunc yaml_document_start_event_initialize(event *yaml_event_t, version_directive *yaml_version_directive_t,\n\ttag_directives []yaml_tag_directive_t, implicit bool) bool {\n\t*event = yaml_event_t{\n\t\ttyp:               yaml_DOCUMENT_START_EVENT,\n\t\tversion_directive: version_directive,\n\t\ttag_directives:    tag_directives,\n\t\timplicit:          implicit,\n\t}\n\treturn true\n}\n\n// Create DOCUMENT-END.\nfunc yaml_document_end_event_initialize(event *yaml_event_t, implicit bool) bool {\n\t*event = yaml_event_t{\n\t\ttyp:      yaml_DOCUMENT_END_EVENT,\n\t\timplicit: implicit,\n\t}\n\treturn true\n}\n\n///*\n// * Create ALIAS.\n// */\n//\n//YAML_DECLARE(int)\n//yaml_alias_event_initialize(event *yaml_event_t, anchor *yaml_char_t)\n//{\n//    mark yaml_mark_t = { 0, 0, 0 }\n//    anchor_copy *yaml_char_t = NULL\n//\n//    assert(event) // Non-NULL event object is expected.\n//    assert(anchor) // Non-NULL anchor is expected.\n//\n//    if (!yaml_check_utf8(anchor, strlen((char *)anchor))) return 0\n//\n//    anchor_copy = yaml_strdup(anchor)\n//    if (!anchor_copy)\n//        return 0\n//\n//    ALIAS_EVENT_INIT(*event, anchor_copy, mark, mark)\n//\n//    return 1\n//}\n\n// Create SCALAR.\nfunc yaml_scalar_event_initialize(event *yaml_event_t, anchor, tag, value []byte, plain_implicit, quoted_implicit bool, style yaml_scalar_style_t) bool {\n\t*event = yaml_event_t{\n\t\ttyp:             yaml_SCALAR_EVENT,\n\t\tanchor:          anchor,\n\t\ttag:             tag,\n\t\tvalue:           value,\n\t\timplicit:        plain_implicit,\n\t\tquoted_implicit: quoted_implicit,\n\t\tstyle:           yaml_style_t(style),\n\t}\n\treturn true\n}\n\n// Create SEQUENCE-START.\nfunc yaml_sequence_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_sequence_style_t) bool {\n\t*event = yaml_event_t{\n\t\ttyp:      yaml_SEQUENCE_START_EVENT,\n\t\tanchor:   anchor,\n\t\ttag:      tag,\n\t\timplicit: implicit,\n\t\tstyle:    yaml_style_t(style),\n\t}\n\treturn true\n}\n\n// Create SEQUENCE-END.\nfunc yaml_sequence_end_event_initialize(event *yaml_event_t) bool {\n\t*event = yaml_event_t{\n\t\ttyp: yaml_SEQUENCE_END_EVENT,\n\t}\n\treturn true\n}\n\n// Create MAPPING-START.\nfunc yaml_mapping_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_mapping_style_t) bool {\n\t*event = yaml_event_t{\n\t\ttyp:      yaml_MAPPING_START_EVENT,\n\t\tanchor:   anchor,\n\t\ttag:      tag,\n\t\timplicit: implicit,\n\t\tstyle:    yaml_style_t(style),\n\t}\n\treturn true\n}\n\n// Create MAPPING-END.\nfunc yaml_mapping_end_event_initialize(event *yaml_event_t) bool {\n\t*event = yaml_event_t{\n\t\ttyp: yaml_MAPPING_END_EVENT,\n\t}\n\treturn true\n}\n\n// Destroy an event object.\nfunc yaml_event_delete(event *yaml_event_t) {\n\t*event = yaml_event_t{}\n}\n\n///*\n// * Create a document object.\n// */\n//\n//YAML_DECLARE(int)\n//yaml_document_initialize(document *yaml_document_t,\n//        version_directive *yaml_version_directive_t,\n//        tag_directives_start *yaml_tag_directive_t,\n//        tag_directives_end *yaml_tag_directive_t,\n//        start_implicit int, end_implicit int)\n//{\n//    struct {\n//        error yaml_error_type_t\n//    } context\n//    struct {\n//        start *yaml_node_t\n//        end *yaml_node_t\n//        top *yaml_node_t\n//    } nodes = { NULL, NULL, NULL }\n//    version_directive_copy *yaml_version_directive_t = NULL\n//    struct {\n//        start *yaml_tag_directive_t\n//        end *yaml_tag_directive_t\n//        top *yaml_tag_directive_t\n//    } tag_directives_copy = { NULL, NULL, NULL }\n//    value yaml_tag_directive_t = { NULL, NULL }\n//    mark yaml_mark_t = { 0, 0, 0 }\n//\n//    assert(document) // Non-NULL document object is expected.\n//    assert((tag_directives_start && tag_directives_end) ||\n//            (tag_directives_start == tag_directives_end))\n//                            // Valid tag directives are expected.\n//\n//    if (!STACK_INIT(&context, nodes, INITIAL_STACK_SIZE)) goto error\n//\n//    if (version_directive) {\n//        version_directive_copy = yaml_malloc(sizeof(yaml_version_directive_t))\n//        if (!version_directive_copy) goto error\n//        version_directive_copy.major = version_directive.major\n//        version_directive_copy.minor = version_directive.minor\n//    }\n//\n//    if (tag_directives_start != tag_directives_end) {\n//        tag_directive *yaml_tag_directive_t\n//        if (!STACK_INIT(&context, tag_directives_copy, INITIAL_STACK_SIZE))\n//            goto error\n//        for (tag_directive = tag_directives_start\n//                tag_directive != tag_directives_end; tag_directive ++) {\n//            assert(tag_directive.handle)\n//            assert(tag_directive.prefix)\n//            if (!yaml_check_utf8(tag_directive.handle,\n//                        strlen((char *)tag_directive.handle)))\n//                goto error\n//            if (!yaml_check_utf8(tag_directive.prefix,\n//                        strlen((char *)tag_directive.prefix)))\n//                goto error\n//            value.handle = yaml_strdup(tag_directive.handle)\n//            value.prefix = yaml_strdup(tag_directive.prefix)\n//            if (!value.handle || !value.prefix) goto error\n//            if (!PUSH(&context, tag_directives_copy, value))\n//                goto error\n//            value.handle = NULL\n//            value.prefix = NULL\n//        }\n//    }\n//\n//    DOCUMENT_INIT(*document, nodes.start, nodes.end, version_directive_copy,\n//            tag_directives_copy.start, tag_directives_copy.top,\n//            start_implicit, end_implicit, mark, mark)\n//\n//    return 1\n//\n//error:\n//    STACK_DEL(&context, nodes)\n//    yaml_free(version_directive_copy)\n//    while (!STACK_EMPTY(&context, tag_directives_copy)) {\n//        value yaml_tag_directive_t = POP(&context, tag_directives_copy)\n//        yaml_free(value.handle)\n//        yaml_free(value.prefix)\n//    }\n//    STACK_DEL(&context, tag_directives_copy)\n//    yaml_free(value.handle)\n//    yaml_free(value.prefix)\n//\n//    return 0\n//}\n//\n///*\n// * Destroy a document object.\n// */\n//\n//YAML_DECLARE(void)\n//yaml_document_delete(document *yaml_document_t)\n//{\n//    struct {\n//        error yaml_error_type_t\n//    } context\n//    tag_directive *yaml_tag_directive_t\n//\n//    context.error = YAML_NO_ERROR // Eliminate a compliler warning.\n//\n//    assert(document) // Non-NULL document object is expected.\n//\n//    while (!STACK_EMPTY(&context, document.nodes)) {\n//        node yaml_node_t = POP(&context, document.nodes)\n//        yaml_free(node.tag)\n//        switch (node.type) {\n//            case YAML_SCALAR_NODE:\n//                yaml_free(node.data.scalar.value)\n//                break\n//            case YAML_SEQUENCE_NODE:\n//                STACK_DEL(&context, node.data.sequence.items)\n//                break\n//            case YAML_MAPPING_NODE:\n//                STACK_DEL(&context, node.data.mapping.pairs)\n//                break\n//            default:\n//                assert(0) // Should not happen.\n//        }\n//    }\n//    STACK_DEL(&context, document.nodes)\n//\n//    yaml_free(document.version_directive)\n//    for (tag_directive = document.tag_directives.start\n//            tag_directive != document.tag_directives.end\n//            tag_directive++) {\n//        yaml_free(tag_directive.handle)\n//        yaml_free(tag_directive.prefix)\n//    }\n//    yaml_free(document.tag_directives.start)\n//\n//    memset(document, 0, sizeof(yaml_document_t))\n//}\n//\n///**\n// * Get a document node.\n// */\n//\n//YAML_DECLARE(yaml_node_t *)\n//yaml_document_get_node(document *yaml_document_t, index int)\n//{\n//    assert(document) // Non-NULL document object is expected.\n//\n//    if (index > 0 && document.nodes.start + index <= document.nodes.top) {\n//        return document.nodes.start + index - 1\n//    }\n//    return NULL\n//}\n//\n///**\n// * Get the root object.\n// */\n//\n//YAML_DECLARE(yaml_node_t *)\n//yaml_document_get_root_node(document *yaml_document_t)\n//{\n//    assert(document) // Non-NULL document object is expected.\n//\n//    if (document.nodes.top != document.nodes.start) {\n//        return document.nodes.start\n//    }\n//    return NULL\n//}\n//\n///*\n// * Add a scalar node to a document.\n// */\n//\n//YAML_DECLARE(int)\n//yaml_document_add_scalar(document *yaml_document_t,\n//        tag *yaml_char_t, value *yaml_char_t, length int,\n//        style yaml_scalar_style_t)\n//{\n//    struct {\n//        error yaml_error_type_t\n//    } context\n//    mark yaml_mark_t = { 0, 0, 0 }\n//    tag_copy *yaml_char_t = NULL\n//    value_copy *yaml_char_t = NULL\n//    node yaml_node_t\n//\n//    assert(document) // Non-NULL document object is expected.\n//    assert(value) // Non-NULL value is expected.\n//\n//    if (!tag) {\n//        tag = (yaml_char_t *)YAML_DEFAULT_SCALAR_TAG\n//    }\n//\n//    if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error\n//    tag_copy = yaml_strdup(tag)\n//    if (!tag_copy) goto error\n//\n//    if (length < 0) {\n//        length = strlen((char *)value)\n//    }\n//\n//    if (!yaml_check_utf8(value, length)) goto error\n//    value_copy = yaml_malloc(length+1)\n//    if (!value_copy) goto error\n//    memcpy(value_copy, value, length)\n//    value_copy[length] = '\\0'\n//\n//    SCALAR_NODE_INIT(node, tag_copy, value_copy, length, style, mark, mark)\n//    if (!PUSH(&context, document.nodes, node)) goto error\n//\n//    return document.nodes.top - document.nodes.start\n//\n//error:\n//    yaml_free(tag_copy)\n//    yaml_free(value_copy)\n//\n//    return 0\n//}\n//\n///*\n// * Add a sequence node to a document.\n// */\n//\n//YAML_DECLARE(int)\n//yaml_document_add_sequence(document *yaml_document_t,\n//        tag *yaml_char_t, style yaml_sequence_style_t)\n//{\n//    struct {\n//        error yaml_error_type_t\n//    } context\n//    mark yaml_mark_t = { 0, 0, 0 }\n//    tag_copy *yaml_char_t = NULL\n//    struct {\n//        start *yaml_node_item_t\n//        end *yaml_node_item_t\n//        top *yaml_node_item_t\n//    } items = { NULL, NULL, NULL }\n//    node yaml_node_t\n//\n//    assert(document) // Non-NULL document object is expected.\n//\n//    if (!tag) {\n//        tag = (yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG\n//    }\n//\n//    if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error\n//    tag_copy = yaml_strdup(tag)\n//    if (!tag_copy) goto error\n//\n//    if (!STACK_INIT(&context, items, INITIAL_STACK_SIZE)) goto error\n//\n//    SEQUENCE_NODE_INIT(node, tag_copy, items.start, items.end,\n//            style, mark, mark)\n//    if (!PUSH(&context, document.nodes, node)) goto error\n//\n//    return document.nodes.top - document.nodes.start\n//\n//error:\n//    STACK_DEL(&context, items)\n//    yaml_free(tag_copy)\n//\n//    return 0\n//}\n//\n///*\n// * Add a mapping node to a document.\n// */\n//\n//YAML_DECLARE(int)\n//yaml_document_add_mapping(document *yaml_document_t,\n//        tag *yaml_char_t, style yaml_mapping_style_t)\n//{\n//    struct {\n//        error yaml_error_type_t\n//    } context\n//    mark yaml_mark_t = { 0, 0, 0 }\n//    tag_copy *yaml_char_t = NULL\n//    struct {\n//        start *yaml_node_pair_t\n//        end *yaml_node_pair_t\n//        top *yaml_node_pair_t\n//    } pairs = { NULL, NULL, NULL }\n//    node yaml_node_t\n//\n//    assert(document) // Non-NULL document object is expected.\n//\n//    if (!tag) {\n//        tag = (yaml_char_t *)YAML_DEFAULT_MAPPING_TAG\n//    }\n//\n//    if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error\n//    tag_copy = yaml_strdup(tag)\n//    if (!tag_copy) goto error\n//\n//    if (!STACK_INIT(&context, pairs, INITIAL_STACK_SIZE)) goto error\n//\n//    MAPPING_NODE_INIT(node, tag_copy, pairs.start, pairs.end,\n//            style, mark, mark)\n//    if (!PUSH(&context, document.nodes, node)) goto error\n//\n//    return document.nodes.top - document.nodes.start\n//\n//error:\n//    STACK_DEL(&context, pairs)\n//    yaml_free(tag_copy)\n//\n//    return 0\n//}\n//\n///*\n// * Append an item to a sequence node.\n// */\n//\n//YAML_DECLARE(int)\n//yaml_document_append_sequence_item(document *yaml_document_t,\n//        sequence int, item int)\n//{\n//    struct {\n//        error yaml_error_type_t\n//    } context\n//\n//    assert(document) // Non-NULL document is required.\n//    assert(sequence > 0\n//            && document.nodes.start + sequence <= document.nodes.top)\n//                            // Valid sequence id is required.\n//    assert(document.nodes.start[sequence-1].type == YAML_SEQUENCE_NODE)\n//                            // A sequence node is required.\n//    assert(item > 0 && document.nodes.start + item <= document.nodes.top)\n//                            // Valid item id is required.\n//\n//    if (!PUSH(&context,\n//                document.nodes.start[sequence-1].data.sequence.items, item))\n//        return 0\n//\n//    return 1\n//}\n//\n///*\n// * Append a pair of a key and a value to a mapping node.\n// */\n//\n//YAML_DECLARE(int)\n//yaml_document_append_mapping_pair(document *yaml_document_t,\n//        mapping int, key int, value int)\n//{\n//    struct {\n//        error yaml_error_type_t\n//    } context\n//\n//    pair yaml_node_pair_t\n//\n//    assert(document) // Non-NULL document is required.\n//    assert(mapping > 0\n//            && document.nodes.start + mapping <= document.nodes.top)\n//                            // Valid mapping id is required.\n//    assert(document.nodes.start[mapping-1].type == YAML_MAPPING_NODE)\n//                            // A mapping node is required.\n//    assert(key > 0 && document.nodes.start + key <= document.nodes.top)\n//                            // Valid key id is required.\n//    assert(value > 0 && document.nodes.start + value <= document.nodes.top)\n//                            // Valid value id is required.\n//\n//    pair.key = key\n//    pair.value = value\n//\n//    if (!PUSH(&context,\n//                document.nodes.start[mapping-1].data.mapping.pairs, pair))\n//        return 0\n//\n//    return 1\n//}\n//\n//\n"
  },
  {
    "path": "vendor/gopkg.in/yaml.v2/decode.go",
    "content": "package yaml\n\nimport (\n\t\"encoding\"\n\t\"encoding/base64\"\n\t\"fmt\"\n\t\"math\"\n\t\"reflect\"\n\t\"strconv\"\n\t\"time\"\n)\n\nconst (\n\tdocumentNode = 1 << iota\n\tmappingNode\n\tsequenceNode\n\tscalarNode\n\taliasNode\n)\n\ntype node struct {\n\tkind         int\n\tline, column int\n\ttag          string\n\tvalue        string\n\timplicit     bool\n\tchildren     []*node\n\tanchors      map[string]*node\n}\n\n// ----------------------------------------------------------------------------\n// Parser, produces a node tree out of a libyaml event stream.\n\ntype parser struct {\n\tparser yaml_parser_t\n\tevent  yaml_event_t\n\tdoc    *node\n}\n\nfunc newParser(b []byte) *parser {\n\tp := parser{}\n\tif !yaml_parser_initialize(&p.parser) {\n\t\tpanic(\"failed to initialize YAML emitter\")\n\t}\n\n\tif len(b) == 0 {\n\t\tb = []byte{'\\n'}\n\t}\n\n\tyaml_parser_set_input_string(&p.parser, b)\n\n\tp.skip()\n\tif p.event.typ != yaml_STREAM_START_EVENT {\n\t\tpanic(\"expected stream start event, got \" + strconv.Itoa(int(p.event.typ)))\n\t}\n\tp.skip()\n\treturn &p\n}\n\nfunc (p *parser) destroy() {\n\tif p.event.typ != yaml_NO_EVENT {\n\t\tyaml_event_delete(&p.event)\n\t}\n\tyaml_parser_delete(&p.parser)\n}\n\nfunc (p *parser) skip() {\n\tif p.event.typ != yaml_NO_EVENT {\n\t\tif p.event.typ == yaml_STREAM_END_EVENT {\n\t\t\tfailf(\"attempted to go past the end of stream; corrupted value?\")\n\t\t}\n\t\tyaml_event_delete(&p.event)\n\t}\n\tif !yaml_parser_parse(&p.parser, &p.event) {\n\t\tp.fail()\n\t}\n}\n\nfunc (p *parser) fail() {\n\tvar where string\n\tvar line int\n\tif p.parser.problem_mark.line != 0 {\n\t\tline = p.parser.problem_mark.line\n\t} else if p.parser.context_mark.line != 0 {\n\t\tline = p.parser.context_mark.line\n\t}\n\tif line != 0 {\n\t\twhere = \"line \" + strconv.Itoa(line) + \": \"\n\t}\n\tvar msg string\n\tif len(p.parser.problem) > 0 {\n\t\tmsg = p.parser.problem\n\t} else {\n\t\tmsg = \"unknown problem parsing YAML content\"\n\t}\n\tfailf(\"%s%s\", where, msg)\n}\n\nfunc (p *parser) anchor(n *node, anchor []byte) {\n\tif anchor != nil {\n\t\tp.doc.anchors[string(anchor)] = n\n\t}\n}\n\nfunc (p *parser) parse() *node {\n\tswitch p.event.typ {\n\tcase yaml_SCALAR_EVENT:\n\t\treturn p.scalar()\n\tcase yaml_ALIAS_EVENT:\n\t\treturn p.alias()\n\tcase yaml_MAPPING_START_EVENT:\n\t\treturn p.mapping()\n\tcase yaml_SEQUENCE_START_EVENT:\n\t\treturn p.sequence()\n\tcase yaml_DOCUMENT_START_EVENT:\n\t\treturn p.document()\n\tcase yaml_STREAM_END_EVENT:\n\t\t// Happens when attempting to decode an empty buffer.\n\t\treturn nil\n\tdefault:\n\t\tpanic(\"attempted to parse unknown event: \" + strconv.Itoa(int(p.event.typ)))\n\t}\n}\n\nfunc (p *parser) node(kind int) *node {\n\treturn &node{\n\t\tkind:   kind,\n\t\tline:   p.event.start_mark.line,\n\t\tcolumn: p.event.start_mark.column,\n\t}\n}\n\nfunc (p *parser) document() *node {\n\tn := p.node(documentNode)\n\tn.anchors = make(map[string]*node)\n\tp.doc = n\n\tp.skip()\n\tn.children = append(n.children, p.parse())\n\tif p.event.typ != yaml_DOCUMENT_END_EVENT {\n\t\tpanic(\"expected end of document event but got \" + strconv.Itoa(int(p.event.typ)))\n\t}\n\tp.skip()\n\treturn n\n}\n\nfunc (p *parser) alias() *node {\n\tn := p.node(aliasNode)\n\tn.value = string(p.event.anchor)\n\tp.skip()\n\treturn n\n}\n\nfunc (p *parser) scalar() *node {\n\tn := p.node(scalarNode)\n\tn.value = string(p.event.value)\n\tn.tag = string(p.event.tag)\n\tn.implicit = p.event.implicit\n\tp.anchor(n, p.event.anchor)\n\tp.skip()\n\treturn n\n}\n\nfunc (p *parser) sequence() *node {\n\tn := p.node(sequenceNode)\n\tp.anchor(n, p.event.anchor)\n\tp.skip()\n\tfor p.event.typ != yaml_SEQUENCE_END_EVENT {\n\t\tn.children = append(n.children, p.parse())\n\t}\n\tp.skip()\n\treturn n\n}\n\nfunc (p *parser) mapping() *node {\n\tn := p.node(mappingNode)\n\tp.anchor(n, p.event.anchor)\n\tp.skip()\n\tfor p.event.typ != yaml_MAPPING_END_EVENT {\n\t\tn.children = append(n.children, p.parse(), p.parse())\n\t}\n\tp.skip()\n\treturn n\n}\n\n// ----------------------------------------------------------------------------\n// Decoder, unmarshals a node into a provided value.\n\ntype decoder struct {\n\tdoc     *node\n\taliases map[string]bool\n\tmapType reflect.Type\n\tterrors []string\n\tstrict  bool\n}\n\nvar (\n\tmapItemType    = reflect.TypeOf(MapItem{})\n\tdurationType   = reflect.TypeOf(time.Duration(0))\n\tdefaultMapType = reflect.TypeOf(map[interface{}]interface{}{})\n\tifaceType      = defaultMapType.Elem()\n)\n\nfunc newDecoder(strict bool) *decoder {\n\td := &decoder{mapType: defaultMapType, strict: strict}\n\td.aliases = make(map[string]bool)\n\treturn d\n}\n\nfunc (d *decoder) terror(n *node, tag string, out reflect.Value) {\n\tif n.tag != \"\" {\n\t\ttag = n.tag\n\t}\n\tvalue := n.value\n\tif tag != yaml_SEQ_TAG && tag != yaml_MAP_TAG {\n\t\tif len(value) > 10 {\n\t\t\tvalue = \" `\" + value[:7] + \"...`\"\n\t\t} else {\n\t\t\tvalue = \" `\" + value + \"`\"\n\t\t}\n\t}\n\td.terrors = append(d.terrors, fmt.Sprintf(\"line %d: cannot unmarshal %s%s into %s\", n.line+1, shortTag(tag), value, out.Type()))\n}\n\nfunc (d *decoder) callUnmarshaler(n *node, u Unmarshaler) (good bool) {\n\tterrlen := len(d.terrors)\n\terr := u.UnmarshalYAML(func(v interface{}) (err error) {\n\t\tdefer handleErr(&err)\n\t\td.unmarshal(n, reflect.ValueOf(v))\n\t\tif len(d.terrors) > terrlen {\n\t\t\tissues := d.terrors[terrlen:]\n\t\t\td.terrors = d.terrors[:terrlen]\n\t\t\treturn &TypeError{issues}\n\t\t}\n\t\treturn nil\n\t})\n\tif e, ok := err.(*TypeError); ok {\n\t\td.terrors = append(d.terrors, e.Errors...)\n\t\treturn false\n\t}\n\tif err != nil {\n\t\tfail(err)\n\t}\n\treturn true\n}\n\n// d.prepare initializes and dereferences pointers and calls UnmarshalYAML\n// if a value is found to implement it.\n// It returns the initialized and dereferenced out value, whether\n// unmarshalling was already done by UnmarshalYAML, and if so whether\n// its types unmarshalled appropriately.\n//\n// If n holds a null value, prepare returns before doing anything.\nfunc (d *decoder) prepare(n *node, out reflect.Value) (newout reflect.Value, unmarshaled, good bool) {\n\tif n.tag == yaml_NULL_TAG || n.kind == scalarNode && n.tag == \"\" && (n.value == \"null\" || n.value == \"\" && n.implicit) {\n\t\treturn out, false, false\n\t}\n\tagain := true\n\tfor again {\n\t\tagain = false\n\t\tif out.Kind() == reflect.Ptr {\n\t\t\tif out.IsNil() {\n\t\t\t\tout.Set(reflect.New(out.Type().Elem()))\n\t\t\t}\n\t\t\tout = out.Elem()\n\t\t\tagain = true\n\t\t}\n\t\tif out.CanAddr() {\n\t\t\tif u, ok := out.Addr().Interface().(Unmarshaler); ok {\n\t\t\t\tgood = d.callUnmarshaler(n, u)\n\t\t\t\treturn out, true, good\n\t\t\t}\n\t\t}\n\t}\n\treturn out, false, false\n}\n\nfunc (d *decoder) unmarshal(n *node, out reflect.Value) (good bool) {\n\tswitch n.kind {\n\tcase documentNode:\n\t\treturn d.document(n, out)\n\tcase aliasNode:\n\t\treturn d.alias(n, out)\n\t}\n\tout, unmarshaled, good := d.prepare(n, out)\n\tif unmarshaled {\n\t\treturn good\n\t}\n\tswitch n.kind {\n\tcase scalarNode:\n\t\tgood = d.scalar(n, out)\n\tcase mappingNode:\n\t\tgood = d.mapping(n, out)\n\tcase sequenceNode:\n\t\tgood = d.sequence(n, out)\n\tdefault:\n\t\tpanic(\"internal error: unknown node kind: \" + strconv.Itoa(n.kind))\n\t}\n\treturn good\n}\n\nfunc (d *decoder) document(n *node, out reflect.Value) (good bool) {\n\tif len(n.children) == 1 {\n\t\td.doc = n\n\t\td.unmarshal(n.children[0], out)\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc (d *decoder) alias(n *node, out reflect.Value) (good bool) {\n\tan, ok := d.doc.anchors[n.value]\n\tif !ok {\n\t\tfailf(\"unknown anchor '%s' referenced\", n.value)\n\t}\n\tif d.aliases[n.value] {\n\t\tfailf(\"anchor '%s' value contains itself\", n.value)\n\t}\n\td.aliases[n.value] = true\n\tgood = d.unmarshal(an, out)\n\tdelete(d.aliases, n.value)\n\treturn good\n}\n\nvar zeroValue reflect.Value\n\nfunc resetMap(out reflect.Value) {\n\tfor _, k := range out.MapKeys() {\n\t\tout.SetMapIndex(k, zeroValue)\n\t}\n}\n\nfunc (d *decoder) scalar(n *node, out reflect.Value) (good bool) {\n\tvar tag string\n\tvar resolved interface{}\n\tif n.tag == \"\" && !n.implicit {\n\t\ttag = yaml_STR_TAG\n\t\tresolved = n.value\n\t} else {\n\t\ttag, resolved = resolve(n.tag, n.value)\n\t\tif tag == yaml_BINARY_TAG {\n\t\t\tdata, err := base64.StdEncoding.DecodeString(resolved.(string))\n\t\t\tif err != nil {\n\t\t\t\tfailf(\"!!binary value contains invalid base64 data\")\n\t\t\t}\n\t\t\tresolved = string(data)\n\t\t}\n\t}\n\tif resolved == nil {\n\t\tif out.Kind() == reflect.Map && !out.CanAddr() {\n\t\t\tresetMap(out)\n\t\t} else {\n\t\t\tout.Set(reflect.Zero(out.Type()))\n\t\t}\n\t\treturn true\n\t}\n\tif s, ok := resolved.(string); ok && out.CanAddr() {\n\t\tif u, ok := out.Addr().Interface().(encoding.TextUnmarshaler); ok {\n\t\t\terr := u.UnmarshalText([]byte(s))\n\t\t\tif err != nil {\n\t\t\t\tfail(err)\n\t\t\t}\n\t\t\treturn true\n\t\t}\n\t}\n\tswitch out.Kind() {\n\tcase reflect.String:\n\t\tif tag == yaml_BINARY_TAG {\n\t\t\tout.SetString(resolved.(string))\n\t\t\tgood = true\n\t\t} else if resolved != nil {\n\t\t\tout.SetString(n.value)\n\t\t\tgood = true\n\t\t}\n\tcase reflect.Interface:\n\t\tif resolved == nil {\n\t\t\tout.Set(reflect.Zero(out.Type()))\n\t\t} else {\n\t\t\tout.Set(reflect.ValueOf(resolved))\n\t\t}\n\t\tgood = true\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\tswitch resolved := resolved.(type) {\n\t\tcase int:\n\t\t\tif !out.OverflowInt(int64(resolved)) {\n\t\t\t\tout.SetInt(int64(resolved))\n\t\t\t\tgood = true\n\t\t\t}\n\t\tcase int64:\n\t\t\tif !out.OverflowInt(resolved) {\n\t\t\t\tout.SetInt(resolved)\n\t\t\t\tgood = true\n\t\t\t}\n\t\tcase uint64:\n\t\t\tif resolved <= math.MaxInt64 && !out.OverflowInt(int64(resolved)) {\n\t\t\t\tout.SetInt(int64(resolved))\n\t\t\t\tgood = true\n\t\t\t}\n\t\tcase float64:\n\t\t\tif resolved <= math.MaxInt64 && !out.OverflowInt(int64(resolved)) {\n\t\t\t\tout.SetInt(int64(resolved))\n\t\t\t\tgood = true\n\t\t\t}\n\t\tcase string:\n\t\t\tif out.Type() == durationType {\n\t\t\t\td, err := time.ParseDuration(resolved)\n\t\t\t\tif err == nil {\n\t\t\t\t\tout.SetInt(int64(d))\n\t\t\t\t\tgood = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\tswitch resolved := resolved.(type) {\n\t\tcase int:\n\t\t\tif resolved >= 0 && !out.OverflowUint(uint64(resolved)) {\n\t\t\t\tout.SetUint(uint64(resolved))\n\t\t\t\tgood = true\n\t\t\t}\n\t\tcase int64:\n\t\t\tif resolved >= 0 && !out.OverflowUint(uint64(resolved)) {\n\t\t\t\tout.SetUint(uint64(resolved))\n\t\t\t\tgood = true\n\t\t\t}\n\t\tcase uint64:\n\t\t\tif !out.OverflowUint(uint64(resolved)) {\n\t\t\t\tout.SetUint(uint64(resolved))\n\t\t\t\tgood = true\n\t\t\t}\n\t\tcase float64:\n\t\t\tif resolved <= math.MaxUint64 && !out.OverflowUint(uint64(resolved)) {\n\t\t\t\tout.SetUint(uint64(resolved))\n\t\t\t\tgood = true\n\t\t\t}\n\t\t}\n\tcase reflect.Bool:\n\t\tswitch resolved := resolved.(type) {\n\t\tcase bool:\n\t\t\tout.SetBool(resolved)\n\t\t\tgood = true\n\t\t}\n\tcase reflect.Float32, reflect.Float64:\n\t\tswitch resolved := resolved.(type) {\n\t\tcase int:\n\t\t\tout.SetFloat(float64(resolved))\n\t\t\tgood = true\n\t\tcase int64:\n\t\t\tout.SetFloat(float64(resolved))\n\t\t\tgood = true\n\t\tcase uint64:\n\t\t\tout.SetFloat(float64(resolved))\n\t\t\tgood = true\n\t\tcase float64:\n\t\t\tout.SetFloat(resolved)\n\t\t\tgood = true\n\t\t}\n\tcase reflect.Ptr:\n\t\tif out.Type().Elem() == reflect.TypeOf(resolved) {\n\t\t\t// TODO DOes this make sense? When is out a Ptr except when decoding a nil value?\n\t\t\telem := reflect.New(out.Type().Elem())\n\t\t\telem.Elem().Set(reflect.ValueOf(resolved))\n\t\t\tout.Set(elem)\n\t\t\tgood = true\n\t\t}\n\t}\n\tif !good {\n\t\td.terror(n, tag, out)\n\t}\n\treturn good\n}\n\nfunc settableValueOf(i interface{}) reflect.Value {\n\tv := reflect.ValueOf(i)\n\tsv := reflect.New(v.Type()).Elem()\n\tsv.Set(v)\n\treturn sv\n}\n\nfunc (d *decoder) sequence(n *node, out reflect.Value) (good bool) {\n\tl := len(n.children)\n\n\tvar iface reflect.Value\n\tswitch out.Kind() {\n\tcase reflect.Slice:\n\t\tout.Set(reflect.MakeSlice(out.Type(), l, l))\n\tcase reflect.Interface:\n\t\t// No type hints. Will have to use a generic sequence.\n\t\tiface = out\n\t\tout = settableValueOf(make([]interface{}, l))\n\tdefault:\n\t\td.terror(n, yaml_SEQ_TAG, out)\n\t\treturn false\n\t}\n\tet := out.Type().Elem()\n\n\tj := 0\n\tfor i := 0; i < l; i++ {\n\t\te := reflect.New(et).Elem()\n\t\tif ok := d.unmarshal(n.children[i], e); ok {\n\t\t\tout.Index(j).Set(e)\n\t\t\tj++\n\t\t}\n\t}\n\tout.Set(out.Slice(0, j))\n\tif iface.IsValid() {\n\t\tiface.Set(out)\n\t}\n\treturn true\n}\n\nfunc (d *decoder) mapping(n *node, out reflect.Value) (good bool) {\n\tswitch out.Kind() {\n\tcase reflect.Struct:\n\t\treturn d.mappingStruct(n, out)\n\tcase reflect.Slice:\n\t\treturn d.mappingSlice(n, out)\n\tcase reflect.Map:\n\t\t// okay\n\tcase reflect.Interface:\n\t\tif d.mapType.Kind() == reflect.Map {\n\t\t\tiface := out\n\t\t\tout = reflect.MakeMap(d.mapType)\n\t\t\tiface.Set(out)\n\t\t} else {\n\t\t\tslicev := reflect.New(d.mapType).Elem()\n\t\t\tif !d.mappingSlice(n, slicev) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tout.Set(slicev)\n\t\t\treturn true\n\t\t}\n\tdefault:\n\t\td.terror(n, yaml_MAP_TAG, out)\n\t\treturn false\n\t}\n\toutt := out.Type()\n\tkt := outt.Key()\n\tet := outt.Elem()\n\n\tmapType := d.mapType\n\tif outt.Key() == ifaceType && outt.Elem() == ifaceType {\n\t\td.mapType = outt\n\t}\n\n\tif out.IsNil() {\n\t\tout.Set(reflect.MakeMap(outt))\n\t}\n\tl := len(n.children)\n\tfor i := 0; i < l; i += 2 {\n\t\tif isMerge(n.children[i]) {\n\t\t\td.merge(n.children[i+1], out)\n\t\t\tcontinue\n\t\t}\n\t\tk := reflect.New(kt).Elem()\n\t\tif d.unmarshal(n.children[i], k) {\n\t\t\tkkind := k.Kind()\n\t\t\tif kkind == reflect.Interface {\n\t\t\t\tkkind = k.Elem().Kind()\n\t\t\t}\n\t\t\tif kkind == reflect.Map || kkind == reflect.Slice {\n\t\t\t\tfailf(\"invalid map key: %#v\", k.Interface())\n\t\t\t}\n\t\t\te := reflect.New(et).Elem()\n\t\t\tif d.unmarshal(n.children[i+1], e) {\n\t\t\t\tout.SetMapIndex(k, e)\n\t\t\t}\n\t\t}\n\t}\n\td.mapType = mapType\n\treturn true\n}\n\nfunc (d *decoder) mappingSlice(n *node, out reflect.Value) (good bool) {\n\toutt := out.Type()\n\tif outt.Elem() != mapItemType {\n\t\td.terror(n, yaml_MAP_TAG, out)\n\t\treturn false\n\t}\n\n\tmapType := d.mapType\n\td.mapType = outt\n\n\tvar slice []MapItem\n\tvar l = len(n.children)\n\tfor i := 0; i < l; i += 2 {\n\t\tif isMerge(n.children[i]) {\n\t\t\td.merge(n.children[i+1], out)\n\t\t\tcontinue\n\t\t}\n\t\titem := MapItem{}\n\t\tk := reflect.ValueOf(&item.Key).Elem()\n\t\tif d.unmarshal(n.children[i], k) {\n\t\t\tv := reflect.ValueOf(&item.Value).Elem()\n\t\t\tif d.unmarshal(n.children[i+1], v) {\n\t\t\t\tslice = append(slice, item)\n\t\t\t}\n\t\t}\n\t}\n\tout.Set(reflect.ValueOf(slice))\n\td.mapType = mapType\n\treturn true\n}\n\nfunc (d *decoder) mappingStruct(n *node, out reflect.Value) (good bool) {\n\tsinfo, err := getStructInfo(out.Type())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tname := settableValueOf(\"\")\n\tl := len(n.children)\n\n\tvar inlineMap reflect.Value\n\tvar elemType reflect.Type\n\tif sinfo.InlineMap != -1 {\n\t\tinlineMap = out.Field(sinfo.InlineMap)\n\t\tinlineMap.Set(reflect.New(inlineMap.Type()).Elem())\n\t\telemType = inlineMap.Type().Elem()\n\t}\n\n\tfor i := 0; i < l; i += 2 {\n\t\tni := n.children[i]\n\t\tif isMerge(ni) {\n\t\t\td.merge(n.children[i+1], out)\n\t\t\tcontinue\n\t\t}\n\t\tif !d.unmarshal(ni, name) {\n\t\t\tcontinue\n\t\t}\n\t\tif info, ok := sinfo.FieldsMap[name.String()]; ok {\n\t\t\tvar field reflect.Value\n\t\t\tif info.Inline == nil {\n\t\t\t\tfield = out.Field(info.Num)\n\t\t\t} else {\n\t\t\t\tfield = out.FieldByIndex(info.Inline)\n\t\t\t}\n\t\t\td.unmarshal(n.children[i+1], field)\n\t\t} else if sinfo.InlineMap != -1 {\n\t\t\tif inlineMap.IsNil() {\n\t\t\t\tinlineMap.Set(reflect.MakeMap(inlineMap.Type()))\n\t\t\t}\n\t\t\tvalue := reflect.New(elemType).Elem()\n\t\t\td.unmarshal(n.children[i+1], value)\n\t\t\tinlineMap.SetMapIndex(name, value)\n\t\t} else if d.strict {\n\t\t\td.terrors = append(d.terrors, fmt.Sprintf(\"line %d: field %s not found in struct %s\", n.line+1, name.String(), out.Type()))\n\t\t}\n\t}\n\treturn true\n}\n\nfunc failWantMap() {\n\tfailf(\"map merge requires map or sequence of maps as the value\")\n}\n\nfunc (d *decoder) merge(n *node, out reflect.Value) {\n\tswitch n.kind {\n\tcase mappingNode:\n\t\td.unmarshal(n, out)\n\tcase aliasNode:\n\t\tan, ok := d.doc.anchors[n.value]\n\t\tif ok && an.kind != mappingNode {\n\t\t\tfailWantMap()\n\t\t}\n\t\td.unmarshal(n, out)\n\tcase sequenceNode:\n\t\t// Step backwards as earlier nodes take precedence.\n\t\tfor i := len(n.children) - 1; i >= 0; i-- {\n\t\t\tni := n.children[i]\n\t\t\tif ni.kind == aliasNode {\n\t\t\t\tan, ok := d.doc.anchors[ni.value]\n\t\t\t\tif ok && an.kind != mappingNode {\n\t\t\t\t\tfailWantMap()\n\t\t\t\t}\n\t\t\t} else if ni.kind != mappingNode {\n\t\t\t\tfailWantMap()\n\t\t\t}\n\t\t\td.unmarshal(ni, out)\n\t\t}\n\tdefault:\n\t\tfailWantMap()\n\t}\n}\n\nfunc isMerge(n *node) bool {\n\treturn n.kind == scalarNode && n.value == \"<<\" && (n.implicit == true || n.tag == yaml_MERGE_TAG)\n}\n"
  },
  {
    "path": "vendor/gopkg.in/yaml.v2/decode_test.go",
    "content": "package yaml_test\n\nimport (\n\t\"errors\"\n\t. \"gopkg.in/check.v1\"\n\t\"gopkg.in/yaml.v2\"\n\t\"math\"\n\t\"net\"\n\t\"reflect\"\n\t\"strings\"\n\t\"time\"\n)\n\nvar unmarshalIntTest = 123\n\nvar unmarshalTests = []struct {\n\tdata  string\n\tvalue interface{}\n}{\n\t{\n\t\t\"\",\n\t\t&struct{}{},\n\t}, {\n\t\t\"{}\", &struct{}{},\n\t}, {\n\t\t\"v: hi\",\n\t\tmap[string]string{\"v\": \"hi\"},\n\t}, {\n\t\t\"v: hi\", map[string]interface{}{\"v\": \"hi\"},\n\t}, {\n\t\t\"v: true\",\n\t\tmap[string]string{\"v\": \"true\"},\n\t}, {\n\t\t\"v: true\",\n\t\tmap[string]interface{}{\"v\": true},\n\t}, {\n\t\t\"v: 10\",\n\t\tmap[string]interface{}{\"v\": 10},\n\t}, {\n\t\t\"v: 0b10\",\n\t\tmap[string]interface{}{\"v\": 2},\n\t}, {\n\t\t\"v: 0xA\",\n\t\tmap[string]interface{}{\"v\": 10},\n\t}, {\n\t\t\"v: 4294967296\",\n\t\tmap[string]int64{\"v\": 4294967296},\n\t}, {\n\t\t\"v: 0.1\",\n\t\tmap[string]interface{}{\"v\": 0.1},\n\t}, {\n\t\t\"v: .1\",\n\t\tmap[string]interface{}{\"v\": 0.1},\n\t}, {\n\t\t\"v: .Inf\",\n\t\tmap[string]interface{}{\"v\": math.Inf(+1)},\n\t}, {\n\t\t\"v: -.Inf\",\n\t\tmap[string]interface{}{\"v\": math.Inf(-1)},\n\t}, {\n\t\t\"v: -10\",\n\t\tmap[string]interface{}{\"v\": -10},\n\t}, {\n\t\t\"v: -.1\",\n\t\tmap[string]interface{}{\"v\": -0.1},\n\t},\n\n\t// Simple values.\n\t{\n\t\t\"123\",\n\t\t&unmarshalIntTest,\n\t},\n\n\t// Floats from spec\n\t{\n\t\t\"canonical: 6.8523e+5\",\n\t\tmap[string]interface{}{\"canonical\": 6.8523e+5},\n\t}, {\n\t\t\"expo: 685.230_15e+03\",\n\t\tmap[string]interface{}{\"expo\": 685.23015e+03},\n\t}, {\n\t\t\"fixed: 685_230.15\",\n\t\tmap[string]interface{}{\"fixed\": 685230.15},\n\t}, {\n\t\t\"neginf: -.inf\",\n\t\tmap[string]interface{}{\"neginf\": math.Inf(-1)},\n\t}, {\n\t\t\"fixed: 685_230.15\",\n\t\tmap[string]float64{\"fixed\": 685230.15},\n\t},\n\t//{\"sexa: 190:20:30.15\", map[string]interface{}{\"sexa\": 0}}, // Unsupported\n\t//{\"notanum: .NaN\", map[string]interface{}{\"notanum\": math.NaN()}}, // Equality of NaN fails.\n\n\t// Bools from spec\n\t{\n\t\t\"canonical: y\",\n\t\tmap[string]interface{}{\"canonical\": true},\n\t}, {\n\t\t\"answer: NO\",\n\t\tmap[string]interface{}{\"answer\": false},\n\t}, {\n\t\t\"logical: True\",\n\t\tmap[string]interface{}{\"logical\": true},\n\t}, {\n\t\t\"option: on\",\n\t\tmap[string]interface{}{\"option\": true},\n\t}, {\n\t\t\"option: on\",\n\t\tmap[string]bool{\"option\": true},\n\t},\n\t// Ints from spec\n\t{\n\t\t\"canonical: 685230\",\n\t\tmap[string]interface{}{\"canonical\": 685230},\n\t}, {\n\t\t\"decimal: +685_230\",\n\t\tmap[string]interface{}{\"decimal\": 685230},\n\t}, {\n\t\t\"octal: 02472256\",\n\t\tmap[string]interface{}{\"octal\": 685230},\n\t}, {\n\t\t\"hexa: 0x_0A_74_AE\",\n\t\tmap[string]interface{}{\"hexa\": 685230},\n\t}, {\n\t\t\"bin: 0b1010_0111_0100_1010_1110\",\n\t\tmap[string]interface{}{\"bin\": 685230},\n\t}, {\n\t\t\"bin: -0b101010\",\n\t\tmap[string]interface{}{\"bin\": -42},\n\t}, {\n\t\t\"decimal: +685_230\",\n\t\tmap[string]int{\"decimal\": 685230},\n\t},\n\n\t//{\"sexa: 190:20:30\", map[string]interface{}{\"sexa\": 0}}, // Unsupported\n\n\t// Nulls from spec\n\t{\n\t\t\"empty:\",\n\t\tmap[string]interface{}{\"empty\": nil},\n\t}, {\n\t\t\"canonical: ~\",\n\t\tmap[string]interface{}{\"canonical\": nil},\n\t}, {\n\t\t\"english: null\",\n\t\tmap[string]interface{}{\"english\": nil},\n\t}, {\n\t\t\"~: null key\",\n\t\tmap[interface{}]string{nil: \"null key\"},\n\t}, {\n\t\t\"empty:\",\n\t\tmap[string]*bool{\"empty\": nil},\n\t},\n\n\t// Flow sequence\n\t{\n\t\t\"seq: [A,B]\",\n\t\tmap[string]interface{}{\"seq\": []interface{}{\"A\", \"B\"}},\n\t}, {\n\t\t\"seq: [A,B,C,]\",\n\t\tmap[string][]string{\"seq\": []string{\"A\", \"B\", \"C\"}},\n\t}, {\n\t\t\"seq: [A,1,C]\",\n\t\tmap[string][]string{\"seq\": []string{\"A\", \"1\", \"C\"}},\n\t}, {\n\t\t\"seq: [A,1,C]\",\n\t\tmap[string][]int{\"seq\": []int{1}},\n\t}, {\n\t\t\"seq: [A,1,C]\",\n\t\tmap[string]interface{}{\"seq\": []interface{}{\"A\", 1, \"C\"}},\n\t},\n\t// Block sequence\n\t{\n\t\t\"seq:\\n - A\\n - B\",\n\t\tmap[string]interface{}{\"seq\": []interface{}{\"A\", \"B\"}},\n\t}, {\n\t\t\"seq:\\n - A\\n - B\\n - C\",\n\t\tmap[string][]string{\"seq\": []string{\"A\", \"B\", \"C\"}},\n\t}, {\n\t\t\"seq:\\n - A\\n - 1\\n - C\",\n\t\tmap[string][]string{\"seq\": []string{\"A\", \"1\", \"C\"}},\n\t}, {\n\t\t\"seq:\\n - A\\n - 1\\n - C\",\n\t\tmap[string][]int{\"seq\": []int{1}},\n\t}, {\n\t\t\"seq:\\n - A\\n - 1\\n - C\",\n\t\tmap[string]interface{}{\"seq\": []interface{}{\"A\", 1, \"C\"}},\n\t},\n\n\t// Literal block scalar\n\t{\n\t\t\"scalar: | # Comment\\n\\n literal\\n\\n \\ttext\\n\\n\",\n\t\tmap[string]string{\"scalar\": \"\\nliteral\\n\\n\\ttext\\n\"},\n\t},\n\n\t// Folded block scalar\n\t{\n\t\t\"scalar: > # Comment\\n\\n folded\\n line\\n \\n next\\n line\\n  * one\\n  * two\\n\\n last\\n line\\n\\n\",\n\t\tmap[string]string{\"scalar\": \"\\nfolded line\\nnext line\\n * one\\n * two\\n\\nlast line\\n\"},\n\t},\n\n\t// Map inside interface with no type hints.\n\t{\n\t\t\"a: {b: c}\",\n\t\tmap[interface{}]interface{}{\"a\": map[interface{}]interface{}{\"b\": \"c\"}},\n\t},\n\n\t// Structs and type conversions.\n\t{\n\t\t\"hello: world\",\n\t\t&struct{ Hello string }{\"world\"},\n\t}, {\n\t\t\"a: {b: c}\",\n\t\t&struct{ A struct{ B string } }{struct{ B string }{\"c\"}},\n\t}, {\n\t\t\"a: {b: c}\",\n\t\t&struct{ A *struct{ B string } }{&struct{ B string }{\"c\"}},\n\t}, {\n\t\t\"a: {b: c}\",\n\t\t&struct{ A map[string]string }{map[string]string{\"b\": \"c\"}},\n\t}, {\n\t\t\"a: {b: c}\",\n\t\t&struct{ A *map[string]string }{&map[string]string{\"b\": \"c\"}},\n\t}, {\n\t\t\"a:\",\n\t\t&struct{ A map[string]string }{},\n\t}, {\n\t\t\"a: 1\",\n\t\t&struct{ A int }{1},\n\t}, {\n\t\t\"a: 1\",\n\t\t&struct{ A float64 }{1},\n\t}, {\n\t\t\"a: 1.0\",\n\t\t&struct{ A int }{1},\n\t}, {\n\t\t\"a: 1.0\",\n\t\t&struct{ A uint }{1},\n\t}, {\n\t\t\"a: [1, 2]\",\n\t\t&struct{ A []int }{[]int{1, 2}},\n\t}, {\n\t\t\"a: 1\",\n\t\t&struct{ B int }{0},\n\t}, {\n\t\t\"a: 1\",\n\t\t&struct {\n\t\t\tB int \"a\"\n\t\t}{1},\n\t}, {\n\t\t\"a: y\",\n\t\t&struct{ A bool }{true},\n\t},\n\n\t// Some cross type conversions\n\t{\n\t\t\"v: 42\",\n\t\tmap[string]uint{\"v\": 42},\n\t}, {\n\t\t\"v: -42\",\n\t\tmap[string]uint{},\n\t}, {\n\t\t\"v: 4294967296\",\n\t\tmap[string]uint64{\"v\": 4294967296},\n\t}, {\n\t\t\"v: -4294967296\",\n\t\tmap[string]uint64{},\n\t},\n\n\t// int\n\t{\n\t\t\"int_max: 2147483647\",\n\t\tmap[string]int{\"int_max\": math.MaxInt32},\n\t},\n\t{\n\t\t\"int_min: -2147483648\",\n\t\tmap[string]int{\"int_min\": math.MinInt32},\n\t},\n\t{\n\t\t\"int_overflow: 9223372036854775808\", // math.MaxInt64 + 1\n\t\tmap[string]int{},\n\t},\n\n\t// int64\n\t{\n\t\t\"int64_max: 9223372036854775807\",\n\t\tmap[string]int64{\"int64_max\": math.MaxInt64},\n\t},\n\t{\n\t\t\"int64_max_base2: 0b111111111111111111111111111111111111111111111111111111111111111\",\n\t\tmap[string]int64{\"int64_max_base2\": math.MaxInt64},\n\t},\n\t{\n\t\t\"int64_min: -9223372036854775808\",\n\t\tmap[string]int64{\"int64_min\": math.MinInt64},\n\t},\n\t{\n\t\t\"int64_neg_base2: -0b111111111111111111111111111111111111111111111111111111111111111\",\n\t\tmap[string]int64{\"int64_neg_base2\": -math.MaxInt64},\n\t},\n\t{\n\t\t\"int64_overflow: 9223372036854775808\", // math.MaxInt64 + 1\n\t\tmap[string]int64{},\n\t},\n\n\t// uint\n\t{\n\t\t\"uint_min: 0\",\n\t\tmap[string]uint{\"uint_min\": 0},\n\t},\n\t{\n\t\t\"uint_max: 4294967295\",\n\t\tmap[string]uint{\"uint_max\": math.MaxUint32},\n\t},\n\t{\n\t\t\"uint_underflow: -1\",\n\t\tmap[string]uint{},\n\t},\n\n\t// uint64\n\t{\n\t\t\"uint64_min: 0\",\n\t\tmap[string]uint{\"uint64_min\": 0},\n\t},\n\t{\n\t\t\"uint64_max: 18446744073709551615\",\n\t\tmap[string]uint64{\"uint64_max\": math.MaxUint64},\n\t},\n\t{\n\t\t\"uint64_max_base2: 0b1111111111111111111111111111111111111111111111111111111111111111\",\n\t\tmap[string]uint64{\"uint64_max_base2\": math.MaxUint64},\n\t},\n\t{\n\t\t\"uint64_maxint64: 9223372036854775807\",\n\t\tmap[string]uint64{\"uint64_maxint64\": math.MaxInt64},\n\t},\n\t{\n\t\t\"uint64_underflow: -1\",\n\t\tmap[string]uint64{},\n\t},\n\n\t// float32\n\t{\n\t\t\"float32_max: 3.40282346638528859811704183484516925440e+38\",\n\t\tmap[string]float32{\"float32_max\": math.MaxFloat32},\n\t},\n\t{\n\t\t\"float32_nonzero: 1.401298464324817070923729583289916131280e-45\",\n\t\tmap[string]float32{\"float32_nonzero\": math.SmallestNonzeroFloat32},\n\t},\n\t{\n\t\t\"float32_maxuint64: 18446744073709551615\",\n\t\tmap[string]float32{\"float32_maxuint64\": float32(math.MaxUint64)},\n\t},\n\t{\n\t\t\"float32_maxuint64+1: 18446744073709551616\",\n\t\tmap[string]float32{\"float32_maxuint64+1\": float32(math.MaxUint64 + 1)},\n\t},\n\n\t// float64\n\t{\n\t\t\"float64_max: 1.797693134862315708145274237317043567981e+308\",\n\t\tmap[string]float64{\"float64_max\": math.MaxFloat64},\n\t},\n\t{\n\t\t\"float64_nonzero: 4.940656458412465441765687928682213723651e-324\",\n\t\tmap[string]float64{\"float64_nonzero\": math.SmallestNonzeroFloat64},\n\t},\n\t{\n\t\t\"float64_maxuint64: 18446744073709551615\",\n\t\tmap[string]float64{\"float64_maxuint64\": float64(math.MaxUint64)},\n\t},\n\t{\n\t\t\"float64_maxuint64+1: 18446744073709551616\",\n\t\tmap[string]float64{\"float64_maxuint64+1\": float64(math.MaxUint64 + 1)},\n\t},\n\n\t// Overflow cases.\n\t{\n\t\t\"v: 4294967297\",\n\t\tmap[string]int32{},\n\t}, {\n\t\t\"v: 128\",\n\t\tmap[string]int8{},\n\t},\n\n\t// Quoted values.\n\t{\n\t\t\"'1': '\\\"2\\\"'\",\n\t\tmap[interface{}]interface{}{\"1\": \"\\\"2\\\"\"},\n\t}, {\n\t\t\"v:\\n- A\\n- 'B\\n\\n  C'\\n\",\n\t\tmap[string][]string{\"v\": []string{\"A\", \"B\\nC\"}},\n\t},\n\n\t// Explicit tags.\n\t{\n\t\t\"v: !!float '1.1'\",\n\t\tmap[string]interface{}{\"v\": 1.1},\n\t}, {\n\t\t\"v: !!null ''\",\n\t\tmap[string]interface{}{\"v\": nil},\n\t}, {\n\t\t\"%TAG !y! tag:yaml.org,2002:\\n---\\nv: !y!int '1'\",\n\t\tmap[string]interface{}{\"v\": 1},\n\t},\n\n\t// Non-specific tag (Issue #75)\n\t{\n\t\t\"v: ! test\",\n\t\tmap[string]interface{}{\"v\": \"test\"},\n\t},\n\n\t// Anchors and aliases.\n\t{\n\t\t\"a: &x 1\\nb: &y 2\\nc: *x\\nd: *y\\n\",\n\t\t&struct{ A, B, C, D int }{1, 2, 1, 2},\n\t}, {\n\t\t\"a: &a {c: 1}\\nb: *a\",\n\t\t&struct {\n\t\t\tA, B struct {\n\t\t\t\tC int\n\t\t\t}\n\t\t}{struct{ C int }{1}, struct{ C int }{1}},\n\t}, {\n\t\t\"a: &a [1, 2]\\nb: *a\",\n\t\t&struct{ B []int }{[]int{1, 2}},\n\t}, {\n\t\t\"b: *a\\na: &a {c: 1}\",\n\t\t&struct {\n\t\t\tA, B struct {\n\t\t\t\tC int\n\t\t\t}\n\t\t}{struct{ C int }{1}, struct{ C int }{1}},\n\t},\n\n\t// Bug #1133337\n\t{\n\t\t\"foo: ''\",\n\t\tmap[string]*string{\"foo\": new(string)},\n\t}, {\n\t\t\"foo: null\",\n\t\tmap[string]string{\"foo\": \"\"},\n\t}, {\n\t\t\"foo: null\",\n\t\tmap[string]interface{}{\"foo\": nil},\n\t},\n\n\t// Ignored field\n\t{\n\t\t\"a: 1\\nb: 2\\n\",\n\t\t&struct {\n\t\t\tA int\n\t\t\tB int \"-\"\n\t\t}{1, 0},\n\t},\n\n\t// Bug #1191981\n\t{\n\t\t\"\" +\n\t\t\t\"%YAML 1.1\\n\" +\n\t\t\t\"--- !!str\\n\" +\n\t\t\t`\"Generic line break (no glyph)\\n\\` + \"\\n\" +\n\t\t\t` Generic line break (glyphed)\\n\\` + \"\\n\" +\n\t\t\t` Line separator\\u2028\\` + \"\\n\" +\n\t\t\t` Paragraph separator\\u2029\"` + \"\\n\",\n\t\t\"\" +\n\t\t\t\"Generic line break (no glyph)\\n\" +\n\t\t\t\"Generic line break (glyphed)\\n\" +\n\t\t\t\"Line separator\\u2028Paragraph separator\\u2029\",\n\t},\n\n\t// Struct inlining\n\t{\n\t\t\"a: 1\\nb: 2\\nc: 3\\n\",\n\t\t&struct {\n\t\t\tA int\n\t\t\tC inlineB `yaml:\",inline\"`\n\t\t}{1, inlineB{2, inlineC{3}}},\n\t},\n\n\t// Map inlining\n\t{\n\t\t\"a: 1\\nb: 2\\nc: 3\\n\",\n\t\t&struct {\n\t\t\tA int\n\t\t\tC map[string]int `yaml:\",inline\"`\n\t\t}{1, map[string]int{\"b\": 2, \"c\": 3}},\n\t},\n\n\t// bug 1243827\n\t{\n\t\t\"a: -b_c\",\n\t\tmap[string]interface{}{\"a\": \"-b_c\"},\n\t},\n\t{\n\t\t\"a: +b_c\",\n\t\tmap[string]interface{}{\"a\": \"+b_c\"},\n\t},\n\t{\n\t\t\"a: 50cent_of_dollar\",\n\t\tmap[string]interface{}{\"a\": \"50cent_of_dollar\"},\n\t},\n\n\t// Duration\n\t{\n\t\t\"a: 3s\",\n\t\tmap[string]time.Duration{\"a\": 3 * time.Second},\n\t},\n\n\t// Issue #24.\n\t{\n\t\t\"a: <foo>\",\n\t\tmap[string]string{\"a\": \"<foo>\"},\n\t},\n\n\t// Base 60 floats are obsolete and unsupported.\n\t{\n\t\t\"a: 1:1\\n\",\n\t\tmap[string]string{\"a\": \"1:1\"},\n\t},\n\n\t// Binary data.\n\t{\n\t\t\"a: !!binary gIGC\\n\",\n\t\tmap[string]string{\"a\": \"\\x80\\x81\\x82\"},\n\t}, {\n\t\t\"a: !!binary |\\n  \" + strings.Repeat(\"kJCQ\", 17) + \"kJ\\n  CQ\\n\",\n\t\tmap[string]string{\"a\": strings.Repeat(\"\\x90\", 54)},\n\t}, {\n\t\t\"a: !!binary |\\n  \" + strings.Repeat(\"A\", 70) + \"\\n  ==\\n\",\n\t\tmap[string]string{\"a\": strings.Repeat(\"\\x00\", 52)},\n\t},\n\n\t// Ordered maps.\n\t{\n\t\t\"{b: 2, a: 1, d: 4, c: 3, sub: {e: 5}}\",\n\t\t&yaml.MapSlice{{\"b\", 2}, {\"a\", 1}, {\"d\", 4}, {\"c\", 3}, {\"sub\", yaml.MapSlice{{\"e\", 5}}}},\n\t},\n\n\t// Issue #39.\n\t{\n\t\t\"a:\\n b:\\n  c: d\\n\",\n\t\tmap[string]struct{ B interface{} }{\"a\": {map[interface{}]interface{}{\"c\": \"d\"}}},\n\t},\n\n\t// Custom map type.\n\t{\n\t\t\"a: {b: c}\",\n\t\tM{\"a\": M{\"b\": \"c\"}},\n\t},\n\n\t// Support encoding.TextUnmarshaler.\n\t{\n\t\t\"a: 1.2.3.4\\n\",\n\t\tmap[string]net.IP{\"a\": net.IPv4(1, 2, 3, 4)},\n\t},\n\t{\n\t\t\"a: 2015-02-24T18:19:39Z\\n\",\n\t\tmap[string]time.Time{\"a\": time.Unix(1424801979, 0).In(time.UTC)},\n\t},\n\n\t// Encode empty lists as zero-length slices.\n\t{\n\t\t\"a: []\",\n\t\t&struct{ A []int }{[]int{}},\n\t},\n\n\t// UTF-16-LE\n\t{\n\t\t\"\\xff\\xfe\\xf1\\x00o\\x00\\xf1\\x00o\\x00:\\x00 \\x00v\\x00e\\x00r\\x00y\\x00 \\x00y\\x00e\\x00s\\x00\\n\\x00\",\n\t\tM{\"ñoño\": \"very yes\"},\n\t},\n\t// UTF-16-LE with surrogate.\n\t{\n\t\t\"\\xff\\xfe\\xf1\\x00o\\x00\\xf1\\x00o\\x00:\\x00 \\x00v\\x00e\\x00r\\x00y\\x00 \\x00y\\x00e\\x00s\\x00 \\x00=\\xd8\\xd4\\xdf\\n\\x00\",\n\t\tM{\"ñoño\": \"very yes 🟔\"},\n\t},\n\n\t// UTF-16-BE\n\t{\n\t\t\"\\xfe\\xff\\x00\\xf1\\x00o\\x00\\xf1\\x00o\\x00:\\x00 \\x00v\\x00e\\x00r\\x00y\\x00 \\x00y\\x00e\\x00s\\x00\\n\",\n\t\tM{\"ñoño\": \"very yes\"},\n\t},\n\t// UTF-16-BE with surrogate.\n\t{\n\t\t\"\\xfe\\xff\\x00\\xf1\\x00o\\x00\\xf1\\x00o\\x00:\\x00 \\x00v\\x00e\\x00r\\x00y\\x00 \\x00y\\x00e\\x00s\\x00 \\xd8=\\xdf\\xd4\\x00\\n\",\n\t\tM{\"ñoño\": \"very yes 🟔\"},\n\t},\n\n\t// YAML Float regex shouldn't match this\n\t{\n\t\t\"a: 123456e1\\n\",\n\t\tM{\"a\": \"123456e1\"},\n\t}, {\n\t\t\"a: 123456E1\\n\",\n\t\tM{\"a\": \"123456E1\"},\n\t},\n}\n\ntype M map[interface{}]interface{}\n\ntype inlineB struct {\n\tB       int\n\tinlineC `yaml:\",inline\"`\n}\n\ntype inlineC struct {\n\tC int\n}\n\nfunc (s *S) TestUnmarshal(c *C) {\n\tfor _, item := range unmarshalTests {\n\t\tt := reflect.ValueOf(item.value).Type()\n\t\tvar value interface{}\n\t\tswitch t.Kind() {\n\t\tcase reflect.Map:\n\t\t\tvalue = reflect.MakeMap(t).Interface()\n\t\tcase reflect.String:\n\t\t\tvalue = reflect.New(t).Interface()\n\t\tcase reflect.Ptr:\n\t\t\tvalue = reflect.New(t.Elem()).Interface()\n\t\tdefault:\n\t\t\tc.Fatalf(\"missing case for %s\", t)\n\t\t}\n\t\terr := yaml.Unmarshal([]byte(item.data), value)\n\t\tif _, ok := err.(*yaml.TypeError); !ok {\n\t\t\tc.Assert(err, IsNil)\n\t\t}\n\t\tif t.Kind() == reflect.String {\n\t\t\tc.Assert(*value.(*string), Equals, item.value)\n\t\t} else {\n\t\t\tc.Assert(value, DeepEquals, item.value)\n\t\t}\n\t}\n}\n\nfunc (s *S) TestUnmarshalNaN(c *C) {\n\tvalue := map[string]interface{}{}\n\terr := yaml.Unmarshal([]byte(\"notanum: .NaN\"), &value)\n\tc.Assert(err, IsNil)\n\tc.Assert(math.IsNaN(value[\"notanum\"].(float64)), Equals, true)\n}\n\nvar unmarshalErrorTests = []struct {\n\tdata, error string\n}{\n\t{\"v: !!float 'error'\", \"yaml: cannot decode !!str `error` as a !!float\"},\n\t{\"v: [A,\", \"yaml: line 1: did not find expected node content\"},\n\t{\"v:\\n- [A,\", \"yaml: line 2: did not find expected node content\"},\n\t{\"a: *b\\n\", \"yaml: unknown anchor 'b' referenced\"},\n\t{\"a: &a\\n  b: *a\\n\", \"yaml: anchor 'a' value contains itself\"},\n\t{\"value: -\", \"yaml: block sequence entries are not allowed in this context\"},\n\t{\"a: !!binary ==\", \"yaml: !!binary value contains invalid base64 data\"},\n\t{\"{[.]}\", `yaml: invalid map key: \\[\\]interface \\{\\}\\{\"\\.\"\\}`},\n\t{\"{{.}}\", `yaml: invalid map key: map\\[interface\\ \\{\\}\\]interface \\{\\}\\{\".\":interface \\{\\}\\(nil\\)\\}`},\n}\n\nfunc (s *S) TestUnmarshalErrors(c *C) {\n\tfor _, item := range unmarshalErrorTests {\n\t\tvar value interface{}\n\t\terr := yaml.Unmarshal([]byte(item.data), &value)\n\t\tc.Assert(err, ErrorMatches, item.error, Commentf(\"Partial unmarshal: %#v\", value))\n\t}\n}\n\nvar unmarshalerTests = []struct {\n\tdata, tag string\n\tvalue     interface{}\n}{\n\t{\"_: {hi: there}\", \"!!map\", map[interface{}]interface{}{\"hi\": \"there\"}},\n\t{\"_: [1,A]\", \"!!seq\", []interface{}{1, \"A\"}},\n\t{\"_: 10\", \"!!int\", 10},\n\t{\"_: null\", \"!!null\", nil},\n\t{`_: BAR!`, \"!!str\", \"BAR!\"},\n\t{`_: \"BAR!\"`, \"!!str\", \"BAR!\"},\n\t{\"_: !!foo 'BAR!'\", \"!!foo\", \"BAR!\"},\n\t{`_: \"\"`, \"!!str\", \"\"},\n}\n\nvar unmarshalerResult = map[int]error{}\n\ntype unmarshalerType struct {\n\tvalue interface{}\n}\n\nfunc (o *unmarshalerType) UnmarshalYAML(unmarshal func(v interface{}) error) error {\n\tif err := unmarshal(&o.value); err != nil {\n\t\treturn err\n\t}\n\tif i, ok := o.value.(int); ok {\n\t\tif result, ok := unmarshalerResult[i]; ok {\n\t\t\treturn result\n\t\t}\n\t}\n\treturn nil\n}\n\ntype unmarshalerPointer struct {\n\tField *unmarshalerType \"_\"\n}\n\ntype unmarshalerValue struct {\n\tField unmarshalerType \"_\"\n}\n\nfunc (s *S) TestUnmarshalerPointerField(c *C) {\n\tfor _, item := range unmarshalerTests {\n\t\tobj := &unmarshalerPointer{}\n\t\terr := yaml.Unmarshal([]byte(item.data), obj)\n\t\tc.Assert(err, IsNil)\n\t\tif item.value == nil {\n\t\t\tc.Assert(obj.Field, IsNil)\n\t\t} else {\n\t\t\tc.Assert(obj.Field, NotNil, Commentf(\"Pointer not initialized (%#v)\", item.value))\n\t\t\tc.Assert(obj.Field.value, DeepEquals, item.value)\n\t\t}\n\t}\n}\n\nfunc (s *S) TestUnmarshalerValueField(c *C) {\n\tfor _, item := range unmarshalerTests {\n\t\tobj := &unmarshalerValue{}\n\t\terr := yaml.Unmarshal([]byte(item.data), obj)\n\t\tc.Assert(err, IsNil)\n\t\tc.Assert(obj.Field, NotNil, Commentf(\"Pointer not initialized (%#v)\", item.value))\n\t\tc.Assert(obj.Field.value, DeepEquals, item.value)\n\t}\n}\n\nfunc (s *S) TestUnmarshalerWholeDocument(c *C) {\n\tobj := &unmarshalerType{}\n\terr := yaml.Unmarshal([]byte(unmarshalerTests[0].data), obj)\n\tc.Assert(err, IsNil)\n\tvalue, ok := obj.value.(map[interface{}]interface{})\n\tc.Assert(ok, Equals, true, Commentf(\"value: %#v\", obj.value))\n\tc.Assert(value[\"_\"], DeepEquals, unmarshalerTests[0].value)\n}\n\nfunc (s *S) TestUnmarshalerTypeError(c *C) {\n\tunmarshalerResult[2] = &yaml.TypeError{[]string{\"foo\"}}\n\tunmarshalerResult[4] = &yaml.TypeError{[]string{\"bar\"}}\n\tdefer func() {\n\t\tdelete(unmarshalerResult, 2)\n\t\tdelete(unmarshalerResult, 4)\n\t}()\n\n\ttype T struct {\n\t\tBefore int\n\t\tAfter  int\n\t\tM      map[string]*unmarshalerType\n\t}\n\tvar v T\n\tdata := `{before: A, m: {abc: 1, def: 2, ghi: 3, jkl: 4}, after: B}`\n\terr := yaml.Unmarshal([]byte(data), &v)\n\tc.Assert(err, ErrorMatches, \"\"+\n\t\t\"yaml: unmarshal errors:\\n\"+\n\t\t\"  line 1: cannot unmarshal !!str `A` into int\\n\"+\n\t\t\"  foo\\n\"+\n\t\t\"  bar\\n\"+\n\t\t\"  line 1: cannot unmarshal !!str `B` into int\")\n\tc.Assert(v.M[\"abc\"], NotNil)\n\tc.Assert(v.M[\"def\"], IsNil)\n\tc.Assert(v.M[\"ghi\"], NotNil)\n\tc.Assert(v.M[\"jkl\"], IsNil)\n\n\tc.Assert(v.M[\"abc\"].value, Equals, 1)\n\tc.Assert(v.M[\"ghi\"].value, Equals, 3)\n}\n\ntype proxyTypeError struct{}\n\nfunc (v *proxyTypeError) UnmarshalYAML(unmarshal func(interface{}) error) error {\n\tvar s string\n\tvar a int32\n\tvar b int64\n\tif err := unmarshal(&s); err != nil {\n\t\tpanic(err)\n\t}\n\tif s == \"a\" {\n\t\tif err := unmarshal(&b); err == nil {\n\t\t\tpanic(\"should have failed\")\n\t\t}\n\t\treturn unmarshal(&a)\n\t}\n\tif err := unmarshal(&a); err == nil {\n\t\tpanic(\"should have failed\")\n\t}\n\treturn unmarshal(&b)\n}\n\nfunc (s *S) TestUnmarshalerTypeErrorProxying(c *C) {\n\ttype T struct {\n\t\tBefore int\n\t\tAfter  int\n\t\tM      map[string]*proxyTypeError\n\t}\n\tvar v T\n\tdata := `{before: A, m: {abc: a, def: b}, after: B}`\n\terr := yaml.Unmarshal([]byte(data), &v)\n\tc.Assert(err, ErrorMatches, \"\"+\n\t\t\"yaml: unmarshal errors:\\n\"+\n\t\t\"  line 1: cannot unmarshal !!str `A` into int\\n\"+\n\t\t\"  line 1: cannot unmarshal !!str `a` into int32\\n\"+\n\t\t\"  line 1: cannot unmarshal !!str `b` into int64\\n\"+\n\t\t\"  line 1: cannot unmarshal !!str `B` into int\")\n}\n\ntype failingUnmarshaler struct{}\n\nvar failingErr = errors.New(\"failingErr\")\n\nfunc (ft *failingUnmarshaler) UnmarshalYAML(unmarshal func(interface{}) error) error {\n\treturn failingErr\n}\n\nfunc (s *S) TestUnmarshalerError(c *C) {\n\terr := yaml.Unmarshal([]byte(\"a: b\"), &failingUnmarshaler{})\n\tc.Assert(err, Equals, failingErr)\n}\n\ntype sliceUnmarshaler []int\n\nfunc (su *sliceUnmarshaler) UnmarshalYAML(unmarshal func(interface{}) error) error {\n\tvar slice []int\n\terr := unmarshal(&slice)\n\tif err == nil {\n\t\t*su = slice\n\t\treturn nil\n\t}\n\n\tvar intVal int\n\terr = unmarshal(&intVal)\n\tif err == nil {\n\t\t*su = []int{intVal}\n\t\treturn nil\n\t}\n\n\treturn err\n}\n\nfunc (s *S) TestUnmarshalerRetry(c *C) {\n\tvar su sliceUnmarshaler\n\terr := yaml.Unmarshal([]byte(\"[1, 2, 3]\"), &su)\n\tc.Assert(err, IsNil)\n\tc.Assert(su, DeepEquals, sliceUnmarshaler([]int{1, 2, 3}))\n\n\terr = yaml.Unmarshal([]byte(\"1\"), &su)\n\tc.Assert(err, IsNil)\n\tc.Assert(su, DeepEquals, sliceUnmarshaler([]int{1}))\n}\n\n// From http://yaml.org/type/merge.html\nvar mergeTests = `\nanchors:\n  list:\n    - &CENTER { \"x\": 1, \"y\": 2 }\n    - &LEFT   { \"x\": 0, \"y\": 2 }\n    - &BIG    { \"r\": 10 }\n    - &SMALL  { \"r\": 1 }\n\n# All the following maps are equal:\n\nplain:\n  # Explicit keys\n  \"x\": 1\n  \"y\": 2\n  \"r\": 10\n  label: center/big\n\nmergeOne:\n  # Merge one map\n  << : *CENTER\n  \"r\": 10\n  label: center/big\n\nmergeMultiple:\n  # Merge multiple maps\n  << : [ *CENTER, *BIG ]\n  label: center/big\n\noverride:\n  # Override\n  << : [ *BIG, *LEFT, *SMALL ]\n  \"x\": 1\n  label: center/big\n\nshortTag:\n  # Explicit short merge tag\n  !!merge \"<<\" : [ *CENTER, *BIG ]\n  label: center/big\n\nlongTag:\n  # Explicit merge long tag\n  !<tag:yaml.org,2002:merge> \"<<\" : [ *CENTER, *BIG ]\n  label: center/big\n\ninlineMap:\n  # Inlined map \n  << : {\"x\": 1, \"y\": 2, \"r\": 10}\n  label: center/big\n\ninlineSequenceMap:\n  # Inlined map in sequence\n  << : [ *CENTER, {\"r\": 10} ]\n  label: center/big\n`\n\nfunc (s *S) TestMerge(c *C) {\n\tvar want = map[interface{}]interface{}{\n\t\t\"x\":     1,\n\t\t\"y\":     2,\n\t\t\"r\":     10,\n\t\t\"label\": \"center/big\",\n\t}\n\n\tvar m map[interface{}]interface{}\n\terr := yaml.Unmarshal([]byte(mergeTests), &m)\n\tc.Assert(err, IsNil)\n\tfor name, test := range m {\n\t\tif name == \"anchors\" {\n\t\t\tcontinue\n\t\t}\n\t\tc.Assert(test, DeepEquals, want, Commentf(\"test %q failed\", name))\n\t}\n}\n\nfunc (s *S) TestMergeStruct(c *C) {\n\ttype Data struct {\n\t\tX, Y, R int\n\t\tLabel   string\n\t}\n\twant := Data{1, 2, 10, \"center/big\"}\n\n\tvar m map[string]Data\n\terr := yaml.Unmarshal([]byte(mergeTests), &m)\n\tc.Assert(err, IsNil)\n\tfor name, test := range m {\n\t\tif name == \"anchors\" {\n\t\t\tcontinue\n\t\t}\n\t\tc.Assert(test, Equals, want, Commentf(\"test %q failed\", name))\n\t}\n}\n\nvar unmarshalNullTests = []func() interface{}{\n\tfunc() interface{} { var v interface{}; v = \"v\"; return &v },\n\tfunc() interface{} { var s = \"s\"; return &s },\n\tfunc() interface{} { var s = \"s\"; sptr := &s; return &sptr },\n\tfunc() interface{} { var i = 1; return &i },\n\tfunc() interface{} { var i = 1; iptr := &i; return &iptr },\n\tfunc() interface{} { m := map[string]int{\"s\": 1}; return &m },\n\tfunc() interface{} { m := map[string]int{\"s\": 1}; return m },\n}\n\nfunc (s *S) TestUnmarshalNull(c *C) {\n\tfor _, test := range unmarshalNullTests {\n\t\titem := test()\n\t\tzero := reflect.Zero(reflect.TypeOf(item).Elem()).Interface()\n\t\terr := yaml.Unmarshal([]byte(\"null\"), item)\n\t\tc.Assert(err, IsNil)\n\t\tif reflect.TypeOf(item).Kind() == reflect.Map {\n\t\t\tc.Assert(reflect.ValueOf(item).Interface(), DeepEquals, reflect.MakeMap(reflect.TypeOf(item)).Interface())\n\t\t} else {\n\t\t\tc.Assert(reflect.ValueOf(item).Elem().Interface(), DeepEquals, zero)\n\t\t}\n\t}\n}\n\nfunc (s *S) TestUnmarshalSliceOnPreset(c *C) {\n\t// Issue #48.\n\tv := struct{ A []int }{[]int{1}}\n\tyaml.Unmarshal([]byte(\"a: [2]\"), &v)\n\tc.Assert(v.A, DeepEquals, []int{2})\n}\n\nfunc (s *S) TestUnmarshalStrict(c *C) {\n\tv := struct{ A, B int }{}\n\n\terr := yaml.UnmarshalStrict([]byte(\"a: 1\\nb: 2\"), &v)\n\tc.Check(err, IsNil)\n\terr = yaml.Unmarshal([]byte(\"a: 1\\nb: 2\\nc: 3\"), &v)\n\tc.Check(err, IsNil)\n\terr = yaml.UnmarshalStrict([]byte(\"a: 1\\nb: 2\\nc: 3\"), &v)\n\tc.Check(err, ErrorMatches, \"yaml: unmarshal errors:\\n  line 1: field c not found in struct struct { A int; B int }\")\n}\n\n//var data []byte\n//func init() {\n//\tvar err error\n//\tdata, err = ioutil.ReadFile(\"/tmp/file.yaml\")\n//\tif err != nil {\n//\t\tpanic(err)\n//\t}\n//}\n//\n//func (s *S) BenchmarkUnmarshal(c *C) {\n//\tvar err error\n//\tfor i := 0; i < c.N; i++ {\n//\t\tvar v map[string]interface{}\n//\t\terr = yaml.Unmarshal(data, &v)\n//\t}\n//\tif err != nil {\n//\t\tpanic(err)\n//\t}\n//}\n//\n//func (s *S) BenchmarkMarshal(c *C) {\n//\tvar v map[string]interface{}\n//\tyaml.Unmarshal(data, &v)\n//\tc.ResetTimer()\n//\tfor i := 0; i < c.N; i++ {\n//\t\tyaml.Marshal(&v)\n//\t}\n//}\n"
  },
  {
    "path": "vendor/gopkg.in/yaml.v2/emitterc.go",
    "content": "package yaml\n\nimport (\n\t\"bytes\"\n)\n\n// Flush the buffer if needed.\nfunc flush(emitter *yaml_emitter_t) bool {\n\tif emitter.buffer_pos+5 >= len(emitter.buffer) {\n\t\treturn yaml_emitter_flush(emitter)\n\t}\n\treturn true\n}\n\n// Put a character to the output buffer.\nfunc put(emitter *yaml_emitter_t, value byte) bool {\n\tif emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) {\n\t\treturn false\n\t}\n\temitter.buffer[emitter.buffer_pos] = value\n\temitter.buffer_pos++\n\temitter.column++\n\treturn true\n}\n\n// Put a line break to the output buffer.\nfunc put_break(emitter *yaml_emitter_t) bool {\n\tif emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) {\n\t\treturn false\n\t}\n\tswitch emitter.line_break {\n\tcase yaml_CR_BREAK:\n\t\temitter.buffer[emitter.buffer_pos] = '\\r'\n\t\temitter.buffer_pos += 1\n\tcase yaml_LN_BREAK:\n\t\temitter.buffer[emitter.buffer_pos] = '\\n'\n\t\temitter.buffer_pos += 1\n\tcase yaml_CRLN_BREAK:\n\t\temitter.buffer[emitter.buffer_pos+0] = '\\r'\n\t\temitter.buffer[emitter.buffer_pos+1] = '\\n'\n\t\temitter.buffer_pos += 2\n\tdefault:\n\t\tpanic(\"unknown line break setting\")\n\t}\n\temitter.column = 0\n\temitter.line++\n\treturn true\n}\n\n// Copy a character from a string into buffer.\nfunc write(emitter *yaml_emitter_t, s []byte, i *int) bool {\n\tif emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) {\n\t\treturn false\n\t}\n\tp := emitter.buffer_pos\n\tw := width(s[*i])\n\tswitch w {\n\tcase 4:\n\t\temitter.buffer[p+3] = s[*i+3]\n\t\tfallthrough\n\tcase 3:\n\t\temitter.buffer[p+2] = s[*i+2]\n\t\tfallthrough\n\tcase 2:\n\t\temitter.buffer[p+1] = s[*i+1]\n\t\tfallthrough\n\tcase 1:\n\t\temitter.buffer[p+0] = s[*i+0]\n\tdefault:\n\t\tpanic(\"unknown character width\")\n\t}\n\temitter.column++\n\temitter.buffer_pos += w\n\t*i += w\n\treturn true\n}\n\n// Write a whole string into buffer.\nfunc write_all(emitter *yaml_emitter_t, s []byte) bool {\n\tfor i := 0; i < len(s); {\n\t\tif !write(emitter, s, &i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n// Copy a line break character from a string into buffer.\nfunc write_break(emitter *yaml_emitter_t, s []byte, i *int) bool {\n\tif s[*i] == '\\n' {\n\t\tif !put_break(emitter) {\n\t\t\treturn false\n\t\t}\n\t\t*i++\n\t} else {\n\t\tif !write(emitter, s, i) {\n\t\t\treturn false\n\t\t}\n\t\temitter.column = 0\n\t\temitter.line++\n\t}\n\treturn true\n}\n\n// Set an emitter error and return false.\nfunc yaml_emitter_set_emitter_error(emitter *yaml_emitter_t, problem string) bool {\n\temitter.error = yaml_EMITTER_ERROR\n\temitter.problem = problem\n\treturn false\n}\n\n// Emit an event.\nfunc yaml_emitter_emit(emitter *yaml_emitter_t, event *yaml_event_t) bool {\n\temitter.events = append(emitter.events, *event)\n\tfor !yaml_emitter_need_more_events(emitter) {\n\t\tevent := &emitter.events[emitter.events_head]\n\t\tif !yaml_emitter_analyze_event(emitter, event) {\n\t\t\treturn false\n\t\t}\n\t\tif !yaml_emitter_state_machine(emitter, event) {\n\t\t\treturn false\n\t\t}\n\t\tyaml_event_delete(event)\n\t\temitter.events_head++\n\t}\n\treturn true\n}\n\n// Check if we need to accumulate more events before emitting.\n//\n// We accumulate extra\n//  - 1 event for DOCUMENT-START\n//  - 2 events for SEQUENCE-START\n//  - 3 events for MAPPING-START\n//\nfunc yaml_emitter_need_more_events(emitter *yaml_emitter_t) bool {\n\tif emitter.events_head == len(emitter.events) {\n\t\treturn true\n\t}\n\tvar accumulate int\n\tswitch emitter.events[emitter.events_head].typ {\n\tcase yaml_DOCUMENT_START_EVENT:\n\t\taccumulate = 1\n\t\tbreak\n\tcase yaml_SEQUENCE_START_EVENT:\n\t\taccumulate = 2\n\t\tbreak\n\tcase yaml_MAPPING_START_EVENT:\n\t\taccumulate = 3\n\t\tbreak\n\tdefault:\n\t\treturn false\n\t}\n\tif len(emitter.events)-emitter.events_head > accumulate {\n\t\treturn false\n\t}\n\tvar level int\n\tfor i := emitter.events_head; i < len(emitter.events); i++ {\n\t\tswitch emitter.events[i].typ {\n\t\tcase yaml_STREAM_START_EVENT, yaml_DOCUMENT_START_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT:\n\t\t\tlevel++\n\t\tcase yaml_STREAM_END_EVENT, yaml_DOCUMENT_END_EVENT, yaml_SEQUENCE_END_EVENT, yaml_MAPPING_END_EVENT:\n\t\t\tlevel--\n\t\t}\n\t\tif level == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n// Append a directive to the directives stack.\nfunc yaml_emitter_append_tag_directive(emitter *yaml_emitter_t, value *yaml_tag_directive_t, allow_duplicates bool) bool {\n\tfor i := 0; i < len(emitter.tag_directives); i++ {\n\t\tif bytes.Equal(value.handle, emitter.tag_directives[i].handle) {\n\t\t\tif allow_duplicates {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn yaml_emitter_set_emitter_error(emitter, \"duplicate %TAG directive\")\n\t\t}\n\t}\n\n\t// [Go] Do we actually need to copy this given garbage collection\n\t// and the lack of deallocating destructors?\n\ttag_copy := yaml_tag_directive_t{\n\t\thandle: make([]byte, len(value.handle)),\n\t\tprefix: make([]byte, len(value.prefix)),\n\t}\n\tcopy(tag_copy.handle, value.handle)\n\tcopy(tag_copy.prefix, value.prefix)\n\temitter.tag_directives = append(emitter.tag_directives, tag_copy)\n\treturn true\n}\n\n// Increase the indentation level.\nfunc yaml_emitter_increase_indent(emitter *yaml_emitter_t, flow, indentless bool) bool {\n\temitter.indents = append(emitter.indents, emitter.indent)\n\tif emitter.indent < 0 {\n\t\tif flow {\n\t\t\temitter.indent = emitter.best_indent\n\t\t} else {\n\t\t\temitter.indent = 0\n\t\t}\n\t} else if !indentless {\n\t\temitter.indent += emitter.best_indent\n\t}\n\treturn true\n}\n\n// State dispatcher.\nfunc yaml_emitter_state_machine(emitter *yaml_emitter_t, event *yaml_event_t) bool {\n\tswitch emitter.state {\n\tdefault:\n\tcase yaml_EMIT_STREAM_START_STATE:\n\t\treturn yaml_emitter_emit_stream_start(emitter, event)\n\n\tcase yaml_EMIT_FIRST_DOCUMENT_START_STATE:\n\t\treturn yaml_emitter_emit_document_start(emitter, event, true)\n\n\tcase yaml_EMIT_DOCUMENT_START_STATE:\n\t\treturn yaml_emitter_emit_document_start(emitter, event, false)\n\n\tcase yaml_EMIT_DOCUMENT_CONTENT_STATE:\n\t\treturn yaml_emitter_emit_document_content(emitter, event)\n\n\tcase yaml_EMIT_DOCUMENT_END_STATE:\n\t\treturn yaml_emitter_emit_document_end(emitter, event)\n\n\tcase yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE:\n\t\treturn yaml_emitter_emit_flow_sequence_item(emitter, event, true)\n\n\tcase yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE:\n\t\treturn yaml_emitter_emit_flow_sequence_item(emitter, event, false)\n\n\tcase yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE:\n\t\treturn yaml_emitter_emit_flow_mapping_key(emitter, event, true)\n\n\tcase yaml_EMIT_FLOW_MAPPING_KEY_STATE:\n\t\treturn yaml_emitter_emit_flow_mapping_key(emitter, event, false)\n\n\tcase yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE:\n\t\treturn yaml_emitter_emit_flow_mapping_value(emitter, event, true)\n\n\tcase yaml_EMIT_FLOW_MAPPING_VALUE_STATE:\n\t\treturn yaml_emitter_emit_flow_mapping_value(emitter, event, false)\n\n\tcase yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE:\n\t\treturn yaml_emitter_emit_block_sequence_item(emitter, event, true)\n\n\tcase yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE:\n\t\treturn yaml_emitter_emit_block_sequence_item(emitter, event, false)\n\n\tcase yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE:\n\t\treturn yaml_emitter_emit_block_mapping_key(emitter, event, true)\n\n\tcase yaml_EMIT_BLOCK_MAPPING_KEY_STATE:\n\t\treturn yaml_emitter_emit_block_mapping_key(emitter, event, false)\n\n\tcase yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE:\n\t\treturn yaml_emitter_emit_block_mapping_value(emitter, event, true)\n\n\tcase yaml_EMIT_BLOCK_MAPPING_VALUE_STATE:\n\t\treturn yaml_emitter_emit_block_mapping_value(emitter, event, false)\n\n\tcase yaml_EMIT_END_STATE:\n\t\treturn yaml_emitter_set_emitter_error(emitter, \"expected nothing after STREAM-END\")\n\t}\n\tpanic(\"invalid emitter state\")\n}\n\n// Expect STREAM-START.\nfunc yaml_emitter_emit_stream_start(emitter *yaml_emitter_t, event *yaml_event_t) bool {\n\tif event.typ != yaml_STREAM_START_EVENT {\n\t\treturn yaml_emitter_set_emitter_error(emitter, \"expected STREAM-START\")\n\t}\n\tif emitter.encoding == yaml_ANY_ENCODING {\n\t\temitter.encoding = event.encoding\n\t\tif emitter.encoding == yaml_ANY_ENCODING {\n\t\t\temitter.encoding = yaml_UTF8_ENCODING\n\t\t}\n\t}\n\tif emitter.best_indent < 2 || emitter.best_indent > 9 {\n\t\temitter.best_indent = 2\n\t}\n\tif emitter.best_width >= 0 && emitter.best_width <= emitter.best_indent*2 {\n\t\temitter.best_width = 80\n\t}\n\tif emitter.best_width < 0 {\n\t\temitter.best_width = 1<<31 - 1\n\t}\n\tif emitter.line_break == yaml_ANY_BREAK {\n\t\temitter.line_break = yaml_LN_BREAK\n\t}\n\n\temitter.indent = -1\n\temitter.line = 0\n\temitter.column = 0\n\temitter.whitespace = true\n\temitter.indention = true\n\n\tif emitter.encoding != yaml_UTF8_ENCODING {\n\t\tif !yaml_emitter_write_bom(emitter) {\n\t\t\treturn false\n\t\t}\n\t}\n\temitter.state = yaml_EMIT_FIRST_DOCUMENT_START_STATE\n\treturn true\n}\n\n// Expect DOCUMENT-START or STREAM-END.\nfunc yaml_emitter_emit_document_start(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool {\n\n\tif event.typ == yaml_DOCUMENT_START_EVENT {\n\n\t\tif event.version_directive != nil {\n\t\t\tif !yaml_emitter_analyze_version_directive(emitter, event.version_directive) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\n\t\tfor i := 0; i < len(event.tag_directives); i++ {\n\t\t\ttag_directive := &event.tag_directives[i]\n\t\t\tif !yaml_emitter_analyze_tag_directive(emitter, tag_directive) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif !yaml_emitter_append_tag_directive(emitter, tag_directive, false) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\n\t\tfor i := 0; i < len(default_tag_directives); i++ {\n\t\t\ttag_directive := &default_tag_directives[i]\n\t\t\tif !yaml_emitter_append_tag_directive(emitter, tag_directive, true) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\n\t\timplicit := event.implicit\n\t\tif !first || emitter.canonical {\n\t\t\timplicit = false\n\t\t}\n\n\t\tif emitter.open_ended && (event.version_directive != nil || len(event.tag_directives) > 0) {\n\t\t\tif !yaml_emitter_write_indicator(emitter, []byte(\"...\"), true, false, false) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif !yaml_emitter_write_indent(emitter) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\n\t\tif event.version_directive != nil {\n\t\t\timplicit = false\n\t\t\tif !yaml_emitter_write_indicator(emitter, []byte(\"%YAML\"), true, false, false) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif !yaml_emitter_write_indicator(emitter, []byte(\"1.1\"), true, false, false) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif !yaml_emitter_write_indent(emitter) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\n\t\tif len(event.tag_directives) > 0 {\n\t\t\timplicit = false\n\t\t\tfor i := 0; i < len(event.tag_directives); i++ {\n\t\t\t\ttag_directive := &event.tag_directives[i]\n\t\t\t\tif !yaml_emitter_write_indicator(emitter, []byte(\"%TAG\"), true, false, false) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tif !yaml_emitter_write_tag_handle(emitter, tag_directive.handle) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tif !yaml_emitter_write_tag_content(emitter, tag_directive.prefix, true) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tif !yaml_emitter_write_indent(emitter) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif yaml_emitter_check_empty_document(emitter) {\n\t\t\timplicit = false\n\t\t}\n\t\tif !implicit {\n\t\t\tif !yaml_emitter_write_indent(emitter) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif !yaml_emitter_write_indicator(emitter, []byte(\"---\"), true, false, false) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif emitter.canonical {\n\t\t\t\tif !yaml_emitter_write_indent(emitter) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\temitter.state = yaml_EMIT_DOCUMENT_CONTENT_STATE\n\t\treturn true\n\t}\n\n\tif event.typ == yaml_STREAM_END_EVENT {\n\t\tif emitter.open_ended {\n\t\t\tif !yaml_emitter_write_indicator(emitter, []byte(\"...\"), true, false, false) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif !yaml_emitter_write_indent(emitter) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\tif !yaml_emitter_flush(emitter) {\n\t\t\treturn false\n\t\t}\n\t\temitter.state = yaml_EMIT_END_STATE\n\t\treturn true\n\t}\n\n\treturn yaml_emitter_set_emitter_error(emitter, \"expected DOCUMENT-START or STREAM-END\")\n}\n\n// Expect the root node.\nfunc yaml_emitter_emit_document_content(emitter *yaml_emitter_t, event *yaml_event_t) bool {\n\temitter.states = append(emitter.states, yaml_EMIT_DOCUMENT_END_STATE)\n\treturn yaml_emitter_emit_node(emitter, event, true, false, false, false)\n}\n\n// Expect DOCUMENT-END.\nfunc yaml_emitter_emit_document_end(emitter *yaml_emitter_t, event *yaml_event_t) bool {\n\tif event.typ != yaml_DOCUMENT_END_EVENT {\n\t\treturn yaml_emitter_set_emitter_error(emitter, \"expected DOCUMENT-END\")\n\t}\n\tif !yaml_emitter_write_indent(emitter) {\n\t\treturn false\n\t}\n\tif !event.implicit {\n\t\t// [Go] Allocate the slice elsewhere.\n\t\tif !yaml_emitter_write_indicator(emitter, []byte(\"...\"), true, false, false) {\n\t\t\treturn false\n\t\t}\n\t\tif !yaml_emitter_write_indent(emitter) {\n\t\t\treturn false\n\t\t}\n\t}\n\tif !yaml_emitter_flush(emitter) {\n\t\treturn false\n\t}\n\temitter.state = yaml_EMIT_DOCUMENT_START_STATE\n\temitter.tag_directives = emitter.tag_directives[:0]\n\treturn true\n}\n\n// Expect a flow item node.\nfunc yaml_emitter_emit_flow_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool {\n\tif first {\n\t\tif !yaml_emitter_write_indicator(emitter, []byte{'['}, true, true, false) {\n\t\t\treturn false\n\t\t}\n\t\tif !yaml_emitter_increase_indent(emitter, true, false) {\n\t\t\treturn false\n\t\t}\n\t\temitter.flow_level++\n\t}\n\n\tif event.typ == yaml_SEQUENCE_END_EVENT {\n\t\temitter.flow_level--\n\t\temitter.indent = emitter.indents[len(emitter.indents)-1]\n\t\temitter.indents = emitter.indents[:len(emitter.indents)-1]\n\t\tif emitter.canonical && !first {\n\t\t\tif !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif !yaml_emitter_write_indent(emitter) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\tif !yaml_emitter_write_indicator(emitter, []byte{']'}, false, false, false) {\n\t\t\treturn false\n\t\t}\n\t\temitter.state = emitter.states[len(emitter.states)-1]\n\t\temitter.states = emitter.states[:len(emitter.states)-1]\n\n\t\treturn true\n\t}\n\n\tif !first {\n\t\tif !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\tif emitter.canonical || emitter.column > emitter.best_width {\n\t\tif !yaml_emitter_write_indent(emitter) {\n\t\t\treturn false\n\t\t}\n\t}\n\temitter.states = append(emitter.states, yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE)\n\treturn yaml_emitter_emit_node(emitter, event, false, true, false, false)\n}\n\n// Expect a flow key node.\nfunc yaml_emitter_emit_flow_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool {\n\tif first {\n\t\tif !yaml_emitter_write_indicator(emitter, []byte{'{'}, true, true, false) {\n\t\t\treturn false\n\t\t}\n\t\tif !yaml_emitter_increase_indent(emitter, true, false) {\n\t\t\treturn false\n\t\t}\n\t\temitter.flow_level++\n\t}\n\n\tif event.typ == yaml_MAPPING_END_EVENT {\n\t\temitter.flow_level--\n\t\temitter.indent = emitter.indents[len(emitter.indents)-1]\n\t\temitter.indents = emitter.indents[:len(emitter.indents)-1]\n\t\tif emitter.canonical && !first {\n\t\t\tif !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif !yaml_emitter_write_indent(emitter) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\tif !yaml_emitter_write_indicator(emitter, []byte{'}'}, false, false, false) {\n\t\t\treturn false\n\t\t}\n\t\temitter.state = emitter.states[len(emitter.states)-1]\n\t\temitter.states = emitter.states[:len(emitter.states)-1]\n\t\treturn true\n\t}\n\n\tif !first {\n\t\tif !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) {\n\t\t\treturn false\n\t\t}\n\t}\n\tif emitter.canonical || emitter.column > emitter.best_width {\n\t\tif !yaml_emitter_write_indent(emitter) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\tif !emitter.canonical && yaml_emitter_check_simple_key(emitter) {\n\t\temitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE)\n\t\treturn yaml_emitter_emit_node(emitter, event, false, false, true, true)\n\t}\n\tif !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, false) {\n\t\treturn false\n\t}\n\temitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_VALUE_STATE)\n\treturn yaml_emitter_emit_node(emitter, event, false, false, true, false)\n}\n\n// Expect a flow value node.\nfunc yaml_emitter_emit_flow_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool {\n\tif simple {\n\t\tif !yaml_emitter_write_indicator(emitter, []byte{':'}, false, false, false) {\n\t\t\treturn false\n\t\t}\n\t} else {\n\t\tif emitter.canonical || emitter.column > emitter.best_width {\n\t\t\tif !yaml_emitter_write_indent(emitter) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\tif !yaml_emitter_write_indicator(emitter, []byte{':'}, true, false, false) {\n\t\t\treturn false\n\t\t}\n\t}\n\temitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_KEY_STATE)\n\treturn yaml_emitter_emit_node(emitter, event, false, false, true, false)\n}\n\n// Expect a block item node.\nfunc yaml_emitter_emit_block_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool {\n\tif first {\n\t\tif !yaml_emitter_increase_indent(emitter, false, emitter.mapping_context && !emitter.indention) {\n\t\t\treturn false\n\t\t}\n\t}\n\tif event.typ == yaml_SEQUENCE_END_EVENT {\n\t\temitter.indent = emitter.indents[len(emitter.indents)-1]\n\t\temitter.indents = emitter.indents[:len(emitter.indents)-1]\n\t\temitter.state = emitter.states[len(emitter.states)-1]\n\t\temitter.states = emitter.states[:len(emitter.states)-1]\n\t\treturn true\n\t}\n\tif !yaml_emitter_write_indent(emitter) {\n\t\treturn false\n\t}\n\tif !yaml_emitter_write_indicator(emitter, []byte{'-'}, true, false, true) {\n\t\treturn false\n\t}\n\temitter.states = append(emitter.states, yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE)\n\treturn yaml_emitter_emit_node(emitter, event, false, true, false, false)\n}\n\n// Expect a block key node.\nfunc yaml_emitter_emit_block_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool {\n\tif first {\n\t\tif !yaml_emitter_increase_indent(emitter, false, false) {\n\t\t\treturn false\n\t\t}\n\t}\n\tif event.typ == yaml_MAPPING_END_EVENT {\n\t\temitter.indent = emitter.indents[len(emitter.indents)-1]\n\t\temitter.indents = emitter.indents[:len(emitter.indents)-1]\n\t\temitter.state = emitter.states[len(emitter.states)-1]\n\t\temitter.states = emitter.states[:len(emitter.states)-1]\n\t\treturn true\n\t}\n\tif !yaml_emitter_write_indent(emitter) {\n\t\treturn false\n\t}\n\tif yaml_emitter_check_simple_key(emitter) {\n\t\temitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE)\n\t\treturn yaml_emitter_emit_node(emitter, event, false, false, true, true)\n\t}\n\tif !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, true) {\n\t\treturn false\n\t}\n\temitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_VALUE_STATE)\n\treturn yaml_emitter_emit_node(emitter, event, false, false, true, false)\n}\n\n// Expect a block value node.\nfunc yaml_emitter_emit_block_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool {\n\tif simple {\n\t\tif !yaml_emitter_write_indicator(emitter, []byte{':'}, false, false, false) {\n\t\t\treturn false\n\t\t}\n\t} else {\n\t\tif !yaml_emitter_write_indent(emitter) {\n\t\t\treturn false\n\t\t}\n\t\tif !yaml_emitter_write_indicator(emitter, []byte{':'}, true, false, true) {\n\t\t\treturn false\n\t\t}\n\t}\n\temitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_KEY_STATE)\n\treturn yaml_emitter_emit_node(emitter, event, false, false, true, false)\n}\n\n// Expect a node.\nfunc yaml_emitter_emit_node(emitter *yaml_emitter_t, event *yaml_event_t,\n\troot bool, sequence bool, mapping bool, simple_key bool) bool {\n\n\temitter.root_context = root\n\temitter.sequence_context = sequence\n\temitter.mapping_context = mapping\n\temitter.simple_key_context = simple_key\n\n\tswitch event.typ {\n\tcase yaml_ALIAS_EVENT:\n\t\treturn yaml_emitter_emit_alias(emitter, event)\n\tcase yaml_SCALAR_EVENT:\n\t\treturn yaml_emitter_emit_scalar(emitter, event)\n\tcase yaml_SEQUENCE_START_EVENT:\n\t\treturn yaml_emitter_emit_sequence_start(emitter, event)\n\tcase yaml_MAPPING_START_EVENT:\n\t\treturn yaml_emitter_emit_mapping_start(emitter, event)\n\tdefault:\n\t\treturn yaml_emitter_set_emitter_error(emitter,\n\t\t\t\"expected SCALAR, SEQUENCE-START, MAPPING-START, or ALIAS\")\n\t}\n}\n\n// Expect ALIAS.\nfunc yaml_emitter_emit_alias(emitter *yaml_emitter_t, event *yaml_event_t) bool {\n\tif !yaml_emitter_process_anchor(emitter) {\n\t\treturn false\n\t}\n\temitter.state = emitter.states[len(emitter.states)-1]\n\temitter.states = emitter.states[:len(emitter.states)-1]\n\treturn true\n}\n\n// Expect SCALAR.\nfunc yaml_emitter_emit_scalar(emitter *yaml_emitter_t, event *yaml_event_t) bool {\n\tif !yaml_emitter_select_scalar_style(emitter, event) {\n\t\treturn false\n\t}\n\tif !yaml_emitter_process_anchor(emitter) {\n\t\treturn false\n\t}\n\tif !yaml_emitter_process_tag(emitter) {\n\t\treturn false\n\t}\n\tif !yaml_emitter_increase_indent(emitter, true, false) {\n\t\treturn false\n\t}\n\tif !yaml_emitter_process_scalar(emitter) {\n\t\treturn false\n\t}\n\temitter.indent = emitter.indents[len(emitter.indents)-1]\n\temitter.indents = emitter.indents[:len(emitter.indents)-1]\n\temitter.state = emitter.states[len(emitter.states)-1]\n\temitter.states = emitter.states[:len(emitter.states)-1]\n\treturn true\n}\n\n// Expect SEQUENCE-START.\nfunc yaml_emitter_emit_sequence_start(emitter *yaml_emitter_t, event *yaml_event_t) bool {\n\tif !yaml_emitter_process_anchor(emitter) {\n\t\treturn false\n\t}\n\tif !yaml_emitter_process_tag(emitter) {\n\t\treturn false\n\t}\n\tif emitter.flow_level > 0 || emitter.canonical || event.sequence_style() == yaml_FLOW_SEQUENCE_STYLE ||\n\t\tyaml_emitter_check_empty_sequence(emitter) {\n\t\temitter.state = yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE\n\t} else {\n\t\temitter.state = yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE\n\t}\n\treturn true\n}\n\n// Expect MAPPING-START.\nfunc yaml_emitter_emit_mapping_start(emitter *yaml_emitter_t, event *yaml_event_t) bool {\n\tif !yaml_emitter_process_anchor(emitter) {\n\t\treturn false\n\t}\n\tif !yaml_emitter_process_tag(emitter) {\n\t\treturn false\n\t}\n\tif emitter.flow_level > 0 || emitter.canonical || event.mapping_style() == yaml_FLOW_MAPPING_STYLE ||\n\t\tyaml_emitter_check_empty_mapping(emitter) {\n\t\temitter.state = yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE\n\t} else {\n\t\temitter.state = yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE\n\t}\n\treturn true\n}\n\n// Check if the document content is an empty scalar.\nfunc yaml_emitter_check_empty_document(emitter *yaml_emitter_t) bool {\n\treturn false // [Go] Huh?\n}\n\n// Check if the next events represent an empty sequence.\nfunc yaml_emitter_check_empty_sequence(emitter *yaml_emitter_t) bool {\n\tif len(emitter.events)-emitter.events_head < 2 {\n\t\treturn false\n\t}\n\treturn emitter.events[emitter.events_head].typ == yaml_SEQUENCE_START_EVENT &&\n\t\temitter.events[emitter.events_head+1].typ == yaml_SEQUENCE_END_EVENT\n}\n\n// Check if the next events represent an empty mapping.\nfunc yaml_emitter_check_empty_mapping(emitter *yaml_emitter_t) bool {\n\tif len(emitter.events)-emitter.events_head < 2 {\n\t\treturn false\n\t}\n\treturn emitter.events[emitter.events_head].typ == yaml_MAPPING_START_EVENT &&\n\t\temitter.events[emitter.events_head+1].typ == yaml_MAPPING_END_EVENT\n}\n\n// Check if the next node can be expressed as a simple key.\nfunc yaml_emitter_check_simple_key(emitter *yaml_emitter_t) bool {\n\tlength := 0\n\tswitch emitter.events[emitter.events_head].typ {\n\tcase yaml_ALIAS_EVENT:\n\t\tlength += len(emitter.anchor_data.anchor)\n\tcase yaml_SCALAR_EVENT:\n\t\tif emitter.scalar_data.multiline {\n\t\t\treturn false\n\t\t}\n\t\tlength += len(emitter.anchor_data.anchor) +\n\t\t\tlen(emitter.tag_data.handle) +\n\t\t\tlen(emitter.tag_data.suffix) +\n\t\t\tlen(emitter.scalar_data.value)\n\tcase yaml_SEQUENCE_START_EVENT:\n\t\tif !yaml_emitter_check_empty_sequence(emitter) {\n\t\t\treturn false\n\t\t}\n\t\tlength += len(emitter.anchor_data.anchor) +\n\t\t\tlen(emitter.tag_data.handle) +\n\t\t\tlen(emitter.tag_data.suffix)\n\tcase yaml_MAPPING_START_EVENT:\n\t\tif !yaml_emitter_check_empty_mapping(emitter) {\n\t\t\treturn false\n\t\t}\n\t\tlength += len(emitter.anchor_data.anchor) +\n\t\t\tlen(emitter.tag_data.handle) +\n\t\t\tlen(emitter.tag_data.suffix)\n\tdefault:\n\t\treturn false\n\t}\n\treturn length <= 128\n}\n\n// Determine an acceptable scalar style.\nfunc yaml_emitter_select_scalar_style(emitter *yaml_emitter_t, event *yaml_event_t) bool {\n\n\tno_tag := len(emitter.tag_data.handle) == 0 && len(emitter.tag_data.suffix) == 0\n\tif no_tag && !event.implicit && !event.quoted_implicit {\n\t\treturn yaml_emitter_set_emitter_error(emitter, \"neither tag nor implicit flags are specified\")\n\t}\n\n\tstyle := event.scalar_style()\n\tif style == yaml_ANY_SCALAR_STYLE {\n\t\tstyle = yaml_PLAIN_SCALAR_STYLE\n\t}\n\tif emitter.canonical {\n\t\tstyle = yaml_DOUBLE_QUOTED_SCALAR_STYLE\n\t}\n\tif emitter.simple_key_context && emitter.scalar_data.multiline {\n\t\tstyle = yaml_DOUBLE_QUOTED_SCALAR_STYLE\n\t}\n\n\tif style == yaml_PLAIN_SCALAR_STYLE {\n\t\tif emitter.flow_level > 0 && !emitter.scalar_data.flow_plain_allowed ||\n\t\t\temitter.flow_level == 0 && !emitter.scalar_data.block_plain_allowed {\n\t\t\tstyle = yaml_SINGLE_QUOTED_SCALAR_STYLE\n\t\t}\n\t\tif len(emitter.scalar_data.value) == 0 && (emitter.flow_level > 0 || emitter.simple_key_context) {\n\t\t\tstyle = yaml_SINGLE_QUOTED_SCALAR_STYLE\n\t\t}\n\t\tif no_tag && !event.implicit {\n\t\t\tstyle = yaml_SINGLE_QUOTED_SCALAR_STYLE\n\t\t}\n\t}\n\tif style == yaml_SINGLE_QUOTED_SCALAR_STYLE {\n\t\tif !emitter.scalar_data.single_quoted_allowed {\n\t\t\tstyle = yaml_DOUBLE_QUOTED_SCALAR_STYLE\n\t\t}\n\t}\n\tif style == yaml_LITERAL_SCALAR_STYLE || style == yaml_FOLDED_SCALAR_STYLE {\n\t\tif !emitter.scalar_data.block_allowed || emitter.flow_level > 0 || emitter.simple_key_context {\n\t\t\tstyle = yaml_DOUBLE_QUOTED_SCALAR_STYLE\n\t\t}\n\t}\n\n\tif no_tag && !event.quoted_implicit && style != yaml_PLAIN_SCALAR_STYLE {\n\t\temitter.tag_data.handle = []byte{'!'}\n\t}\n\temitter.scalar_data.style = style\n\treturn true\n}\n\n// Write an achor.\nfunc yaml_emitter_process_anchor(emitter *yaml_emitter_t) bool {\n\tif emitter.anchor_data.anchor == nil {\n\t\treturn true\n\t}\n\tc := []byte{'&'}\n\tif emitter.anchor_data.alias {\n\t\tc[0] = '*'\n\t}\n\tif !yaml_emitter_write_indicator(emitter, c, true, false, false) {\n\t\treturn false\n\t}\n\treturn yaml_emitter_write_anchor(emitter, emitter.anchor_data.anchor)\n}\n\n// Write a tag.\nfunc yaml_emitter_process_tag(emitter *yaml_emitter_t) bool {\n\tif len(emitter.tag_data.handle) == 0 && len(emitter.tag_data.suffix) == 0 {\n\t\treturn true\n\t}\n\tif len(emitter.tag_data.handle) > 0 {\n\t\tif !yaml_emitter_write_tag_handle(emitter, emitter.tag_data.handle) {\n\t\t\treturn false\n\t\t}\n\t\tif len(emitter.tag_data.suffix) > 0 {\n\t\t\tif !yaml_emitter_write_tag_content(emitter, emitter.tag_data.suffix, false) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// [Go] Allocate these slices elsewhere.\n\t\tif !yaml_emitter_write_indicator(emitter, []byte(\"!<\"), true, false, false) {\n\t\t\treturn false\n\t\t}\n\t\tif !yaml_emitter_write_tag_content(emitter, emitter.tag_data.suffix, false) {\n\t\t\treturn false\n\t\t}\n\t\tif !yaml_emitter_write_indicator(emitter, []byte{'>'}, false, false, false) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n// Write a scalar.\nfunc yaml_emitter_process_scalar(emitter *yaml_emitter_t) bool {\n\tswitch emitter.scalar_data.style {\n\tcase yaml_PLAIN_SCALAR_STYLE:\n\t\treturn yaml_emitter_write_plain_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context)\n\n\tcase yaml_SINGLE_QUOTED_SCALAR_STYLE:\n\t\treturn yaml_emitter_write_single_quoted_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context)\n\n\tcase yaml_DOUBLE_QUOTED_SCALAR_STYLE:\n\t\treturn yaml_emitter_write_double_quoted_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context)\n\n\tcase yaml_LITERAL_SCALAR_STYLE:\n\t\treturn yaml_emitter_write_literal_scalar(emitter, emitter.scalar_data.value)\n\n\tcase yaml_FOLDED_SCALAR_STYLE:\n\t\treturn yaml_emitter_write_folded_scalar(emitter, emitter.scalar_data.value)\n\t}\n\tpanic(\"unknown scalar style\")\n}\n\n// Check if a %YAML directive is valid.\nfunc yaml_emitter_analyze_version_directive(emitter *yaml_emitter_t, version_directive *yaml_version_directive_t) bool {\n\tif version_directive.major != 1 || version_directive.minor != 1 {\n\t\treturn yaml_emitter_set_emitter_error(emitter, \"incompatible %YAML directive\")\n\t}\n\treturn true\n}\n\n// Check if a %TAG directive is valid.\nfunc yaml_emitter_analyze_tag_directive(emitter *yaml_emitter_t, tag_directive *yaml_tag_directive_t) bool {\n\thandle := tag_directive.handle\n\tprefix := tag_directive.prefix\n\tif len(handle) == 0 {\n\t\treturn yaml_emitter_set_emitter_error(emitter, \"tag handle must not be empty\")\n\t}\n\tif handle[0] != '!' {\n\t\treturn yaml_emitter_set_emitter_error(emitter, \"tag handle must start with '!'\")\n\t}\n\tif handle[len(handle)-1] != '!' {\n\t\treturn yaml_emitter_set_emitter_error(emitter, \"tag handle must end with '!'\")\n\t}\n\tfor i := 1; i < len(handle)-1; i += width(handle[i]) {\n\t\tif !is_alpha(handle, i) {\n\t\t\treturn yaml_emitter_set_emitter_error(emitter, \"tag handle must contain alphanumerical characters only\")\n\t\t}\n\t}\n\tif len(prefix) == 0 {\n\t\treturn yaml_emitter_set_emitter_error(emitter, \"tag prefix must not be empty\")\n\t}\n\treturn true\n}\n\n// Check if an anchor is valid.\nfunc yaml_emitter_analyze_anchor(emitter *yaml_emitter_t, anchor []byte, alias bool) bool {\n\tif len(anchor) == 0 {\n\t\tproblem := \"anchor value must not be empty\"\n\t\tif alias {\n\t\t\tproblem = \"alias value must not be empty\"\n\t\t}\n\t\treturn yaml_emitter_set_emitter_error(emitter, problem)\n\t}\n\tfor i := 0; i < len(anchor); i += width(anchor[i]) {\n\t\tif !is_alpha(anchor, i) {\n\t\t\tproblem := \"anchor value must contain alphanumerical characters only\"\n\t\t\tif alias {\n\t\t\t\tproblem = \"alias value must contain alphanumerical characters only\"\n\t\t\t}\n\t\t\treturn yaml_emitter_set_emitter_error(emitter, problem)\n\t\t}\n\t}\n\temitter.anchor_data.anchor = anchor\n\temitter.anchor_data.alias = alias\n\treturn true\n}\n\n// Check if a tag is valid.\nfunc yaml_emitter_analyze_tag(emitter *yaml_emitter_t, tag []byte) bool {\n\tif len(tag) == 0 {\n\t\treturn yaml_emitter_set_emitter_error(emitter, \"tag value must not be empty\")\n\t}\n\tfor i := 0; i < len(emitter.tag_directives); i++ {\n\t\ttag_directive := &emitter.tag_directives[i]\n\t\tif bytes.HasPrefix(tag, tag_directive.prefix) {\n\t\t\temitter.tag_data.handle = tag_directive.handle\n\t\t\temitter.tag_data.suffix = tag[len(tag_directive.prefix):]\n\t\t\treturn true\n\t\t}\n\t}\n\temitter.tag_data.suffix = tag\n\treturn true\n}\n\n// Check if a scalar is valid.\nfunc yaml_emitter_analyze_scalar(emitter *yaml_emitter_t, value []byte) bool {\n\tvar (\n\t\tblock_indicators   = false\n\t\tflow_indicators    = false\n\t\tline_breaks        = false\n\t\tspecial_characters = false\n\n\t\tleading_space  = false\n\t\tleading_break  = false\n\t\ttrailing_space = false\n\t\ttrailing_break = false\n\t\tbreak_space    = false\n\t\tspace_break    = false\n\n\t\tpreceded_by_whitespace = false\n\t\tfollowed_by_whitespace  = false\n\t\tprevious_space          = false\n\t\tprevious_break          = false\n\t)\n\n\temitter.scalar_data.value = value\n\n\tif len(value) == 0 {\n\t\temitter.scalar_data.multiline = false\n\t\temitter.scalar_data.flow_plain_allowed = false\n\t\temitter.scalar_data.block_plain_allowed = true\n\t\temitter.scalar_data.single_quoted_allowed = true\n\t\temitter.scalar_data.block_allowed = false\n\t\treturn true\n\t}\n\n\tif len(value) >= 3 && ((value[0] == '-' && value[1] == '-' && value[2] == '-') || (value[0] == '.' && value[1] == '.' && value[2] == '.')) {\n\t\tblock_indicators = true\n\t\tflow_indicators = true\n\t}\n\n\tpreceded_by_whitespace = true\n\tfor i, w := 0, 0; i < len(value); i += w {\n\t\tw = width(value[i])\n\t\tfollowed_by_whitespace = i+w >= len(value) || is_blank(value, i+w)\n\n\t\tif i == 0 {\n\t\t\tswitch value[i] {\n\t\t\tcase '#', ',', '[', ']', '{', '}', '&', '*', '!', '|', '>', '\\'', '\"', '%', '@', '`':\n\t\t\t\tflow_indicators = true\n\t\t\t\tblock_indicators = true\n\t\t\tcase '?', ':':\n\t\t\t\tflow_indicators = true\n\t\t\t\tif followed_by_whitespace {\n\t\t\t\t\tblock_indicators = true\n\t\t\t\t}\n\t\t\tcase '-':\n\t\t\t\tif followed_by_whitespace {\n\t\t\t\t\tflow_indicators = true\n\t\t\t\t\tblock_indicators = true\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tswitch value[i] {\n\t\t\tcase ',', '?', '[', ']', '{', '}':\n\t\t\t\tflow_indicators = true\n\t\t\tcase ':':\n\t\t\t\tflow_indicators = true\n\t\t\t\tif followed_by_whitespace {\n\t\t\t\t\tblock_indicators = true\n\t\t\t\t}\n\t\t\tcase '#':\n\t\t\t\tif preceded_by_whitespace {\n\t\t\t\t\tflow_indicators = true\n\t\t\t\t\tblock_indicators = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif !is_printable(value, i) || !is_ascii(value, i) && !emitter.unicode {\n\t\t\tspecial_characters = true\n\t\t}\n\t\tif is_space(value, i) {\n\t\t\tif i == 0 {\n\t\t\t\tleading_space = true\n\t\t\t}\n\t\t\tif i+width(value[i]) == len(value) {\n\t\t\t\ttrailing_space = true\n\t\t\t}\n\t\t\tif previous_break {\n\t\t\t\tbreak_space = true\n\t\t\t}\n\t\t\tprevious_space = true\n\t\t\tprevious_break = false\n\t\t} else if is_break(value, i) {\n\t\t\tline_breaks = true\n\t\t\tif i == 0 {\n\t\t\t\tleading_break = true\n\t\t\t}\n\t\t\tif i+width(value[i]) == len(value) {\n\t\t\t\ttrailing_break = true\n\t\t\t}\n\t\t\tif previous_space {\n\t\t\t\tspace_break = true\n\t\t\t}\n\t\t\tprevious_space = false\n\t\t\tprevious_break = true\n\t\t} else {\n\t\t\tprevious_space = false\n\t\t\tprevious_break = false\n\t\t}\n\n\t\t// [Go]: Why 'z'? Couldn't be the end of the string as that's the loop condition.\n\t\tpreceded_by_whitespace = is_blankz(value, i)\n\t}\n\n\temitter.scalar_data.multiline = line_breaks\n\temitter.scalar_data.flow_plain_allowed = true\n\temitter.scalar_data.block_plain_allowed = true\n\temitter.scalar_data.single_quoted_allowed = true\n\temitter.scalar_data.block_allowed = true\n\n\tif leading_space || leading_break || trailing_space || trailing_break {\n\t\temitter.scalar_data.flow_plain_allowed = false\n\t\temitter.scalar_data.block_plain_allowed = false\n\t}\n\tif trailing_space {\n\t\temitter.scalar_data.block_allowed = false\n\t}\n\tif break_space {\n\t\temitter.scalar_data.flow_plain_allowed = false\n\t\temitter.scalar_data.block_plain_allowed = false\n\t\temitter.scalar_data.single_quoted_allowed = false\n\t}\n\tif space_break || special_characters {\n\t\temitter.scalar_data.flow_plain_allowed = false\n\t\temitter.scalar_data.block_plain_allowed = false\n\t\temitter.scalar_data.single_quoted_allowed = false\n\t\temitter.scalar_data.block_allowed = false\n\t}\n\tif line_breaks {\n\t\temitter.scalar_data.flow_plain_allowed = false\n\t\temitter.scalar_data.block_plain_allowed = false\n\t}\n\tif flow_indicators {\n\t\temitter.scalar_data.flow_plain_allowed = false\n\t}\n\tif block_indicators {\n\t\temitter.scalar_data.block_plain_allowed = false\n\t}\n\treturn true\n}\n\n// Check if the event data is valid.\nfunc yaml_emitter_analyze_event(emitter *yaml_emitter_t, event *yaml_event_t) bool {\n\n\temitter.anchor_data.anchor = nil\n\temitter.tag_data.handle = nil\n\temitter.tag_data.suffix = nil\n\temitter.scalar_data.value = nil\n\n\tswitch event.typ {\n\tcase yaml_ALIAS_EVENT:\n\t\tif !yaml_emitter_analyze_anchor(emitter, event.anchor, true) {\n\t\t\treturn false\n\t\t}\n\n\tcase yaml_SCALAR_EVENT:\n\t\tif len(event.anchor) > 0 {\n\t\t\tif !yaml_emitter_analyze_anchor(emitter, event.anchor, false) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\tif len(event.tag) > 0 && (emitter.canonical || (!event.implicit && !event.quoted_implicit)) {\n\t\t\tif !yaml_emitter_analyze_tag(emitter, event.tag) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\tif !yaml_emitter_analyze_scalar(emitter, event.value) {\n\t\t\treturn false\n\t\t}\n\n\tcase yaml_SEQUENCE_START_EVENT:\n\t\tif len(event.anchor) > 0 {\n\t\t\tif !yaml_emitter_analyze_anchor(emitter, event.anchor, false) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\tif len(event.tag) > 0 && (emitter.canonical || !event.implicit) {\n\t\t\tif !yaml_emitter_analyze_tag(emitter, event.tag) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\n\tcase yaml_MAPPING_START_EVENT:\n\t\tif len(event.anchor) > 0 {\n\t\t\tif !yaml_emitter_analyze_anchor(emitter, event.anchor, false) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\tif len(event.tag) > 0 && (emitter.canonical || !event.implicit) {\n\t\t\tif !yaml_emitter_analyze_tag(emitter, event.tag) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\treturn true\n}\n\n// Write the BOM character.\nfunc yaml_emitter_write_bom(emitter *yaml_emitter_t) bool {\n\tif !flush(emitter) {\n\t\treturn false\n\t}\n\tpos := emitter.buffer_pos\n\temitter.buffer[pos+0] = '\\xEF'\n\temitter.buffer[pos+1] = '\\xBB'\n\temitter.buffer[pos+2] = '\\xBF'\n\temitter.buffer_pos += 3\n\treturn true\n}\n\nfunc yaml_emitter_write_indent(emitter *yaml_emitter_t) bool {\n\tindent := emitter.indent\n\tif indent < 0 {\n\t\tindent = 0\n\t}\n\tif !emitter.indention || emitter.column > indent || (emitter.column == indent && !emitter.whitespace) {\n\t\tif !put_break(emitter) {\n\t\t\treturn false\n\t\t}\n\t}\n\tfor emitter.column < indent {\n\t\tif !put(emitter, ' ') {\n\t\t\treturn false\n\t\t}\n\t}\n\temitter.whitespace = true\n\temitter.indention = true\n\treturn true\n}\n\nfunc yaml_emitter_write_indicator(emitter *yaml_emitter_t, indicator []byte, need_whitespace, is_whitespace, is_indention bool) bool {\n\tif need_whitespace && !emitter.whitespace {\n\t\tif !put(emitter, ' ') {\n\t\t\treturn false\n\t\t}\n\t}\n\tif !write_all(emitter, indicator) {\n\t\treturn false\n\t}\n\temitter.whitespace = is_whitespace\n\temitter.indention = (emitter.indention && is_indention)\n\temitter.open_ended = false\n\treturn true\n}\n\nfunc yaml_emitter_write_anchor(emitter *yaml_emitter_t, value []byte) bool {\n\tif !write_all(emitter, value) {\n\t\treturn false\n\t}\n\temitter.whitespace = false\n\temitter.indention = false\n\treturn true\n}\n\nfunc yaml_emitter_write_tag_handle(emitter *yaml_emitter_t, value []byte) bool {\n\tif !emitter.whitespace {\n\t\tif !put(emitter, ' ') {\n\t\t\treturn false\n\t\t}\n\t}\n\tif !write_all(emitter, value) {\n\t\treturn false\n\t}\n\temitter.whitespace = false\n\temitter.indention = false\n\treturn true\n}\n\nfunc yaml_emitter_write_tag_content(emitter *yaml_emitter_t, value []byte, need_whitespace bool) bool {\n\tif need_whitespace && !emitter.whitespace {\n\t\tif !put(emitter, ' ') {\n\t\t\treturn false\n\t\t}\n\t}\n\tfor i := 0; i < len(value); {\n\t\tvar must_write bool\n\t\tswitch value[i] {\n\t\tcase ';', '/', '?', ':', '@', '&', '=', '+', '$', ',', '_', '.', '~', '*', '\\'', '(', ')', '[', ']':\n\t\t\tmust_write = true\n\t\tdefault:\n\t\t\tmust_write = is_alpha(value, i)\n\t\t}\n\t\tif must_write {\n\t\t\tif !write(emitter, value, &i) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t} else {\n\t\t\tw := width(value[i])\n\t\t\tfor k := 0; k < w; k++ {\n\t\t\t\toctet := value[i]\n\t\t\t\ti++\n\t\t\t\tif !put(emitter, '%') {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\n\t\t\t\tc := octet >> 4\n\t\t\t\tif c < 10 {\n\t\t\t\t\tc += '0'\n\t\t\t\t} else {\n\t\t\t\t\tc += 'A' - 10\n\t\t\t\t}\n\t\t\t\tif !put(emitter, c) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\n\t\t\t\tc = octet & 0x0f\n\t\t\t\tif c < 10 {\n\t\t\t\t\tc += '0'\n\t\t\t\t} else {\n\t\t\t\t\tc += 'A' - 10\n\t\t\t\t}\n\t\t\t\tif !put(emitter, c) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\temitter.whitespace = false\n\temitter.indention = false\n\treturn true\n}\n\nfunc yaml_emitter_write_plain_scalar(emitter *yaml_emitter_t, value []byte, allow_breaks bool) bool {\n\tif !emitter.whitespace {\n\t\tif !put(emitter, ' ') {\n\t\t\treturn false\n\t\t}\n\t}\n\n\tspaces := false\n\tbreaks := false\n\tfor i := 0; i < len(value); {\n\t\tif is_space(value, i) {\n\t\t\tif allow_breaks && !spaces && emitter.column > emitter.best_width && !is_space(value, i+1) {\n\t\t\t\tif !yaml_emitter_write_indent(emitter) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\ti += width(value[i])\n\t\t\t} else {\n\t\t\t\tif !write(emitter, value, &i) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\tspaces = true\n\t\t} else if is_break(value, i) {\n\t\t\tif !breaks && value[i] == '\\n' {\n\t\t\t\tif !put_break(emitter) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !write_break(emitter, value, &i) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\temitter.indention = true\n\t\t\tbreaks = true\n\t\t} else {\n\t\t\tif breaks {\n\t\t\t\tif !yaml_emitter_write_indent(emitter) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !write(emitter, value, &i) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\temitter.indention = false\n\t\t\tspaces = false\n\t\t\tbreaks = false\n\t\t}\n\t}\n\n\temitter.whitespace = false\n\temitter.indention = false\n\tif emitter.root_context {\n\t\temitter.open_ended = true\n\t}\n\n\treturn true\n}\n\nfunc yaml_emitter_write_single_quoted_scalar(emitter *yaml_emitter_t, value []byte, allow_breaks bool) bool {\n\n\tif !yaml_emitter_write_indicator(emitter, []byte{'\\''}, true, false, false) {\n\t\treturn false\n\t}\n\n\tspaces := false\n\tbreaks := false\n\tfor i := 0; i < len(value); {\n\t\tif is_space(value, i) {\n\t\t\tif allow_breaks && !spaces && emitter.column > emitter.best_width && i > 0 && i < len(value)-1 && !is_space(value, i+1) {\n\t\t\t\tif !yaml_emitter_write_indent(emitter) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\ti += width(value[i])\n\t\t\t} else {\n\t\t\t\tif !write(emitter, value, &i) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\tspaces = true\n\t\t} else if is_break(value, i) {\n\t\t\tif !breaks && value[i] == '\\n' {\n\t\t\t\tif !put_break(emitter) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !write_break(emitter, value, &i) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\temitter.indention = true\n\t\t\tbreaks = true\n\t\t} else {\n\t\t\tif breaks {\n\t\t\t\tif !yaml_emitter_write_indent(emitter) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\tif value[i] == '\\'' {\n\t\t\t\tif !put(emitter, '\\'') {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !write(emitter, value, &i) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\temitter.indention = false\n\t\t\tspaces = false\n\t\t\tbreaks = false\n\t\t}\n\t}\n\tif !yaml_emitter_write_indicator(emitter, []byte{'\\''}, false, false, false) {\n\t\treturn false\n\t}\n\temitter.whitespace = false\n\temitter.indention = false\n\treturn true\n}\n\nfunc yaml_emitter_write_double_quoted_scalar(emitter *yaml_emitter_t, value []byte, allow_breaks bool) bool {\n\tspaces := false\n\tif !yaml_emitter_write_indicator(emitter, []byte{'\"'}, true, false, false) {\n\t\treturn false\n\t}\n\n\tfor i := 0; i < len(value); {\n\t\tif !is_printable(value, i) || (!emitter.unicode && !is_ascii(value, i)) ||\n\t\t\tis_bom(value, i) || is_break(value, i) ||\n\t\t\tvalue[i] == '\"' || value[i] == '\\\\' {\n\n\t\t\toctet := value[i]\n\n\t\t\tvar w int\n\t\t\tvar v rune\n\t\t\tswitch {\n\t\t\tcase octet&0x80 == 0x00:\n\t\t\t\tw, v = 1, rune(octet&0x7F)\n\t\t\tcase octet&0xE0 == 0xC0:\n\t\t\t\tw, v = 2, rune(octet&0x1F)\n\t\t\tcase octet&0xF0 == 0xE0:\n\t\t\t\tw, v = 3, rune(octet&0x0F)\n\t\t\tcase octet&0xF8 == 0xF0:\n\t\t\t\tw, v = 4, rune(octet&0x07)\n\t\t\t}\n\t\t\tfor k := 1; k < w; k++ {\n\t\t\t\toctet = value[i+k]\n\t\t\t\tv = (v << 6) + (rune(octet) & 0x3F)\n\t\t\t}\n\t\t\ti += w\n\n\t\t\tif !put(emitter, '\\\\') {\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\tvar ok bool\n\t\t\tswitch v {\n\t\t\tcase 0x00:\n\t\t\t\tok = put(emitter, '0')\n\t\t\tcase 0x07:\n\t\t\t\tok = put(emitter, 'a')\n\t\t\tcase 0x08:\n\t\t\t\tok = put(emitter, 'b')\n\t\t\tcase 0x09:\n\t\t\t\tok = put(emitter, 't')\n\t\t\tcase 0x0A:\n\t\t\t\tok = put(emitter, 'n')\n\t\t\tcase 0x0b:\n\t\t\t\tok = put(emitter, 'v')\n\t\t\tcase 0x0c:\n\t\t\t\tok = put(emitter, 'f')\n\t\t\tcase 0x0d:\n\t\t\t\tok = put(emitter, 'r')\n\t\t\tcase 0x1b:\n\t\t\t\tok = put(emitter, 'e')\n\t\t\tcase 0x22:\n\t\t\t\tok = put(emitter, '\"')\n\t\t\tcase 0x5c:\n\t\t\t\tok = put(emitter, '\\\\')\n\t\t\tcase 0x85:\n\t\t\t\tok = put(emitter, 'N')\n\t\t\tcase 0xA0:\n\t\t\t\tok = put(emitter, '_')\n\t\t\tcase 0x2028:\n\t\t\t\tok = put(emitter, 'L')\n\t\t\tcase 0x2029:\n\t\t\t\tok = put(emitter, 'P')\n\t\t\tdefault:\n\t\t\t\tif v <= 0xFF {\n\t\t\t\t\tok = put(emitter, 'x')\n\t\t\t\t\tw = 2\n\t\t\t\t} else if v <= 0xFFFF {\n\t\t\t\t\tok = put(emitter, 'u')\n\t\t\t\t\tw = 4\n\t\t\t\t} else {\n\t\t\t\t\tok = put(emitter, 'U')\n\t\t\t\t\tw = 8\n\t\t\t\t}\n\t\t\t\tfor k := (w - 1) * 4; ok && k >= 0; k -= 4 {\n\t\t\t\t\tdigit := byte((v >> uint(k)) & 0x0F)\n\t\t\t\t\tif digit < 10 {\n\t\t\t\t\t\tok = put(emitter, digit+'0')\n\t\t\t\t\t} else {\n\t\t\t\t\t\tok = put(emitter, digit+'A'-10)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !ok {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tspaces = false\n\t\t} else if is_space(value, i) {\n\t\t\tif allow_breaks && !spaces && emitter.column > emitter.best_width && i > 0 && i < len(value)-1 {\n\t\t\t\tif !yaml_emitter_write_indent(emitter) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tif is_space(value, i+1) {\n\t\t\t\t\tif !put(emitter, '\\\\') {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ti += width(value[i])\n\t\t\t} else if !write(emitter, value, &i) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tspaces = true\n\t\t} else {\n\t\t\tif !write(emitter, value, &i) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tspaces = false\n\t\t}\n\t}\n\tif !yaml_emitter_write_indicator(emitter, []byte{'\"'}, false, false, false) {\n\t\treturn false\n\t}\n\temitter.whitespace = false\n\temitter.indention = false\n\treturn true\n}\n\nfunc yaml_emitter_write_block_scalar_hints(emitter *yaml_emitter_t, value []byte) bool {\n\tif is_space(value, 0) || is_break(value, 0) {\n\t\tindent_hint := []byte{'0' + byte(emitter.best_indent)}\n\t\tif !yaml_emitter_write_indicator(emitter, indent_hint, false, false, false) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\temitter.open_ended = false\n\n\tvar chomp_hint [1]byte\n\tif len(value) == 0 {\n\t\tchomp_hint[0] = '-'\n\t} else {\n\t\ti := len(value) - 1\n\t\tfor value[i]&0xC0 == 0x80 {\n\t\t\ti--\n\t\t}\n\t\tif !is_break(value, i) {\n\t\t\tchomp_hint[0] = '-'\n\t\t} else if i == 0 {\n\t\t\tchomp_hint[0] = '+'\n\t\t\temitter.open_ended = true\n\t\t} else {\n\t\t\ti--\n\t\t\tfor value[i]&0xC0 == 0x80 {\n\t\t\t\ti--\n\t\t\t}\n\t\t\tif is_break(value, i) {\n\t\t\t\tchomp_hint[0] = '+'\n\t\t\t\temitter.open_ended = true\n\t\t\t}\n\t\t}\n\t}\n\tif chomp_hint[0] != 0 {\n\t\tif !yaml_emitter_write_indicator(emitter, chomp_hint[:], false, false, false) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc yaml_emitter_write_literal_scalar(emitter *yaml_emitter_t, value []byte) bool {\n\tif !yaml_emitter_write_indicator(emitter, []byte{'|'}, true, false, false) {\n\t\treturn false\n\t}\n\tif !yaml_emitter_write_block_scalar_hints(emitter, value) {\n\t\treturn false\n\t}\n\tif !put_break(emitter) {\n\t\treturn false\n\t}\n\temitter.indention = true\n\temitter.whitespace = true\n\tbreaks := true\n\tfor i := 0; i < len(value); {\n\t\tif is_break(value, i) {\n\t\t\tif !write_break(emitter, value, &i) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\temitter.indention = true\n\t\t\tbreaks = true\n\t\t} else {\n\t\t\tif breaks {\n\t\t\t\tif !yaml_emitter_write_indent(emitter) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !write(emitter, value, &i) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\temitter.indention = false\n\t\t\tbreaks = false\n\t\t}\n\t}\n\n\treturn true\n}\n\nfunc yaml_emitter_write_folded_scalar(emitter *yaml_emitter_t, value []byte) bool {\n\tif !yaml_emitter_write_indicator(emitter, []byte{'>'}, true, false, false) {\n\t\treturn false\n\t}\n\tif !yaml_emitter_write_block_scalar_hints(emitter, value) {\n\t\treturn false\n\t}\n\n\tif !put_break(emitter) {\n\t\treturn false\n\t}\n\temitter.indention = true\n\temitter.whitespace = true\n\n\tbreaks := true\n\tleading_spaces := true\n\tfor i := 0; i < len(value); {\n\t\tif is_break(value, i) {\n\t\t\tif !breaks && !leading_spaces && value[i] == '\\n' {\n\t\t\t\tk := 0\n\t\t\t\tfor is_break(value, k) {\n\t\t\t\t\tk += width(value[k])\n\t\t\t\t}\n\t\t\t\tif !is_blankz(value, k) {\n\t\t\t\t\tif !put_break(emitter) {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !write_break(emitter, value, &i) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\temitter.indention = true\n\t\t\tbreaks = true\n\t\t} else {\n\t\t\tif breaks {\n\t\t\t\tif !yaml_emitter_write_indent(emitter) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tleading_spaces = is_blank(value, i)\n\t\t\t}\n\t\t\tif !breaks && is_space(value, i) && !is_space(value, i+1) && emitter.column > emitter.best_width {\n\t\t\t\tif !yaml_emitter_write_indent(emitter) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\ti += width(value[i])\n\t\t\t} else {\n\t\t\t\tif !write(emitter, value, &i) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\temitter.indention = false\n\t\t\tbreaks = false\n\t\t}\n\t}\n\treturn true\n}\n"
  },
  {
    "path": "vendor/gopkg.in/yaml.v2/encode.go",
    "content": "package yaml\n\nimport (\n\t\"encoding\"\n\t\"fmt\"\n\t\"reflect\"\n\t\"regexp\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n)\n\ntype encoder struct {\n\temitter yaml_emitter_t\n\tevent   yaml_event_t\n\tout     []byte\n\tflow    bool\n}\n\nfunc newEncoder() (e *encoder) {\n\te = &encoder{}\n\te.must(yaml_emitter_initialize(&e.emitter))\n\tyaml_emitter_set_output_string(&e.emitter, &e.out)\n\tyaml_emitter_set_unicode(&e.emitter, true)\n\te.must(yaml_stream_start_event_initialize(&e.event, yaml_UTF8_ENCODING))\n\te.emit()\n\te.must(yaml_document_start_event_initialize(&e.event, nil, nil, true))\n\te.emit()\n\treturn e\n}\n\nfunc (e *encoder) finish() {\n\te.must(yaml_document_end_event_initialize(&e.event, true))\n\te.emit()\n\te.emitter.open_ended = false\n\te.must(yaml_stream_end_event_initialize(&e.event))\n\te.emit()\n}\n\nfunc (e *encoder) destroy() {\n\tyaml_emitter_delete(&e.emitter)\n}\n\nfunc (e *encoder) emit() {\n\t// This will internally delete the e.event value.\n\tif !yaml_emitter_emit(&e.emitter, &e.event) && e.event.typ != yaml_DOCUMENT_END_EVENT && e.event.typ != yaml_STREAM_END_EVENT {\n\t\te.must(false)\n\t}\n}\n\nfunc (e *encoder) must(ok bool) {\n\tif !ok {\n\t\tmsg := e.emitter.problem\n\t\tif msg == \"\" {\n\t\t\tmsg = \"unknown problem generating YAML content\"\n\t\t}\n\t\tfailf(\"%s\", msg)\n\t}\n}\n\nfunc (e *encoder) marshal(tag string, in reflect.Value) {\n\tif !in.IsValid() {\n\t\te.nilv()\n\t\treturn\n\t}\n\tiface := in.Interface()\n\tif m, ok := iface.(Marshaler); ok {\n\t\tv, err := m.MarshalYAML()\n\t\tif err != nil {\n\t\t\tfail(err)\n\t\t}\n\t\tif v == nil {\n\t\t\te.nilv()\n\t\t\treturn\n\t\t}\n\t\tin = reflect.ValueOf(v)\n\t} else if m, ok := iface.(encoding.TextMarshaler); ok {\n\t\ttext, err := m.MarshalText()\n\t\tif err != nil {\n\t\t\tfail(err)\n\t\t}\n\t\tin = reflect.ValueOf(string(text))\n\t}\n\tswitch in.Kind() {\n\tcase reflect.Interface:\n\t\tif in.IsNil() {\n\t\t\te.nilv()\n\t\t} else {\n\t\t\te.marshal(tag, in.Elem())\n\t\t}\n\tcase reflect.Map:\n\t\te.mapv(tag, in)\n\tcase reflect.Ptr:\n\t\tif in.IsNil() {\n\t\t\te.nilv()\n\t\t} else {\n\t\t\te.marshal(tag, in.Elem())\n\t\t}\n\tcase reflect.Struct:\n\t\te.structv(tag, in)\n\tcase reflect.Slice:\n\t\tif in.Type().Elem() == mapItemType {\n\t\t\te.itemsv(tag, in)\n\t\t} else {\n\t\t\te.slicev(tag, in)\n\t\t}\n\tcase reflect.String:\n\t\te.stringv(tag, in)\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\tif in.Type() == durationType {\n\t\t\te.stringv(tag, reflect.ValueOf(iface.(time.Duration).String()))\n\t\t} else {\n\t\t\te.intv(tag, in)\n\t\t}\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\te.uintv(tag, in)\n\tcase reflect.Float32, reflect.Float64:\n\t\te.floatv(tag, in)\n\tcase reflect.Bool:\n\t\te.boolv(tag, in)\n\tdefault:\n\t\tpanic(\"cannot marshal type: \" + in.Type().String())\n\t}\n}\n\nfunc (e *encoder) mapv(tag string, in reflect.Value) {\n\te.mappingv(tag, func() {\n\t\tkeys := keyList(in.MapKeys())\n\t\tsort.Sort(keys)\n\t\tfor _, k := range keys {\n\t\t\te.marshal(\"\", k)\n\t\t\te.marshal(\"\", in.MapIndex(k))\n\t\t}\n\t})\n}\n\nfunc (e *encoder) itemsv(tag string, in reflect.Value) {\n\te.mappingv(tag, func() {\n\t\tslice := in.Convert(reflect.TypeOf([]MapItem{})).Interface().([]MapItem)\n\t\tfor _, item := range slice {\n\t\t\te.marshal(\"\", reflect.ValueOf(item.Key))\n\t\t\te.marshal(\"\", reflect.ValueOf(item.Value))\n\t\t}\n\t})\n}\n\nfunc (e *encoder) structv(tag string, in reflect.Value) {\n\tsinfo, err := getStructInfo(in.Type())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\te.mappingv(tag, func() {\n\t\tfor _, info := range sinfo.FieldsList {\n\t\t\tvar value reflect.Value\n\t\t\tif info.Inline == nil {\n\t\t\t\tvalue = in.Field(info.Num)\n\t\t\t} else {\n\t\t\t\tvalue = in.FieldByIndex(info.Inline)\n\t\t\t}\n\t\t\tif info.OmitEmpty && isZero(value) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\te.marshal(\"\", reflect.ValueOf(info.Key))\n\t\t\te.flow = info.Flow\n\t\t\te.marshal(\"\", value)\n\t\t}\n\t\tif sinfo.InlineMap >= 0 {\n\t\t\tm := in.Field(sinfo.InlineMap)\n\t\t\tif m.Len() > 0 {\n\t\t\t\te.flow = false\n\t\t\t\tkeys := keyList(m.MapKeys())\n\t\t\t\tsort.Sort(keys)\n\t\t\t\tfor _, k := range keys {\n\t\t\t\t\tif _, found := sinfo.FieldsMap[k.String()]; found {\n\t\t\t\t\t\tpanic(fmt.Sprintf(\"Can't have key %q in inlined map; conflicts with struct field\", k.String()))\n\t\t\t\t\t}\n\t\t\t\t\te.marshal(\"\", k)\n\t\t\t\t\te.flow = false\n\t\t\t\t\te.marshal(\"\", m.MapIndex(k))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t})\n}\n\nfunc (e *encoder) mappingv(tag string, f func()) {\n\timplicit := tag == \"\"\n\tstyle := yaml_BLOCK_MAPPING_STYLE\n\tif e.flow {\n\t\te.flow = false\n\t\tstyle = yaml_FLOW_MAPPING_STYLE\n\t}\n\te.must(yaml_mapping_start_event_initialize(&e.event, nil, []byte(tag), implicit, style))\n\te.emit()\n\tf()\n\te.must(yaml_mapping_end_event_initialize(&e.event))\n\te.emit()\n}\n\nfunc (e *encoder) slicev(tag string, in reflect.Value) {\n\timplicit := tag == \"\"\n\tstyle := yaml_BLOCK_SEQUENCE_STYLE\n\tif e.flow {\n\t\te.flow = false\n\t\tstyle = yaml_FLOW_SEQUENCE_STYLE\n\t}\n\te.must(yaml_sequence_start_event_initialize(&e.event, nil, []byte(tag), implicit, style))\n\te.emit()\n\tn := in.Len()\n\tfor i := 0; i < n; i++ {\n\t\te.marshal(\"\", in.Index(i))\n\t}\n\te.must(yaml_sequence_end_event_initialize(&e.event))\n\te.emit()\n}\n\n// isBase60 returns whether s is in base 60 notation as defined in YAML 1.1.\n//\n// The base 60 float notation in YAML 1.1 is a terrible idea and is unsupported\n// in YAML 1.2 and by this package, but these should be marshalled quoted for\n// the time being for compatibility with other parsers.\nfunc isBase60Float(s string) (result bool) {\n\t// Fast path.\n\tif s == \"\" {\n\t\treturn false\n\t}\n\tc := s[0]\n\tif !(c == '+' || c == '-' || c >= '0' && c <= '9') || strings.IndexByte(s, ':') < 0 {\n\t\treturn false\n\t}\n\t// Do the full match.\n\treturn base60float.MatchString(s)\n}\n\n// From http://yaml.org/type/float.html, except the regular expression there\n// is bogus. In practice parsers do not enforce the \"\\.[0-9_]*\" suffix.\nvar base60float = regexp.MustCompile(`^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+(?:\\.[0-9_]*)?$`)\n\nfunc (e *encoder) stringv(tag string, in reflect.Value) {\n\tvar style yaml_scalar_style_t\n\ts := in.String()\n\trtag, rs := resolve(\"\", s)\n\tif rtag == yaml_BINARY_TAG {\n\t\tif tag == \"\" || tag == yaml_STR_TAG {\n\t\t\ttag = rtag\n\t\t\ts = rs.(string)\n\t\t} else if tag == yaml_BINARY_TAG {\n\t\t\tfailf(\"explicitly tagged !!binary data must be base64-encoded\")\n\t\t} else {\n\t\t\tfailf(\"cannot marshal invalid UTF-8 data as %s\", shortTag(tag))\n\t\t}\n\t}\n\tif tag == \"\" && (rtag != yaml_STR_TAG || isBase60Float(s)) {\n\t\tstyle = yaml_DOUBLE_QUOTED_SCALAR_STYLE\n\t} else if strings.Contains(s, \"\\n\") {\n\t\tstyle = yaml_LITERAL_SCALAR_STYLE\n\t} else {\n\t\tstyle = yaml_PLAIN_SCALAR_STYLE\n\t}\n\te.emitScalar(s, \"\", tag, style)\n}\n\nfunc (e *encoder) boolv(tag string, in reflect.Value) {\n\tvar s string\n\tif in.Bool() {\n\t\ts = \"true\"\n\t} else {\n\t\ts = \"false\"\n\t}\n\te.emitScalar(s, \"\", tag, yaml_PLAIN_SCALAR_STYLE)\n}\n\nfunc (e *encoder) intv(tag string, in reflect.Value) {\n\ts := strconv.FormatInt(in.Int(), 10)\n\te.emitScalar(s, \"\", tag, yaml_PLAIN_SCALAR_STYLE)\n}\n\nfunc (e *encoder) uintv(tag string, in reflect.Value) {\n\ts := strconv.FormatUint(in.Uint(), 10)\n\te.emitScalar(s, \"\", tag, yaml_PLAIN_SCALAR_STYLE)\n}\n\nfunc (e *encoder) floatv(tag string, in reflect.Value) {\n\t// FIXME: Handle 64 bits here.\n\ts := strconv.FormatFloat(float64(in.Float()), 'g', -1, 32)\n\tswitch s {\n\tcase \"+Inf\":\n\t\ts = \".inf\"\n\tcase \"-Inf\":\n\t\ts = \"-.inf\"\n\tcase \"NaN\":\n\t\ts = \".nan\"\n\t}\n\te.emitScalar(s, \"\", tag, yaml_PLAIN_SCALAR_STYLE)\n}\n\nfunc (e *encoder) nilv() {\n\te.emitScalar(\"null\", \"\", \"\", yaml_PLAIN_SCALAR_STYLE)\n}\n\nfunc (e *encoder) emitScalar(value, anchor, tag string, style yaml_scalar_style_t) {\n\timplicit := tag == \"\"\n\te.must(yaml_scalar_event_initialize(&e.event, []byte(anchor), []byte(tag), []byte(value), implicit, implicit, style))\n\te.emit()\n}\n"
  },
  {
    "path": "vendor/gopkg.in/yaml.v2/encode_test.go",
    "content": "package yaml_test\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n\n\t. \"gopkg.in/check.v1\"\n\t\"gopkg.in/yaml.v2\"\n\t\"net\"\n\t\"os\"\n)\n\nvar marshalIntTest = 123\n\nvar marshalTests = []struct {\n\tvalue interface{}\n\tdata  string\n}{\n\t{\n\t\tnil,\n\t\t\"null\\n\",\n\t}, {\n\t\t&struct{}{},\n\t\t\"{}\\n\",\n\t}, {\n\t\tmap[string]string{\"v\": \"hi\"},\n\t\t\"v: hi\\n\",\n\t}, {\n\t\tmap[string]interface{}{\"v\": \"hi\"},\n\t\t\"v: hi\\n\",\n\t}, {\n\t\tmap[string]string{\"v\": \"true\"},\n\t\t\"v: \\\"true\\\"\\n\",\n\t}, {\n\t\tmap[string]string{\"v\": \"false\"},\n\t\t\"v: \\\"false\\\"\\n\",\n\t}, {\n\t\tmap[string]interface{}{\"v\": true},\n\t\t\"v: true\\n\",\n\t}, {\n\t\tmap[string]interface{}{\"v\": false},\n\t\t\"v: false\\n\",\n\t}, {\n\t\tmap[string]interface{}{\"v\": 10},\n\t\t\"v: 10\\n\",\n\t}, {\n\t\tmap[string]interface{}{\"v\": -10},\n\t\t\"v: -10\\n\",\n\t}, {\n\t\tmap[string]uint{\"v\": 42},\n\t\t\"v: 42\\n\",\n\t}, {\n\t\tmap[string]interface{}{\"v\": int64(4294967296)},\n\t\t\"v: 4294967296\\n\",\n\t}, {\n\t\tmap[string]int64{\"v\": int64(4294967296)},\n\t\t\"v: 4294967296\\n\",\n\t}, {\n\t\tmap[string]uint64{\"v\": 4294967296},\n\t\t\"v: 4294967296\\n\",\n\t}, {\n\t\tmap[string]interface{}{\"v\": \"10\"},\n\t\t\"v: \\\"10\\\"\\n\",\n\t}, {\n\t\tmap[string]interface{}{\"v\": 0.1},\n\t\t\"v: 0.1\\n\",\n\t}, {\n\t\tmap[string]interface{}{\"v\": float64(0.1)},\n\t\t\"v: 0.1\\n\",\n\t}, {\n\t\tmap[string]interface{}{\"v\": -0.1},\n\t\t\"v: -0.1\\n\",\n\t}, {\n\t\tmap[string]interface{}{\"v\": math.Inf(+1)},\n\t\t\"v: .inf\\n\",\n\t}, {\n\t\tmap[string]interface{}{\"v\": math.Inf(-1)},\n\t\t\"v: -.inf\\n\",\n\t}, {\n\t\tmap[string]interface{}{\"v\": math.NaN()},\n\t\t\"v: .nan\\n\",\n\t}, {\n\t\tmap[string]interface{}{\"v\": nil},\n\t\t\"v: null\\n\",\n\t}, {\n\t\tmap[string]interface{}{\"v\": \"\"},\n\t\t\"v: \\\"\\\"\\n\",\n\t}, {\n\t\tmap[string][]string{\"v\": []string{\"A\", \"B\"}},\n\t\t\"v:\\n- A\\n- B\\n\",\n\t}, {\n\t\tmap[string][]string{\"v\": []string{\"A\", \"B\\nC\"}},\n\t\t\"v:\\n- A\\n- |-\\n  B\\n  C\\n\",\n\t}, {\n\t\tmap[string][]interface{}{\"v\": []interface{}{\"A\", 1, map[string][]int{\"B\": []int{2, 3}}}},\n\t\t\"v:\\n- A\\n- 1\\n- B:\\n  - 2\\n  - 3\\n\",\n\t}, {\n\t\tmap[string]interface{}{\"a\": map[interface{}]interface{}{\"b\": \"c\"}},\n\t\t\"a:\\n  b: c\\n\",\n\t}, {\n\t\tmap[string]interface{}{\"a\": \"-\"},\n\t\t\"a: '-'\\n\",\n\t},\n\n\t// Simple values.\n\t{\n\t\t&marshalIntTest,\n\t\t\"123\\n\",\n\t},\n\n\t// Structures\n\t{\n\t\t&struct{ Hello string }{\"world\"},\n\t\t\"hello: world\\n\",\n\t}, {\n\t\t&struct {\n\t\t\tA struct {\n\t\t\t\tB string\n\t\t\t}\n\t\t}{struct{ B string }{\"c\"}},\n\t\t\"a:\\n  b: c\\n\",\n\t}, {\n\t\t&struct {\n\t\t\tA *struct {\n\t\t\t\tB string\n\t\t\t}\n\t\t}{&struct{ B string }{\"c\"}},\n\t\t\"a:\\n  b: c\\n\",\n\t}, {\n\t\t&struct {\n\t\t\tA *struct {\n\t\t\t\tB string\n\t\t\t}\n\t\t}{},\n\t\t\"a: null\\n\",\n\t}, {\n\t\t&struct{ A int }{1},\n\t\t\"a: 1\\n\",\n\t}, {\n\t\t&struct{ A []int }{[]int{1, 2}},\n\t\t\"a:\\n- 1\\n- 2\\n\",\n\t}, {\n\t\t&struct {\n\t\t\tB int \"a\"\n\t\t}{1},\n\t\t\"a: 1\\n\",\n\t}, {\n\t\t&struct{ A bool }{true},\n\t\t\"a: true\\n\",\n\t},\n\n\t// Conditional flag\n\t{\n\t\t&struct {\n\t\t\tA int \"a,omitempty\"\n\t\t\tB int \"b,omitempty\"\n\t\t}{1, 0},\n\t\t\"a: 1\\n\",\n\t}, {\n\t\t&struct {\n\t\t\tA int \"a,omitempty\"\n\t\t\tB int \"b,omitempty\"\n\t\t}{0, 0},\n\t\t\"{}\\n\",\n\t}, {\n\t\t&struct {\n\t\t\tA *struct{ X, y int } \"a,omitempty,flow\"\n\t\t}{&struct{ X, y int }{1, 2}},\n\t\t\"a: {x: 1}\\n\",\n\t}, {\n\t\t&struct {\n\t\t\tA *struct{ X, y int } \"a,omitempty,flow\"\n\t\t}{nil},\n\t\t\"{}\\n\",\n\t}, {\n\t\t&struct {\n\t\t\tA *struct{ X, y int } \"a,omitempty,flow\"\n\t\t}{&struct{ X, y int }{}},\n\t\t\"a: {x: 0}\\n\",\n\t}, {\n\t\t&struct {\n\t\t\tA struct{ X, y int } \"a,omitempty,flow\"\n\t\t}{struct{ X, y int }{1, 2}},\n\t\t\"a: {x: 1}\\n\",\n\t}, {\n\t\t&struct {\n\t\t\tA struct{ X, y int } \"a,omitempty,flow\"\n\t\t}{struct{ X, y int }{0, 1}},\n\t\t\"{}\\n\",\n\t}, {\n\t\t&struct {\n\t\t\tA float64 \"a,omitempty\"\n\t\t\tB float64 \"b,omitempty\"\n\t\t}{1, 0},\n\t\t\"a: 1\\n\",\n\t},\n\n\t// Flow flag\n\t{\n\t\t&struct {\n\t\t\tA []int \"a,flow\"\n\t\t}{[]int{1, 2}},\n\t\t\"a: [1, 2]\\n\",\n\t}, {\n\t\t&struct {\n\t\t\tA map[string]string \"a,flow\"\n\t\t}{map[string]string{\"b\": \"c\", \"d\": \"e\"}},\n\t\t\"a: {b: c, d: e}\\n\",\n\t}, {\n\t\t&struct {\n\t\t\tA struct {\n\t\t\t\tB, D string\n\t\t\t} \"a,flow\"\n\t\t}{struct{ B, D string }{\"c\", \"e\"}},\n\t\t\"a: {b: c, d: e}\\n\",\n\t},\n\n\t// Unexported field\n\t{\n\t\t&struct {\n\t\t\tu int\n\t\t\tA int\n\t\t}{0, 1},\n\t\t\"a: 1\\n\",\n\t},\n\n\t// Ignored field\n\t{\n\t\t&struct {\n\t\t\tA int\n\t\t\tB int \"-\"\n\t\t}{1, 2},\n\t\t\"a: 1\\n\",\n\t},\n\n\t// Struct inlining\n\t{\n\t\t&struct {\n\t\t\tA int\n\t\t\tC inlineB `yaml:\",inline\"`\n\t\t}{1, inlineB{2, inlineC{3}}},\n\t\t\"a: 1\\nb: 2\\nc: 3\\n\",\n\t},\n\n\t// Map inlining\n\t{\n\t\t&struct {\n\t\t\tA int\n\t\t\tC map[string]int `yaml:\",inline\"`\n\t\t}{1, map[string]int{\"b\": 2, \"c\": 3}},\n\t\t\"a: 1\\nb: 2\\nc: 3\\n\",\n\t},\n\n\t// Duration\n\t{\n\t\tmap[string]time.Duration{\"a\": 3 * time.Second},\n\t\t\"a: 3s\\n\",\n\t},\n\n\t// Issue #24: bug in map merging logic.\n\t{\n\t\tmap[string]string{\"a\": \"<foo>\"},\n\t\t\"a: <foo>\\n\",\n\t},\n\n\t// Issue #34: marshal unsupported base 60 floats quoted for compatibility\n\t// with old YAML 1.1 parsers.\n\t{\n\t\tmap[string]string{\"a\": \"1:1\"},\n\t\t\"a: \\\"1:1\\\"\\n\",\n\t},\n\n\t// Binary data.\n\t{\n\t\tmap[string]string{\"a\": \"\\x00\"},\n\t\t\"a: \\\"\\\\0\\\"\\n\",\n\t}, {\n\t\tmap[string]string{\"a\": \"\\x80\\x81\\x82\"},\n\t\t\"a: !!binary gIGC\\n\",\n\t}, {\n\t\tmap[string]string{\"a\": strings.Repeat(\"\\x90\", 54)},\n\t\t\"a: !!binary |\\n  \" + strings.Repeat(\"kJCQ\", 17) + \"kJ\\n  CQ\\n\",\n\t},\n\n\t// Ordered maps.\n\t{\n\t\t&yaml.MapSlice{{\"b\", 2}, {\"a\", 1}, {\"d\", 4}, {\"c\", 3}, {\"sub\", yaml.MapSlice{{\"e\", 5}}}},\n\t\t\"b: 2\\na: 1\\nd: 4\\nc: 3\\nsub:\\n  e: 5\\n\",\n\t},\n\n\t// Encode unicode as utf-8 rather than in escaped form.\n\t{\n\t\tmap[string]string{\"a\": \"你好\"},\n\t\t\"a: 你好\\n\",\n\t},\n\n\t// Support encoding.TextMarshaler.\n\t{\n\t\tmap[string]net.IP{\"a\": net.IPv4(1, 2, 3, 4)},\n\t\t\"a: 1.2.3.4\\n\",\n\t},\n\t{\n\t\tmap[string]time.Time{\"a\": time.Unix(1424801979, 0)},\n\t\t\"a: 2015-02-24T18:19:39Z\\n\",\n\t},\n\n\t// Ensure strings containing \": \" are quoted (reported as PR #43, but not reproducible).\n\t{\n\t\tmap[string]string{\"a\": \"b: c\"},\n\t\t\"a: 'b: c'\\n\",\n\t},\n\n\t// Containing hash mark ('#') in string should be quoted\n\t{\n\t\tmap[string]string{\"a\": \"Hello #comment\"},\n\t\t\"a: 'Hello #comment'\\n\",\n\t},\n\t{\n\t\tmap[string]string{\"a\": \"你好 #comment\"},\n\t\t\"a: '你好 #comment'\\n\",\n\t},\n}\n\nfunc (s *S) TestMarshal(c *C) {\n\tdefer os.Setenv(\"TZ\", os.Getenv(\"TZ\"))\n\tos.Setenv(\"TZ\", \"UTC\")\n\tfor _, item := range marshalTests {\n\t\tdata, err := yaml.Marshal(item.value)\n\t\tc.Assert(err, IsNil)\n\t\tc.Assert(string(data), Equals, item.data)\n\t}\n}\n\nvar marshalErrorTests = []struct {\n\tvalue interface{}\n\terror string\n\tpanic string\n}{{\n\tvalue: &struct {\n\t\tB       int\n\t\tinlineB \",inline\"\n\t}{1, inlineB{2, inlineC{3}}},\n\tpanic: `Duplicated key 'b' in struct struct \\{ B int; .*`,\n}, {\n\tvalue: &struct {\n\t\tA int\n\t\tB map[string]int \",inline\"\n\t}{1, map[string]int{\"a\": 2}},\n\tpanic: `Can't have key \"a\" in inlined map; conflicts with struct field`,\n}}\n\nfunc (s *S) TestMarshalErrors(c *C) {\n\tfor _, item := range marshalErrorTests {\n\t\tif item.panic != \"\" {\n\t\t\tc.Assert(func() { yaml.Marshal(item.value) }, PanicMatches, item.panic)\n\t\t} else {\n\t\t\t_, err := yaml.Marshal(item.value)\n\t\t\tc.Assert(err, ErrorMatches, item.error)\n\t\t}\n\t}\n}\n\nfunc (s *S) TestMarshalTypeCache(c *C) {\n\tvar data []byte\n\tvar err error\n\tfunc() {\n\t\ttype T struct{ A int }\n\t\tdata, err = yaml.Marshal(&T{})\n\t\tc.Assert(err, IsNil)\n\t}()\n\tfunc() {\n\t\ttype T struct{ B int }\n\t\tdata, err = yaml.Marshal(&T{})\n\t\tc.Assert(err, IsNil)\n\t}()\n\tc.Assert(string(data), Equals, \"b: 0\\n\")\n}\n\nvar marshalerTests = []struct {\n\tdata  string\n\tvalue interface{}\n}{\n\t{\"_:\\n  hi: there\\n\", map[interface{}]interface{}{\"hi\": \"there\"}},\n\t{\"_:\\n- 1\\n- A\\n\", []interface{}{1, \"A\"}},\n\t{\"_: 10\\n\", 10},\n\t{\"_: null\\n\", nil},\n\t{\"_: BAR!\\n\", \"BAR!\"},\n}\n\ntype marshalerType struct {\n\tvalue interface{}\n}\n\nfunc (o marshalerType) MarshalText() ([]byte, error) {\n\tpanic(\"MarshalText called on type with MarshalYAML\")\n}\n\nfunc (o marshalerType) MarshalYAML() (interface{}, error) {\n\treturn o.value, nil\n}\n\ntype marshalerValue struct {\n\tField marshalerType \"_\"\n}\n\nfunc (s *S) TestMarshaler(c *C) {\n\tfor _, item := range marshalerTests {\n\t\tobj := &marshalerValue{}\n\t\tobj.Field.value = item.value\n\t\tdata, err := yaml.Marshal(obj)\n\t\tc.Assert(err, IsNil)\n\t\tc.Assert(string(data), Equals, string(item.data))\n\t}\n}\n\nfunc (s *S) TestMarshalerWholeDocument(c *C) {\n\tobj := &marshalerType{}\n\tobj.value = map[string]string{\"hello\": \"world!\"}\n\tdata, err := yaml.Marshal(obj)\n\tc.Assert(err, IsNil)\n\tc.Assert(string(data), Equals, \"hello: world!\\n\")\n}\n\ntype failingMarshaler struct{}\n\nfunc (ft *failingMarshaler) MarshalYAML() (interface{}, error) {\n\treturn nil, failingErr\n}\n\nfunc (s *S) TestMarshalerError(c *C) {\n\t_, err := yaml.Marshal(&failingMarshaler{})\n\tc.Assert(err, Equals, failingErr)\n}\n\nfunc (s *S) TestSortedOutput(c *C) {\n\torder := []interface{}{\n\t\tfalse,\n\t\ttrue,\n\t\t1,\n\t\tuint(1),\n\t\t1.0,\n\t\t1.1,\n\t\t1.2,\n\t\t2,\n\t\tuint(2),\n\t\t2.0,\n\t\t2.1,\n\t\t\"\",\n\t\t\".1\",\n\t\t\".2\",\n\t\t\".a\",\n\t\t\"1\",\n\t\t\"2\",\n\t\t\"a!10\",\n\t\t\"a/2\",\n\t\t\"a/10\",\n\t\t\"a~10\",\n\t\t\"ab/1\",\n\t\t\"b/1\",\n\t\t\"b/01\",\n\t\t\"b/2\",\n\t\t\"b/02\",\n\t\t\"b/3\",\n\t\t\"b/03\",\n\t\t\"b1\",\n\t\t\"b01\",\n\t\t\"b3\",\n\t\t\"c2.10\",\n\t\t\"c10.2\",\n\t\t\"d1\",\n\t\t\"d12\",\n\t\t\"d12a\",\n\t}\n\tm := make(map[interface{}]int)\n\tfor _, k := range order {\n\t\tm[k] = 1\n\t}\n\tdata, err := yaml.Marshal(m)\n\tc.Assert(err, IsNil)\n\tout := \"\\n\" + string(data)\n\tlast := 0\n\tfor i, k := range order {\n\t\trepr := fmt.Sprint(k)\n\t\tif s, ok := k.(string); ok {\n\t\t\tif _, err = strconv.ParseFloat(repr, 32); s == \"\" || err == nil {\n\t\t\t\trepr = `\"` + repr + `\"`\n\t\t\t}\n\t\t}\n\t\tindex := strings.Index(out, \"\\n\"+repr+\":\")\n\t\tif index == -1 {\n\t\t\tc.Fatalf(\"%#v is not in the output: %#v\", k, out)\n\t\t}\n\t\tif index < last {\n\t\t\tc.Fatalf(\"%#v was generated before %#v: %q\", k, order[i-1], out)\n\t\t}\n\t\tlast = index\n\t}\n}\n"
  },
  {
    "path": "vendor/gopkg.in/yaml.v2/example_embedded_test.go",
    "content": "package yaml_test\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\n        \"gopkg.in/yaml.v2\"\n)\n\n// An example showing how to unmarshal embedded\n// structs from YAML.\n\ntype StructA struct {\n\tA string `yaml:\"a\"`\n}\n\ntype StructB struct {\n\t// Embedded structs are not treated as embedded in YAML by default. To do that,\n\t// add the \",inline\" annotation below\n\tStructA   `yaml:\",inline\"`\n\tB string `yaml:\"b\"`\n}\n\nvar data = `\na: a string from struct A\nb: a string from struct B\n`\n\nfunc ExampleUnmarshal_embedded() {\n\tvar b StructB\n\n\terr := yaml.Unmarshal([]byte(data), &b)\n\tif err != nil {\n\t\tlog.Fatal(\"cannot unmarshal data: %v\", err)\n\t}\n        fmt.Println(b.A)\n        fmt.Println(b.B)\n        // Output:\n        // a string from struct A\n        // a string from struct B\n}\n"
  },
  {
    "path": "vendor/gopkg.in/yaml.v2/parserc.go",
    "content": "package yaml\n\nimport (\n\t\"bytes\"\n)\n\n// The parser implements the following grammar:\n//\n// stream               ::= STREAM-START implicit_document? explicit_document* STREAM-END\n// implicit_document    ::= block_node DOCUMENT-END*\n// explicit_document    ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*\n// block_node_or_indentless_sequence    ::=\n//                          ALIAS\n//                          | properties (block_content | indentless_block_sequence)?\n//                          | block_content\n//                          | indentless_block_sequence\n// block_node           ::= ALIAS\n//                          | properties block_content?\n//                          | block_content\n// flow_node            ::= ALIAS\n//                          | properties flow_content?\n//                          | flow_content\n// properties           ::= TAG ANCHOR? | ANCHOR TAG?\n// block_content        ::= block_collection | flow_collection | SCALAR\n// flow_content         ::= flow_collection | SCALAR\n// block_collection     ::= block_sequence | block_mapping\n// flow_collection      ::= flow_sequence | flow_mapping\n// block_sequence       ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END\n// indentless_sequence  ::= (BLOCK-ENTRY block_node?)+\n// block_mapping        ::= BLOCK-MAPPING_START\n//                          ((KEY block_node_or_indentless_sequence?)?\n//                          (VALUE block_node_or_indentless_sequence?)?)*\n//                          BLOCK-END\n// flow_sequence        ::= FLOW-SEQUENCE-START\n//                          (flow_sequence_entry FLOW-ENTRY)*\n//                          flow_sequence_entry?\n//                          FLOW-SEQUENCE-END\n// flow_sequence_entry  ::= flow_node | KEY flow_node? (VALUE flow_node?)?\n// flow_mapping         ::= FLOW-MAPPING-START\n//                          (flow_mapping_entry FLOW-ENTRY)*\n//                          flow_mapping_entry?\n//                          FLOW-MAPPING-END\n// flow_mapping_entry   ::= flow_node | KEY flow_node? (VALUE flow_node?)?\n\n// Peek the next token in the token queue.\nfunc peek_token(parser *yaml_parser_t) *yaml_token_t {\n\tif parser.token_available || yaml_parser_fetch_more_tokens(parser) {\n\t\treturn &parser.tokens[parser.tokens_head]\n\t}\n\treturn nil\n}\n\n// Remove the next token from the queue (must be called after peek_token).\nfunc skip_token(parser *yaml_parser_t) {\n\tparser.token_available = false\n\tparser.tokens_parsed++\n\tparser.stream_end_produced = parser.tokens[parser.tokens_head].typ == yaml_STREAM_END_TOKEN\n\tparser.tokens_head++\n}\n\n// Get the next event.\nfunc yaml_parser_parse(parser *yaml_parser_t, event *yaml_event_t) bool {\n\t// Erase the event object.\n\t*event = yaml_event_t{}\n\n\t// No events after the end of the stream or error.\n\tif parser.stream_end_produced || parser.error != yaml_NO_ERROR || parser.state == yaml_PARSE_END_STATE {\n\t\treturn true\n\t}\n\n\t// Generate the next event.\n\treturn yaml_parser_state_machine(parser, event)\n}\n\n// Set parser error.\nfunc yaml_parser_set_parser_error(parser *yaml_parser_t, problem string, problem_mark yaml_mark_t) bool {\n\tparser.error = yaml_PARSER_ERROR\n\tparser.problem = problem\n\tparser.problem_mark = problem_mark\n\treturn false\n}\n\nfunc yaml_parser_set_parser_error_context(parser *yaml_parser_t, context string, context_mark yaml_mark_t, problem string, problem_mark yaml_mark_t) bool {\n\tparser.error = yaml_PARSER_ERROR\n\tparser.context = context\n\tparser.context_mark = context_mark\n\tparser.problem = problem\n\tparser.problem_mark = problem_mark\n\treturn false\n}\n\n// State dispatcher.\nfunc yaml_parser_state_machine(parser *yaml_parser_t, event *yaml_event_t) bool {\n\t//trace(\"yaml_parser_state_machine\", \"state:\", parser.state.String())\n\n\tswitch parser.state {\n\tcase yaml_PARSE_STREAM_START_STATE:\n\t\treturn yaml_parser_parse_stream_start(parser, event)\n\n\tcase yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE:\n\t\treturn yaml_parser_parse_document_start(parser, event, true)\n\n\tcase yaml_PARSE_DOCUMENT_START_STATE:\n\t\treturn yaml_parser_parse_document_start(parser, event, false)\n\n\tcase yaml_PARSE_DOCUMENT_CONTENT_STATE:\n\t\treturn yaml_parser_parse_document_content(parser, event)\n\n\tcase yaml_PARSE_DOCUMENT_END_STATE:\n\t\treturn yaml_parser_parse_document_end(parser, event)\n\n\tcase yaml_PARSE_BLOCK_NODE_STATE:\n\t\treturn yaml_parser_parse_node(parser, event, true, false)\n\n\tcase yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE:\n\t\treturn yaml_parser_parse_node(parser, event, true, true)\n\n\tcase yaml_PARSE_FLOW_NODE_STATE:\n\t\treturn yaml_parser_parse_node(parser, event, false, false)\n\n\tcase yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE:\n\t\treturn yaml_parser_parse_block_sequence_entry(parser, event, true)\n\n\tcase yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE:\n\t\treturn yaml_parser_parse_block_sequence_entry(parser, event, false)\n\n\tcase yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE:\n\t\treturn yaml_parser_parse_indentless_sequence_entry(parser, event)\n\n\tcase yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE:\n\t\treturn yaml_parser_parse_block_mapping_key(parser, event, true)\n\n\tcase yaml_PARSE_BLOCK_MAPPING_KEY_STATE:\n\t\treturn yaml_parser_parse_block_mapping_key(parser, event, false)\n\n\tcase yaml_PARSE_BLOCK_MAPPING_VALUE_STATE:\n\t\treturn yaml_parser_parse_block_mapping_value(parser, event)\n\n\tcase yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE:\n\t\treturn yaml_parser_parse_flow_sequence_entry(parser, event, true)\n\n\tcase yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE:\n\t\treturn yaml_parser_parse_flow_sequence_entry(parser, event, false)\n\n\tcase yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE:\n\t\treturn yaml_parser_parse_flow_sequence_entry_mapping_key(parser, event)\n\n\tcase yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE:\n\t\treturn yaml_parser_parse_flow_sequence_entry_mapping_value(parser, event)\n\n\tcase yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE:\n\t\treturn yaml_parser_parse_flow_sequence_entry_mapping_end(parser, event)\n\n\tcase yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE:\n\t\treturn yaml_parser_parse_flow_mapping_key(parser, event, true)\n\n\tcase yaml_PARSE_FLOW_MAPPING_KEY_STATE:\n\t\treturn yaml_parser_parse_flow_mapping_key(parser, event, false)\n\n\tcase yaml_PARSE_FLOW_MAPPING_VALUE_STATE:\n\t\treturn yaml_parser_parse_flow_mapping_value(parser, event, false)\n\n\tcase yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE:\n\t\treturn yaml_parser_parse_flow_mapping_value(parser, event, true)\n\n\tdefault:\n\t\tpanic(\"invalid parser state\")\n\t}\n}\n\n// Parse the production:\n// stream   ::= STREAM-START implicit_document? explicit_document* STREAM-END\n//              ************\nfunc yaml_parser_parse_stream_start(parser *yaml_parser_t, event *yaml_event_t) bool {\n\ttoken := peek_token(parser)\n\tif token == nil {\n\t\treturn false\n\t}\n\tif token.typ != yaml_STREAM_START_TOKEN {\n\t\treturn yaml_parser_set_parser_error(parser, \"did not find expected <stream-start>\", token.start_mark)\n\t}\n\tparser.state = yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE\n\t*event = yaml_event_t{\n\t\ttyp:        yaml_STREAM_START_EVENT,\n\t\tstart_mark: token.start_mark,\n\t\tend_mark:   token.end_mark,\n\t\tencoding:   token.encoding,\n\t}\n\tskip_token(parser)\n\treturn true\n}\n\n// Parse the productions:\n// implicit_document    ::= block_node DOCUMENT-END*\n//                          *\n// explicit_document    ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*\n//                          *************************\nfunc yaml_parser_parse_document_start(parser *yaml_parser_t, event *yaml_event_t, implicit bool) bool {\n\n\ttoken := peek_token(parser)\n\tif token == nil {\n\t\treturn false\n\t}\n\n\t// Parse extra document end indicators.\n\tif !implicit {\n\t\tfor token.typ == yaml_DOCUMENT_END_TOKEN {\n\t\t\tskip_token(parser)\n\t\t\ttoken = peek_token(parser)\n\t\t\tif token == nil {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\n\tif implicit && token.typ != yaml_VERSION_DIRECTIVE_TOKEN &&\n\t\ttoken.typ != yaml_TAG_DIRECTIVE_TOKEN &&\n\t\ttoken.typ != yaml_DOCUMENT_START_TOKEN &&\n\t\ttoken.typ != yaml_STREAM_END_TOKEN {\n\t\t// Parse an implicit document.\n\t\tif !yaml_parser_process_directives(parser, nil, nil) {\n\t\t\treturn false\n\t\t}\n\t\tparser.states = append(parser.states, yaml_PARSE_DOCUMENT_END_STATE)\n\t\tparser.state = yaml_PARSE_BLOCK_NODE_STATE\n\n\t\t*event = yaml_event_t{\n\t\t\ttyp:        yaml_DOCUMENT_START_EVENT,\n\t\t\tstart_mark: token.start_mark,\n\t\t\tend_mark:   token.end_mark,\n\t\t}\n\n\t} else if token.typ != yaml_STREAM_END_TOKEN {\n\t\t// Parse an explicit document.\n\t\tvar version_directive *yaml_version_directive_t\n\t\tvar tag_directives []yaml_tag_directive_t\n\t\tstart_mark := token.start_mark\n\t\tif !yaml_parser_process_directives(parser, &version_directive, &tag_directives) {\n\t\t\treturn false\n\t\t}\n\t\ttoken = peek_token(parser)\n\t\tif token == nil {\n\t\t\treturn false\n\t\t}\n\t\tif token.typ != yaml_DOCUMENT_START_TOKEN {\n\t\t\tyaml_parser_set_parser_error(parser,\n\t\t\t\t\"did not find expected <document start>\", token.start_mark)\n\t\t\treturn false\n\t\t}\n\t\tparser.states = append(parser.states, yaml_PARSE_DOCUMENT_END_STATE)\n\t\tparser.state = yaml_PARSE_DOCUMENT_CONTENT_STATE\n\t\tend_mark := token.end_mark\n\n\t\t*event = yaml_event_t{\n\t\t\ttyp:               yaml_DOCUMENT_START_EVENT,\n\t\t\tstart_mark:        start_mark,\n\t\t\tend_mark:          end_mark,\n\t\t\tversion_directive: version_directive,\n\t\t\ttag_directives:    tag_directives,\n\t\t\timplicit:          false,\n\t\t}\n\t\tskip_token(parser)\n\n\t} else {\n\t\t// Parse the stream end.\n\t\tparser.state = yaml_PARSE_END_STATE\n\t\t*event = yaml_event_t{\n\t\t\ttyp:        yaml_STREAM_END_EVENT,\n\t\t\tstart_mark: token.start_mark,\n\t\t\tend_mark:   token.end_mark,\n\t\t}\n\t\tskip_token(parser)\n\t}\n\n\treturn true\n}\n\n// Parse the productions:\n// explicit_document    ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*\n//                                                    ***********\n//\nfunc yaml_parser_parse_document_content(parser *yaml_parser_t, event *yaml_event_t) bool {\n\ttoken := peek_token(parser)\n\tif token == nil {\n\t\treturn false\n\t}\n\tif token.typ == yaml_VERSION_DIRECTIVE_TOKEN ||\n\t\ttoken.typ == yaml_TAG_DIRECTIVE_TOKEN ||\n\t\ttoken.typ == yaml_DOCUMENT_START_TOKEN ||\n\t\ttoken.typ == yaml_DOCUMENT_END_TOKEN ||\n\t\ttoken.typ == yaml_STREAM_END_TOKEN {\n\t\tparser.state = parser.states[len(parser.states)-1]\n\t\tparser.states = parser.states[:len(parser.states)-1]\n\t\treturn yaml_parser_process_empty_scalar(parser, event,\n\t\t\ttoken.start_mark)\n\t}\n\treturn yaml_parser_parse_node(parser, event, true, false)\n}\n\n// Parse the productions:\n// implicit_document    ::= block_node DOCUMENT-END*\n//                                     *************\n// explicit_document    ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*\n//\nfunc yaml_parser_parse_document_end(parser *yaml_parser_t, event *yaml_event_t) bool {\n\ttoken := peek_token(parser)\n\tif token == nil {\n\t\treturn false\n\t}\n\n\tstart_mark := token.start_mark\n\tend_mark := token.start_mark\n\n\timplicit := true\n\tif token.typ == yaml_DOCUMENT_END_TOKEN {\n\t\tend_mark = token.end_mark\n\t\tskip_token(parser)\n\t\timplicit = false\n\t}\n\n\tparser.tag_directives = parser.tag_directives[:0]\n\n\tparser.state = yaml_PARSE_DOCUMENT_START_STATE\n\t*event = yaml_event_t{\n\t\ttyp:        yaml_DOCUMENT_END_EVENT,\n\t\tstart_mark: start_mark,\n\t\tend_mark:   end_mark,\n\t\timplicit:   implicit,\n\t}\n\treturn true\n}\n\n// Parse the productions:\n// block_node_or_indentless_sequence    ::=\n//                          ALIAS\n//                          *****\n//                          | properties (block_content | indentless_block_sequence)?\n//                            **********  *\n//                          | block_content | indentless_block_sequence\n//                            *\n// block_node           ::= ALIAS\n//                          *****\n//                          | properties block_content?\n//                            ********** *\n//                          | block_content\n//                            *\n// flow_node            ::= ALIAS\n//                          *****\n//                          | properties flow_content?\n//                            ********** *\n//                          | flow_content\n//                            *\n// properties           ::= TAG ANCHOR? | ANCHOR TAG?\n//                          *************************\n// block_content        ::= block_collection | flow_collection | SCALAR\n//                                                               ******\n// flow_content         ::= flow_collection | SCALAR\n//                                            ******\nfunc yaml_parser_parse_node(parser *yaml_parser_t, event *yaml_event_t, block, indentless_sequence bool) bool {\n\t//defer trace(\"yaml_parser_parse_node\", \"block:\", block, \"indentless_sequence:\", indentless_sequence)()\n\n\ttoken := peek_token(parser)\n\tif token == nil {\n\t\treturn false\n\t}\n\n\tif token.typ == yaml_ALIAS_TOKEN {\n\t\tparser.state = parser.states[len(parser.states)-1]\n\t\tparser.states = parser.states[:len(parser.states)-1]\n\t\t*event = yaml_event_t{\n\t\t\ttyp:        yaml_ALIAS_EVENT,\n\t\t\tstart_mark: token.start_mark,\n\t\t\tend_mark:   token.end_mark,\n\t\t\tanchor:     token.value,\n\t\t}\n\t\tskip_token(parser)\n\t\treturn true\n\t}\n\n\tstart_mark := token.start_mark\n\tend_mark := token.start_mark\n\n\tvar tag_token bool\n\tvar tag_handle, tag_suffix, anchor []byte\n\tvar tag_mark yaml_mark_t\n\tif token.typ == yaml_ANCHOR_TOKEN {\n\t\tanchor = token.value\n\t\tstart_mark = token.start_mark\n\t\tend_mark = token.end_mark\n\t\tskip_token(parser)\n\t\ttoken = peek_token(parser)\n\t\tif token == nil {\n\t\t\treturn false\n\t\t}\n\t\tif token.typ == yaml_TAG_TOKEN {\n\t\t\ttag_token = true\n\t\t\ttag_handle = token.value\n\t\t\ttag_suffix = token.suffix\n\t\t\ttag_mark = token.start_mark\n\t\t\tend_mark = token.end_mark\n\t\t\tskip_token(parser)\n\t\t\ttoken = peek_token(parser)\n\t\t\tif token == nil {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t} else if token.typ == yaml_TAG_TOKEN {\n\t\ttag_token = true\n\t\ttag_handle = token.value\n\t\ttag_suffix = token.suffix\n\t\tstart_mark = token.start_mark\n\t\ttag_mark = token.start_mark\n\t\tend_mark = token.end_mark\n\t\tskip_token(parser)\n\t\ttoken = peek_token(parser)\n\t\tif token == nil {\n\t\t\treturn false\n\t\t}\n\t\tif token.typ == yaml_ANCHOR_TOKEN {\n\t\t\tanchor = token.value\n\t\t\tend_mark = token.end_mark\n\t\t\tskip_token(parser)\n\t\t\ttoken = peek_token(parser)\n\t\t\tif token == nil {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\n\tvar tag []byte\n\tif tag_token {\n\t\tif len(tag_handle) == 0 {\n\t\t\ttag = tag_suffix\n\t\t\ttag_suffix = nil\n\t\t} else {\n\t\t\tfor i := range parser.tag_directives {\n\t\t\t\tif bytes.Equal(parser.tag_directives[i].handle, tag_handle) {\n\t\t\t\t\ttag = append([]byte(nil), parser.tag_directives[i].prefix...)\n\t\t\t\t\ttag = append(tag, tag_suffix...)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif len(tag) == 0 {\n\t\t\t\tyaml_parser_set_parser_error_context(parser,\n\t\t\t\t\t\"while parsing a node\", start_mark,\n\t\t\t\t\t\"found undefined tag handle\", tag_mark)\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\n\timplicit := len(tag) == 0\n\tif indentless_sequence && token.typ == yaml_BLOCK_ENTRY_TOKEN {\n\t\tend_mark = token.end_mark\n\t\tparser.state = yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE\n\t\t*event = yaml_event_t{\n\t\t\ttyp:        yaml_SEQUENCE_START_EVENT,\n\t\t\tstart_mark: start_mark,\n\t\t\tend_mark:   end_mark,\n\t\t\tanchor:     anchor,\n\t\t\ttag:        tag,\n\t\t\timplicit:   implicit,\n\t\t\tstyle:      yaml_style_t(yaml_BLOCK_SEQUENCE_STYLE),\n\t\t}\n\t\treturn true\n\t}\n\tif token.typ == yaml_SCALAR_TOKEN {\n\t\tvar plain_implicit, quoted_implicit bool\n\t\tend_mark = token.end_mark\n\t\tif (len(tag) == 0 && token.style == yaml_PLAIN_SCALAR_STYLE) || (len(tag) == 1 && tag[0] == '!') {\n\t\t\tplain_implicit = true\n\t\t} else if len(tag) == 0 {\n\t\t\tquoted_implicit = true\n\t\t}\n\t\tparser.state = parser.states[len(parser.states)-1]\n\t\tparser.states = parser.states[:len(parser.states)-1]\n\n\t\t*event = yaml_event_t{\n\t\t\ttyp:             yaml_SCALAR_EVENT,\n\t\t\tstart_mark:      start_mark,\n\t\t\tend_mark:        end_mark,\n\t\t\tanchor:          anchor,\n\t\t\ttag:             tag,\n\t\t\tvalue:           token.value,\n\t\t\timplicit:        plain_implicit,\n\t\t\tquoted_implicit: quoted_implicit,\n\t\t\tstyle:           yaml_style_t(token.style),\n\t\t}\n\t\tskip_token(parser)\n\t\treturn true\n\t}\n\tif token.typ == yaml_FLOW_SEQUENCE_START_TOKEN {\n\t\t// [Go] Some of the events below can be merged as they differ only on style.\n\t\tend_mark = token.end_mark\n\t\tparser.state = yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE\n\t\t*event = yaml_event_t{\n\t\t\ttyp:        yaml_SEQUENCE_START_EVENT,\n\t\t\tstart_mark: start_mark,\n\t\t\tend_mark:   end_mark,\n\t\t\tanchor:     anchor,\n\t\t\ttag:        tag,\n\t\t\timplicit:   implicit,\n\t\t\tstyle:      yaml_style_t(yaml_FLOW_SEQUENCE_STYLE),\n\t\t}\n\t\treturn true\n\t}\n\tif token.typ == yaml_FLOW_MAPPING_START_TOKEN {\n\t\tend_mark = token.end_mark\n\t\tparser.state = yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE\n\t\t*event = yaml_event_t{\n\t\t\ttyp:        yaml_MAPPING_START_EVENT,\n\t\t\tstart_mark: start_mark,\n\t\t\tend_mark:   end_mark,\n\t\t\tanchor:     anchor,\n\t\t\ttag:        tag,\n\t\t\timplicit:   implicit,\n\t\t\tstyle:      yaml_style_t(yaml_FLOW_MAPPING_STYLE),\n\t\t}\n\t\treturn true\n\t}\n\tif block && token.typ == yaml_BLOCK_SEQUENCE_START_TOKEN {\n\t\tend_mark = token.end_mark\n\t\tparser.state = yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE\n\t\t*event = yaml_event_t{\n\t\t\ttyp:        yaml_SEQUENCE_START_EVENT,\n\t\t\tstart_mark: start_mark,\n\t\t\tend_mark:   end_mark,\n\t\t\tanchor:     anchor,\n\t\t\ttag:        tag,\n\t\t\timplicit:   implicit,\n\t\t\tstyle:      yaml_style_t(yaml_BLOCK_SEQUENCE_STYLE),\n\t\t}\n\t\treturn true\n\t}\n\tif block && token.typ == yaml_BLOCK_MAPPING_START_TOKEN {\n\t\tend_mark = token.end_mark\n\t\tparser.state = yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE\n\t\t*event = yaml_event_t{\n\t\t\ttyp:        yaml_MAPPING_START_EVENT,\n\t\t\tstart_mark: start_mark,\n\t\t\tend_mark:   end_mark,\n\t\t\tanchor:     anchor,\n\t\t\ttag:        tag,\n\t\t\timplicit:   implicit,\n\t\t\tstyle:      yaml_style_t(yaml_BLOCK_MAPPING_STYLE),\n\t\t}\n\t\treturn true\n\t}\n\tif len(anchor) > 0 || len(tag) > 0 {\n\t\tparser.state = parser.states[len(parser.states)-1]\n\t\tparser.states = parser.states[:len(parser.states)-1]\n\n\t\t*event = yaml_event_t{\n\t\t\ttyp:             yaml_SCALAR_EVENT,\n\t\t\tstart_mark:      start_mark,\n\t\t\tend_mark:        end_mark,\n\t\t\tanchor:          anchor,\n\t\t\ttag:             tag,\n\t\t\timplicit:        implicit,\n\t\t\tquoted_implicit: false,\n\t\t\tstyle:           yaml_style_t(yaml_PLAIN_SCALAR_STYLE),\n\t\t}\n\t\treturn true\n\t}\n\n\tcontext := \"while parsing a flow node\"\n\tif block {\n\t\tcontext = \"while parsing a block node\"\n\t}\n\tyaml_parser_set_parser_error_context(parser, context, start_mark,\n\t\t\"did not find expected node content\", token.start_mark)\n\treturn false\n}\n\n// Parse the productions:\n// block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END\n//                    ********************  *********** *             *********\n//\nfunc yaml_parser_parse_block_sequence_entry(parser *yaml_parser_t, event *yaml_event_t, first bool) bool {\n\tif first {\n\t\ttoken := peek_token(parser)\n\t\tparser.marks = append(parser.marks, token.start_mark)\n\t\tskip_token(parser)\n\t}\n\n\ttoken := peek_token(parser)\n\tif token == nil {\n\t\treturn false\n\t}\n\n\tif token.typ == yaml_BLOCK_ENTRY_TOKEN {\n\t\tmark := token.end_mark\n\t\tskip_token(parser)\n\t\ttoken = peek_token(parser)\n\t\tif token == nil {\n\t\t\treturn false\n\t\t}\n\t\tif token.typ != yaml_BLOCK_ENTRY_TOKEN && token.typ != yaml_BLOCK_END_TOKEN {\n\t\t\tparser.states = append(parser.states, yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE)\n\t\t\treturn yaml_parser_parse_node(parser, event, true, false)\n\t\t} else {\n\t\t\tparser.state = yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE\n\t\t\treturn yaml_parser_process_empty_scalar(parser, event, mark)\n\t\t}\n\t}\n\tif token.typ == yaml_BLOCK_END_TOKEN {\n\t\tparser.state = parser.states[len(parser.states)-1]\n\t\tparser.states = parser.states[:len(parser.states)-1]\n\t\tparser.marks = parser.marks[:len(parser.marks)-1]\n\n\t\t*event = yaml_event_t{\n\t\t\ttyp:        yaml_SEQUENCE_END_EVENT,\n\t\t\tstart_mark: token.start_mark,\n\t\t\tend_mark:   token.end_mark,\n\t\t}\n\n\t\tskip_token(parser)\n\t\treturn true\n\t}\n\n\tcontext_mark := parser.marks[len(parser.marks)-1]\n\tparser.marks = parser.marks[:len(parser.marks)-1]\n\treturn yaml_parser_set_parser_error_context(parser,\n\t\t\"while parsing a block collection\", context_mark,\n\t\t\"did not find expected '-' indicator\", token.start_mark)\n}\n\n// Parse the productions:\n// indentless_sequence  ::= (BLOCK-ENTRY block_node?)+\n//                           *********** *\nfunc yaml_parser_parse_indentless_sequence_entry(parser *yaml_parser_t, event *yaml_event_t) bool {\n\ttoken := peek_token(parser)\n\tif token == nil {\n\t\treturn false\n\t}\n\n\tif token.typ == yaml_BLOCK_ENTRY_TOKEN {\n\t\tmark := token.end_mark\n\t\tskip_token(parser)\n\t\ttoken = peek_token(parser)\n\t\tif token == nil {\n\t\t\treturn false\n\t\t}\n\t\tif token.typ != yaml_BLOCK_ENTRY_TOKEN &&\n\t\t\ttoken.typ != yaml_KEY_TOKEN &&\n\t\t\ttoken.typ != yaml_VALUE_TOKEN &&\n\t\t\ttoken.typ != yaml_BLOCK_END_TOKEN {\n\t\t\tparser.states = append(parser.states, yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE)\n\t\t\treturn yaml_parser_parse_node(parser, event, true, false)\n\t\t}\n\t\tparser.state = yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE\n\t\treturn yaml_parser_process_empty_scalar(parser, event, mark)\n\t}\n\tparser.state = parser.states[len(parser.states)-1]\n\tparser.states = parser.states[:len(parser.states)-1]\n\n\t*event = yaml_event_t{\n\t\ttyp:        yaml_SEQUENCE_END_EVENT,\n\t\tstart_mark: token.start_mark,\n\t\tend_mark:   token.start_mark, // [Go] Shouldn't this be token.end_mark?\n\t}\n\treturn true\n}\n\n// Parse the productions:\n// block_mapping        ::= BLOCK-MAPPING_START\n//                          *******************\n//                          ((KEY block_node_or_indentless_sequence?)?\n//                            *** *\n//                          (VALUE block_node_or_indentless_sequence?)?)*\n//\n//                          BLOCK-END\n//                          *********\n//\nfunc yaml_parser_parse_block_mapping_key(parser *yaml_parser_t, event *yaml_event_t, first bool) bool {\n\tif first {\n\t\ttoken := peek_token(parser)\n\t\tparser.marks = append(parser.marks, token.start_mark)\n\t\tskip_token(parser)\n\t}\n\n\ttoken := peek_token(parser)\n\tif token == nil {\n\t\treturn false\n\t}\n\n\tif token.typ == yaml_KEY_TOKEN {\n\t\tmark := token.end_mark\n\t\tskip_token(parser)\n\t\ttoken = peek_token(parser)\n\t\tif token == nil {\n\t\t\treturn false\n\t\t}\n\t\tif token.typ != yaml_KEY_TOKEN &&\n\t\t\ttoken.typ != yaml_VALUE_TOKEN &&\n\t\t\ttoken.typ != yaml_BLOCK_END_TOKEN {\n\t\t\tparser.states = append(parser.states, yaml_PARSE_BLOCK_MAPPING_VALUE_STATE)\n\t\t\treturn yaml_parser_parse_node(parser, event, true, true)\n\t\t} else {\n\t\t\tparser.state = yaml_PARSE_BLOCK_MAPPING_VALUE_STATE\n\t\t\treturn yaml_parser_process_empty_scalar(parser, event, mark)\n\t\t}\n\t} else if token.typ == yaml_BLOCK_END_TOKEN {\n\t\tparser.state = parser.states[len(parser.states)-1]\n\t\tparser.states = parser.states[:len(parser.states)-1]\n\t\tparser.marks = parser.marks[:len(parser.marks)-1]\n\t\t*event = yaml_event_t{\n\t\t\ttyp:        yaml_MAPPING_END_EVENT,\n\t\t\tstart_mark: token.start_mark,\n\t\t\tend_mark:   token.end_mark,\n\t\t}\n\t\tskip_token(parser)\n\t\treturn true\n\t}\n\n\tcontext_mark := parser.marks[len(parser.marks)-1]\n\tparser.marks = parser.marks[:len(parser.marks)-1]\n\treturn yaml_parser_set_parser_error_context(parser,\n\t\t\"while parsing a block mapping\", context_mark,\n\t\t\"did not find expected key\", token.start_mark)\n}\n\n// Parse the productions:\n// block_mapping        ::= BLOCK-MAPPING_START\n//\n//                          ((KEY block_node_or_indentless_sequence?)?\n//\n//                          (VALUE block_node_or_indentless_sequence?)?)*\n//                           ***** *\n//                          BLOCK-END\n//\n//\nfunc yaml_parser_parse_block_mapping_value(parser *yaml_parser_t, event *yaml_event_t) bool {\n\ttoken := peek_token(parser)\n\tif token == nil {\n\t\treturn false\n\t}\n\tif token.typ == yaml_VALUE_TOKEN {\n\t\tmark := token.end_mark\n\t\tskip_token(parser)\n\t\ttoken = peek_token(parser)\n\t\tif token == nil {\n\t\t\treturn false\n\t\t}\n\t\tif token.typ != yaml_KEY_TOKEN &&\n\t\t\ttoken.typ != yaml_VALUE_TOKEN &&\n\t\t\ttoken.typ != yaml_BLOCK_END_TOKEN {\n\t\t\tparser.states = append(parser.states, yaml_PARSE_BLOCK_MAPPING_KEY_STATE)\n\t\t\treturn yaml_parser_parse_node(parser, event, true, true)\n\t\t}\n\t\tparser.state = yaml_PARSE_BLOCK_MAPPING_KEY_STATE\n\t\treturn yaml_parser_process_empty_scalar(parser, event, mark)\n\t}\n\tparser.state = yaml_PARSE_BLOCK_MAPPING_KEY_STATE\n\treturn yaml_parser_process_empty_scalar(parser, event, token.start_mark)\n}\n\n// Parse the productions:\n// flow_sequence        ::= FLOW-SEQUENCE-START\n//                          *******************\n//                          (flow_sequence_entry FLOW-ENTRY)*\n//                           *                   **********\n//                          flow_sequence_entry?\n//                          *\n//                          FLOW-SEQUENCE-END\n//                          *****************\n// flow_sequence_entry  ::= flow_node | KEY flow_node? (VALUE flow_node?)?\n//                          *\n//\nfunc yaml_parser_parse_flow_sequence_entry(parser *yaml_parser_t, event *yaml_event_t, first bool) bool {\n\tif first {\n\t\ttoken := peek_token(parser)\n\t\tparser.marks = append(parser.marks, token.start_mark)\n\t\tskip_token(parser)\n\t}\n\ttoken := peek_token(parser)\n\tif token == nil {\n\t\treturn false\n\t}\n\tif token.typ != yaml_FLOW_SEQUENCE_END_TOKEN {\n\t\tif !first {\n\t\t\tif token.typ == yaml_FLOW_ENTRY_TOKEN {\n\t\t\t\tskip_token(parser)\n\t\t\t\ttoken = peek_token(parser)\n\t\t\t\tif token == nil {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcontext_mark := parser.marks[len(parser.marks)-1]\n\t\t\t\tparser.marks = parser.marks[:len(parser.marks)-1]\n\t\t\t\treturn yaml_parser_set_parser_error_context(parser,\n\t\t\t\t\t\"while parsing a flow sequence\", context_mark,\n\t\t\t\t\t\"did not find expected ',' or ']'\", token.start_mark)\n\t\t\t}\n\t\t}\n\n\t\tif token.typ == yaml_KEY_TOKEN {\n\t\t\tparser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE\n\t\t\t*event = yaml_event_t{\n\t\t\t\ttyp:        yaml_MAPPING_START_EVENT,\n\t\t\t\tstart_mark: token.start_mark,\n\t\t\t\tend_mark:   token.end_mark,\n\t\t\t\timplicit:   true,\n\t\t\t\tstyle:      yaml_style_t(yaml_FLOW_MAPPING_STYLE),\n\t\t\t}\n\t\t\tskip_token(parser)\n\t\t\treturn true\n\t\t} else if token.typ != yaml_FLOW_SEQUENCE_END_TOKEN {\n\t\t\tparser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE)\n\t\t\treturn yaml_parser_parse_node(parser, event, false, false)\n\t\t}\n\t}\n\n\tparser.state = parser.states[len(parser.states)-1]\n\tparser.states = parser.states[:len(parser.states)-1]\n\tparser.marks = parser.marks[:len(parser.marks)-1]\n\n\t*event = yaml_event_t{\n\t\ttyp:        yaml_SEQUENCE_END_EVENT,\n\t\tstart_mark: token.start_mark,\n\t\tend_mark:   token.end_mark,\n\t}\n\n\tskip_token(parser)\n\treturn true\n}\n\n//\n// Parse the productions:\n// flow_sequence_entry  ::= flow_node | KEY flow_node? (VALUE flow_node?)?\n//                                      *** *\n//\nfunc yaml_parser_parse_flow_sequence_entry_mapping_key(parser *yaml_parser_t, event *yaml_event_t) bool {\n\ttoken := peek_token(parser)\n\tif token == nil {\n\t\treturn false\n\t}\n\tif token.typ != yaml_VALUE_TOKEN &&\n\t\ttoken.typ != yaml_FLOW_ENTRY_TOKEN &&\n\t\ttoken.typ != yaml_FLOW_SEQUENCE_END_TOKEN {\n\t\tparser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE)\n\t\treturn yaml_parser_parse_node(parser, event, false, false)\n\t}\n\tmark := token.end_mark\n\tskip_token(parser)\n\tparser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE\n\treturn yaml_parser_process_empty_scalar(parser, event, mark)\n}\n\n// Parse the productions:\n// flow_sequence_entry  ::= flow_node | KEY flow_node? (VALUE flow_node?)?\n//                                                      ***** *\n//\nfunc yaml_parser_parse_flow_sequence_entry_mapping_value(parser *yaml_parser_t, event *yaml_event_t) bool {\n\ttoken := peek_token(parser)\n\tif token == nil {\n\t\treturn false\n\t}\n\tif token.typ == yaml_VALUE_TOKEN {\n\t\tskip_token(parser)\n\t\ttoken := peek_token(parser)\n\t\tif token == nil {\n\t\t\treturn false\n\t\t}\n\t\tif token.typ != yaml_FLOW_ENTRY_TOKEN && token.typ != yaml_FLOW_SEQUENCE_END_TOKEN {\n\t\t\tparser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE)\n\t\t\treturn yaml_parser_parse_node(parser, event, false, false)\n\t\t}\n\t}\n\tparser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE\n\treturn yaml_parser_process_empty_scalar(parser, event, token.start_mark)\n}\n\n// Parse the productions:\n// flow_sequence_entry  ::= flow_node | KEY flow_node? (VALUE flow_node?)?\n//                                                                      *\n//\nfunc yaml_parser_parse_flow_sequence_entry_mapping_end(parser *yaml_parser_t, event *yaml_event_t) bool {\n\ttoken := peek_token(parser)\n\tif token == nil {\n\t\treturn false\n\t}\n\tparser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE\n\t*event = yaml_event_t{\n\t\ttyp:        yaml_MAPPING_END_EVENT,\n\t\tstart_mark: token.start_mark,\n\t\tend_mark:   token.start_mark, // [Go] Shouldn't this be end_mark?\n\t}\n\treturn true\n}\n\n// Parse the productions:\n// flow_mapping         ::= FLOW-MAPPING-START\n//                          ******************\n//                          (flow_mapping_entry FLOW-ENTRY)*\n//                           *                  **********\n//                          flow_mapping_entry?\n//                          ******************\n//                          FLOW-MAPPING-END\n//                          ****************\n// flow_mapping_entry   ::= flow_node | KEY flow_node? (VALUE flow_node?)?\n//                          *           *** *\n//\nfunc yaml_parser_parse_flow_mapping_key(parser *yaml_parser_t, event *yaml_event_t, first bool) bool {\n\tif first {\n\t\ttoken := peek_token(parser)\n\t\tparser.marks = append(parser.marks, token.start_mark)\n\t\tskip_token(parser)\n\t}\n\n\ttoken := peek_token(parser)\n\tif token == nil {\n\t\treturn false\n\t}\n\n\tif token.typ != yaml_FLOW_MAPPING_END_TOKEN {\n\t\tif !first {\n\t\t\tif token.typ == yaml_FLOW_ENTRY_TOKEN {\n\t\t\t\tskip_token(parser)\n\t\t\t\ttoken = peek_token(parser)\n\t\t\t\tif token == nil {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcontext_mark := parser.marks[len(parser.marks)-1]\n\t\t\t\tparser.marks = parser.marks[:len(parser.marks)-1]\n\t\t\t\treturn yaml_parser_set_parser_error_context(parser,\n\t\t\t\t\t\"while parsing a flow mapping\", context_mark,\n\t\t\t\t\t\"did not find expected ',' or '}'\", token.start_mark)\n\t\t\t}\n\t\t}\n\n\t\tif token.typ == yaml_KEY_TOKEN {\n\t\t\tskip_token(parser)\n\t\t\ttoken = peek_token(parser)\n\t\t\tif token == nil {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif token.typ != yaml_VALUE_TOKEN &&\n\t\t\t\ttoken.typ != yaml_FLOW_ENTRY_TOKEN &&\n\t\t\t\ttoken.typ != yaml_FLOW_MAPPING_END_TOKEN {\n\t\t\t\tparser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_VALUE_STATE)\n\t\t\t\treturn yaml_parser_parse_node(parser, event, false, false)\n\t\t\t} else {\n\t\t\t\tparser.state = yaml_PARSE_FLOW_MAPPING_VALUE_STATE\n\t\t\t\treturn yaml_parser_process_empty_scalar(parser, event, token.start_mark)\n\t\t\t}\n\t\t} else if token.typ != yaml_FLOW_MAPPING_END_TOKEN {\n\t\t\tparser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE)\n\t\t\treturn yaml_parser_parse_node(parser, event, false, false)\n\t\t}\n\t}\n\n\tparser.state = parser.states[len(parser.states)-1]\n\tparser.states = parser.states[:len(parser.states)-1]\n\tparser.marks = parser.marks[:len(parser.marks)-1]\n\t*event = yaml_event_t{\n\t\ttyp:        yaml_MAPPING_END_EVENT,\n\t\tstart_mark: token.start_mark,\n\t\tend_mark:   token.end_mark,\n\t}\n\tskip_token(parser)\n\treturn true\n}\n\n// Parse the productions:\n// flow_mapping_entry   ::= flow_node | KEY flow_node? (VALUE flow_node?)?\n//                                   *                  ***** *\n//\nfunc yaml_parser_parse_flow_mapping_value(parser *yaml_parser_t, event *yaml_event_t, empty bool) bool {\n\ttoken := peek_token(parser)\n\tif token == nil {\n\t\treturn false\n\t}\n\tif empty {\n\t\tparser.state = yaml_PARSE_FLOW_MAPPING_KEY_STATE\n\t\treturn yaml_parser_process_empty_scalar(parser, event, token.start_mark)\n\t}\n\tif token.typ == yaml_VALUE_TOKEN {\n\t\tskip_token(parser)\n\t\ttoken = peek_token(parser)\n\t\tif token == nil {\n\t\t\treturn false\n\t\t}\n\t\tif token.typ != yaml_FLOW_ENTRY_TOKEN && token.typ != yaml_FLOW_MAPPING_END_TOKEN {\n\t\t\tparser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_KEY_STATE)\n\t\t\treturn yaml_parser_parse_node(parser, event, false, false)\n\t\t}\n\t}\n\tparser.state = yaml_PARSE_FLOW_MAPPING_KEY_STATE\n\treturn yaml_parser_process_empty_scalar(parser, event, token.start_mark)\n}\n\n// Generate an empty scalar event.\nfunc yaml_parser_process_empty_scalar(parser *yaml_parser_t, event *yaml_event_t, mark yaml_mark_t) bool {\n\t*event = yaml_event_t{\n\t\ttyp:        yaml_SCALAR_EVENT,\n\t\tstart_mark: mark,\n\t\tend_mark:   mark,\n\t\tvalue:      nil, // Empty\n\t\timplicit:   true,\n\t\tstyle:      yaml_style_t(yaml_PLAIN_SCALAR_STYLE),\n\t}\n\treturn true\n}\n\nvar default_tag_directives = []yaml_tag_directive_t{\n\t{[]byte(\"!\"), []byte(\"!\")},\n\t{[]byte(\"!!\"), []byte(\"tag:yaml.org,2002:\")},\n}\n\n// Parse directives.\nfunc yaml_parser_process_directives(parser *yaml_parser_t,\n\tversion_directive_ref **yaml_version_directive_t,\n\ttag_directives_ref *[]yaml_tag_directive_t) bool {\n\n\tvar version_directive *yaml_version_directive_t\n\tvar tag_directives []yaml_tag_directive_t\n\n\ttoken := peek_token(parser)\n\tif token == nil {\n\t\treturn false\n\t}\n\n\tfor token.typ == yaml_VERSION_DIRECTIVE_TOKEN || token.typ == yaml_TAG_DIRECTIVE_TOKEN {\n\t\tif token.typ == yaml_VERSION_DIRECTIVE_TOKEN {\n\t\t\tif version_directive != nil {\n\t\t\t\tyaml_parser_set_parser_error(parser,\n\t\t\t\t\t\"found duplicate %YAML directive\", token.start_mark)\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif token.major != 1 || token.minor != 1 {\n\t\t\t\tyaml_parser_set_parser_error(parser,\n\t\t\t\t\t\"found incompatible YAML document\", token.start_mark)\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tversion_directive = &yaml_version_directive_t{\n\t\t\t\tmajor: token.major,\n\t\t\t\tminor: token.minor,\n\t\t\t}\n\t\t} else if token.typ == yaml_TAG_DIRECTIVE_TOKEN {\n\t\t\tvalue := yaml_tag_directive_t{\n\t\t\t\thandle: token.value,\n\t\t\t\tprefix: token.prefix,\n\t\t\t}\n\t\t\tif !yaml_parser_append_tag_directive(parser, value, false, token.start_mark) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\ttag_directives = append(tag_directives, value)\n\t\t}\n\n\t\tskip_token(parser)\n\t\ttoken = peek_token(parser)\n\t\tif token == nil {\n\t\t\treturn false\n\t\t}\n\t}\n\n\tfor i := range default_tag_directives {\n\t\tif !yaml_parser_append_tag_directive(parser, default_tag_directives[i], true, token.start_mark) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\tif version_directive_ref != nil {\n\t\t*version_directive_ref = version_directive\n\t}\n\tif tag_directives_ref != nil {\n\t\t*tag_directives_ref = tag_directives\n\t}\n\treturn true\n}\n\n// Append a tag directive to the directives stack.\nfunc yaml_parser_append_tag_directive(parser *yaml_parser_t, value yaml_tag_directive_t, allow_duplicates bool, mark yaml_mark_t) bool {\n\tfor i := range parser.tag_directives {\n\t\tif bytes.Equal(value.handle, parser.tag_directives[i].handle) {\n\t\t\tif allow_duplicates {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn yaml_parser_set_parser_error(parser, \"found duplicate %TAG directive\", mark)\n\t\t}\n\t}\n\n\t// [Go] I suspect the copy is unnecessary. This was likely done\n\t// because there was no way to track ownership of the data.\n\tvalue_copy := yaml_tag_directive_t{\n\t\thandle: make([]byte, len(value.handle)),\n\t\tprefix: make([]byte, len(value.prefix)),\n\t}\n\tcopy(value_copy.handle, value.handle)\n\tcopy(value_copy.prefix, value.prefix)\n\tparser.tag_directives = append(parser.tag_directives, value_copy)\n\treturn true\n}\n"
  },
  {
    "path": "vendor/gopkg.in/yaml.v2/readerc.go",
    "content": "package yaml\n\nimport (\n\t\"io\"\n)\n\n// Set the reader error and return 0.\nfunc yaml_parser_set_reader_error(parser *yaml_parser_t, problem string, offset int, value int) bool {\n\tparser.error = yaml_READER_ERROR\n\tparser.problem = problem\n\tparser.problem_offset = offset\n\tparser.problem_value = value\n\treturn false\n}\n\n// Byte order marks.\nconst (\n\tbom_UTF8    = \"\\xef\\xbb\\xbf\"\n\tbom_UTF16LE = \"\\xff\\xfe\"\n\tbom_UTF16BE = \"\\xfe\\xff\"\n)\n\n// Determine the input stream encoding by checking the BOM symbol. If no BOM is\n// found, the UTF-8 encoding is assumed. Return 1 on success, 0 on failure.\nfunc yaml_parser_determine_encoding(parser *yaml_parser_t) bool {\n\t// Ensure that we had enough bytes in the raw buffer.\n\tfor !parser.eof && len(parser.raw_buffer)-parser.raw_buffer_pos < 3 {\n\t\tif !yaml_parser_update_raw_buffer(parser) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// Determine the encoding.\n\tbuf := parser.raw_buffer\n\tpos := parser.raw_buffer_pos\n\tavail := len(buf) - pos\n\tif avail >= 2 && buf[pos] == bom_UTF16LE[0] && buf[pos+1] == bom_UTF16LE[1] {\n\t\tparser.encoding = yaml_UTF16LE_ENCODING\n\t\tparser.raw_buffer_pos += 2\n\t\tparser.offset += 2\n\t} else if avail >= 2 && buf[pos] == bom_UTF16BE[0] && buf[pos+1] == bom_UTF16BE[1] {\n\t\tparser.encoding = yaml_UTF16BE_ENCODING\n\t\tparser.raw_buffer_pos += 2\n\t\tparser.offset += 2\n\t} else if avail >= 3 && buf[pos] == bom_UTF8[0] && buf[pos+1] == bom_UTF8[1] && buf[pos+2] == bom_UTF8[2] {\n\t\tparser.encoding = yaml_UTF8_ENCODING\n\t\tparser.raw_buffer_pos += 3\n\t\tparser.offset += 3\n\t} else {\n\t\tparser.encoding = yaml_UTF8_ENCODING\n\t}\n\treturn true\n}\n\n// Update the raw buffer.\nfunc yaml_parser_update_raw_buffer(parser *yaml_parser_t) bool {\n\tsize_read := 0\n\n\t// Return if the raw buffer is full.\n\tif parser.raw_buffer_pos == 0 && len(parser.raw_buffer) == cap(parser.raw_buffer) {\n\t\treturn true\n\t}\n\n\t// Return on EOF.\n\tif parser.eof {\n\t\treturn true\n\t}\n\n\t// Move the remaining bytes in the raw buffer to the beginning.\n\tif parser.raw_buffer_pos > 0 && parser.raw_buffer_pos < len(parser.raw_buffer) {\n\t\tcopy(parser.raw_buffer, parser.raw_buffer[parser.raw_buffer_pos:])\n\t}\n\tparser.raw_buffer = parser.raw_buffer[:len(parser.raw_buffer)-parser.raw_buffer_pos]\n\tparser.raw_buffer_pos = 0\n\n\t// Call the read handler to fill the buffer.\n\tsize_read, err := parser.read_handler(parser, parser.raw_buffer[len(parser.raw_buffer):cap(parser.raw_buffer)])\n\tparser.raw_buffer = parser.raw_buffer[:len(parser.raw_buffer)+size_read]\n\tif err == io.EOF {\n\t\tparser.eof = true\n\t} else if err != nil {\n\t\treturn yaml_parser_set_reader_error(parser, \"input error: \"+err.Error(), parser.offset, -1)\n\t}\n\treturn true\n}\n\n// Ensure that the buffer contains at least `length` characters.\n// Return true on success, false on failure.\n//\n// The length is supposed to be significantly less that the buffer size.\nfunc yaml_parser_update_buffer(parser *yaml_parser_t, length int) bool {\n\tif parser.read_handler == nil {\n\t\tpanic(\"read handler must be set\")\n\t}\n\n\t// If the EOF flag is set and the raw buffer is empty, do nothing.\n\tif parser.eof && parser.raw_buffer_pos == len(parser.raw_buffer) {\n\t\treturn true\n\t}\n\n\t// Return if the buffer contains enough characters.\n\tif parser.unread >= length {\n\t\treturn true\n\t}\n\n\t// Determine the input encoding if it is not known yet.\n\tif parser.encoding == yaml_ANY_ENCODING {\n\t\tif !yaml_parser_determine_encoding(parser) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// Move the unread characters to the beginning of the buffer.\n\tbuffer_len := len(parser.buffer)\n\tif parser.buffer_pos > 0 && parser.buffer_pos < buffer_len {\n\t\tcopy(parser.buffer, parser.buffer[parser.buffer_pos:])\n\t\tbuffer_len -= parser.buffer_pos\n\t\tparser.buffer_pos = 0\n\t} else if parser.buffer_pos == buffer_len {\n\t\tbuffer_len = 0\n\t\tparser.buffer_pos = 0\n\t}\n\n\t// Open the whole buffer for writing, and cut it before returning.\n\tparser.buffer = parser.buffer[:cap(parser.buffer)]\n\n\t// Fill the buffer until it has enough characters.\n\tfirst := true\n\tfor parser.unread < length {\n\n\t\t// Fill the raw buffer if necessary.\n\t\tif !first || parser.raw_buffer_pos == len(parser.raw_buffer) {\n\t\t\tif !yaml_parser_update_raw_buffer(parser) {\n\t\t\t\tparser.buffer = parser.buffer[:buffer_len]\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\tfirst = false\n\n\t\t// Decode the raw buffer.\n\tinner:\n\t\tfor parser.raw_buffer_pos != len(parser.raw_buffer) {\n\t\t\tvar value rune\n\t\t\tvar width int\n\n\t\t\traw_unread := len(parser.raw_buffer) - parser.raw_buffer_pos\n\n\t\t\t// Decode the next character.\n\t\t\tswitch parser.encoding {\n\t\t\tcase yaml_UTF8_ENCODING:\n\t\t\t\t// Decode a UTF-8 character.  Check RFC 3629\n\t\t\t\t// (http://www.ietf.org/rfc/rfc3629.txt) for more details.\n\t\t\t\t//\n\t\t\t\t// The following table (taken from the RFC) is used for\n\t\t\t\t// decoding.\n\t\t\t\t//\n\t\t\t\t//    Char. number range |        UTF-8 octet sequence\n\t\t\t\t//      (hexadecimal)    |              (binary)\n\t\t\t\t//   --------------------+------------------------------------\n\t\t\t\t//   0000 0000-0000 007F | 0xxxxxxx\n\t\t\t\t//   0000 0080-0000 07FF | 110xxxxx 10xxxxxx\n\t\t\t\t//   0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx\n\t\t\t\t//   0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx\n\t\t\t\t//\n\t\t\t\t// Additionally, the characters in the range 0xD800-0xDFFF\n\t\t\t\t// are prohibited as they are reserved for use with UTF-16\n\t\t\t\t// surrogate pairs.\n\n\t\t\t\t// Determine the length of the UTF-8 sequence.\n\t\t\t\toctet := parser.raw_buffer[parser.raw_buffer_pos]\n\t\t\t\tswitch {\n\t\t\t\tcase octet&0x80 == 0x00:\n\t\t\t\t\twidth = 1\n\t\t\t\tcase octet&0xE0 == 0xC0:\n\t\t\t\t\twidth = 2\n\t\t\t\tcase octet&0xF0 == 0xE0:\n\t\t\t\t\twidth = 3\n\t\t\t\tcase octet&0xF8 == 0xF0:\n\t\t\t\t\twidth = 4\n\t\t\t\tdefault:\n\t\t\t\t\t// The leading octet is invalid.\n\t\t\t\t\treturn yaml_parser_set_reader_error(parser,\n\t\t\t\t\t\t\"invalid leading UTF-8 octet\",\n\t\t\t\t\t\tparser.offset, int(octet))\n\t\t\t\t}\n\n\t\t\t\t// Check if the raw buffer contains an incomplete character.\n\t\t\t\tif width > raw_unread {\n\t\t\t\t\tif parser.eof {\n\t\t\t\t\t\treturn yaml_parser_set_reader_error(parser,\n\t\t\t\t\t\t\t\"incomplete UTF-8 octet sequence\",\n\t\t\t\t\t\t\tparser.offset, -1)\n\t\t\t\t\t}\n\t\t\t\t\tbreak inner\n\t\t\t\t}\n\n\t\t\t\t// Decode the leading octet.\n\t\t\t\tswitch {\n\t\t\t\tcase octet&0x80 == 0x00:\n\t\t\t\t\tvalue = rune(octet & 0x7F)\n\t\t\t\tcase octet&0xE0 == 0xC0:\n\t\t\t\t\tvalue = rune(octet & 0x1F)\n\t\t\t\tcase octet&0xF0 == 0xE0:\n\t\t\t\t\tvalue = rune(octet & 0x0F)\n\t\t\t\tcase octet&0xF8 == 0xF0:\n\t\t\t\t\tvalue = rune(octet & 0x07)\n\t\t\t\tdefault:\n\t\t\t\t\tvalue = 0\n\t\t\t\t}\n\n\t\t\t\t// Check and decode the trailing octets.\n\t\t\t\tfor k := 1; k < width; k++ {\n\t\t\t\t\toctet = parser.raw_buffer[parser.raw_buffer_pos+k]\n\n\t\t\t\t\t// Check if the octet is valid.\n\t\t\t\t\tif (octet & 0xC0) != 0x80 {\n\t\t\t\t\t\treturn yaml_parser_set_reader_error(parser,\n\t\t\t\t\t\t\t\"invalid trailing UTF-8 octet\",\n\t\t\t\t\t\t\tparser.offset+k, int(octet))\n\t\t\t\t\t}\n\n\t\t\t\t\t// Decode the octet.\n\t\t\t\t\tvalue = (value << 6) + rune(octet&0x3F)\n\t\t\t\t}\n\n\t\t\t\t// Check the length of the sequence against the value.\n\t\t\t\tswitch {\n\t\t\t\tcase width == 1:\n\t\t\t\tcase width == 2 && value >= 0x80:\n\t\t\t\tcase width == 3 && value >= 0x800:\n\t\t\t\tcase width == 4 && value >= 0x10000:\n\t\t\t\tdefault:\n\t\t\t\t\treturn yaml_parser_set_reader_error(parser,\n\t\t\t\t\t\t\"invalid length of a UTF-8 sequence\",\n\t\t\t\t\t\tparser.offset, -1)\n\t\t\t\t}\n\n\t\t\t\t// Check the range of the value.\n\t\t\t\tif value >= 0xD800 && value <= 0xDFFF || value > 0x10FFFF {\n\t\t\t\t\treturn yaml_parser_set_reader_error(parser,\n\t\t\t\t\t\t\"invalid Unicode character\",\n\t\t\t\t\t\tparser.offset, int(value))\n\t\t\t\t}\n\n\t\t\tcase yaml_UTF16LE_ENCODING, yaml_UTF16BE_ENCODING:\n\t\t\t\tvar low, high int\n\t\t\t\tif parser.encoding == yaml_UTF16LE_ENCODING {\n\t\t\t\t\tlow, high = 0, 1\n\t\t\t\t} else {\n\t\t\t\t\tlow, high = 1, 0\n\t\t\t\t}\n\n\t\t\t\t// The UTF-16 encoding is not as simple as one might\n\t\t\t\t// naively think.  Check RFC 2781\n\t\t\t\t// (http://www.ietf.org/rfc/rfc2781.txt).\n\t\t\t\t//\n\t\t\t\t// Normally, two subsequent bytes describe a Unicode\n\t\t\t\t// character.  However a special technique (called a\n\t\t\t\t// surrogate pair) is used for specifying character\n\t\t\t\t// values larger than 0xFFFF.\n\t\t\t\t//\n\t\t\t\t// A surrogate pair consists of two pseudo-characters:\n\t\t\t\t//      high surrogate area (0xD800-0xDBFF)\n\t\t\t\t//      low surrogate area (0xDC00-0xDFFF)\n\t\t\t\t//\n\t\t\t\t// The following formulas are used for decoding\n\t\t\t\t// and encoding characters using surrogate pairs:\n\t\t\t\t//\n\t\t\t\t//  U  = U' + 0x10000   (0x01 00 00 <= U <= 0x10 FF FF)\n\t\t\t\t//  U' = yyyyyyyyyyxxxxxxxxxx   (0 <= U' <= 0x0F FF FF)\n\t\t\t\t//  W1 = 110110yyyyyyyyyy\n\t\t\t\t//  W2 = 110111xxxxxxxxxx\n\t\t\t\t//\n\t\t\t\t// where U is the character value, W1 is the high surrogate\n\t\t\t\t// area, W2 is the low surrogate area.\n\n\t\t\t\t// Check for incomplete UTF-16 character.\n\t\t\t\tif raw_unread < 2 {\n\t\t\t\t\tif parser.eof {\n\t\t\t\t\t\treturn yaml_parser_set_reader_error(parser,\n\t\t\t\t\t\t\t\"incomplete UTF-16 character\",\n\t\t\t\t\t\t\tparser.offset, -1)\n\t\t\t\t\t}\n\t\t\t\t\tbreak inner\n\t\t\t\t}\n\n\t\t\t\t// Get the character.\n\t\t\t\tvalue = rune(parser.raw_buffer[parser.raw_buffer_pos+low]) +\n\t\t\t\t\t(rune(parser.raw_buffer[parser.raw_buffer_pos+high]) << 8)\n\n\t\t\t\t// Check for unexpected low surrogate area.\n\t\t\t\tif value&0xFC00 == 0xDC00 {\n\t\t\t\t\treturn yaml_parser_set_reader_error(parser,\n\t\t\t\t\t\t\"unexpected low surrogate area\",\n\t\t\t\t\t\tparser.offset, int(value))\n\t\t\t\t}\n\n\t\t\t\t// Check for a high surrogate area.\n\t\t\t\tif value&0xFC00 == 0xD800 {\n\t\t\t\t\twidth = 4\n\n\t\t\t\t\t// Check for incomplete surrogate pair.\n\t\t\t\t\tif raw_unread < 4 {\n\t\t\t\t\t\tif parser.eof {\n\t\t\t\t\t\t\treturn yaml_parser_set_reader_error(parser,\n\t\t\t\t\t\t\t\t\"incomplete UTF-16 surrogate pair\",\n\t\t\t\t\t\t\t\tparser.offset, -1)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak inner\n\t\t\t\t\t}\n\n\t\t\t\t\t// Get the next character.\n\t\t\t\t\tvalue2 := rune(parser.raw_buffer[parser.raw_buffer_pos+low+2]) +\n\t\t\t\t\t\t(rune(parser.raw_buffer[parser.raw_buffer_pos+high+2]) << 8)\n\n\t\t\t\t\t// Check for a low surrogate area.\n\t\t\t\t\tif value2&0xFC00 != 0xDC00 {\n\t\t\t\t\t\treturn yaml_parser_set_reader_error(parser,\n\t\t\t\t\t\t\t\"expected low surrogate area\",\n\t\t\t\t\t\t\tparser.offset+2, int(value2))\n\t\t\t\t\t}\n\n\t\t\t\t\t// Generate the value of the surrogate pair.\n\t\t\t\t\tvalue = 0x10000 + ((value & 0x3FF) << 10) + (value2 & 0x3FF)\n\t\t\t\t} else {\n\t\t\t\t\twidth = 2\n\t\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tpanic(\"impossible\")\n\t\t\t}\n\n\t\t\t// Check if the character is in the allowed range:\n\t\t\t//      #x9 | #xA | #xD | [#x20-#x7E]               (8 bit)\n\t\t\t//      | #x85 | [#xA0-#xD7FF] | [#xE000-#xFFFD]    (16 bit)\n\t\t\t//      | [#x10000-#x10FFFF]                        (32 bit)\n\t\t\tswitch {\n\t\t\tcase value == 0x09:\n\t\t\tcase value == 0x0A:\n\t\t\tcase value == 0x0D:\n\t\t\tcase value >= 0x20 && value <= 0x7E:\n\t\t\tcase value == 0x85:\n\t\t\tcase value >= 0xA0 && value <= 0xD7FF:\n\t\t\tcase value >= 0xE000 && value <= 0xFFFD:\n\t\t\tcase value >= 0x10000 && value <= 0x10FFFF:\n\t\t\tdefault:\n\t\t\t\treturn yaml_parser_set_reader_error(parser,\n\t\t\t\t\t\"control characters are not allowed\",\n\t\t\t\t\tparser.offset, int(value))\n\t\t\t}\n\n\t\t\t// Move the raw pointers.\n\t\t\tparser.raw_buffer_pos += width\n\t\t\tparser.offset += width\n\n\t\t\t// Finally put the character into the buffer.\n\t\t\tif value <= 0x7F {\n\t\t\t\t// 0000 0000-0000 007F . 0xxxxxxx\n\t\t\t\tparser.buffer[buffer_len+0] = byte(value)\n\t\t\t\tbuffer_len += 1\n\t\t\t} else if value <= 0x7FF {\n\t\t\t\t// 0000 0080-0000 07FF . 110xxxxx 10xxxxxx\n\t\t\t\tparser.buffer[buffer_len+0] = byte(0xC0 + (value >> 6))\n\t\t\t\tparser.buffer[buffer_len+1] = byte(0x80 + (value & 0x3F))\n\t\t\t\tbuffer_len += 2\n\t\t\t} else if value <= 0xFFFF {\n\t\t\t\t// 0000 0800-0000 FFFF . 1110xxxx 10xxxxxx 10xxxxxx\n\t\t\t\tparser.buffer[buffer_len+0] = byte(0xE0 + (value >> 12))\n\t\t\t\tparser.buffer[buffer_len+1] = byte(0x80 + ((value >> 6) & 0x3F))\n\t\t\t\tparser.buffer[buffer_len+2] = byte(0x80 + (value & 0x3F))\n\t\t\t\tbuffer_len += 3\n\t\t\t} else {\n\t\t\t\t// 0001 0000-0010 FFFF . 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx\n\t\t\t\tparser.buffer[buffer_len+0] = byte(0xF0 + (value >> 18))\n\t\t\t\tparser.buffer[buffer_len+1] = byte(0x80 + ((value >> 12) & 0x3F))\n\t\t\t\tparser.buffer[buffer_len+2] = byte(0x80 + ((value >> 6) & 0x3F))\n\t\t\t\tparser.buffer[buffer_len+3] = byte(0x80 + (value & 0x3F))\n\t\t\t\tbuffer_len += 4\n\t\t\t}\n\n\t\t\tparser.unread++\n\t\t}\n\n\t\t// On EOF, put NUL into the buffer and return.\n\t\tif parser.eof {\n\t\t\tparser.buffer[buffer_len] = 0\n\t\t\tbuffer_len++\n\t\t\tparser.unread++\n\t\t\tbreak\n\t\t}\n\t}\n\tparser.buffer = parser.buffer[:buffer_len]\n\treturn true\n}\n"
  },
  {
    "path": "vendor/gopkg.in/yaml.v2/resolve.go",
    "content": "package yaml\n\nimport (\n\t\"encoding/base64\"\n\t\"math\"\n\t\"regexp\"\n\t\"strconv\"\n\t\"strings\"\n\t\"unicode/utf8\"\n)\n\ntype resolveMapItem struct {\n\tvalue interface{}\n\ttag   string\n}\n\nvar resolveTable = make([]byte, 256)\nvar resolveMap = make(map[string]resolveMapItem)\n\nfunc init() {\n\tt := resolveTable\n\tt[int('+')] = 'S' // Sign\n\tt[int('-')] = 'S'\n\tfor _, c := range \"0123456789\" {\n\t\tt[int(c)] = 'D' // Digit\n\t}\n\tfor _, c := range \"yYnNtTfFoO~\" {\n\t\tt[int(c)] = 'M' // In map\n\t}\n\tt[int('.')] = '.' // Float (potentially in map)\n\n\tvar resolveMapList = []struct {\n\t\tv   interface{}\n\t\ttag string\n\t\tl   []string\n\t}{\n\t\t{true, yaml_BOOL_TAG, []string{\"y\", \"Y\", \"yes\", \"Yes\", \"YES\"}},\n\t\t{true, yaml_BOOL_TAG, []string{\"true\", \"True\", \"TRUE\"}},\n\t\t{true, yaml_BOOL_TAG, []string{\"on\", \"On\", \"ON\"}},\n\t\t{false, yaml_BOOL_TAG, []string{\"n\", \"N\", \"no\", \"No\", \"NO\"}},\n\t\t{false, yaml_BOOL_TAG, []string{\"false\", \"False\", \"FALSE\"}},\n\t\t{false, yaml_BOOL_TAG, []string{\"off\", \"Off\", \"OFF\"}},\n\t\t{nil, yaml_NULL_TAG, []string{\"\", \"~\", \"null\", \"Null\", \"NULL\"}},\n\t\t{math.NaN(), yaml_FLOAT_TAG, []string{\".nan\", \".NaN\", \".NAN\"}},\n\t\t{math.Inf(+1), yaml_FLOAT_TAG, []string{\".inf\", \".Inf\", \".INF\"}},\n\t\t{math.Inf(+1), yaml_FLOAT_TAG, []string{\"+.inf\", \"+.Inf\", \"+.INF\"}},\n\t\t{math.Inf(-1), yaml_FLOAT_TAG, []string{\"-.inf\", \"-.Inf\", \"-.INF\"}},\n\t\t{\"<<\", yaml_MERGE_TAG, []string{\"<<\"}},\n\t}\n\n\tm := resolveMap\n\tfor _, item := range resolveMapList {\n\t\tfor _, s := range item.l {\n\t\t\tm[s] = resolveMapItem{item.v, item.tag}\n\t\t}\n\t}\n}\n\nconst longTagPrefix = \"tag:yaml.org,2002:\"\n\nfunc shortTag(tag string) string {\n\t// TODO This can easily be made faster and produce less garbage.\n\tif strings.HasPrefix(tag, longTagPrefix) {\n\t\treturn \"!!\" + tag[len(longTagPrefix):]\n\t}\n\treturn tag\n}\n\nfunc longTag(tag string) string {\n\tif strings.HasPrefix(tag, \"!!\") {\n\t\treturn longTagPrefix + tag[2:]\n\t}\n\treturn tag\n}\n\nfunc resolvableTag(tag string) bool {\n\tswitch tag {\n\tcase \"\", yaml_STR_TAG, yaml_BOOL_TAG, yaml_INT_TAG, yaml_FLOAT_TAG, yaml_NULL_TAG:\n\t\treturn true\n\t}\n\treturn false\n}\n\nvar yamlStyleFloat = regexp.MustCompile(`^[-+]?[0-9]*\\.?[0-9]+([eE][-+][0-9]+)?$`)\n\nfunc resolve(tag string, in string) (rtag string, out interface{}) {\n\tif !resolvableTag(tag) {\n\t\treturn tag, in\n\t}\n\n\tdefer func() {\n\t\tswitch tag {\n\t\tcase \"\", rtag, yaml_STR_TAG, yaml_BINARY_TAG:\n\t\t\treturn\n\t\t}\n\t\tfailf(\"cannot decode %s `%s` as a %s\", shortTag(rtag), in, shortTag(tag))\n\t}()\n\n\t// Any data is accepted as a !!str or !!binary.\n\t// Otherwise, the prefix is enough of a hint about what it might be.\n\thint := byte('N')\n\tif in != \"\" {\n\t\thint = resolveTable[in[0]]\n\t}\n\tif hint != 0 && tag != yaml_STR_TAG && tag != yaml_BINARY_TAG {\n\t\t// Handle things we can lookup in a map.\n\t\tif item, ok := resolveMap[in]; ok {\n\t\t\treturn item.tag, item.value\n\t\t}\n\n\t\t// Base 60 floats are a bad idea, were dropped in YAML 1.2, and\n\t\t// are purposefully unsupported here. They're still quoted on\n\t\t// the way out for compatibility with other parser, though.\n\n\t\tswitch hint {\n\t\tcase 'M':\n\t\t\t// We've already checked the map above.\n\n\t\tcase '.':\n\t\t\t// Not in the map, so maybe a normal float.\n\t\t\tfloatv, err := strconv.ParseFloat(in, 64)\n\t\t\tif err == nil {\n\t\t\t\treturn yaml_FLOAT_TAG, floatv\n\t\t\t}\n\n\t\tcase 'D', 'S':\n\t\t\t// Int, float, or timestamp.\n\t\t\tplain := strings.Replace(in, \"_\", \"\", -1)\n\t\t\tintv, err := strconv.ParseInt(plain, 0, 64)\n\t\t\tif err == nil {\n\t\t\t\tif intv == int64(int(intv)) {\n\t\t\t\t\treturn yaml_INT_TAG, int(intv)\n\t\t\t\t} else {\n\t\t\t\t\treturn yaml_INT_TAG, intv\n\t\t\t\t}\n\t\t\t}\n\t\t\tuintv, err := strconv.ParseUint(plain, 0, 64)\n\t\t\tif err == nil {\n\t\t\t\treturn yaml_INT_TAG, uintv\n\t\t\t}\n\t\t\tif yamlStyleFloat.MatchString(plain) {\n\t\t\t\tfloatv, err := strconv.ParseFloat(plain, 64)\n\t\t\t\tif err == nil {\n\t\t\t\t\treturn yaml_FLOAT_TAG, floatv\n\t\t\t\t}\n\t\t\t}\n\t\t\tif strings.HasPrefix(plain, \"0b\") {\n\t\t\t\tintv, err := strconv.ParseInt(plain[2:], 2, 64)\n\t\t\t\tif err == nil {\n\t\t\t\t\tif intv == int64(int(intv)) {\n\t\t\t\t\t\treturn yaml_INT_TAG, int(intv)\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn yaml_INT_TAG, intv\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tuintv, err := strconv.ParseUint(plain[2:], 2, 64)\n\t\t\t\tif err == nil {\n\t\t\t\t\treturn yaml_INT_TAG, uintv\n\t\t\t\t}\n\t\t\t} else if strings.HasPrefix(plain, \"-0b\") {\n\t\t\t\tintv, err := strconv.ParseInt(plain[3:], 2, 64)\n\t\t\t\tif err == nil {\n\t\t\t\t\tif intv == int64(int(intv)) {\n\t\t\t\t\t\treturn yaml_INT_TAG, -int(intv)\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn yaml_INT_TAG, -intv\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t// XXX Handle timestamps here.\n\n\t\tdefault:\n\t\t\tpanic(\"resolveTable item not yet handled: \" + string(rune(hint)) + \" (with \" + in + \")\")\n\t\t}\n\t}\n\tif tag == yaml_BINARY_TAG {\n\t\treturn yaml_BINARY_TAG, in\n\t}\n\tif utf8.ValidString(in) {\n\t\treturn yaml_STR_TAG, in\n\t}\n\treturn yaml_BINARY_TAG, encodeBase64(in)\n}\n\n// encodeBase64 encodes s as base64 that is broken up into multiple lines\n// as appropriate for the resulting length.\nfunc encodeBase64(s string) string {\n\tconst lineLen = 70\n\tencLen := base64.StdEncoding.EncodedLen(len(s))\n\tlines := encLen/lineLen + 1\n\tbuf := make([]byte, encLen*2+lines)\n\tin := buf[0:encLen]\n\tout := buf[encLen:]\n\tbase64.StdEncoding.Encode(in, []byte(s))\n\tk := 0\n\tfor i := 0; i < len(in); i += lineLen {\n\t\tj := i + lineLen\n\t\tif j > len(in) {\n\t\t\tj = len(in)\n\t\t}\n\t\tk += copy(out[k:], in[i:j])\n\t\tif lines > 1 {\n\t\t\tout[k] = '\\n'\n\t\t\tk++\n\t\t}\n\t}\n\treturn string(out[:k])\n}\n"
  },
  {
    "path": "vendor/gopkg.in/yaml.v2/scannerc.go",
    "content": "package yaml\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n)\n\n// Introduction\n// ************\n//\n// The following notes assume that you are familiar with the YAML specification\n// (http://yaml.org/spec/1.2/spec.html).  We mostly follow it, although in\n// some cases we are less restrictive that it requires.\n//\n// The process of transforming a YAML stream into a sequence of events is\n// divided on two steps: Scanning and Parsing.\n//\n// The Scanner transforms the input stream into a sequence of tokens, while the\n// parser transform the sequence of tokens produced by the Scanner into a\n// sequence of parsing events.\n//\n// The Scanner is rather clever and complicated. The Parser, on the contrary,\n// is a straightforward implementation of a recursive-descendant parser (or,\n// LL(1) parser, as it is usually called).\n//\n// Actually there are two issues of Scanning that might be called \"clever\", the\n// rest is quite straightforward.  The issues are \"block collection start\" and\n// \"simple keys\".  Both issues are explained below in details.\n//\n// Here the Scanning step is explained and implemented.  We start with the list\n// of all the tokens produced by the Scanner together with short descriptions.\n//\n// Now, tokens:\n//\n//      STREAM-START(encoding)          # The stream start.\n//      STREAM-END                      # The stream end.\n//      VERSION-DIRECTIVE(major,minor)  # The '%YAML' directive.\n//      TAG-DIRECTIVE(handle,prefix)    # The '%TAG' directive.\n//      DOCUMENT-START                  # '---'\n//      DOCUMENT-END                    # '...'\n//      BLOCK-SEQUENCE-START            # Indentation increase denoting a block\n//      BLOCK-MAPPING-START             # sequence or a block mapping.\n//      BLOCK-END                       # Indentation decrease.\n//      FLOW-SEQUENCE-START             # '['\n//      FLOW-SEQUENCE-END               # ']'\n//      BLOCK-SEQUENCE-START            # '{'\n//      BLOCK-SEQUENCE-END              # '}'\n//      BLOCK-ENTRY                     # '-'\n//      FLOW-ENTRY                      # ','\n//      KEY                             # '?' or nothing (simple keys).\n//      VALUE                           # ':'\n//      ALIAS(anchor)                   # '*anchor'\n//      ANCHOR(anchor)                  # '&anchor'\n//      TAG(handle,suffix)              # '!handle!suffix'\n//      SCALAR(value,style)             # A scalar.\n//\n// The following two tokens are \"virtual\" tokens denoting the beginning and the\n// end of the stream:\n//\n//      STREAM-START(encoding)\n//      STREAM-END\n//\n// We pass the information about the input stream encoding with the\n// STREAM-START token.\n//\n// The next two tokens are responsible for tags:\n//\n//      VERSION-DIRECTIVE(major,minor)\n//      TAG-DIRECTIVE(handle,prefix)\n//\n// Example:\n//\n//      %YAML   1.1\n//      %TAG    !   !foo\n//      %TAG    !yaml!  tag:yaml.org,2002:\n//      ---\n//\n// The correspoding sequence of tokens:\n//\n//      STREAM-START(utf-8)\n//      VERSION-DIRECTIVE(1,1)\n//      TAG-DIRECTIVE(\"!\",\"!foo\")\n//      TAG-DIRECTIVE(\"!yaml\",\"tag:yaml.org,2002:\")\n//      DOCUMENT-START\n//      STREAM-END\n//\n// Note that the VERSION-DIRECTIVE and TAG-DIRECTIVE tokens occupy a whole\n// line.\n//\n// The document start and end indicators are represented by:\n//\n//      DOCUMENT-START\n//      DOCUMENT-END\n//\n// Note that if a YAML stream contains an implicit document (without '---'\n// and '...' indicators), no DOCUMENT-START and DOCUMENT-END tokens will be\n// produced.\n//\n// In the following examples, we present whole documents together with the\n// produced tokens.\n//\n//      1. An implicit document:\n//\n//          'a scalar'\n//\n//      Tokens:\n//\n//          STREAM-START(utf-8)\n//          SCALAR(\"a scalar\",single-quoted)\n//          STREAM-END\n//\n//      2. An explicit document:\n//\n//          ---\n//          'a scalar'\n//          ...\n//\n//      Tokens:\n//\n//          STREAM-START(utf-8)\n//          DOCUMENT-START\n//          SCALAR(\"a scalar\",single-quoted)\n//          DOCUMENT-END\n//          STREAM-END\n//\n//      3. Several documents in a stream:\n//\n//          'a scalar'\n//          ---\n//          'another scalar'\n//          ---\n//          'yet another scalar'\n//\n//      Tokens:\n//\n//          STREAM-START(utf-8)\n//          SCALAR(\"a scalar\",single-quoted)\n//          DOCUMENT-START\n//          SCALAR(\"another scalar\",single-quoted)\n//          DOCUMENT-START\n//          SCALAR(\"yet another scalar\",single-quoted)\n//          STREAM-END\n//\n// We have already introduced the SCALAR token above.  The following tokens are\n// used to describe aliases, anchors, tag, and scalars:\n//\n//      ALIAS(anchor)\n//      ANCHOR(anchor)\n//      TAG(handle,suffix)\n//      SCALAR(value,style)\n//\n// The following series of examples illustrate the usage of these tokens:\n//\n//      1. A recursive sequence:\n//\n//          &A [ *A ]\n//\n//      Tokens:\n//\n//          STREAM-START(utf-8)\n//          ANCHOR(\"A\")\n//          FLOW-SEQUENCE-START\n//          ALIAS(\"A\")\n//          FLOW-SEQUENCE-END\n//          STREAM-END\n//\n//      2. A tagged scalar:\n//\n//          !!float \"3.14\"  # A good approximation.\n//\n//      Tokens:\n//\n//          STREAM-START(utf-8)\n//          TAG(\"!!\",\"float\")\n//          SCALAR(\"3.14\",double-quoted)\n//          STREAM-END\n//\n//      3. Various scalar styles:\n//\n//          --- # Implicit empty plain scalars do not produce tokens.\n//          --- a plain scalar\n//          --- 'a single-quoted scalar'\n//          --- \"a double-quoted scalar\"\n//          --- |-\n//            a literal scalar\n//          --- >-\n//            a folded\n//            scalar\n//\n//      Tokens:\n//\n//          STREAM-START(utf-8)\n//          DOCUMENT-START\n//          DOCUMENT-START\n//          SCALAR(\"a plain scalar\",plain)\n//          DOCUMENT-START\n//          SCALAR(\"a single-quoted scalar\",single-quoted)\n//          DOCUMENT-START\n//          SCALAR(\"a double-quoted scalar\",double-quoted)\n//          DOCUMENT-START\n//          SCALAR(\"a literal scalar\",literal)\n//          DOCUMENT-START\n//          SCALAR(\"a folded scalar\",folded)\n//          STREAM-END\n//\n// Now it's time to review collection-related tokens. We will start with\n// flow collections:\n//\n//      FLOW-SEQUENCE-START\n//      FLOW-SEQUENCE-END\n//      FLOW-MAPPING-START\n//      FLOW-MAPPING-END\n//      FLOW-ENTRY\n//      KEY\n//      VALUE\n//\n// The tokens FLOW-SEQUENCE-START, FLOW-SEQUENCE-END, FLOW-MAPPING-START, and\n// FLOW-MAPPING-END represent the indicators '[', ']', '{', and '}'\n// correspondingly.  FLOW-ENTRY represent the ',' indicator.  Finally the\n// indicators '?' and ':', which are used for denoting mapping keys and values,\n// are represented by the KEY and VALUE tokens.\n//\n// The following examples show flow collections:\n//\n//      1. A flow sequence:\n//\n//          [item 1, item 2, item 3]\n//\n//      Tokens:\n//\n//          STREAM-START(utf-8)\n//          FLOW-SEQUENCE-START\n//          SCALAR(\"item 1\",plain)\n//          FLOW-ENTRY\n//          SCALAR(\"item 2\",plain)\n//          FLOW-ENTRY\n//          SCALAR(\"item 3\",plain)\n//          FLOW-SEQUENCE-END\n//          STREAM-END\n//\n//      2. A flow mapping:\n//\n//          {\n//              a simple key: a value,  # Note that the KEY token is produced.\n//              ? a complex key: another value,\n//          }\n//\n//      Tokens:\n//\n//          STREAM-START(utf-8)\n//          FLOW-MAPPING-START\n//          KEY\n//          SCALAR(\"a simple key\",plain)\n//          VALUE\n//          SCALAR(\"a value\",plain)\n//          FLOW-ENTRY\n//          KEY\n//          SCALAR(\"a complex key\",plain)\n//          VALUE\n//          SCALAR(\"another value\",plain)\n//          FLOW-ENTRY\n//          FLOW-MAPPING-END\n//          STREAM-END\n//\n// A simple key is a key which is not denoted by the '?' indicator.  Note that\n// the Scanner still produce the KEY token whenever it encounters a simple key.\n//\n// For scanning block collections, the following tokens are used (note that we\n// repeat KEY and VALUE here):\n//\n//      BLOCK-SEQUENCE-START\n//      BLOCK-MAPPING-START\n//      BLOCK-END\n//      BLOCK-ENTRY\n//      KEY\n//      VALUE\n//\n// The tokens BLOCK-SEQUENCE-START and BLOCK-MAPPING-START denote indentation\n// increase that precedes a block collection (cf. the INDENT token in Python).\n// The token BLOCK-END denote indentation decrease that ends a block collection\n// (cf. the DEDENT token in Python).  However YAML has some syntax pecularities\n// that makes detections of these tokens more complex.\n//\n// The tokens BLOCK-ENTRY, KEY, and VALUE are used to represent the indicators\n// '-', '?', and ':' correspondingly.\n//\n// The following examples show how the tokens BLOCK-SEQUENCE-START,\n// BLOCK-MAPPING-START, and BLOCK-END are emitted by the Scanner:\n//\n//      1. Block sequences:\n//\n//          - item 1\n//          - item 2\n//          -\n//            - item 3.1\n//            - item 3.2\n//          -\n//            key 1: value 1\n//            key 2: value 2\n//\n//      Tokens:\n//\n//          STREAM-START(utf-8)\n//          BLOCK-SEQUENCE-START\n//          BLOCK-ENTRY\n//          SCALAR(\"item 1\",plain)\n//          BLOCK-ENTRY\n//          SCALAR(\"item 2\",plain)\n//          BLOCK-ENTRY\n//          BLOCK-SEQUENCE-START\n//          BLOCK-ENTRY\n//          SCALAR(\"item 3.1\",plain)\n//          BLOCK-ENTRY\n//          SCALAR(\"item 3.2\",plain)\n//          BLOCK-END\n//          BLOCK-ENTRY\n//          BLOCK-MAPPING-START\n//          KEY\n//          SCALAR(\"key 1\",plain)\n//          VALUE\n//          SCALAR(\"value 1\",plain)\n//          KEY\n//          SCALAR(\"key 2\",plain)\n//          VALUE\n//          SCALAR(\"value 2\",plain)\n//          BLOCK-END\n//          BLOCK-END\n//          STREAM-END\n//\n//      2. Block mappings:\n//\n//          a simple key: a value   # The KEY token is produced here.\n//          ? a complex key\n//          : another value\n//          a mapping:\n//            key 1: value 1\n//            key 2: value 2\n//          a sequence:\n//            - item 1\n//            - item 2\n//\n//      Tokens:\n//\n//          STREAM-START(utf-8)\n//          BLOCK-MAPPING-START\n//          KEY\n//          SCALAR(\"a simple key\",plain)\n//          VALUE\n//          SCALAR(\"a value\",plain)\n//          KEY\n//          SCALAR(\"a complex key\",plain)\n//          VALUE\n//          SCALAR(\"another value\",plain)\n//          KEY\n//          SCALAR(\"a mapping\",plain)\n//          BLOCK-MAPPING-START\n//          KEY\n//          SCALAR(\"key 1\",plain)\n//          VALUE\n//          SCALAR(\"value 1\",plain)\n//          KEY\n//          SCALAR(\"key 2\",plain)\n//          VALUE\n//          SCALAR(\"value 2\",plain)\n//          BLOCK-END\n//          KEY\n//          SCALAR(\"a sequence\",plain)\n//          VALUE\n//          BLOCK-SEQUENCE-START\n//          BLOCK-ENTRY\n//          SCALAR(\"item 1\",plain)\n//          BLOCK-ENTRY\n//          SCALAR(\"item 2\",plain)\n//          BLOCK-END\n//          BLOCK-END\n//          STREAM-END\n//\n// YAML does not always require to start a new block collection from a new\n// line.  If the current line contains only '-', '?', and ':' indicators, a new\n// block collection may start at the current line.  The following examples\n// illustrate this case:\n//\n//      1. Collections in a sequence:\n//\n//          - - item 1\n//            - item 2\n//          - key 1: value 1\n//            key 2: value 2\n//          - ? complex key\n//            : complex value\n//\n//      Tokens:\n//\n//          STREAM-START(utf-8)\n//          BLOCK-SEQUENCE-START\n//          BLOCK-ENTRY\n//          BLOCK-SEQUENCE-START\n//          BLOCK-ENTRY\n//          SCALAR(\"item 1\",plain)\n//          BLOCK-ENTRY\n//          SCALAR(\"item 2\",plain)\n//          BLOCK-END\n//          BLOCK-ENTRY\n//          BLOCK-MAPPING-START\n//          KEY\n//          SCALAR(\"key 1\",plain)\n//          VALUE\n//          SCALAR(\"value 1\",plain)\n//          KEY\n//          SCALAR(\"key 2\",plain)\n//          VALUE\n//          SCALAR(\"value 2\",plain)\n//          BLOCK-END\n//          BLOCK-ENTRY\n//          BLOCK-MAPPING-START\n//          KEY\n//          SCALAR(\"complex key\")\n//          VALUE\n//          SCALAR(\"complex value\")\n//          BLOCK-END\n//          BLOCK-END\n//          STREAM-END\n//\n//      2. Collections in a mapping:\n//\n//          ? a sequence\n//          : - item 1\n//            - item 2\n//          ? a mapping\n//          : key 1: value 1\n//            key 2: value 2\n//\n//      Tokens:\n//\n//          STREAM-START(utf-8)\n//          BLOCK-MAPPING-START\n//          KEY\n//          SCALAR(\"a sequence\",plain)\n//          VALUE\n//          BLOCK-SEQUENCE-START\n//          BLOCK-ENTRY\n//          SCALAR(\"item 1\",plain)\n//          BLOCK-ENTRY\n//          SCALAR(\"item 2\",plain)\n//          BLOCK-END\n//          KEY\n//          SCALAR(\"a mapping\",plain)\n//          VALUE\n//          BLOCK-MAPPING-START\n//          KEY\n//          SCALAR(\"key 1\",plain)\n//          VALUE\n//          SCALAR(\"value 1\",plain)\n//          KEY\n//          SCALAR(\"key 2\",plain)\n//          VALUE\n//          SCALAR(\"value 2\",plain)\n//          BLOCK-END\n//          BLOCK-END\n//          STREAM-END\n//\n// YAML also permits non-indented sequences if they are included into a block\n// mapping.  In this case, the token BLOCK-SEQUENCE-START is not produced:\n//\n//      key:\n//      - item 1    # BLOCK-SEQUENCE-START is NOT produced here.\n//      - item 2\n//\n// Tokens:\n//\n//      STREAM-START(utf-8)\n//      BLOCK-MAPPING-START\n//      KEY\n//      SCALAR(\"key\",plain)\n//      VALUE\n//      BLOCK-ENTRY\n//      SCALAR(\"item 1\",plain)\n//      BLOCK-ENTRY\n//      SCALAR(\"item 2\",plain)\n//      BLOCK-END\n//\n\n// Ensure that the buffer contains the required number of characters.\n// Return true on success, false on failure (reader error or memory error).\nfunc cache(parser *yaml_parser_t, length int) bool {\n\t// [Go] This was inlined: !cache(A, B) -> unread < B && !update(A, B)\n\treturn parser.unread >= length || yaml_parser_update_buffer(parser, length)\n}\n\n// Advance the buffer pointer.\nfunc skip(parser *yaml_parser_t) {\n\tparser.mark.index++\n\tparser.mark.column++\n\tparser.unread--\n\tparser.buffer_pos += width(parser.buffer[parser.buffer_pos])\n}\n\nfunc skip_line(parser *yaml_parser_t) {\n\tif is_crlf(parser.buffer, parser.buffer_pos) {\n\t\tparser.mark.index += 2\n\t\tparser.mark.column = 0\n\t\tparser.mark.line++\n\t\tparser.unread -= 2\n\t\tparser.buffer_pos += 2\n\t} else if is_break(parser.buffer, parser.buffer_pos) {\n\t\tparser.mark.index++\n\t\tparser.mark.column = 0\n\t\tparser.mark.line++\n\t\tparser.unread--\n\t\tparser.buffer_pos += width(parser.buffer[parser.buffer_pos])\n\t}\n}\n\n// Copy a character to a string buffer and advance pointers.\nfunc read(parser *yaml_parser_t, s []byte) []byte {\n\tw := width(parser.buffer[parser.buffer_pos])\n\tif w == 0 {\n\t\tpanic(\"invalid character sequence\")\n\t}\n\tif len(s) == 0 {\n\t\ts = make([]byte, 0, 32)\n\t}\n\tif w == 1 && len(s)+w <= cap(s) {\n\t\ts = s[:len(s)+1]\n\t\ts[len(s)-1] = parser.buffer[parser.buffer_pos]\n\t\tparser.buffer_pos++\n\t} else {\n\t\ts = append(s, parser.buffer[parser.buffer_pos:parser.buffer_pos+w]...)\n\t\tparser.buffer_pos += w\n\t}\n\tparser.mark.index++\n\tparser.mark.column++\n\tparser.unread--\n\treturn s\n}\n\n// Copy a line break character to a string buffer and advance pointers.\nfunc read_line(parser *yaml_parser_t, s []byte) []byte {\n\tbuf := parser.buffer\n\tpos := parser.buffer_pos\n\tswitch {\n\tcase buf[pos] == '\\r' && buf[pos+1] == '\\n':\n\t\t// CR LF . LF\n\t\ts = append(s, '\\n')\n\t\tparser.buffer_pos += 2\n\t\tparser.mark.index++\n\t\tparser.unread--\n\tcase buf[pos] == '\\r' || buf[pos] == '\\n':\n\t\t// CR|LF . LF\n\t\ts = append(s, '\\n')\n\t\tparser.buffer_pos += 1\n\tcase buf[pos] == '\\xC2' && buf[pos+1] == '\\x85':\n\t\t// NEL . LF\n\t\ts = append(s, '\\n')\n\t\tparser.buffer_pos += 2\n\tcase buf[pos] == '\\xE2' && buf[pos+1] == '\\x80' && (buf[pos+2] == '\\xA8' || buf[pos+2] == '\\xA9'):\n\t\t// LS|PS . LS|PS\n\t\ts = append(s, buf[parser.buffer_pos:pos+3]...)\n\t\tparser.buffer_pos += 3\n\tdefault:\n\t\treturn s\n\t}\n\tparser.mark.index++\n\tparser.mark.column = 0\n\tparser.mark.line++\n\tparser.unread--\n\treturn s\n}\n\n// Get the next token.\nfunc yaml_parser_scan(parser *yaml_parser_t, token *yaml_token_t) bool {\n\t// Erase the token object.\n\t*token = yaml_token_t{} // [Go] Is this necessary?\n\n\t// No tokens after STREAM-END or error.\n\tif parser.stream_end_produced || parser.error != yaml_NO_ERROR {\n\t\treturn true\n\t}\n\n\t// Ensure that the tokens queue contains enough tokens.\n\tif !parser.token_available {\n\t\tif !yaml_parser_fetch_more_tokens(parser) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// Fetch the next token from the queue.\n\t*token = parser.tokens[parser.tokens_head]\n\tparser.tokens_head++\n\tparser.tokens_parsed++\n\tparser.token_available = false\n\n\tif token.typ == yaml_STREAM_END_TOKEN {\n\t\tparser.stream_end_produced = true\n\t}\n\treturn true\n}\n\n// Set the scanner error and return false.\nfunc yaml_parser_set_scanner_error(parser *yaml_parser_t, context string, context_mark yaml_mark_t, problem string) bool {\n\tparser.error = yaml_SCANNER_ERROR\n\tparser.context = context\n\tparser.context_mark = context_mark\n\tparser.problem = problem\n\tparser.problem_mark = parser.mark\n\treturn false\n}\n\nfunc yaml_parser_set_scanner_tag_error(parser *yaml_parser_t, directive bool, context_mark yaml_mark_t, problem string) bool {\n\tcontext := \"while parsing a tag\"\n\tif directive {\n\t\tcontext = \"while parsing a %TAG directive\"\n\t}\n\treturn yaml_parser_set_scanner_error(parser, context, context_mark, problem)\n}\n\nfunc trace(args ...interface{}) func() {\n\tpargs := append([]interface{}{\"+++\"}, args...)\n\tfmt.Println(pargs...)\n\tpargs = append([]interface{}{\"---\"}, args...)\n\treturn func() { fmt.Println(pargs...) }\n}\n\n// Ensure that the tokens queue contains at least one token which can be\n// returned to the Parser.\nfunc yaml_parser_fetch_more_tokens(parser *yaml_parser_t) bool {\n\t// While we need more tokens to fetch, do it.\n\tfor {\n\t\t// Check if we really need to fetch more tokens.\n\t\tneed_more_tokens := false\n\n\t\tif parser.tokens_head == len(parser.tokens) {\n\t\t\t// Queue is empty.\n\t\t\tneed_more_tokens = true\n\t\t} else {\n\t\t\t// Check if any potential simple key may occupy the head position.\n\t\t\tif !yaml_parser_stale_simple_keys(parser) {\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\tfor i := range parser.simple_keys {\n\t\t\t\tsimple_key := &parser.simple_keys[i]\n\t\t\t\tif simple_key.possible && simple_key.token_number == parser.tokens_parsed {\n\t\t\t\t\tneed_more_tokens = true\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// We are finished.\n\t\tif !need_more_tokens {\n\t\t\tbreak\n\t\t}\n\t\t// Fetch the next token.\n\t\tif !yaml_parser_fetch_next_token(parser) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\tparser.token_available = true\n\treturn true\n}\n\n// The dispatcher for token fetchers.\nfunc yaml_parser_fetch_next_token(parser *yaml_parser_t) bool {\n\t// Ensure that the buffer is initialized.\n\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\treturn false\n\t}\n\n\t// Check if we just started scanning.  Fetch STREAM-START then.\n\tif !parser.stream_start_produced {\n\t\treturn yaml_parser_fetch_stream_start(parser)\n\t}\n\n\t// Eat whitespaces and comments until we reach the next token.\n\tif !yaml_parser_scan_to_next_token(parser) {\n\t\treturn false\n\t}\n\n\t// Remove obsolete potential simple keys.\n\tif !yaml_parser_stale_simple_keys(parser) {\n\t\treturn false\n\t}\n\n\t// Check the indentation level against the current column.\n\tif !yaml_parser_unroll_indent(parser, parser.mark.column) {\n\t\treturn false\n\t}\n\n\t// Ensure that the buffer contains at least 4 characters.  4 is the length\n\t// of the longest indicators ('--- ' and '... ').\n\tif parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) {\n\t\treturn false\n\t}\n\n\t// Is it the end of the stream?\n\tif is_z(parser.buffer, parser.buffer_pos) {\n\t\treturn yaml_parser_fetch_stream_end(parser)\n\t}\n\n\t// Is it a directive?\n\tif parser.mark.column == 0 && parser.buffer[parser.buffer_pos] == '%' {\n\t\treturn yaml_parser_fetch_directive(parser)\n\t}\n\n\tbuf := parser.buffer\n\tpos := parser.buffer_pos\n\n\t// Is it the document start indicator?\n\tif parser.mark.column == 0 && buf[pos] == '-' && buf[pos+1] == '-' && buf[pos+2] == '-' && is_blankz(buf, pos+3) {\n\t\treturn yaml_parser_fetch_document_indicator(parser, yaml_DOCUMENT_START_TOKEN)\n\t}\n\n\t// Is it the document end indicator?\n\tif parser.mark.column == 0 && buf[pos] == '.' && buf[pos+1] == '.' && buf[pos+2] == '.' && is_blankz(buf, pos+3) {\n\t\treturn yaml_parser_fetch_document_indicator(parser, yaml_DOCUMENT_END_TOKEN)\n\t}\n\n\t// Is it the flow sequence start indicator?\n\tif buf[pos] == '[' {\n\t\treturn yaml_parser_fetch_flow_collection_start(parser, yaml_FLOW_SEQUENCE_START_TOKEN)\n\t}\n\n\t// Is it the flow mapping start indicator?\n\tif parser.buffer[parser.buffer_pos] == '{' {\n\t\treturn yaml_parser_fetch_flow_collection_start(parser, yaml_FLOW_MAPPING_START_TOKEN)\n\t}\n\n\t// Is it the flow sequence end indicator?\n\tif parser.buffer[parser.buffer_pos] == ']' {\n\t\treturn yaml_parser_fetch_flow_collection_end(parser,\n\t\t\tyaml_FLOW_SEQUENCE_END_TOKEN)\n\t}\n\n\t// Is it the flow mapping end indicator?\n\tif parser.buffer[parser.buffer_pos] == '}' {\n\t\treturn yaml_parser_fetch_flow_collection_end(parser,\n\t\t\tyaml_FLOW_MAPPING_END_TOKEN)\n\t}\n\n\t// Is it the flow entry indicator?\n\tif parser.buffer[parser.buffer_pos] == ',' {\n\t\treturn yaml_parser_fetch_flow_entry(parser)\n\t}\n\n\t// Is it the block entry indicator?\n\tif parser.buffer[parser.buffer_pos] == '-' && is_blankz(parser.buffer, parser.buffer_pos+1) {\n\t\treturn yaml_parser_fetch_block_entry(parser)\n\t}\n\n\t// Is it the key indicator?\n\tif parser.buffer[parser.buffer_pos] == '?' && (parser.flow_level > 0 || is_blankz(parser.buffer, parser.buffer_pos+1)) {\n\t\treturn yaml_parser_fetch_key(parser)\n\t}\n\n\t// Is it the value indicator?\n\tif parser.buffer[parser.buffer_pos] == ':' && (parser.flow_level > 0 || is_blankz(parser.buffer, parser.buffer_pos+1)) {\n\t\treturn yaml_parser_fetch_value(parser)\n\t}\n\n\t// Is it an alias?\n\tif parser.buffer[parser.buffer_pos] == '*' {\n\t\treturn yaml_parser_fetch_anchor(parser, yaml_ALIAS_TOKEN)\n\t}\n\n\t// Is it an anchor?\n\tif parser.buffer[parser.buffer_pos] == '&' {\n\t\treturn yaml_parser_fetch_anchor(parser, yaml_ANCHOR_TOKEN)\n\t}\n\n\t// Is it a tag?\n\tif parser.buffer[parser.buffer_pos] == '!' {\n\t\treturn yaml_parser_fetch_tag(parser)\n\t}\n\n\t// Is it a literal scalar?\n\tif parser.buffer[parser.buffer_pos] == '|' && parser.flow_level == 0 {\n\t\treturn yaml_parser_fetch_block_scalar(parser, true)\n\t}\n\n\t// Is it a folded scalar?\n\tif parser.buffer[parser.buffer_pos] == '>' && parser.flow_level == 0 {\n\t\treturn yaml_parser_fetch_block_scalar(parser, false)\n\t}\n\n\t// Is it a single-quoted scalar?\n\tif parser.buffer[parser.buffer_pos] == '\\'' {\n\t\treturn yaml_parser_fetch_flow_scalar(parser, true)\n\t}\n\n\t// Is it a double-quoted scalar?\n\tif parser.buffer[parser.buffer_pos] == '\"' {\n\t\treturn yaml_parser_fetch_flow_scalar(parser, false)\n\t}\n\n\t// Is it a plain scalar?\n\t//\n\t// A plain scalar may start with any non-blank characters except\n\t//\n\t//      '-', '?', ':', ',', '[', ']', '{', '}',\n\t//      '#', '&', '*', '!', '|', '>', '\\'', '\\\"',\n\t//      '%', '@', '`'.\n\t//\n\t// In the block context (and, for the '-' indicator, in the flow context\n\t// too), it may also start with the characters\n\t//\n\t//      '-', '?', ':'\n\t//\n\t// if it is followed by a non-space character.\n\t//\n\t// The last rule is more restrictive than the specification requires.\n\t// [Go] Make this logic more reasonable.\n\t//switch parser.buffer[parser.buffer_pos] {\n\t//case '-', '?', ':', ',', '?', '-', ',', ':', ']', '[', '}', '{', '&', '#', '!', '*', '>', '|', '\"', '\\'', '@', '%', '-', '`':\n\t//}\n\tif !(is_blankz(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == '-' ||\n\t\tparser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == ':' ||\n\t\tparser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == '[' ||\n\t\tparser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '{' ||\n\t\tparser.buffer[parser.buffer_pos] == '}' || parser.buffer[parser.buffer_pos] == '#' ||\n\t\tparser.buffer[parser.buffer_pos] == '&' || parser.buffer[parser.buffer_pos] == '*' ||\n\t\tparser.buffer[parser.buffer_pos] == '!' || parser.buffer[parser.buffer_pos] == '|' ||\n\t\tparser.buffer[parser.buffer_pos] == '>' || parser.buffer[parser.buffer_pos] == '\\'' ||\n\t\tparser.buffer[parser.buffer_pos] == '\"' || parser.buffer[parser.buffer_pos] == '%' ||\n\t\tparser.buffer[parser.buffer_pos] == '@' || parser.buffer[parser.buffer_pos] == '`') ||\n\t\t(parser.buffer[parser.buffer_pos] == '-' && !is_blank(parser.buffer, parser.buffer_pos+1)) ||\n\t\t(parser.flow_level == 0 &&\n\t\t\t(parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == ':') &&\n\t\t\t!is_blankz(parser.buffer, parser.buffer_pos+1)) {\n\t\treturn yaml_parser_fetch_plain_scalar(parser)\n\t}\n\n\t// If we don't determine the token type so far, it is an error.\n\treturn yaml_parser_set_scanner_error(parser,\n\t\t\"while scanning for the next token\", parser.mark,\n\t\t\"found character that cannot start any token\")\n}\n\n// Check the list of potential simple keys and remove the positions that\n// cannot contain simple keys anymore.\nfunc yaml_parser_stale_simple_keys(parser *yaml_parser_t) bool {\n\t// Check for a potential simple key for each flow level.\n\tfor i := range parser.simple_keys {\n\t\tsimple_key := &parser.simple_keys[i]\n\n\t\t// The specification requires that a simple key\n\t\t//\n\t\t//  - is limited to a single line,\n\t\t//  - is shorter than 1024 characters.\n\t\tif simple_key.possible && (simple_key.mark.line < parser.mark.line || simple_key.mark.index+1024 < parser.mark.index) {\n\n\t\t\t// Check if the potential simple key to be removed is required.\n\t\t\tif simple_key.required {\n\t\t\t\treturn yaml_parser_set_scanner_error(parser,\n\t\t\t\t\t\"while scanning a simple key\", simple_key.mark,\n\t\t\t\t\t\"could not find expected ':'\")\n\t\t\t}\n\t\t\tsimple_key.possible = false\n\t\t}\n\t}\n\treturn true\n}\n\n// Check if a simple key may start at the current position and add it if\n// needed.\nfunc yaml_parser_save_simple_key(parser *yaml_parser_t) bool {\n\t// A simple key is required at the current position if the scanner is in\n\t// the block context and the current column coincides with the indentation\n\t// level.\n\n\trequired := parser.flow_level == 0 && parser.indent == parser.mark.column\n\n\t// A simple key is required only when it is the first token in the current\n\t// line.  Therefore it is always allowed.  But we add a check anyway.\n\tif required && !parser.simple_key_allowed {\n\t\tpanic(\"should not happen\")\n\t}\n\n\t//\n\t// If the current position may start a simple key, save it.\n\t//\n\tif parser.simple_key_allowed {\n\t\tsimple_key := yaml_simple_key_t{\n\t\t\tpossible:     true,\n\t\t\trequired:     required,\n\t\t\ttoken_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head),\n\t\t}\n\t\tsimple_key.mark = parser.mark\n\n\t\tif !yaml_parser_remove_simple_key(parser) {\n\t\t\treturn false\n\t\t}\n\t\tparser.simple_keys[len(parser.simple_keys)-1] = simple_key\n\t}\n\treturn true\n}\n\n// Remove a potential simple key at the current flow level.\nfunc yaml_parser_remove_simple_key(parser *yaml_parser_t) bool {\n\ti := len(parser.simple_keys) - 1\n\tif parser.simple_keys[i].possible {\n\t\t// If the key is required, it is an error.\n\t\tif parser.simple_keys[i].required {\n\t\t\treturn yaml_parser_set_scanner_error(parser,\n\t\t\t\t\"while scanning a simple key\", parser.simple_keys[i].mark,\n\t\t\t\t\"could not find expected ':'\")\n\t\t}\n\t}\n\t// Remove the key from the stack.\n\tparser.simple_keys[i].possible = false\n\treturn true\n}\n\n// Increase the flow level and resize the simple key list if needed.\nfunc yaml_parser_increase_flow_level(parser *yaml_parser_t) bool {\n\t// Reset the simple key on the next level.\n\tparser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{})\n\n\t// Increase the flow level.\n\tparser.flow_level++\n\treturn true\n}\n\n// Decrease the flow level.\nfunc yaml_parser_decrease_flow_level(parser *yaml_parser_t) bool {\n\tif parser.flow_level > 0 {\n\t\tparser.flow_level--\n\t\tparser.simple_keys = parser.simple_keys[:len(parser.simple_keys)-1]\n\t}\n\treturn true\n}\n\n// Push the current indentation level to the stack and set the new level\n// the current column is greater than the indentation level.  In this case,\n// append or insert the specified token into the token queue.\nfunc yaml_parser_roll_indent(parser *yaml_parser_t, column, number int, typ yaml_token_type_t, mark yaml_mark_t) bool {\n\t// In the flow context, do nothing.\n\tif parser.flow_level > 0 {\n\t\treturn true\n\t}\n\n\tif parser.indent < column {\n\t\t// Push the current indentation level to the stack and set the new\n\t\t// indentation level.\n\t\tparser.indents = append(parser.indents, parser.indent)\n\t\tparser.indent = column\n\n\t\t// Create a token and insert it into the queue.\n\t\ttoken := yaml_token_t{\n\t\t\ttyp:        typ,\n\t\t\tstart_mark: mark,\n\t\t\tend_mark:   mark,\n\t\t}\n\t\tif number > -1 {\n\t\t\tnumber -= parser.tokens_parsed\n\t\t}\n\t\tyaml_insert_token(parser, number, &token)\n\t}\n\treturn true\n}\n\n// Pop indentation levels from the indents stack until the current level\n// becomes less or equal to the column.  For each indentation level, append\n// the BLOCK-END token.\nfunc yaml_parser_unroll_indent(parser *yaml_parser_t, column int) bool {\n\t// In the flow context, do nothing.\n\tif parser.flow_level > 0 {\n\t\treturn true\n\t}\n\n\t// Loop through the indentation levels in the stack.\n\tfor parser.indent > column {\n\t\t// Create a token and append it to the queue.\n\t\ttoken := yaml_token_t{\n\t\t\ttyp:        yaml_BLOCK_END_TOKEN,\n\t\t\tstart_mark: parser.mark,\n\t\t\tend_mark:   parser.mark,\n\t\t}\n\t\tyaml_insert_token(parser, -1, &token)\n\n\t\t// Pop the indentation level.\n\t\tparser.indent = parser.indents[len(parser.indents)-1]\n\t\tparser.indents = parser.indents[:len(parser.indents)-1]\n\t}\n\treturn true\n}\n\n// Initialize the scanner and produce the STREAM-START token.\nfunc yaml_parser_fetch_stream_start(parser *yaml_parser_t) bool {\n\n\t// Set the initial indentation.\n\tparser.indent = -1\n\n\t// Initialize the simple key stack.\n\tparser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{})\n\n\t// A simple key is allowed at the beginning of the stream.\n\tparser.simple_key_allowed = true\n\n\t// We have started.\n\tparser.stream_start_produced = true\n\n\t// Create the STREAM-START token and append it to the queue.\n\ttoken := yaml_token_t{\n\t\ttyp:        yaml_STREAM_START_TOKEN,\n\t\tstart_mark: parser.mark,\n\t\tend_mark:   parser.mark,\n\t\tencoding:   parser.encoding,\n\t}\n\tyaml_insert_token(parser, -1, &token)\n\treturn true\n}\n\n// Produce the STREAM-END token and shut down the scanner.\nfunc yaml_parser_fetch_stream_end(parser *yaml_parser_t) bool {\n\n\t// Force new line.\n\tif parser.mark.column != 0 {\n\t\tparser.mark.column = 0\n\t\tparser.mark.line++\n\t}\n\n\t// Reset the indentation level.\n\tif !yaml_parser_unroll_indent(parser, -1) {\n\t\treturn false\n\t}\n\n\t// Reset simple keys.\n\tif !yaml_parser_remove_simple_key(parser) {\n\t\treturn false\n\t}\n\n\tparser.simple_key_allowed = false\n\n\t// Create the STREAM-END token and append it to the queue.\n\ttoken := yaml_token_t{\n\t\ttyp:        yaml_STREAM_END_TOKEN,\n\t\tstart_mark: parser.mark,\n\t\tend_mark:   parser.mark,\n\t}\n\tyaml_insert_token(parser, -1, &token)\n\treturn true\n}\n\n// Produce a VERSION-DIRECTIVE or TAG-DIRECTIVE token.\nfunc yaml_parser_fetch_directive(parser *yaml_parser_t) bool {\n\t// Reset the indentation level.\n\tif !yaml_parser_unroll_indent(parser, -1) {\n\t\treturn false\n\t}\n\n\t// Reset simple keys.\n\tif !yaml_parser_remove_simple_key(parser) {\n\t\treturn false\n\t}\n\n\tparser.simple_key_allowed = false\n\n\t// Create the YAML-DIRECTIVE or TAG-DIRECTIVE token.\n\ttoken := yaml_token_t{}\n\tif !yaml_parser_scan_directive(parser, &token) {\n\t\treturn false\n\t}\n\t// Append the token to the queue.\n\tyaml_insert_token(parser, -1, &token)\n\treturn true\n}\n\n// Produce the DOCUMENT-START or DOCUMENT-END token.\nfunc yaml_parser_fetch_document_indicator(parser *yaml_parser_t, typ yaml_token_type_t) bool {\n\t// Reset the indentation level.\n\tif !yaml_parser_unroll_indent(parser, -1) {\n\t\treturn false\n\t}\n\n\t// Reset simple keys.\n\tif !yaml_parser_remove_simple_key(parser) {\n\t\treturn false\n\t}\n\n\tparser.simple_key_allowed = false\n\n\t// Consume the token.\n\tstart_mark := parser.mark\n\n\tskip(parser)\n\tskip(parser)\n\tskip(parser)\n\n\tend_mark := parser.mark\n\n\t// Create the DOCUMENT-START or DOCUMENT-END token.\n\ttoken := yaml_token_t{\n\t\ttyp:        typ,\n\t\tstart_mark: start_mark,\n\t\tend_mark:   end_mark,\n\t}\n\t// Append the token to the queue.\n\tyaml_insert_token(parser, -1, &token)\n\treturn true\n}\n\n// Produce the FLOW-SEQUENCE-START or FLOW-MAPPING-START token.\nfunc yaml_parser_fetch_flow_collection_start(parser *yaml_parser_t, typ yaml_token_type_t) bool {\n\t// The indicators '[' and '{' may start a simple key.\n\tif !yaml_parser_save_simple_key(parser) {\n\t\treturn false\n\t}\n\n\t// Increase the flow level.\n\tif !yaml_parser_increase_flow_level(parser) {\n\t\treturn false\n\t}\n\n\t// A simple key may follow the indicators '[' and '{'.\n\tparser.simple_key_allowed = true\n\n\t// Consume the token.\n\tstart_mark := parser.mark\n\tskip(parser)\n\tend_mark := parser.mark\n\n\t// Create the FLOW-SEQUENCE-START of FLOW-MAPPING-START token.\n\ttoken := yaml_token_t{\n\t\ttyp:        typ,\n\t\tstart_mark: start_mark,\n\t\tend_mark:   end_mark,\n\t}\n\t// Append the token to the queue.\n\tyaml_insert_token(parser, -1, &token)\n\treturn true\n}\n\n// Produce the FLOW-SEQUENCE-END or FLOW-MAPPING-END token.\nfunc yaml_parser_fetch_flow_collection_end(parser *yaml_parser_t, typ yaml_token_type_t) bool {\n\t// Reset any potential simple key on the current flow level.\n\tif !yaml_parser_remove_simple_key(parser) {\n\t\treturn false\n\t}\n\n\t// Decrease the flow level.\n\tif !yaml_parser_decrease_flow_level(parser) {\n\t\treturn false\n\t}\n\n\t// No simple keys after the indicators ']' and '}'.\n\tparser.simple_key_allowed = false\n\n\t// Consume the token.\n\n\tstart_mark := parser.mark\n\tskip(parser)\n\tend_mark := parser.mark\n\n\t// Create the FLOW-SEQUENCE-END of FLOW-MAPPING-END token.\n\ttoken := yaml_token_t{\n\t\ttyp:        typ,\n\t\tstart_mark: start_mark,\n\t\tend_mark:   end_mark,\n\t}\n\t// Append the token to the queue.\n\tyaml_insert_token(parser, -1, &token)\n\treturn true\n}\n\n// Produce the FLOW-ENTRY token.\nfunc yaml_parser_fetch_flow_entry(parser *yaml_parser_t) bool {\n\t// Reset any potential simple keys on the current flow level.\n\tif !yaml_parser_remove_simple_key(parser) {\n\t\treturn false\n\t}\n\n\t// Simple keys are allowed after ','.\n\tparser.simple_key_allowed = true\n\n\t// Consume the token.\n\tstart_mark := parser.mark\n\tskip(parser)\n\tend_mark := parser.mark\n\n\t// Create the FLOW-ENTRY token and append it to the queue.\n\ttoken := yaml_token_t{\n\t\ttyp:        yaml_FLOW_ENTRY_TOKEN,\n\t\tstart_mark: start_mark,\n\t\tend_mark:   end_mark,\n\t}\n\tyaml_insert_token(parser, -1, &token)\n\treturn true\n}\n\n// Produce the BLOCK-ENTRY token.\nfunc yaml_parser_fetch_block_entry(parser *yaml_parser_t) bool {\n\t// Check if the scanner is in the block context.\n\tif parser.flow_level == 0 {\n\t\t// Check if we are allowed to start a new entry.\n\t\tif !parser.simple_key_allowed {\n\t\t\treturn yaml_parser_set_scanner_error(parser, \"\", parser.mark,\n\t\t\t\t\"block sequence entries are not allowed in this context\")\n\t\t}\n\t\t// Add the BLOCK-SEQUENCE-START token if needed.\n\t\tif !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_SEQUENCE_START_TOKEN, parser.mark) {\n\t\t\treturn false\n\t\t}\n\t} else {\n\t\t// It is an error for the '-' indicator to occur in the flow context,\n\t\t// but we let the Parser detect and report about it because the Parser\n\t\t// is able to point to the context.\n\t}\n\n\t// Reset any potential simple keys on the current flow level.\n\tif !yaml_parser_remove_simple_key(parser) {\n\t\treturn false\n\t}\n\n\t// Simple keys are allowed after '-'.\n\tparser.simple_key_allowed = true\n\n\t// Consume the token.\n\tstart_mark := parser.mark\n\tskip(parser)\n\tend_mark := parser.mark\n\n\t// Create the BLOCK-ENTRY token and append it to the queue.\n\ttoken := yaml_token_t{\n\t\ttyp:        yaml_BLOCK_ENTRY_TOKEN,\n\t\tstart_mark: start_mark,\n\t\tend_mark:   end_mark,\n\t}\n\tyaml_insert_token(parser, -1, &token)\n\treturn true\n}\n\n// Produce the KEY token.\nfunc yaml_parser_fetch_key(parser *yaml_parser_t) bool {\n\n\t// In the block context, additional checks are required.\n\tif parser.flow_level == 0 {\n\t\t// Check if we are allowed to start a new key (not nessesary simple).\n\t\tif !parser.simple_key_allowed {\n\t\t\treturn yaml_parser_set_scanner_error(parser, \"\", parser.mark,\n\t\t\t\t\"mapping keys are not allowed in this context\")\n\t\t}\n\t\t// Add the BLOCK-MAPPING-START token if needed.\n\t\tif !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_MAPPING_START_TOKEN, parser.mark) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// Reset any potential simple keys on the current flow level.\n\tif !yaml_parser_remove_simple_key(parser) {\n\t\treturn false\n\t}\n\n\t// Simple keys are allowed after '?' in the block context.\n\tparser.simple_key_allowed = parser.flow_level == 0\n\n\t// Consume the token.\n\tstart_mark := parser.mark\n\tskip(parser)\n\tend_mark := parser.mark\n\n\t// Create the KEY token and append it to the queue.\n\ttoken := yaml_token_t{\n\t\ttyp:        yaml_KEY_TOKEN,\n\t\tstart_mark: start_mark,\n\t\tend_mark:   end_mark,\n\t}\n\tyaml_insert_token(parser, -1, &token)\n\treturn true\n}\n\n// Produce the VALUE token.\nfunc yaml_parser_fetch_value(parser *yaml_parser_t) bool {\n\n\tsimple_key := &parser.simple_keys[len(parser.simple_keys)-1]\n\n\t// Have we found a simple key?\n\tif simple_key.possible {\n\t\t// Create the KEY token and insert it into the queue.\n\t\ttoken := yaml_token_t{\n\t\t\ttyp:        yaml_KEY_TOKEN,\n\t\t\tstart_mark: simple_key.mark,\n\t\t\tend_mark:   simple_key.mark,\n\t\t}\n\t\tyaml_insert_token(parser, simple_key.token_number-parser.tokens_parsed, &token)\n\n\t\t// In the block context, we may need to add the BLOCK-MAPPING-START token.\n\t\tif !yaml_parser_roll_indent(parser, simple_key.mark.column,\n\t\t\tsimple_key.token_number,\n\t\t\tyaml_BLOCK_MAPPING_START_TOKEN, simple_key.mark) {\n\t\t\treturn false\n\t\t}\n\n\t\t// Remove the simple key.\n\t\tsimple_key.possible = false\n\n\t\t// A simple key cannot follow another simple key.\n\t\tparser.simple_key_allowed = false\n\n\t} else {\n\t\t// The ':' indicator follows a complex key.\n\n\t\t// In the block context, extra checks are required.\n\t\tif parser.flow_level == 0 {\n\n\t\t\t// Check if we are allowed to start a complex value.\n\t\t\tif !parser.simple_key_allowed {\n\t\t\t\treturn yaml_parser_set_scanner_error(parser, \"\", parser.mark,\n\t\t\t\t\t\"mapping values are not allowed in this context\")\n\t\t\t}\n\n\t\t\t// Add the BLOCK-MAPPING-START token if needed.\n\t\t\tif !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_MAPPING_START_TOKEN, parser.mark) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\n\t\t// Simple keys after ':' are allowed in the block context.\n\t\tparser.simple_key_allowed = parser.flow_level == 0\n\t}\n\n\t// Consume the token.\n\tstart_mark := parser.mark\n\tskip(parser)\n\tend_mark := parser.mark\n\n\t// Create the VALUE token and append it to the queue.\n\ttoken := yaml_token_t{\n\t\ttyp:        yaml_VALUE_TOKEN,\n\t\tstart_mark: start_mark,\n\t\tend_mark:   end_mark,\n\t}\n\tyaml_insert_token(parser, -1, &token)\n\treturn true\n}\n\n// Produce the ALIAS or ANCHOR token.\nfunc yaml_parser_fetch_anchor(parser *yaml_parser_t, typ yaml_token_type_t) bool {\n\t// An anchor or an alias could be a simple key.\n\tif !yaml_parser_save_simple_key(parser) {\n\t\treturn false\n\t}\n\n\t// A simple key cannot follow an anchor or an alias.\n\tparser.simple_key_allowed = false\n\n\t// Create the ALIAS or ANCHOR token and append it to the queue.\n\tvar token yaml_token_t\n\tif !yaml_parser_scan_anchor(parser, &token, typ) {\n\t\treturn false\n\t}\n\tyaml_insert_token(parser, -1, &token)\n\treturn true\n}\n\n// Produce the TAG token.\nfunc yaml_parser_fetch_tag(parser *yaml_parser_t) bool {\n\t// A tag could be a simple key.\n\tif !yaml_parser_save_simple_key(parser) {\n\t\treturn false\n\t}\n\n\t// A simple key cannot follow a tag.\n\tparser.simple_key_allowed = false\n\n\t// Create the TAG token and append it to the queue.\n\tvar token yaml_token_t\n\tif !yaml_parser_scan_tag(parser, &token) {\n\t\treturn false\n\t}\n\tyaml_insert_token(parser, -1, &token)\n\treturn true\n}\n\n// Produce the SCALAR(...,literal) or SCALAR(...,folded) tokens.\nfunc yaml_parser_fetch_block_scalar(parser *yaml_parser_t, literal bool) bool {\n\t// Remove any potential simple keys.\n\tif !yaml_parser_remove_simple_key(parser) {\n\t\treturn false\n\t}\n\n\t// A simple key may follow a block scalar.\n\tparser.simple_key_allowed = true\n\n\t// Create the SCALAR token and append it to the queue.\n\tvar token yaml_token_t\n\tif !yaml_parser_scan_block_scalar(parser, &token, literal) {\n\t\treturn false\n\t}\n\tyaml_insert_token(parser, -1, &token)\n\treturn true\n}\n\n// Produce the SCALAR(...,single-quoted) or SCALAR(...,double-quoted) tokens.\nfunc yaml_parser_fetch_flow_scalar(parser *yaml_parser_t, single bool) bool {\n\t// A plain scalar could be a simple key.\n\tif !yaml_parser_save_simple_key(parser) {\n\t\treturn false\n\t}\n\n\t// A simple key cannot follow a flow scalar.\n\tparser.simple_key_allowed = false\n\n\t// Create the SCALAR token and append it to the queue.\n\tvar token yaml_token_t\n\tif !yaml_parser_scan_flow_scalar(parser, &token, single) {\n\t\treturn false\n\t}\n\tyaml_insert_token(parser, -1, &token)\n\treturn true\n}\n\n// Produce the SCALAR(...,plain) token.\nfunc yaml_parser_fetch_plain_scalar(parser *yaml_parser_t) bool {\n\t// A plain scalar could be a simple key.\n\tif !yaml_parser_save_simple_key(parser) {\n\t\treturn false\n\t}\n\n\t// A simple key cannot follow a flow scalar.\n\tparser.simple_key_allowed = false\n\n\t// Create the SCALAR token and append it to the queue.\n\tvar token yaml_token_t\n\tif !yaml_parser_scan_plain_scalar(parser, &token) {\n\t\treturn false\n\t}\n\tyaml_insert_token(parser, -1, &token)\n\treturn true\n}\n\n// Eat whitespaces and comments until the next token is found.\nfunc yaml_parser_scan_to_next_token(parser *yaml_parser_t) bool {\n\n\t// Until the next token is not found.\n\tfor {\n\t\t// Allow the BOM mark to start a line.\n\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\treturn false\n\t\t}\n\t\tif parser.mark.column == 0 && is_bom(parser.buffer, parser.buffer_pos) {\n\t\t\tskip(parser)\n\t\t}\n\n\t\t// Eat whitespaces.\n\t\t// Tabs are allowed:\n\t\t//  - in the flow context\n\t\t//  - in the block context, but not at the beginning of the line or\n\t\t//  after '-', '?', or ':' (complex value).\n\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\treturn false\n\t\t}\n\n\t\tfor parser.buffer[parser.buffer_pos] == ' ' || ((parser.flow_level > 0 || !parser.simple_key_allowed) && parser.buffer[parser.buffer_pos] == '\\t') {\n\t\t\tskip(parser)\n\t\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\n\t\t// Eat a comment until a line break.\n\t\tif parser.buffer[parser.buffer_pos] == '#' {\n\t\t\tfor !is_breakz(parser.buffer, parser.buffer_pos) {\n\t\t\t\tskip(parser)\n\t\t\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// If it is a line break, eat it.\n\t\tif is_break(parser.buffer, parser.buffer_pos) {\n\t\t\tif parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tskip_line(parser)\n\n\t\t\t// In the block context, a new line may start a simple key.\n\t\t\tif parser.flow_level == 0 {\n\t\t\t\tparser.simple_key_allowed = true\n\t\t\t}\n\t\t} else {\n\t\t\tbreak // We have found a token.\n\t\t}\n\t}\n\n\treturn true\n}\n\n// Scan a YAML-DIRECTIVE or TAG-DIRECTIVE token.\n//\n// Scope:\n//      %YAML    1.1    # a comment \\n\n//      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n//      %TAG    !yaml!  tag:yaml.org,2002:  \\n\n//      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n//\nfunc yaml_parser_scan_directive(parser *yaml_parser_t, token *yaml_token_t) bool {\n\t// Eat '%'.\n\tstart_mark := parser.mark\n\tskip(parser)\n\n\t// Scan the directive name.\n\tvar name []byte\n\tif !yaml_parser_scan_directive_name(parser, start_mark, &name) {\n\t\treturn false\n\t}\n\n\t// Is it a YAML directive?\n\tif bytes.Equal(name, []byte(\"YAML\")) {\n\t\t// Scan the VERSION directive value.\n\t\tvar major, minor int8\n\t\tif !yaml_parser_scan_version_directive_value(parser, start_mark, &major, &minor) {\n\t\t\treturn false\n\t\t}\n\t\tend_mark := parser.mark\n\n\t\t// Create a VERSION-DIRECTIVE token.\n\t\t*token = yaml_token_t{\n\t\t\ttyp:        yaml_VERSION_DIRECTIVE_TOKEN,\n\t\t\tstart_mark: start_mark,\n\t\t\tend_mark:   end_mark,\n\t\t\tmajor:      major,\n\t\t\tminor:      minor,\n\t\t}\n\n\t\t// Is it a TAG directive?\n\t} else if bytes.Equal(name, []byte(\"TAG\")) {\n\t\t// Scan the TAG directive value.\n\t\tvar handle, prefix []byte\n\t\tif !yaml_parser_scan_tag_directive_value(parser, start_mark, &handle, &prefix) {\n\t\t\treturn false\n\t\t}\n\t\tend_mark := parser.mark\n\n\t\t// Create a TAG-DIRECTIVE token.\n\t\t*token = yaml_token_t{\n\t\t\ttyp:        yaml_TAG_DIRECTIVE_TOKEN,\n\t\t\tstart_mark: start_mark,\n\t\t\tend_mark:   end_mark,\n\t\t\tvalue:      handle,\n\t\t\tprefix:     prefix,\n\t\t}\n\n\t\t// Unknown directive.\n\t} else {\n\t\tyaml_parser_set_scanner_error(parser, \"while scanning a directive\",\n\t\t\tstart_mark, \"found unknown directive name\")\n\t\treturn false\n\t}\n\n\t// Eat the rest of the line including any comments.\n\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\treturn false\n\t}\n\n\tfor is_blank(parser.buffer, parser.buffer_pos) {\n\t\tskip(parser)\n\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\tif parser.buffer[parser.buffer_pos] == '#' {\n\t\tfor !is_breakz(parser.buffer, parser.buffer_pos) {\n\t\t\tskip(parser)\n\t\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\n\t// Check if we are at the end of the line.\n\tif !is_breakz(parser.buffer, parser.buffer_pos) {\n\t\tyaml_parser_set_scanner_error(parser, \"while scanning a directive\",\n\t\t\tstart_mark, \"did not find expected comment or line break\")\n\t\treturn false\n\t}\n\n\t// Eat a line break.\n\tif is_break(parser.buffer, parser.buffer_pos) {\n\t\tif parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {\n\t\t\treturn false\n\t\t}\n\t\tskip_line(parser)\n\t}\n\n\treturn true\n}\n\n// Scan the directive name.\n//\n// Scope:\n//      %YAML   1.1     # a comment \\n\n//       ^^^^\n//      %TAG    !yaml!  tag:yaml.org,2002:  \\n\n//       ^^^\n//\nfunc yaml_parser_scan_directive_name(parser *yaml_parser_t, start_mark yaml_mark_t, name *[]byte) bool {\n\t// Consume the directive name.\n\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\treturn false\n\t}\n\n\tvar s []byte\n\tfor is_alpha(parser.buffer, parser.buffer_pos) {\n\t\ts = read(parser, s)\n\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// Check if the name is empty.\n\tif len(s) == 0 {\n\t\tyaml_parser_set_scanner_error(parser, \"while scanning a directive\",\n\t\t\tstart_mark, \"could not find expected directive name\")\n\t\treturn false\n\t}\n\n\t// Check for an blank character after the name.\n\tif !is_blankz(parser.buffer, parser.buffer_pos) {\n\t\tyaml_parser_set_scanner_error(parser, \"while scanning a directive\",\n\t\t\tstart_mark, \"found unexpected non-alphabetical character\")\n\t\treturn false\n\t}\n\t*name = s\n\treturn true\n}\n\n// Scan the value of VERSION-DIRECTIVE.\n//\n// Scope:\n//      %YAML   1.1     # a comment \\n\n//           ^^^^^^\nfunc yaml_parser_scan_version_directive_value(parser *yaml_parser_t, start_mark yaml_mark_t, major, minor *int8) bool {\n\t// Eat whitespaces.\n\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\treturn false\n\t}\n\tfor is_blank(parser.buffer, parser.buffer_pos) {\n\t\tskip(parser)\n\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// Consume the major version number.\n\tif !yaml_parser_scan_version_directive_number(parser, start_mark, major) {\n\t\treturn false\n\t}\n\n\t// Eat '.'.\n\tif parser.buffer[parser.buffer_pos] != '.' {\n\t\treturn yaml_parser_set_scanner_error(parser, \"while scanning a %YAML directive\",\n\t\t\tstart_mark, \"did not find expected digit or '.' character\")\n\t}\n\n\tskip(parser)\n\n\t// Consume the minor version number.\n\tif !yaml_parser_scan_version_directive_number(parser, start_mark, minor) {\n\t\treturn false\n\t}\n\treturn true\n}\n\nconst max_number_length = 2\n\n// Scan the version number of VERSION-DIRECTIVE.\n//\n// Scope:\n//      %YAML   1.1     # a comment \\n\n//              ^\n//      %YAML   1.1     # a comment \\n\n//                ^\nfunc yaml_parser_scan_version_directive_number(parser *yaml_parser_t, start_mark yaml_mark_t, number *int8) bool {\n\n\t// Repeat while the next character is digit.\n\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\treturn false\n\t}\n\tvar value, length int8\n\tfor is_digit(parser.buffer, parser.buffer_pos) {\n\t\t// Check if the number is too long.\n\t\tlength++\n\t\tif length > max_number_length {\n\t\t\treturn yaml_parser_set_scanner_error(parser, \"while scanning a %YAML directive\",\n\t\t\t\tstart_mark, \"found extremely long version number\")\n\t\t}\n\t\tvalue = value*10 + int8(as_digit(parser.buffer, parser.buffer_pos))\n\t\tskip(parser)\n\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// Check if the number was present.\n\tif length == 0 {\n\t\treturn yaml_parser_set_scanner_error(parser, \"while scanning a %YAML directive\",\n\t\t\tstart_mark, \"did not find expected version number\")\n\t}\n\t*number = value\n\treturn true\n}\n\n// Scan the value of a TAG-DIRECTIVE token.\n//\n// Scope:\n//      %TAG    !yaml!  tag:yaml.org,2002:  \\n\n//          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n//\nfunc yaml_parser_scan_tag_directive_value(parser *yaml_parser_t, start_mark yaml_mark_t, handle, prefix *[]byte) bool {\n\tvar handle_value, prefix_value []byte\n\n\t// Eat whitespaces.\n\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\treturn false\n\t}\n\n\tfor is_blank(parser.buffer, parser.buffer_pos) {\n\t\tskip(parser)\n\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// Scan a handle.\n\tif !yaml_parser_scan_tag_handle(parser, true, start_mark, &handle_value) {\n\t\treturn false\n\t}\n\n\t// Expect a whitespace.\n\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\treturn false\n\t}\n\tif !is_blank(parser.buffer, parser.buffer_pos) {\n\t\tyaml_parser_set_scanner_error(parser, \"while scanning a %TAG directive\",\n\t\t\tstart_mark, \"did not find expected whitespace\")\n\t\treturn false\n\t}\n\n\t// Eat whitespaces.\n\tfor is_blank(parser.buffer, parser.buffer_pos) {\n\t\tskip(parser)\n\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// Scan a prefix.\n\tif !yaml_parser_scan_tag_uri(parser, true, nil, start_mark, &prefix_value) {\n\t\treturn false\n\t}\n\n\t// Expect a whitespace or line break.\n\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\treturn false\n\t}\n\tif !is_blankz(parser.buffer, parser.buffer_pos) {\n\t\tyaml_parser_set_scanner_error(parser, \"while scanning a %TAG directive\",\n\t\t\tstart_mark, \"did not find expected whitespace or line break\")\n\t\treturn false\n\t}\n\n\t*handle = handle_value\n\t*prefix = prefix_value\n\treturn true\n}\n\nfunc yaml_parser_scan_anchor(parser *yaml_parser_t, token *yaml_token_t, typ yaml_token_type_t) bool {\n\tvar s []byte\n\n\t// Eat the indicator character.\n\tstart_mark := parser.mark\n\tskip(parser)\n\n\t// Consume the value.\n\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\treturn false\n\t}\n\n\tfor is_alpha(parser.buffer, parser.buffer_pos) {\n\t\ts = read(parser, s)\n\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\tend_mark := parser.mark\n\n\t/*\n\t * Check if length of the anchor is greater than 0 and it is followed by\n\t * a whitespace character or one of the indicators:\n\t *\n\t *      '?', ':', ',', ']', '}', '%', '@', '`'.\n\t */\n\n\tif len(s) == 0 ||\n\t\t!(is_blankz(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == '?' ||\n\t\t\tparser.buffer[parser.buffer_pos] == ':' || parser.buffer[parser.buffer_pos] == ',' ||\n\t\t\tparser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '}' ||\n\t\t\tparser.buffer[parser.buffer_pos] == '%' || parser.buffer[parser.buffer_pos] == '@' ||\n\t\t\tparser.buffer[parser.buffer_pos] == '`') {\n\t\tcontext := \"while scanning an alias\"\n\t\tif typ == yaml_ANCHOR_TOKEN {\n\t\t\tcontext = \"while scanning an anchor\"\n\t\t}\n\t\tyaml_parser_set_scanner_error(parser, context, start_mark,\n\t\t\t\"did not find expected alphabetic or numeric character\")\n\t\treturn false\n\t}\n\n\t// Create a token.\n\t*token = yaml_token_t{\n\t\ttyp:        typ,\n\t\tstart_mark: start_mark,\n\t\tend_mark:   end_mark,\n\t\tvalue:      s,\n\t}\n\n\treturn true\n}\n\n/*\n * Scan a TAG token.\n */\n\nfunc yaml_parser_scan_tag(parser *yaml_parser_t, token *yaml_token_t) bool {\n\tvar handle, suffix []byte\n\n\tstart_mark := parser.mark\n\n\t// Check if the tag is in the canonical form.\n\tif parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {\n\t\treturn false\n\t}\n\n\tif parser.buffer[parser.buffer_pos+1] == '<' {\n\t\t// Keep the handle as ''\n\n\t\t// Eat '!<'\n\t\tskip(parser)\n\t\tskip(parser)\n\n\t\t// Consume the tag value.\n\t\tif !yaml_parser_scan_tag_uri(parser, false, nil, start_mark, &suffix) {\n\t\t\treturn false\n\t\t}\n\n\t\t// Check for '>' and eat it.\n\t\tif parser.buffer[parser.buffer_pos] != '>' {\n\t\t\tyaml_parser_set_scanner_error(parser, \"while scanning a tag\",\n\t\t\t\tstart_mark, \"did not find the expected '>'\")\n\t\t\treturn false\n\t\t}\n\n\t\tskip(parser)\n\t} else {\n\t\t// The tag has either the '!suffix' or the '!handle!suffix' form.\n\n\t\t// First, try to scan a handle.\n\t\tif !yaml_parser_scan_tag_handle(parser, false, start_mark, &handle) {\n\t\t\treturn false\n\t\t}\n\n\t\t// Check if it is, indeed, handle.\n\t\tif handle[0] == '!' && len(handle) > 1 && handle[len(handle)-1] == '!' {\n\t\t\t// Scan the suffix now.\n\t\t\tif !yaml_parser_scan_tag_uri(parser, false, nil, start_mark, &suffix) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t} else {\n\t\t\t// It wasn't a handle after all.  Scan the rest of the tag.\n\t\t\tif !yaml_parser_scan_tag_uri(parser, false, handle, start_mark, &suffix) {\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\t// Set the handle to '!'.\n\t\t\thandle = []byte{'!'}\n\n\t\t\t// A special case: the '!' tag.  Set the handle to '' and the\n\t\t\t// suffix to '!'.\n\t\t\tif len(suffix) == 0 {\n\t\t\t\thandle, suffix = suffix, handle\n\t\t\t}\n\t\t}\n\t}\n\n\t// Check the character which ends the tag.\n\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\treturn false\n\t}\n\tif !is_blankz(parser.buffer, parser.buffer_pos) {\n\t\tyaml_parser_set_scanner_error(parser, \"while scanning a tag\",\n\t\t\tstart_mark, \"did not find expected whitespace or line break\")\n\t\treturn false\n\t}\n\n\tend_mark := parser.mark\n\n\t// Create a token.\n\t*token = yaml_token_t{\n\t\ttyp:        yaml_TAG_TOKEN,\n\t\tstart_mark: start_mark,\n\t\tend_mark:   end_mark,\n\t\tvalue:      handle,\n\t\tsuffix:     suffix,\n\t}\n\treturn true\n}\n\n// Scan a tag handle.\nfunc yaml_parser_scan_tag_handle(parser *yaml_parser_t, directive bool, start_mark yaml_mark_t, handle *[]byte) bool {\n\t// Check the initial '!' character.\n\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\treturn false\n\t}\n\tif parser.buffer[parser.buffer_pos] != '!' {\n\t\tyaml_parser_set_scanner_tag_error(parser, directive,\n\t\t\tstart_mark, \"did not find expected '!'\")\n\t\treturn false\n\t}\n\n\tvar s []byte\n\n\t// Copy the '!' character.\n\ts = read(parser, s)\n\n\t// Copy all subsequent alphabetical and numerical characters.\n\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\treturn false\n\t}\n\tfor is_alpha(parser.buffer, parser.buffer_pos) {\n\t\ts = read(parser, s)\n\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// Check if the trailing character is '!' and copy it.\n\tif parser.buffer[parser.buffer_pos] == '!' {\n\t\ts = read(parser, s)\n\t} else {\n\t\t// It's either the '!' tag or not really a tag handle.  If it's a %TAG\n\t\t// directive, it's an error.  If it's a tag token, it must be a part of URI.\n\t\tif directive && !(s[0] == '!' && s[1] == 0) {\n\t\t\tyaml_parser_set_scanner_tag_error(parser, directive,\n\t\t\t\tstart_mark, \"did not find expected '!'\")\n\t\t\treturn false\n\t\t}\n\t}\n\n\t*handle = s\n\treturn true\n}\n\n// Scan a tag.\nfunc yaml_parser_scan_tag_uri(parser *yaml_parser_t, directive bool, head []byte, start_mark yaml_mark_t, uri *[]byte) bool {\n\t//size_t length = head ? strlen((char *)head) : 0\n\tvar s []byte\n\tlength := len(head)\n\n\t// Copy the head if needed.\n\t//\n\t// Note that we don't copy the leading '!' character.\n\tif length > 0 {\n\t\ts = append(s, head[1:]...)\n\t}\n\n\t// Scan the tag.\n\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\treturn false\n\t}\n\n\t// The set of characters that may appear in URI is as follows:\n\t//\n\t//      '0'-'9', 'A'-'Z', 'a'-'z', '_', '-', ';', '/', '?', ':', '@', '&',\n\t//      '=', '+', '$', ',', '.', '!', '~', '*', '\\'', '(', ')', '[', ']',\n\t//      '%'.\n\t// [Go] Convert this into more reasonable logic.\n\tfor is_alpha(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == ';' ||\n\t\tparser.buffer[parser.buffer_pos] == '/' || parser.buffer[parser.buffer_pos] == '?' ||\n\t\tparser.buffer[parser.buffer_pos] == ':' || parser.buffer[parser.buffer_pos] == '@' ||\n\t\tparser.buffer[parser.buffer_pos] == '&' || parser.buffer[parser.buffer_pos] == '=' ||\n\t\tparser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '$' ||\n\t\tparser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == '.' ||\n\t\tparser.buffer[parser.buffer_pos] == '!' || parser.buffer[parser.buffer_pos] == '~' ||\n\t\tparser.buffer[parser.buffer_pos] == '*' || parser.buffer[parser.buffer_pos] == '\\'' ||\n\t\tparser.buffer[parser.buffer_pos] == '(' || parser.buffer[parser.buffer_pos] == ')' ||\n\t\tparser.buffer[parser.buffer_pos] == '[' || parser.buffer[parser.buffer_pos] == ']' ||\n\t\tparser.buffer[parser.buffer_pos] == '%' {\n\t\t// Check if it is a URI-escape sequence.\n\t\tif parser.buffer[parser.buffer_pos] == '%' {\n\t\t\tif !yaml_parser_scan_uri_escapes(parser, directive, start_mark, &s) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t} else {\n\t\t\ts = read(parser, s)\n\t\t\tlength++\n\t\t}\n\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// Check if the tag is non-empty.\n\tif length == 0 {\n\t\tyaml_parser_set_scanner_tag_error(parser, directive,\n\t\t\tstart_mark, \"did not find expected tag URI\")\n\t\treturn false\n\t}\n\t*uri = s\n\treturn true\n}\n\n// Decode an URI-escape sequence corresponding to a single UTF-8 character.\nfunc yaml_parser_scan_uri_escapes(parser *yaml_parser_t, directive bool, start_mark yaml_mark_t, s *[]byte) bool {\n\n\t// Decode the required number of characters.\n\tw := 1024\n\tfor w > 0 {\n\t\t// Check for a URI-escaped octet.\n\t\tif parser.unread < 3 && !yaml_parser_update_buffer(parser, 3) {\n\t\t\treturn false\n\t\t}\n\n\t\tif !(parser.buffer[parser.buffer_pos] == '%' &&\n\t\t\tis_hex(parser.buffer, parser.buffer_pos+1) &&\n\t\t\tis_hex(parser.buffer, parser.buffer_pos+2)) {\n\t\t\treturn yaml_parser_set_scanner_tag_error(parser, directive,\n\t\t\t\tstart_mark, \"did not find URI escaped octet\")\n\t\t}\n\n\t\t// Get the octet.\n\t\toctet := byte((as_hex(parser.buffer, parser.buffer_pos+1) << 4) + as_hex(parser.buffer, parser.buffer_pos+2))\n\n\t\t// If it is the leading octet, determine the length of the UTF-8 sequence.\n\t\tif w == 1024 {\n\t\t\tw = width(octet)\n\t\t\tif w == 0 {\n\t\t\t\treturn yaml_parser_set_scanner_tag_error(parser, directive,\n\t\t\t\t\tstart_mark, \"found an incorrect leading UTF-8 octet\")\n\t\t\t}\n\t\t} else {\n\t\t\t// Check if the trailing octet is correct.\n\t\t\tif octet&0xC0 != 0x80 {\n\t\t\t\treturn yaml_parser_set_scanner_tag_error(parser, directive,\n\t\t\t\t\tstart_mark, \"found an incorrect trailing UTF-8 octet\")\n\t\t\t}\n\t\t}\n\n\t\t// Copy the octet and move the pointers.\n\t\t*s = append(*s, octet)\n\t\tskip(parser)\n\t\tskip(parser)\n\t\tskip(parser)\n\t\tw--\n\t}\n\treturn true\n}\n\n// Scan a block scalar.\nfunc yaml_parser_scan_block_scalar(parser *yaml_parser_t, token *yaml_token_t, literal bool) bool {\n\t// Eat the indicator '|' or '>'.\n\tstart_mark := parser.mark\n\tskip(parser)\n\n\t// Scan the additional block scalar indicators.\n\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\treturn false\n\t}\n\n\t// Check for a chomping indicator.\n\tvar chomping, increment int\n\tif parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '-' {\n\t\t// Set the chomping method and eat the indicator.\n\t\tif parser.buffer[parser.buffer_pos] == '+' {\n\t\t\tchomping = +1\n\t\t} else {\n\t\t\tchomping = -1\n\t\t}\n\t\tskip(parser)\n\n\t\t// Check for an indentation indicator.\n\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\treturn false\n\t\t}\n\t\tif is_digit(parser.buffer, parser.buffer_pos) {\n\t\t\t// Check that the indentation is greater than 0.\n\t\t\tif parser.buffer[parser.buffer_pos] == '0' {\n\t\t\t\tyaml_parser_set_scanner_error(parser, \"while scanning a block scalar\",\n\t\t\t\t\tstart_mark, \"found an indentation indicator equal to 0\")\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\t// Get the indentation level and eat the indicator.\n\t\t\tincrement = as_digit(parser.buffer, parser.buffer_pos)\n\t\t\tskip(parser)\n\t\t}\n\n\t} else if is_digit(parser.buffer, parser.buffer_pos) {\n\t\t// Do the same as above, but in the opposite order.\n\n\t\tif parser.buffer[parser.buffer_pos] == '0' {\n\t\t\tyaml_parser_set_scanner_error(parser, \"while scanning a block scalar\",\n\t\t\t\tstart_mark, \"found an indentation indicator equal to 0\")\n\t\t\treturn false\n\t\t}\n\t\tincrement = as_digit(parser.buffer, parser.buffer_pos)\n\t\tskip(parser)\n\n\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\treturn false\n\t\t}\n\t\tif parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '-' {\n\t\t\tif parser.buffer[parser.buffer_pos] == '+' {\n\t\t\t\tchomping = +1\n\t\t\t} else {\n\t\t\t\tchomping = -1\n\t\t\t}\n\t\t\tskip(parser)\n\t\t}\n\t}\n\n\t// Eat whitespaces and comments to the end of the line.\n\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\treturn false\n\t}\n\tfor is_blank(parser.buffer, parser.buffer_pos) {\n\t\tskip(parser)\n\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\treturn false\n\t\t}\n\t}\n\tif parser.buffer[parser.buffer_pos] == '#' {\n\t\tfor !is_breakz(parser.buffer, parser.buffer_pos) {\n\t\t\tskip(parser)\n\t\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\n\t// Check if we are at the end of the line.\n\tif !is_breakz(parser.buffer, parser.buffer_pos) {\n\t\tyaml_parser_set_scanner_error(parser, \"while scanning a block scalar\",\n\t\t\tstart_mark, \"did not find expected comment or line break\")\n\t\treturn false\n\t}\n\n\t// Eat a line break.\n\tif is_break(parser.buffer, parser.buffer_pos) {\n\t\tif parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {\n\t\t\treturn false\n\t\t}\n\t\tskip_line(parser)\n\t}\n\n\tend_mark := parser.mark\n\n\t// Set the indentation level if it was specified.\n\tvar indent int\n\tif increment > 0 {\n\t\tif parser.indent >= 0 {\n\t\t\tindent = parser.indent + increment\n\t\t} else {\n\t\t\tindent = increment\n\t\t}\n\t}\n\n\t// Scan the leading line breaks and determine the indentation level if needed.\n\tvar s, leading_break, trailing_breaks []byte\n\tif !yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark) {\n\t\treturn false\n\t}\n\n\t// Scan the block scalar content.\n\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\treturn false\n\t}\n\tvar leading_blank, trailing_blank bool\n\tfor parser.mark.column == indent && !is_z(parser.buffer, parser.buffer_pos) {\n\t\t// We are at the beginning of a non-empty line.\n\n\t\t// Is it a trailing whitespace?\n\t\ttrailing_blank = is_blank(parser.buffer, parser.buffer_pos)\n\n\t\t// Check if we need to fold the leading line break.\n\t\tif !literal && !leading_blank && !trailing_blank && len(leading_break) > 0 && leading_break[0] == '\\n' {\n\t\t\t// Do we need to join the lines by space?\n\t\t\tif len(trailing_breaks) == 0 {\n\t\t\t\ts = append(s, ' ')\n\t\t\t}\n\t\t} else {\n\t\t\ts = append(s, leading_break...)\n\t\t}\n\t\tleading_break = leading_break[:0]\n\n\t\t// Append the remaining line breaks.\n\t\ts = append(s, trailing_breaks...)\n\t\ttrailing_breaks = trailing_breaks[:0]\n\n\t\t// Is it a leading whitespace?\n\t\tleading_blank = is_blank(parser.buffer, parser.buffer_pos)\n\n\t\t// Consume the current line.\n\t\tfor !is_breakz(parser.buffer, parser.buffer_pos) {\n\t\t\ts = read(parser, s)\n\t\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\n\t\t// Consume the line break.\n\t\tif parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {\n\t\t\treturn false\n\t\t}\n\n\t\tleading_break = read_line(parser, leading_break)\n\n\t\t// Eat the following indentation spaces and line breaks.\n\t\tif !yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// Chomp the tail.\n\tif chomping != -1 {\n\t\ts = append(s, leading_break...)\n\t}\n\tif chomping == 1 {\n\t\ts = append(s, trailing_breaks...)\n\t}\n\n\t// Create a token.\n\t*token = yaml_token_t{\n\t\ttyp:        yaml_SCALAR_TOKEN,\n\t\tstart_mark: start_mark,\n\t\tend_mark:   end_mark,\n\t\tvalue:      s,\n\t\tstyle:      yaml_LITERAL_SCALAR_STYLE,\n\t}\n\tif !literal {\n\t\ttoken.style = yaml_FOLDED_SCALAR_STYLE\n\t}\n\treturn true\n}\n\n// Scan indentation spaces and line breaks for a block scalar.  Determine the\n// indentation level if needed.\nfunc yaml_parser_scan_block_scalar_breaks(parser *yaml_parser_t, indent *int, breaks *[]byte, start_mark yaml_mark_t, end_mark *yaml_mark_t) bool {\n\t*end_mark = parser.mark\n\n\t// Eat the indentation spaces and line breaks.\n\tmax_indent := 0\n\tfor {\n\t\t// Eat the indentation spaces.\n\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\treturn false\n\t\t}\n\t\tfor (*indent == 0 || parser.mark.column < *indent) && is_space(parser.buffer, parser.buffer_pos) {\n\t\t\tskip(parser)\n\t\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\tif parser.mark.column > max_indent {\n\t\t\tmax_indent = parser.mark.column\n\t\t}\n\n\t\t// Check for a tab character messing the indentation.\n\t\tif (*indent == 0 || parser.mark.column < *indent) && is_tab(parser.buffer, parser.buffer_pos) {\n\t\t\treturn yaml_parser_set_scanner_error(parser, \"while scanning a block scalar\",\n\t\t\t\tstart_mark, \"found a tab character where an indentation space is expected\")\n\t\t}\n\n\t\t// Have we found a non-empty line?\n\t\tif !is_break(parser.buffer, parser.buffer_pos) {\n\t\t\tbreak\n\t\t}\n\n\t\t// Consume the line break.\n\t\tif parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {\n\t\t\treturn false\n\t\t}\n\t\t// [Go] Should really be returning breaks instead.\n\t\t*breaks = read_line(parser, *breaks)\n\t\t*end_mark = parser.mark\n\t}\n\n\t// Determine the indentation level if needed.\n\tif *indent == 0 {\n\t\t*indent = max_indent\n\t\tif *indent < parser.indent+1 {\n\t\t\t*indent = parser.indent + 1\n\t\t}\n\t\tif *indent < 1 {\n\t\t\t*indent = 1\n\t\t}\n\t}\n\treturn true\n}\n\n// Scan a quoted scalar.\nfunc yaml_parser_scan_flow_scalar(parser *yaml_parser_t, token *yaml_token_t, single bool) bool {\n\t// Eat the left quote.\n\tstart_mark := parser.mark\n\tskip(parser)\n\n\t// Consume the content of the quoted scalar.\n\tvar s, leading_break, trailing_breaks, whitespaces []byte\n\tfor {\n\t\t// Check that there are no document indicators at the beginning of the line.\n\t\tif parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) {\n\t\t\treturn false\n\t\t}\n\n\t\tif parser.mark.column == 0 &&\n\t\t\t((parser.buffer[parser.buffer_pos+0] == '-' &&\n\t\t\t\tparser.buffer[parser.buffer_pos+1] == '-' &&\n\t\t\t\tparser.buffer[parser.buffer_pos+2] == '-') ||\n\t\t\t\t(parser.buffer[parser.buffer_pos+0] == '.' &&\n\t\t\t\t\tparser.buffer[parser.buffer_pos+1] == '.' &&\n\t\t\t\t\tparser.buffer[parser.buffer_pos+2] == '.')) &&\n\t\t\tis_blankz(parser.buffer, parser.buffer_pos+3) {\n\t\t\tyaml_parser_set_scanner_error(parser, \"while scanning a quoted scalar\",\n\t\t\t\tstart_mark, \"found unexpected document indicator\")\n\t\t\treturn false\n\t\t}\n\n\t\t// Check for EOF.\n\t\tif is_z(parser.buffer, parser.buffer_pos) {\n\t\t\tyaml_parser_set_scanner_error(parser, \"while scanning a quoted scalar\",\n\t\t\t\tstart_mark, \"found unexpected end of stream\")\n\t\t\treturn false\n\t\t}\n\n\t\t// Consume non-blank characters.\n\t\tleading_blanks := false\n\t\tfor !is_blankz(parser.buffer, parser.buffer_pos) {\n\t\t\tif single && parser.buffer[parser.buffer_pos] == '\\'' && parser.buffer[parser.buffer_pos+1] == '\\'' {\n\t\t\t\t// Is is an escaped single quote.\n\t\t\t\ts = append(s, '\\'')\n\t\t\t\tskip(parser)\n\t\t\t\tskip(parser)\n\n\t\t\t} else if single && parser.buffer[parser.buffer_pos] == '\\'' {\n\t\t\t\t// It is a right single quote.\n\t\t\t\tbreak\n\t\t\t} else if !single && parser.buffer[parser.buffer_pos] == '\"' {\n\t\t\t\t// It is a right double quote.\n\t\t\t\tbreak\n\n\t\t\t} else if !single && parser.buffer[parser.buffer_pos] == '\\\\' && is_break(parser.buffer, parser.buffer_pos+1) {\n\t\t\t\t// It is an escaped line break.\n\t\t\t\tif parser.unread < 3 && !yaml_parser_update_buffer(parser, 3) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tskip(parser)\n\t\t\t\tskip_line(parser)\n\t\t\t\tleading_blanks = true\n\t\t\t\tbreak\n\n\t\t\t} else if !single && parser.buffer[parser.buffer_pos] == '\\\\' {\n\t\t\t\t// It is an escape sequence.\n\t\t\t\tcode_length := 0\n\n\t\t\t\t// Check the escape character.\n\t\t\t\tswitch parser.buffer[parser.buffer_pos+1] {\n\t\t\t\tcase '0':\n\t\t\t\t\ts = append(s, 0)\n\t\t\t\tcase 'a':\n\t\t\t\t\ts = append(s, '\\x07')\n\t\t\t\tcase 'b':\n\t\t\t\t\ts = append(s, '\\x08')\n\t\t\t\tcase 't', '\\t':\n\t\t\t\t\ts = append(s, '\\x09')\n\t\t\t\tcase 'n':\n\t\t\t\t\ts = append(s, '\\x0A')\n\t\t\t\tcase 'v':\n\t\t\t\t\ts = append(s, '\\x0B')\n\t\t\t\tcase 'f':\n\t\t\t\t\ts = append(s, '\\x0C')\n\t\t\t\tcase 'r':\n\t\t\t\t\ts = append(s, '\\x0D')\n\t\t\t\tcase 'e':\n\t\t\t\t\ts = append(s, '\\x1B')\n\t\t\t\tcase ' ':\n\t\t\t\t\ts = append(s, '\\x20')\n\t\t\t\tcase '\"':\n\t\t\t\t\ts = append(s, '\"')\n\t\t\t\tcase '\\'':\n\t\t\t\t\ts = append(s, '\\'')\n\t\t\t\tcase '\\\\':\n\t\t\t\t\ts = append(s, '\\\\')\n\t\t\t\tcase 'N': // NEL (#x85)\n\t\t\t\t\ts = append(s, '\\xC2')\n\t\t\t\t\ts = append(s, '\\x85')\n\t\t\t\tcase '_': // #xA0\n\t\t\t\t\ts = append(s, '\\xC2')\n\t\t\t\t\ts = append(s, '\\xA0')\n\t\t\t\tcase 'L': // LS (#x2028)\n\t\t\t\t\ts = append(s, '\\xE2')\n\t\t\t\t\ts = append(s, '\\x80')\n\t\t\t\t\ts = append(s, '\\xA8')\n\t\t\t\tcase 'P': // PS (#x2029)\n\t\t\t\t\ts = append(s, '\\xE2')\n\t\t\t\t\ts = append(s, '\\x80')\n\t\t\t\t\ts = append(s, '\\xA9')\n\t\t\t\tcase 'x':\n\t\t\t\t\tcode_length = 2\n\t\t\t\tcase 'u':\n\t\t\t\t\tcode_length = 4\n\t\t\t\tcase 'U':\n\t\t\t\t\tcode_length = 8\n\t\t\t\tdefault:\n\t\t\t\t\tyaml_parser_set_scanner_error(parser, \"while parsing a quoted scalar\",\n\t\t\t\t\t\tstart_mark, \"found unknown escape character\")\n\t\t\t\t\treturn false\n\t\t\t\t}\n\n\t\t\t\tskip(parser)\n\t\t\t\tskip(parser)\n\n\t\t\t\t// Consume an arbitrary escape code.\n\t\t\t\tif code_length > 0 {\n\t\t\t\t\tvar value int\n\n\t\t\t\t\t// Scan the character value.\n\t\t\t\t\tif parser.unread < code_length && !yaml_parser_update_buffer(parser, code_length) {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t\tfor k := 0; k < code_length; k++ {\n\t\t\t\t\t\tif !is_hex(parser.buffer, parser.buffer_pos+k) {\n\t\t\t\t\t\t\tyaml_parser_set_scanner_error(parser, \"while parsing a quoted scalar\",\n\t\t\t\t\t\t\t\tstart_mark, \"did not find expected hexdecimal number\")\n\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue = (value << 4) + as_hex(parser.buffer, parser.buffer_pos+k)\n\t\t\t\t\t}\n\n\t\t\t\t\t// Check the value and write the character.\n\t\t\t\t\tif (value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF {\n\t\t\t\t\t\tyaml_parser_set_scanner_error(parser, \"while parsing a quoted scalar\",\n\t\t\t\t\t\t\tstart_mark, \"found invalid Unicode character escape code\")\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t\tif value <= 0x7F {\n\t\t\t\t\t\ts = append(s, byte(value))\n\t\t\t\t\t} else if value <= 0x7FF {\n\t\t\t\t\t\ts = append(s, byte(0xC0+(value>>6)))\n\t\t\t\t\t\ts = append(s, byte(0x80+(value&0x3F)))\n\t\t\t\t\t} else if value <= 0xFFFF {\n\t\t\t\t\t\ts = append(s, byte(0xE0+(value>>12)))\n\t\t\t\t\t\ts = append(s, byte(0x80+((value>>6)&0x3F)))\n\t\t\t\t\t\ts = append(s, byte(0x80+(value&0x3F)))\n\t\t\t\t\t} else {\n\t\t\t\t\t\ts = append(s, byte(0xF0+(value>>18)))\n\t\t\t\t\t\ts = append(s, byte(0x80+((value>>12)&0x3F)))\n\t\t\t\t\t\ts = append(s, byte(0x80+((value>>6)&0x3F)))\n\t\t\t\t\t\ts = append(s, byte(0x80+(value&0x3F)))\n\t\t\t\t\t}\n\n\t\t\t\t\t// Advance the pointer.\n\t\t\t\t\tfor k := 0; k < code_length; k++ {\n\t\t\t\t\t\tskip(parser)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// It is a non-escaped non-blank character.\n\t\t\t\ts = read(parser, s)\n\t\t\t}\n\t\t\tif parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\n\t\t// Check if we are at the end of the scalar.\n\t\tif single {\n\t\t\tif parser.buffer[parser.buffer_pos] == '\\'' {\n\t\t\t\tbreak\n\t\t\t}\n\t\t} else {\n\t\t\tif parser.buffer[parser.buffer_pos] == '\"' {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t// Consume blank characters.\n\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\treturn false\n\t\t}\n\n\t\tfor is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos) {\n\t\t\tif is_blank(parser.buffer, parser.buffer_pos) {\n\t\t\t\t// Consume a space or a tab character.\n\t\t\t\tif !leading_blanks {\n\t\t\t\t\twhitespaces = read(parser, whitespaces)\n\t\t\t\t} else {\n\t\t\t\t\tskip(parser)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\n\t\t\t\t// Check if it is a first line break.\n\t\t\t\tif !leading_blanks {\n\t\t\t\t\twhitespaces = whitespaces[:0]\n\t\t\t\t\tleading_break = read_line(parser, leading_break)\n\t\t\t\t\tleading_blanks = true\n\t\t\t\t} else {\n\t\t\t\t\ttrailing_breaks = read_line(parser, trailing_breaks)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\n\t\t// Join the whitespaces or fold line breaks.\n\t\tif leading_blanks {\n\t\t\t// Do we need to fold line breaks?\n\t\t\tif len(leading_break) > 0 && leading_break[0] == '\\n' {\n\t\t\t\tif len(trailing_breaks) == 0 {\n\t\t\t\t\ts = append(s, ' ')\n\t\t\t\t} else {\n\t\t\t\t\ts = append(s, trailing_breaks...)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ts = append(s, leading_break...)\n\t\t\t\ts = append(s, trailing_breaks...)\n\t\t\t}\n\t\t\ttrailing_breaks = trailing_breaks[:0]\n\t\t\tleading_break = leading_break[:0]\n\t\t} else {\n\t\t\ts = append(s, whitespaces...)\n\t\t\twhitespaces = whitespaces[:0]\n\t\t}\n\t}\n\n\t// Eat the right quote.\n\tskip(parser)\n\tend_mark := parser.mark\n\n\t// Create a token.\n\t*token = yaml_token_t{\n\t\ttyp:        yaml_SCALAR_TOKEN,\n\t\tstart_mark: start_mark,\n\t\tend_mark:   end_mark,\n\t\tvalue:      s,\n\t\tstyle:      yaml_SINGLE_QUOTED_SCALAR_STYLE,\n\t}\n\tif !single {\n\t\ttoken.style = yaml_DOUBLE_QUOTED_SCALAR_STYLE\n\t}\n\treturn true\n}\n\n// Scan a plain scalar.\nfunc yaml_parser_scan_plain_scalar(parser *yaml_parser_t, token *yaml_token_t) bool {\n\n\tvar s, leading_break, trailing_breaks, whitespaces []byte\n\tvar leading_blanks bool\n\tvar indent = parser.indent + 1\n\n\tstart_mark := parser.mark\n\tend_mark := parser.mark\n\n\t// Consume the content of the plain scalar.\n\tfor {\n\t\t// Check for a document indicator.\n\t\tif parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) {\n\t\t\treturn false\n\t\t}\n\t\tif parser.mark.column == 0 &&\n\t\t\t((parser.buffer[parser.buffer_pos+0] == '-' &&\n\t\t\t\tparser.buffer[parser.buffer_pos+1] == '-' &&\n\t\t\t\tparser.buffer[parser.buffer_pos+2] == '-') ||\n\t\t\t\t(parser.buffer[parser.buffer_pos+0] == '.' &&\n\t\t\t\t\tparser.buffer[parser.buffer_pos+1] == '.' &&\n\t\t\t\t\tparser.buffer[parser.buffer_pos+2] == '.')) &&\n\t\t\tis_blankz(parser.buffer, parser.buffer_pos+3) {\n\t\t\tbreak\n\t\t}\n\n\t\t// Check for a comment.\n\t\tif parser.buffer[parser.buffer_pos] == '#' {\n\t\t\tbreak\n\t\t}\n\n\t\t// Consume non-blank characters.\n\t\tfor !is_blankz(parser.buffer, parser.buffer_pos) {\n\n\t\t\t// Check for 'x:x' in the flow context. TODO: Fix the test \"spec-08-13\".\n\t\t\tif parser.flow_level > 0 &&\n\t\t\t\tparser.buffer[parser.buffer_pos] == ':' &&\n\t\t\t\t!is_blankz(parser.buffer, parser.buffer_pos+1) {\n\t\t\t\tyaml_parser_set_scanner_error(parser, \"while scanning a plain scalar\",\n\t\t\t\t\tstart_mark, \"found unexpected ':'\")\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\t// Check for indicators that may end a plain scalar.\n\t\t\tif (parser.buffer[parser.buffer_pos] == ':' && is_blankz(parser.buffer, parser.buffer_pos+1)) ||\n\t\t\t\t(parser.flow_level > 0 &&\n\t\t\t\t\t(parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == ':' ||\n\t\t\t\t\t\tparser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == '[' ||\n\t\t\t\t\t\tparser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '{' ||\n\t\t\t\t\t\tparser.buffer[parser.buffer_pos] == '}')) {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t// Check if we need to join whitespaces and breaks.\n\t\t\tif leading_blanks || len(whitespaces) > 0 {\n\t\t\t\tif leading_blanks {\n\t\t\t\t\t// Do we need to fold line breaks?\n\t\t\t\t\tif leading_break[0] == '\\n' {\n\t\t\t\t\t\tif len(trailing_breaks) == 0 {\n\t\t\t\t\t\t\ts = append(s, ' ')\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ts = append(s, trailing_breaks...)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\ts = append(s, leading_break...)\n\t\t\t\t\t\ts = append(s, trailing_breaks...)\n\t\t\t\t\t}\n\t\t\t\t\ttrailing_breaks = trailing_breaks[:0]\n\t\t\t\t\tleading_break = leading_break[:0]\n\t\t\t\t\tleading_blanks = false\n\t\t\t\t} else {\n\t\t\t\t\ts = append(s, whitespaces...)\n\t\t\t\t\twhitespaces = whitespaces[:0]\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Copy the character.\n\t\t\ts = read(parser, s)\n\n\t\t\tend_mark = parser.mark\n\t\t\tif parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\n\t\t// Is it the end?\n\t\tif !(is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos)) {\n\t\t\tbreak\n\t\t}\n\n\t\t// Consume blank characters.\n\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\treturn false\n\t\t}\n\n\t\tfor is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos) {\n\t\t\tif is_blank(parser.buffer, parser.buffer_pos) {\n\n\t\t\t\t// Check for tab character that abuse indentation.\n\t\t\t\tif leading_blanks && parser.mark.column < indent && is_tab(parser.buffer, parser.buffer_pos) {\n\t\t\t\t\tyaml_parser_set_scanner_error(parser, \"while scanning a plain scalar\",\n\t\t\t\t\t\tstart_mark, \"found a tab character that violate indentation\")\n\t\t\t\t\treturn false\n\t\t\t\t}\n\n\t\t\t\t// Consume a space or a tab character.\n\t\t\t\tif !leading_blanks {\n\t\t\t\t\twhitespaces = read(parser, whitespaces)\n\t\t\t\t} else {\n\t\t\t\t\tskip(parser)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\n\t\t\t\t// Check if it is a first line break.\n\t\t\t\tif !leading_blanks {\n\t\t\t\t\twhitespaces = whitespaces[:0]\n\t\t\t\t\tleading_break = read_line(parser, leading_break)\n\t\t\t\t\tleading_blanks = true\n\t\t\t\t} else {\n\t\t\t\t\ttrailing_breaks = read_line(parser, trailing_breaks)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\n\t\t// Check indentation level.\n\t\tif parser.flow_level == 0 && parser.mark.column < indent {\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// Create a token.\n\t*token = yaml_token_t{\n\t\ttyp:        yaml_SCALAR_TOKEN,\n\t\tstart_mark: start_mark,\n\t\tend_mark:   end_mark,\n\t\tvalue:      s,\n\t\tstyle:      yaml_PLAIN_SCALAR_STYLE,\n\t}\n\n\t// Note that we change the 'simple_key_allowed' flag.\n\tif leading_blanks {\n\t\tparser.simple_key_allowed = true\n\t}\n\treturn true\n}\n"
  },
  {
    "path": "vendor/gopkg.in/yaml.v2/sorter.go",
    "content": "package yaml\n\nimport (\n\t\"reflect\"\n\t\"unicode\"\n)\n\ntype keyList []reflect.Value\n\nfunc (l keyList) Len() int      { return len(l) }\nfunc (l keyList) Swap(i, j int) { l[i], l[j] = l[j], l[i] }\nfunc (l keyList) Less(i, j int) bool {\n\ta := l[i]\n\tb := l[j]\n\tak := a.Kind()\n\tbk := b.Kind()\n\tfor (ak == reflect.Interface || ak == reflect.Ptr) && !a.IsNil() {\n\t\ta = a.Elem()\n\t\tak = a.Kind()\n\t}\n\tfor (bk == reflect.Interface || bk == reflect.Ptr) && !b.IsNil() {\n\t\tb = b.Elem()\n\t\tbk = b.Kind()\n\t}\n\taf, aok := keyFloat(a)\n\tbf, bok := keyFloat(b)\n\tif aok && bok {\n\t\tif af != bf {\n\t\t\treturn af < bf\n\t\t}\n\t\tif ak != bk {\n\t\t\treturn ak < bk\n\t\t}\n\t\treturn numLess(a, b)\n\t}\n\tif ak != reflect.String || bk != reflect.String {\n\t\treturn ak < bk\n\t}\n\tar, br := []rune(a.String()), []rune(b.String())\n\tfor i := 0; i < len(ar) && i < len(br); i++ {\n\t\tif ar[i] == br[i] {\n\t\t\tcontinue\n\t\t}\n\t\tal := unicode.IsLetter(ar[i])\n\t\tbl := unicode.IsLetter(br[i])\n\t\tif al && bl {\n\t\t\treturn ar[i] < br[i]\n\t\t}\n\t\tif al || bl {\n\t\t\treturn bl\n\t\t}\n\t\tvar ai, bi int\n\t\tvar an, bn int64\n\t\tfor ai = i; ai < len(ar) && unicode.IsDigit(ar[ai]); ai++ {\n\t\t\tan = an*10 + int64(ar[ai]-'0')\n\t\t}\n\t\tfor bi = i; bi < len(br) && unicode.IsDigit(br[bi]); bi++ {\n\t\t\tbn = bn*10 + int64(br[bi]-'0')\n\t\t}\n\t\tif an != bn {\n\t\t\treturn an < bn\n\t\t}\n\t\tif ai != bi {\n\t\t\treturn ai < bi\n\t\t}\n\t\treturn ar[i] < br[i]\n\t}\n\treturn len(ar) < len(br)\n}\n\n// keyFloat returns a float value for v if it is a number/bool\n// and whether it is a number/bool or not.\nfunc keyFloat(v reflect.Value) (f float64, ok bool) {\n\tswitch v.Kind() {\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn float64(v.Int()), true\n\tcase reflect.Float32, reflect.Float64:\n\t\treturn v.Float(), true\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\treturn float64(v.Uint()), true\n\tcase reflect.Bool:\n\t\tif v.Bool() {\n\t\t\treturn 1, true\n\t\t}\n\t\treturn 0, true\n\t}\n\treturn 0, false\n}\n\n// numLess returns whether a < b.\n// a and b must necessarily have the same kind.\nfunc numLess(a, b reflect.Value) bool {\n\tswitch a.Kind() {\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn a.Int() < b.Int()\n\tcase reflect.Float32, reflect.Float64:\n\t\treturn a.Float() < b.Float()\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\treturn a.Uint() < b.Uint()\n\tcase reflect.Bool:\n\t\treturn !a.Bool() && b.Bool()\n\t}\n\tpanic(\"not a number\")\n}\n"
  },
  {
    "path": "vendor/gopkg.in/yaml.v2/suite_test.go",
    "content": "package yaml_test\n\nimport (\n\t. \"gopkg.in/check.v1\"\n\t\"testing\"\n)\n\nfunc Test(t *testing.T) { TestingT(t) }\n\ntype S struct{}\n\nvar _ = Suite(&S{})\n"
  },
  {
    "path": "vendor/gopkg.in/yaml.v2/writerc.go",
    "content": "package yaml\n\n// Set the writer error and return false.\nfunc yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool {\n\temitter.error = yaml_WRITER_ERROR\n\temitter.problem = problem\n\treturn false\n}\n\n// Flush the output buffer.\nfunc yaml_emitter_flush(emitter *yaml_emitter_t) bool {\n\tif emitter.write_handler == nil {\n\t\tpanic(\"write handler not set\")\n\t}\n\n\t// Check if the buffer is empty.\n\tif emitter.buffer_pos == 0 {\n\t\treturn true\n\t}\n\n\t// If the output encoding is UTF-8, we don't need to recode the buffer.\n\tif emitter.encoding == yaml_UTF8_ENCODING {\n\t\tif err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil {\n\t\t\treturn yaml_emitter_set_writer_error(emitter, \"write error: \"+err.Error())\n\t\t}\n\t\temitter.buffer_pos = 0\n\t\treturn true\n\t}\n\n\t// Recode the buffer into the raw buffer.\n\tvar low, high int\n\tif emitter.encoding == yaml_UTF16LE_ENCODING {\n\t\tlow, high = 0, 1\n\t} else {\n\t\thigh, low = 1, 0\n\t}\n\n\tpos := 0\n\tfor pos < emitter.buffer_pos {\n\t\t// See the \"reader.c\" code for more details on UTF-8 encoding.  Note\n\t\t// that we assume that the buffer contains a valid UTF-8 sequence.\n\n\t\t// Read the next UTF-8 character.\n\t\toctet := emitter.buffer[pos]\n\n\t\tvar w int\n\t\tvar value rune\n\t\tswitch {\n\t\tcase octet&0x80 == 0x00:\n\t\t\tw, value = 1, rune(octet&0x7F)\n\t\tcase octet&0xE0 == 0xC0:\n\t\t\tw, value = 2, rune(octet&0x1F)\n\t\tcase octet&0xF0 == 0xE0:\n\t\t\tw, value = 3, rune(octet&0x0F)\n\t\tcase octet&0xF8 == 0xF0:\n\t\t\tw, value = 4, rune(octet&0x07)\n\t\t}\n\t\tfor k := 1; k < w; k++ {\n\t\t\toctet = emitter.buffer[pos+k]\n\t\t\tvalue = (value << 6) + (rune(octet) & 0x3F)\n\t\t}\n\t\tpos += w\n\n\t\t// Write the character.\n\t\tif value < 0x10000 {\n\t\t\tvar b [2]byte\n\t\t\tb[high] = byte(value >> 8)\n\t\t\tb[low] = byte(value & 0xFF)\n\t\t\temitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1])\n\t\t} else {\n\t\t\t// Write the character using a surrogate pair (check \"reader.c\").\n\t\t\tvar b [4]byte\n\t\t\tvalue -= 0x10000\n\t\t\tb[high] = byte(0xD8 + (value >> 18))\n\t\t\tb[low] = byte((value >> 10) & 0xFF)\n\t\t\tb[high+2] = byte(0xDC + ((value >> 8) & 0xFF))\n\t\t\tb[low+2] = byte(value & 0xFF)\n\t\t\temitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1], b[2], b[3])\n\t\t}\n\t}\n\n\t// Write the raw buffer.\n\tif err := emitter.write_handler(emitter, emitter.raw_buffer); err != nil {\n\t\treturn yaml_emitter_set_writer_error(emitter, \"write error: \"+err.Error())\n\t}\n\temitter.buffer_pos = 0\n\temitter.raw_buffer = emitter.raw_buffer[:0]\n\treturn true\n}\n"
  },
  {
    "path": "vendor/gopkg.in/yaml.v2/yaml.go",
    "content": "// Package yaml implements YAML support for the Go language.\n//\n// Source code and other details for the project are available at GitHub:\n//\n//   https://github.com/go-yaml/yaml\n//\npackage yaml\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"reflect\"\n\t\"strings\"\n\t\"sync\"\n)\n\n// MapSlice encodes and decodes as a YAML map.\n// The order of keys is preserved when encoding and decoding.\ntype MapSlice []MapItem\n\n// MapItem is an item in a MapSlice.\ntype MapItem struct {\n\tKey, Value interface{}\n}\n\n// The Unmarshaler interface may be implemented by types to customize their\n// behavior when being unmarshaled from a YAML document. The UnmarshalYAML\n// method receives a function that may be called to unmarshal the original\n// YAML value into a field or variable. It is safe to call the unmarshal\n// function parameter more than once if necessary.\ntype Unmarshaler interface {\n\tUnmarshalYAML(unmarshal func(interface{}) error) error\n}\n\n// The Marshaler interface may be implemented by types to customize their\n// behavior when being marshaled into a YAML document. The returned value\n// is marshaled in place of the original value implementing Marshaler.\n//\n// If an error is returned by MarshalYAML, the marshaling procedure stops\n// and returns with the provided error.\ntype Marshaler interface {\n\tMarshalYAML() (interface{}, error)\n}\n\n// Unmarshal decodes the first document found within the in byte slice\n// and assigns decoded values into the out value.\n//\n// Maps and pointers (to a struct, string, int, etc) are accepted as out\n// values. If an internal pointer within a struct is not initialized,\n// the yaml package will initialize it if necessary for unmarshalling\n// the provided data. The out parameter must not be nil.\n//\n// The type of the decoded values should be compatible with the respective\n// values in out. If one or more values cannot be decoded due to a type\n// mismatches, decoding continues partially until the end of the YAML\n// content, and a *yaml.TypeError is returned with details for all\n// missed values.\n//\n// Struct fields are only unmarshalled if they are exported (have an\n// upper case first letter), and are unmarshalled using the field name\n// lowercased as the default key. Custom keys may be defined via the\n// \"yaml\" name in the field tag: the content preceding the first comma\n// is used as the key, and the following comma-separated options are\n// used to tweak the marshalling process (see Marshal).\n// Conflicting names result in a runtime error.\n//\n// For example:\n//\n//     type T struct {\n//         F int `yaml:\"a,omitempty\"`\n//         B int\n//     }\n//     var t T\n//     yaml.Unmarshal([]byte(\"a: 1\\nb: 2\"), &t)\n//\n// See the documentation of Marshal for the format of tags and a list of\n// supported tag options.\n//\nfunc Unmarshal(in []byte, out interface{}) (err error) {\n\treturn unmarshal(in, out, false)\n}\n\n// UnmarshalStrict is like Unmarshal except that any fields that are found\n// in the data that do not have corresponding struct members will result in\n// an error.\nfunc UnmarshalStrict(in []byte, out interface{}) (err error) {\n\treturn unmarshal(in, out, true)\n}\n\nfunc unmarshal(in []byte, out interface{}, strict bool) (err error) {\n\tdefer handleErr(&err)\n\td := newDecoder(strict)\n\tp := newParser(in)\n\tdefer p.destroy()\n\tnode := p.parse()\n\tif node != nil {\n\t\tv := reflect.ValueOf(out)\n\t\tif v.Kind() == reflect.Ptr && !v.IsNil() {\n\t\t\tv = v.Elem()\n\t\t}\n\t\td.unmarshal(node, v)\n\t}\n\tif len(d.terrors) > 0 {\n\t\treturn &TypeError{d.terrors}\n\t}\n\treturn nil\n}\n\n// Marshal serializes the value provided into a YAML document. The structure\n// of the generated document will reflect the structure of the value itself.\n// Maps and pointers (to struct, string, int, etc) are accepted as the in value.\n//\n// Struct fields are only unmarshalled if they are exported (have an upper case\n// first letter), and are unmarshalled using the field name lowercased as the\n// default key. Custom keys may be defined via the \"yaml\" name in the field\n// tag: the content preceding the first comma is used as the key, and the\n// following comma-separated options are used to tweak the marshalling process.\n// Conflicting names result in a runtime error.\n//\n// The field tag format accepted is:\n//\n//     `(...) yaml:\"[<key>][,<flag1>[,<flag2>]]\" (...)`\n//\n// The following flags are currently supported:\n//\n//     omitempty    Only include the field if it's not set to the zero\n//                  value for the type or to empty slices or maps.\n//                  Does not apply to zero valued structs.\n//\n//     flow         Marshal using a flow style (useful for structs,\n//                  sequences and maps).\n//\n//     inline       Inline the field, which must be a struct or a map,\n//                  causing all of its fields or keys to be processed as if\n//                  they were part of the outer struct. For maps, keys must\n//                  not conflict with the yaml keys of other struct fields.\n//\n// In addition, if the key is \"-\", the field is ignored.\n//\n// For example:\n//\n//     type T struct {\n//         F int \"a,omitempty\"\n//         B int\n//     }\n//     yaml.Marshal(&T{B: 2}) // Returns \"b: 2\\n\"\n//     yaml.Marshal(&T{F: 1}} // Returns \"a: 1\\nb: 0\\n\"\n//\nfunc Marshal(in interface{}) (out []byte, err error) {\n\tdefer handleErr(&err)\n\te := newEncoder()\n\tdefer e.destroy()\n\te.marshal(\"\", reflect.ValueOf(in))\n\te.finish()\n\tout = e.out\n\treturn\n}\n\nfunc handleErr(err *error) {\n\tif v := recover(); v != nil {\n\t\tif e, ok := v.(yamlError); ok {\n\t\t\t*err = e.err\n\t\t} else {\n\t\t\tpanic(v)\n\t\t}\n\t}\n}\n\ntype yamlError struct {\n\terr error\n}\n\nfunc fail(err error) {\n\tpanic(yamlError{err})\n}\n\nfunc failf(format string, args ...interface{}) {\n\tpanic(yamlError{fmt.Errorf(\"yaml: \"+format, args...)})\n}\n\n// A TypeError is returned by Unmarshal when one or more fields in\n// the YAML document cannot be properly decoded into the requested\n// types. When this error is returned, the value is still\n// unmarshaled partially.\ntype TypeError struct {\n\tErrors []string\n}\n\nfunc (e *TypeError) Error() string {\n\treturn fmt.Sprintf(\"yaml: unmarshal errors:\\n  %s\", strings.Join(e.Errors, \"\\n  \"))\n}\n\n// --------------------------------------------------------------------------\n// Maintain a mapping of keys to structure field indexes\n\n// The code in this section was copied from mgo/bson.\n\n// structInfo holds details for the serialization of fields of\n// a given struct.\ntype structInfo struct {\n\tFieldsMap  map[string]fieldInfo\n\tFieldsList []fieldInfo\n\n\t// InlineMap is the number of the field in the struct that\n\t// contains an ,inline map, or -1 if there's none.\n\tInlineMap int\n}\n\ntype fieldInfo struct {\n\tKey       string\n\tNum       int\n\tOmitEmpty bool\n\tFlow      bool\n\n\t// Inline holds the field index if the field is part of an inlined struct.\n\tInline []int\n}\n\nvar structMap = make(map[reflect.Type]*structInfo)\nvar fieldMapMutex sync.RWMutex\n\nfunc getStructInfo(st reflect.Type) (*structInfo, error) {\n\tfieldMapMutex.RLock()\n\tsinfo, found := structMap[st]\n\tfieldMapMutex.RUnlock()\n\tif found {\n\t\treturn sinfo, nil\n\t}\n\n\tn := st.NumField()\n\tfieldsMap := make(map[string]fieldInfo)\n\tfieldsList := make([]fieldInfo, 0, n)\n\tinlineMap := -1\n\tfor i := 0; i != n; i++ {\n\t\tfield := st.Field(i)\n\t\tif field.PkgPath != \"\" && !field.Anonymous {\n\t\t\tcontinue // Private field\n\t\t}\n\n\t\tinfo := fieldInfo{Num: i}\n\n\t\ttag := field.Tag.Get(\"yaml\")\n\t\tif tag == \"\" && strings.Index(string(field.Tag), \":\") < 0 {\n\t\t\ttag = string(field.Tag)\n\t\t}\n\t\tif tag == \"-\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tinline := false\n\t\tfields := strings.Split(tag, \",\")\n\t\tif len(fields) > 1 {\n\t\t\tfor _, flag := range fields[1:] {\n\t\t\t\tswitch flag {\n\t\t\t\tcase \"omitempty\":\n\t\t\t\t\tinfo.OmitEmpty = true\n\t\t\t\tcase \"flow\":\n\t\t\t\t\tinfo.Flow = true\n\t\t\t\tcase \"inline\":\n\t\t\t\t\tinline = true\n\t\t\t\tdefault:\n\t\t\t\t\treturn nil, errors.New(fmt.Sprintf(\"Unsupported flag %q in tag %q of type %s\", flag, tag, st))\n\t\t\t\t}\n\t\t\t}\n\t\t\ttag = fields[0]\n\t\t}\n\n\t\tif inline {\n\t\t\tswitch field.Type.Kind() {\n\t\t\tcase reflect.Map:\n\t\t\t\tif inlineMap >= 0 {\n\t\t\t\t\treturn nil, errors.New(\"Multiple ,inline maps in struct \" + st.String())\n\t\t\t\t}\n\t\t\t\tif field.Type.Key() != reflect.TypeOf(\"\") {\n\t\t\t\t\treturn nil, errors.New(\"Option ,inline needs a map with string keys in struct \" + st.String())\n\t\t\t\t}\n\t\t\t\tinlineMap = info.Num\n\t\t\tcase reflect.Struct:\n\t\t\t\tsinfo, err := getStructInfo(field.Type)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tfor _, finfo := range sinfo.FieldsList {\n\t\t\t\t\tif _, found := fieldsMap[finfo.Key]; found {\n\t\t\t\t\t\tmsg := \"Duplicated key '\" + finfo.Key + \"' in struct \" + st.String()\n\t\t\t\t\t\treturn nil, errors.New(msg)\n\t\t\t\t\t}\n\t\t\t\t\tif finfo.Inline == nil {\n\t\t\t\t\t\tfinfo.Inline = []int{i, finfo.Num}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfinfo.Inline = append([]int{i}, finfo.Inline...)\n\t\t\t\t\t}\n\t\t\t\t\tfieldsMap[finfo.Key] = finfo\n\t\t\t\t\tfieldsList = append(fieldsList, finfo)\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\t//return nil, errors.New(\"Option ,inline needs a struct value or map field\")\n\t\t\t\treturn nil, errors.New(\"Option ,inline needs a struct value field\")\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tif tag != \"\" {\n\t\t\tinfo.Key = tag\n\t\t} else {\n\t\t\tinfo.Key = strings.ToLower(field.Name)\n\t\t}\n\n\t\tif _, found = fieldsMap[info.Key]; found {\n\t\t\tmsg := \"Duplicated key '\" + info.Key + \"' in struct \" + st.String()\n\t\t\treturn nil, errors.New(msg)\n\t\t}\n\n\t\tfieldsList = append(fieldsList, info)\n\t\tfieldsMap[info.Key] = info\n\t}\n\n\tsinfo = &structInfo{fieldsMap, fieldsList, inlineMap}\n\n\tfieldMapMutex.Lock()\n\tstructMap[st] = sinfo\n\tfieldMapMutex.Unlock()\n\treturn sinfo, nil\n}\n\nfunc isZero(v reflect.Value) bool {\n\tswitch v.Kind() {\n\tcase reflect.String:\n\t\treturn len(v.String()) == 0\n\tcase reflect.Interface, reflect.Ptr:\n\t\treturn v.IsNil()\n\tcase reflect.Slice:\n\t\treturn v.Len() == 0\n\tcase reflect.Map:\n\t\treturn v.Len() == 0\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn v.Int() == 0\n\tcase reflect.Float32, reflect.Float64:\n\t\treturn v.Float() == 0\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\treturn v.Uint() == 0\n\tcase reflect.Bool:\n\t\treturn !v.Bool()\n\tcase reflect.Struct:\n\t\tvt := v.Type()\n\t\tfor i := v.NumField() - 1; i >= 0; i-- {\n\t\t\tif vt.Field(i).PkgPath != \"\" {\n\t\t\t\tcontinue // Private field\n\t\t\t}\n\t\t\tif !isZero(v.Field(i)) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\treturn false\n}\n"
  },
  {
    "path": "vendor/gopkg.in/yaml.v2/yamlh.go",
    "content": "package yaml\n\nimport (\n\t\"io\"\n)\n\n// The version directive data.\ntype yaml_version_directive_t struct {\n\tmajor int8 // The major version number.\n\tminor int8 // The minor version number.\n}\n\n// The tag directive data.\ntype yaml_tag_directive_t struct {\n\thandle []byte // The tag handle.\n\tprefix []byte // The tag prefix.\n}\n\ntype yaml_encoding_t int\n\n// The stream encoding.\nconst (\n\t// Let the parser choose the encoding.\n\tyaml_ANY_ENCODING yaml_encoding_t = iota\n\n\tyaml_UTF8_ENCODING    // The default UTF-8 encoding.\n\tyaml_UTF16LE_ENCODING // The UTF-16-LE encoding with BOM.\n\tyaml_UTF16BE_ENCODING // The UTF-16-BE encoding with BOM.\n)\n\ntype yaml_break_t int\n\n// Line break types.\nconst (\n\t// Let the parser choose the break type.\n\tyaml_ANY_BREAK yaml_break_t = iota\n\n\tyaml_CR_BREAK   // Use CR for line breaks (Mac style).\n\tyaml_LN_BREAK   // Use LN for line breaks (Unix style).\n\tyaml_CRLN_BREAK // Use CR LN for line breaks (DOS style).\n)\n\ntype yaml_error_type_t int\n\n// Many bad things could happen with the parser and emitter.\nconst (\n\t// No error is produced.\n\tyaml_NO_ERROR yaml_error_type_t = iota\n\n\tyaml_MEMORY_ERROR   // Cannot allocate or reallocate a block of memory.\n\tyaml_READER_ERROR   // Cannot read or decode the input stream.\n\tyaml_SCANNER_ERROR  // Cannot scan the input stream.\n\tyaml_PARSER_ERROR   // Cannot parse the input stream.\n\tyaml_COMPOSER_ERROR // Cannot compose a YAML document.\n\tyaml_WRITER_ERROR   // Cannot write to the output stream.\n\tyaml_EMITTER_ERROR  // Cannot emit a YAML stream.\n)\n\n// The pointer position.\ntype yaml_mark_t struct {\n\tindex  int // The position index.\n\tline   int // The position line.\n\tcolumn int // The position column.\n}\n\n// Node Styles\n\ntype yaml_style_t int8\n\ntype yaml_scalar_style_t yaml_style_t\n\n// Scalar styles.\nconst (\n\t// Let the emitter choose the style.\n\tyaml_ANY_SCALAR_STYLE yaml_scalar_style_t = iota\n\n\tyaml_PLAIN_SCALAR_STYLE         // The plain scalar style.\n\tyaml_SINGLE_QUOTED_SCALAR_STYLE // The single-quoted scalar style.\n\tyaml_DOUBLE_QUOTED_SCALAR_STYLE // The double-quoted scalar style.\n\tyaml_LITERAL_SCALAR_STYLE       // The literal scalar style.\n\tyaml_FOLDED_SCALAR_STYLE        // The folded scalar style.\n)\n\ntype yaml_sequence_style_t yaml_style_t\n\n// Sequence styles.\nconst (\n\t// Let the emitter choose the style.\n\tyaml_ANY_SEQUENCE_STYLE yaml_sequence_style_t = iota\n\n\tyaml_BLOCK_SEQUENCE_STYLE // The block sequence style.\n\tyaml_FLOW_SEQUENCE_STYLE  // The flow sequence style.\n)\n\ntype yaml_mapping_style_t yaml_style_t\n\n// Mapping styles.\nconst (\n\t// Let the emitter choose the style.\n\tyaml_ANY_MAPPING_STYLE yaml_mapping_style_t = iota\n\n\tyaml_BLOCK_MAPPING_STYLE // The block mapping style.\n\tyaml_FLOW_MAPPING_STYLE  // The flow mapping style.\n)\n\n// Tokens\n\ntype yaml_token_type_t int\n\n// Token types.\nconst (\n\t// An empty token.\n\tyaml_NO_TOKEN yaml_token_type_t = iota\n\n\tyaml_STREAM_START_TOKEN // A STREAM-START token.\n\tyaml_STREAM_END_TOKEN   // A STREAM-END token.\n\n\tyaml_VERSION_DIRECTIVE_TOKEN // A VERSION-DIRECTIVE token.\n\tyaml_TAG_DIRECTIVE_TOKEN     // A TAG-DIRECTIVE token.\n\tyaml_DOCUMENT_START_TOKEN    // A DOCUMENT-START token.\n\tyaml_DOCUMENT_END_TOKEN      // A DOCUMENT-END token.\n\n\tyaml_BLOCK_SEQUENCE_START_TOKEN // A BLOCK-SEQUENCE-START token.\n\tyaml_BLOCK_MAPPING_START_TOKEN  // A BLOCK-SEQUENCE-END token.\n\tyaml_BLOCK_END_TOKEN            // A BLOCK-END token.\n\n\tyaml_FLOW_SEQUENCE_START_TOKEN // A FLOW-SEQUENCE-START token.\n\tyaml_FLOW_SEQUENCE_END_TOKEN   // A FLOW-SEQUENCE-END token.\n\tyaml_FLOW_MAPPING_START_TOKEN  // A FLOW-MAPPING-START token.\n\tyaml_FLOW_MAPPING_END_TOKEN    // A FLOW-MAPPING-END token.\n\n\tyaml_BLOCK_ENTRY_TOKEN // A BLOCK-ENTRY token.\n\tyaml_FLOW_ENTRY_TOKEN  // A FLOW-ENTRY token.\n\tyaml_KEY_TOKEN         // A KEY token.\n\tyaml_VALUE_TOKEN       // A VALUE token.\n\n\tyaml_ALIAS_TOKEN  // An ALIAS token.\n\tyaml_ANCHOR_TOKEN // An ANCHOR token.\n\tyaml_TAG_TOKEN    // A TAG token.\n\tyaml_SCALAR_TOKEN // A SCALAR token.\n)\n\nfunc (tt yaml_token_type_t) String() string {\n\tswitch tt {\n\tcase yaml_NO_TOKEN:\n\t\treturn \"yaml_NO_TOKEN\"\n\tcase yaml_STREAM_START_TOKEN:\n\t\treturn \"yaml_STREAM_START_TOKEN\"\n\tcase yaml_STREAM_END_TOKEN:\n\t\treturn \"yaml_STREAM_END_TOKEN\"\n\tcase yaml_VERSION_DIRECTIVE_TOKEN:\n\t\treturn \"yaml_VERSION_DIRECTIVE_TOKEN\"\n\tcase yaml_TAG_DIRECTIVE_TOKEN:\n\t\treturn \"yaml_TAG_DIRECTIVE_TOKEN\"\n\tcase yaml_DOCUMENT_START_TOKEN:\n\t\treturn \"yaml_DOCUMENT_START_TOKEN\"\n\tcase yaml_DOCUMENT_END_TOKEN:\n\t\treturn \"yaml_DOCUMENT_END_TOKEN\"\n\tcase yaml_BLOCK_SEQUENCE_START_TOKEN:\n\t\treturn \"yaml_BLOCK_SEQUENCE_START_TOKEN\"\n\tcase yaml_BLOCK_MAPPING_START_TOKEN:\n\t\treturn \"yaml_BLOCK_MAPPING_START_TOKEN\"\n\tcase yaml_BLOCK_END_TOKEN:\n\t\treturn \"yaml_BLOCK_END_TOKEN\"\n\tcase yaml_FLOW_SEQUENCE_START_TOKEN:\n\t\treturn \"yaml_FLOW_SEQUENCE_START_TOKEN\"\n\tcase yaml_FLOW_SEQUENCE_END_TOKEN:\n\t\treturn \"yaml_FLOW_SEQUENCE_END_TOKEN\"\n\tcase yaml_FLOW_MAPPING_START_TOKEN:\n\t\treturn \"yaml_FLOW_MAPPING_START_TOKEN\"\n\tcase yaml_FLOW_MAPPING_END_TOKEN:\n\t\treturn \"yaml_FLOW_MAPPING_END_TOKEN\"\n\tcase yaml_BLOCK_ENTRY_TOKEN:\n\t\treturn \"yaml_BLOCK_ENTRY_TOKEN\"\n\tcase yaml_FLOW_ENTRY_TOKEN:\n\t\treturn \"yaml_FLOW_ENTRY_TOKEN\"\n\tcase yaml_KEY_TOKEN:\n\t\treturn \"yaml_KEY_TOKEN\"\n\tcase yaml_VALUE_TOKEN:\n\t\treturn \"yaml_VALUE_TOKEN\"\n\tcase yaml_ALIAS_TOKEN:\n\t\treturn \"yaml_ALIAS_TOKEN\"\n\tcase yaml_ANCHOR_TOKEN:\n\t\treturn \"yaml_ANCHOR_TOKEN\"\n\tcase yaml_TAG_TOKEN:\n\t\treturn \"yaml_TAG_TOKEN\"\n\tcase yaml_SCALAR_TOKEN:\n\t\treturn \"yaml_SCALAR_TOKEN\"\n\t}\n\treturn \"<unknown token>\"\n}\n\n// The token structure.\ntype yaml_token_t struct {\n\t// The token type.\n\ttyp yaml_token_type_t\n\n\t// The start/end of the token.\n\tstart_mark, end_mark yaml_mark_t\n\n\t// The stream encoding (for yaml_STREAM_START_TOKEN).\n\tencoding yaml_encoding_t\n\n\t// The alias/anchor/scalar value or tag/tag directive handle\n\t// (for yaml_ALIAS_TOKEN, yaml_ANCHOR_TOKEN, yaml_SCALAR_TOKEN, yaml_TAG_TOKEN, yaml_TAG_DIRECTIVE_TOKEN).\n\tvalue []byte\n\n\t// The tag suffix (for yaml_TAG_TOKEN).\n\tsuffix []byte\n\n\t// The tag directive prefix (for yaml_TAG_DIRECTIVE_TOKEN).\n\tprefix []byte\n\n\t// The scalar style (for yaml_SCALAR_TOKEN).\n\tstyle yaml_scalar_style_t\n\n\t// The version directive major/minor (for yaml_VERSION_DIRECTIVE_TOKEN).\n\tmajor, minor int8\n}\n\n// Events\n\ntype yaml_event_type_t int8\n\n// Event types.\nconst (\n\t// An empty event.\n\tyaml_NO_EVENT yaml_event_type_t = iota\n\n\tyaml_STREAM_START_EVENT   // A STREAM-START event.\n\tyaml_STREAM_END_EVENT     // A STREAM-END event.\n\tyaml_DOCUMENT_START_EVENT // A DOCUMENT-START event.\n\tyaml_DOCUMENT_END_EVENT   // A DOCUMENT-END event.\n\tyaml_ALIAS_EVENT          // An ALIAS event.\n\tyaml_SCALAR_EVENT         // A SCALAR event.\n\tyaml_SEQUENCE_START_EVENT // A SEQUENCE-START event.\n\tyaml_SEQUENCE_END_EVENT   // A SEQUENCE-END event.\n\tyaml_MAPPING_START_EVENT  // A MAPPING-START event.\n\tyaml_MAPPING_END_EVENT    // A MAPPING-END event.\n)\n\n// The event structure.\ntype yaml_event_t struct {\n\n\t// The event type.\n\ttyp yaml_event_type_t\n\n\t// The start and end of the event.\n\tstart_mark, end_mark yaml_mark_t\n\n\t// The document encoding (for yaml_STREAM_START_EVENT).\n\tencoding yaml_encoding_t\n\n\t// The version directive (for yaml_DOCUMENT_START_EVENT).\n\tversion_directive *yaml_version_directive_t\n\n\t// The list of tag directives (for yaml_DOCUMENT_START_EVENT).\n\ttag_directives []yaml_tag_directive_t\n\n\t// The anchor (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT, yaml_ALIAS_EVENT).\n\tanchor []byte\n\n\t// The tag (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT).\n\ttag []byte\n\n\t// The scalar value (for yaml_SCALAR_EVENT).\n\tvalue []byte\n\n\t// Is the document start/end indicator implicit, or the tag optional?\n\t// (for yaml_DOCUMENT_START_EVENT, yaml_DOCUMENT_END_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT, yaml_SCALAR_EVENT).\n\timplicit bool\n\n\t// Is the tag optional for any non-plain style? (for yaml_SCALAR_EVENT).\n\tquoted_implicit bool\n\n\t// The style (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT).\n\tstyle yaml_style_t\n}\n\nfunc (e *yaml_event_t) scalar_style() yaml_scalar_style_t     { return yaml_scalar_style_t(e.style) }\nfunc (e *yaml_event_t) sequence_style() yaml_sequence_style_t { return yaml_sequence_style_t(e.style) }\nfunc (e *yaml_event_t) mapping_style() yaml_mapping_style_t   { return yaml_mapping_style_t(e.style) }\n\n// Nodes\n\nconst (\n\tyaml_NULL_TAG      = \"tag:yaml.org,2002:null\"      // The tag !!null with the only possible value: null.\n\tyaml_BOOL_TAG      = \"tag:yaml.org,2002:bool\"      // The tag !!bool with the values: true and false.\n\tyaml_STR_TAG       = \"tag:yaml.org,2002:str\"       // The tag !!str for string values.\n\tyaml_INT_TAG       = \"tag:yaml.org,2002:int\"       // The tag !!int for integer values.\n\tyaml_FLOAT_TAG     = \"tag:yaml.org,2002:float\"     // The tag !!float for float values.\n\tyaml_TIMESTAMP_TAG = \"tag:yaml.org,2002:timestamp\" // The tag !!timestamp for date and time values.\n\n\tyaml_SEQ_TAG = \"tag:yaml.org,2002:seq\" // The tag !!seq is used to denote sequences.\n\tyaml_MAP_TAG = \"tag:yaml.org,2002:map\" // The tag !!map is used to denote mapping.\n\n\t// Not in original libyaml.\n\tyaml_BINARY_TAG = \"tag:yaml.org,2002:binary\"\n\tyaml_MERGE_TAG  = \"tag:yaml.org,2002:merge\"\n\n\tyaml_DEFAULT_SCALAR_TAG   = yaml_STR_TAG // The default scalar tag is !!str.\n\tyaml_DEFAULT_SEQUENCE_TAG = yaml_SEQ_TAG // The default sequence tag is !!seq.\n\tyaml_DEFAULT_MAPPING_TAG  = yaml_MAP_TAG // The default mapping tag is !!map.\n)\n\ntype yaml_node_type_t int\n\n// Node types.\nconst (\n\t// An empty node.\n\tyaml_NO_NODE yaml_node_type_t = iota\n\n\tyaml_SCALAR_NODE   // A scalar node.\n\tyaml_SEQUENCE_NODE // A sequence node.\n\tyaml_MAPPING_NODE  // A mapping node.\n)\n\n// An element of a sequence node.\ntype yaml_node_item_t int\n\n// An element of a mapping node.\ntype yaml_node_pair_t struct {\n\tkey   int // The key of the element.\n\tvalue int // The value of the element.\n}\n\n// The node structure.\ntype yaml_node_t struct {\n\ttyp yaml_node_type_t // The node type.\n\ttag []byte           // The node tag.\n\n\t// The node data.\n\n\t// The scalar parameters (for yaml_SCALAR_NODE).\n\tscalar struct {\n\t\tvalue  []byte              // The scalar value.\n\t\tlength int                 // The length of the scalar value.\n\t\tstyle  yaml_scalar_style_t // The scalar style.\n\t}\n\n\t// The sequence parameters (for YAML_SEQUENCE_NODE).\n\tsequence struct {\n\t\titems_data []yaml_node_item_t    // The stack of sequence items.\n\t\tstyle      yaml_sequence_style_t // The sequence style.\n\t}\n\n\t// The mapping parameters (for yaml_MAPPING_NODE).\n\tmapping struct {\n\t\tpairs_data  []yaml_node_pair_t   // The stack of mapping pairs (key, value).\n\t\tpairs_start *yaml_node_pair_t    // The beginning of the stack.\n\t\tpairs_end   *yaml_node_pair_t    // The end of the stack.\n\t\tpairs_top   *yaml_node_pair_t    // The top of the stack.\n\t\tstyle       yaml_mapping_style_t // The mapping style.\n\t}\n\n\tstart_mark yaml_mark_t // The beginning of the node.\n\tend_mark   yaml_mark_t // The end of the node.\n\n}\n\n// The document structure.\ntype yaml_document_t struct {\n\n\t// The document nodes.\n\tnodes []yaml_node_t\n\n\t// The version directive.\n\tversion_directive *yaml_version_directive_t\n\n\t// The list of tag directives.\n\ttag_directives_data  []yaml_tag_directive_t\n\ttag_directives_start int // The beginning of the tag directives list.\n\ttag_directives_end   int // The end of the tag directives list.\n\n\tstart_implicit int // Is the document start indicator implicit?\n\tend_implicit   int // Is the document end indicator implicit?\n\n\t// The start/end of the document.\n\tstart_mark, end_mark yaml_mark_t\n}\n\n// The prototype of a read handler.\n//\n// The read handler is called when the parser needs to read more bytes from the\n// source. The handler should write not more than size bytes to the buffer.\n// The number of written bytes should be set to the size_read variable.\n//\n// [in,out]   data        A pointer to an application data specified by\n//                        yaml_parser_set_input().\n// [out]      buffer      The buffer to write the data from the source.\n// [in]       size        The size of the buffer.\n// [out]      size_read   The actual number of bytes read from the source.\n//\n// On success, the handler should return 1.  If the handler failed,\n// the returned value should be 0. On EOF, the handler should set the\n// size_read to 0 and return 1.\ntype yaml_read_handler_t func(parser *yaml_parser_t, buffer []byte) (n int, err error)\n\n// This structure holds information about a potential simple key.\ntype yaml_simple_key_t struct {\n\tpossible     bool        // Is a simple key possible?\n\trequired     bool        // Is a simple key required?\n\ttoken_number int         // The number of the token.\n\tmark         yaml_mark_t // The position mark.\n}\n\n// The states of the parser.\ntype yaml_parser_state_t int\n\nconst (\n\tyaml_PARSE_STREAM_START_STATE yaml_parser_state_t = iota\n\n\tyaml_PARSE_IMPLICIT_DOCUMENT_START_STATE           // Expect the beginning of an implicit document.\n\tyaml_PARSE_DOCUMENT_START_STATE                    // Expect DOCUMENT-START.\n\tyaml_PARSE_DOCUMENT_CONTENT_STATE                  // Expect the content of a document.\n\tyaml_PARSE_DOCUMENT_END_STATE                      // Expect DOCUMENT-END.\n\tyaml_PARSE_BLOCK_NODE_STATE                        // Expect a block node.\n\tyaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE // Expect a block node or indentless sequence.\n\tyaml_PARSE_FLOW_NODE_STATE                         // Expect a flow node.\n\tyaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE        // Expect the first entry of a block sequence.\n\tyaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE              // Expect an entry of a block sequence.\n\tyaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE         // Expect an entry of an indentless sequence.\n\tyaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE           // Expect the first key of a block mapping.\n\tyaml_PARSE_BLOCK_MAPPING_KEY_STATE                 // Expect a block mapping key.\n\tyaml_PARSE_BLOCK_MAPPING_VALUE_STATE               // Expect a block mapping value.\n\tyaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE         // Expect the first entry of a flow sequence.\n\tyaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE               // Expect an entry of a flow sequence.\n\tyaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE   // Expect a key of an ordered mapping.\n\tyaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE // Expect a value of an ordered mapping.\n\tyaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE   // Expect the and of an ordered mapping entry.\n\tyaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE            // Expect the first key of a flow mapping.\n\tyaml_PARSE_FLOW_MAPPING_KEY_STATE                  // Expect a key of a flow mapping.\n\tyaml_PARSE_FLOW_MAPPING_VALUE_STATE                // Expect a value of a flow mapping.\n\tyaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE          // Expect an empty value of a flow mapping.\n\tyaml_PARSE_END_STATE                               // Expect nothing.\n)\n\nfunc (ps yaml_parser_state_t) String() string {\n\tswitch ps {\n\tcase yaml_PARSE_STREAM_START_STATE:\n\t\treturn \"yaml_PARSE_STREAM_START_STATE\"\n\tcase yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE:\n\t\treturn \"yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE\"\n\tcase yaml_PARSE_DOCUMENT_START_STATE:\n\t\treturn \"yaml_PARSE_DOCUMENT_START_STATE\"\n\tcase yaml_PARSE_DOCUMENT_CONTENT_STATE:\n\t\treturn \"yaml_PARSE_DOCUMENT_CONTENT_STATE\"\n\tcase yaml_PARSE_DOCUMENT_END_STATE:\n\t\treturn \"yaml_PARSE_DOCUMENT_END_STATE\"\n\tcase yaml_PARSE_BLOCK_NODE_STATE:\n\t\treturn \"yaml_PARSE_BLOCK_NODE_STATE\"\n\tcase yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE:\n\t\treturn \"yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE\"\n\tcase yaml_PARSE_FLOW_NODE_STATE:\n\t\treturn \"yaml_PARSE_FLOW_NODE_STATE\"\n\tcase yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE:\n\t\treturn \"yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE\"\n\tcase yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE:\n\t\treturn \"yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE\"\n\tcase yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE:\n\t\treturn \"yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE\"\n\tcase yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE:\n\t\treturn \"yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE\"\n\tcase yaml_PARSE_BLOCK_MAPPING_KEY_STATE:\n\t\treturn \"yaml_PARSE_BLOCK_MAPPING_KEY_STATE\"\n\tcase yaml_PARSE_BLOCK_MAPPING_VALUE_STATE:\n\t\treturn \"yaml_PARSE_BLOCK_MAPPING_VALUE_STATE\"\n\tcase yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE:\n\t\treturn \"yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE\"\n\tcase yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE:\n\t\treturn \"yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE\"\n\tcase yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE:\n\t\treturn \"yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE\"\n\tcase yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE:\n\t\treturn \"yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE\"\n\tcase yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE:\n\t\treturn \"yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE\"\n\tcase yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE:\n\t\treturn \"yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE\"\n\tcase yaml_PARSE_FLOW_MAPPING_KEY_STATE:\n\t\treturn \"yaml_PARSE_FLOW_MAPPING_KEY_STATE\"\n\tcase yaml_PARSE_FLOW_MAPPING_VALUE_STATE:\n\t\treturn \"yaml_PARSE_FLOW_MAPPING_VALUE_STATE\"\n\tcase yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE:\n\t\treturn \"yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE\"\n\tcase yaml_PARSE_END_STATE:\n\t\treturn \"yaml_PARSE_END_STATE\"\n\t}\n\treturn \"<unknown parser state>\"\n}\n\n// This structure holds aliases data.\ntype yaml_alias_data_t struct {\n\tanchor []byte      // The anchor.\n\tindex  int         // The node id.\n\tmark   yaml_mark_t // The anchor mark.\n}\n\n// The parser structure.\n//\n// All members are internal. Manage the structure using the\n// yaml_parser_ family of functions.\ntype yaml_parser_t struct {\n\n\t// Error handling\n\n\terror yaml_error_type_t // Error type.\n\n\tproblem string // Error description.\n\n\t// The byte about which the problem occurred.\n\tproblem_offset int\n\tproblem_value  int\n\tproblem_mark   yaml_mark_t\n\n\t// The error context.\n\tcontext      string\n\tcontext_mark yaml_mark_t\n\n\t// Reader stuff\n\n\tread_handler yaml_read_handler_t // Read handler.\n\n\tinput_file io.Reader // File input data.\n\tinput      []byte    // String input data.\n\tinput_pos  int\n\n\teof bool // EOF flag\n\n\tbuffer     []byte // The working buffer.\n\tbuffer_pos int    // The current position of the buffer.\n\n\tunread int // The number of unread characters in the buffer.\n\n\traw_buffer     []byte // The raw buffer.\n\traw_buffer_pos int    // The current position of the buffer.\n\n\tencoding yaml_encoding_t // The input encoding.\n\n\toffset int         // The offset of the current position (in bytes).\n\tmark   yaml_mark_t // The mark of the current position.\n\n\t// Scanner stuff\n\n\tstream_start_produced bool // Have we started to scan the input stream?\n\tstream_end_produced   bool // Have we reached the end of the input stream?\n\n\tflow_level int // The number of unclosed '[' and '{' indicators.\n\n\ttokens          []yaml_token_t // The tokens queue.\n\ttokens_head     int            // The head of the tokens queue.\n\ttokens_parsed   int            // The number of tokens fetched from the queue.\n\ttoken_available bool           // Does the tokens queue contain a token ready for dequeueing.\n\n\tindent  int   // The current indentation level.\n\tindents []int // The indentation levels stack.\n\n\tsimple_key_allowed bool                // May a simple key occur at the current position?\n\tsimple_keys        []yaml_simple_key_t // The stack of simple keys.\n\n\t// Parser stuff\n\n\tstate          yaml_parser_state_t    // The current parser state.\n\tstates         []yaml_parser_state_t  // The parser states stack.\n\tmarks          []yaml_mark_t          // The stack of marks.\n\ttag_directives []yaml_tag_directive_t // The list of TAG directives.\n\n\t// Dumper stuff\n\n\taliases []yaml_alias_data_t // The alias data.\n\n\tdocument *yaml_document_t // The currently parsed document.\n}\n\n// Emitter Definitions\n\n// The prototype of a write handler.\n//\n// The write handler is called when the emitter needs to flush the accumulated\n// characters to the output.  The handler should write @a size bytes of the\n// @a buffer to the output.\n//\n// @param[in,out]   data        A pointer to an application data specified by\n//                              yaml_emitter_set_output().\n// @param[in]       buffer      The buffer with bytes to be written.\n// @param[in]       size        The size of the buffer.\n//\n// @returns On success, the handler should return @c 1.  If the handler failed,\n// the returned value should be @c 0.\n//\ntype yaml_write_handler_t func(emitter *yaml_emitter_t, buffer []byte) error\n\ntype yaml_emitter_state_t int\n\n// The emitter states.\nconst (\n\t// Expect STREAM-START.\n\tyaml_EMIT_STREAM_START_STATE yaml_emitter_state_t = iota\n\n\tyaml_EMIT_FIRST_DOCUMENT_START_STATE       // Expect the first DOCUMENT-START or STREAM-END.\n\tyaml_EMIT_DOCUMENT_START_STATE             // Expect DOCUMENT-START or STREAM-END.\n\tyaml_EMIT_DOCUMENT_CONTENT_STATE           // Expect the content of a document.\n\tyaml_EMIT_DOCUMENT_END_STATE               // Expect DOCUMENT-END.\n\tyaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE   // Expect the first item of a flow sequence.\n\tyaml_EMIT_FLOW_SEQUENCE_ITEM_STATE         // Expect an item of a flow sequence.\n\tyaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE     // Expect the first key of a flow mapping.\n\tyaml_EMIT_FLOW_MAPPING_KEY_STATE           // Expect a key of a flow mapping.\n\tyaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE  // Expect a value for a simple key of a flow mapping.\n\tyaml_EMIT_FLOW_MAPPING_VALUE_STATE         // Expect a value of a flow mapping.\n\tyaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE  // Expect the first item of a block sequence.\n\tyaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE        // Expect an item of a block sequence.\n\tyaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE    // Expect the first key of a block mapping.\n\tyaml_EMIT_BLOCK_MAPPING_KEY_STATE          // Expect the key of a block mapping.\n\tyaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE // Expect a value for a simple key of a block mapping.\n\tyaml_EMIT_BLOCK_MAPPING_VALUE_STATE        // Expect a value of a block mapping.\n\tyaml_EMIT_END_STATE                        // Expect nothing.\n)\n\n// The emitter structure.\n//\n// All members are internal.  Manage the structure using the @c yaml_emitter_\n// family of functions.\ntype yaml_emitter_t struct {\n\n\t// Error handling\n\n\terror   yaml_error_type_t // Error type.\n\tproblem string            // Error description.\n\n\t// Writer stuff\n\n\twrite_handler yaml_write_handler_t // Write handler.\n\n\toutput_buffer *[]byte   // String output data.\n\toutput_file   io.Writer // File output data.\n\n\tbuffer     []byte // The working buffer.\n\tbuffer_pos int    // The current position of the buffer.\n\n\traw_buffer     []byte // The raw buffer.\n\traw_buffer_pos int    // The current position of the buffer.\n\n\tencoding yaml_encoding_t // The stream encoding.\n\n\t// Emitter stuff\n\n\tcanonical   bool         // If the output is in the canonical style?\n\tbest_indent int          // The number of indentation spaces.\n\tbest_width  int          // The preferred width of the output lines.\n\tunicode     bool         // Allow unescaped non-ASCII characters?\n\tline_break  yaml_break_t // The preferred line break.\n\n\tstate  yaml_emitter_state_t   // The current emitter state.\n\tstates []yaml_emitter_state_t // The stack of states.\n\n\tevents      []yaml_event_t // The event queue.\n\tevents_head int            // The head of the event queue.\n\n\tindents []int // The stack of indentation levels.\n\n\ttag_directives []yaml_tag_directive_t // The list of tag directives.\n\n\tindent int // The current indentation level.\n\n\tflow_level int // The current flow level.\n\n\troot_context       bool // Is it the document root context?\n\tsequence_context   bool // Is it a sequence context?\n\tmapping_context    bool // Is it a mapping context?\n\tsimple_key_context bool // Is it a simple mapping key context?\n\n\tline       int  // The current line.\n\tcolumn     int  // The current column.\n\twhitespace bool // If the last character was a whitespace?\n\tindention  bool // If the last character was an indentation character (' ', '-', '?', ':')?\n\topen_ended bool // If an explicit document end is required?\n\n\t// Anchor analysis.\n\tanchor_data struct {\n\t\tanchor []byte // The anchor value.\n\t\talias  bool   // Is it an alias?\n\t}\n\n\t// Tag analysis.\n\ttag_data struct {\n\t\thandle []byte // The tag handle.\n\t\tsuffix []byte // The tag suffix.\n\t}\n\n\t// Scalar analysis.\n\tscalar_data struct {\n\t\tvalue                 []byte              // The scalar value.\n\t\tmultiline             bool                // Does the scalar contain line breaks?\n\t\tflow_plain_allowed    bool                // Can the scalar be expessed in the flow plain style?\n\t\tblock_plain_allowed   bool                // Can the scalar be expressed in the block plain style?\n\t\tsingle_quoted_allowed bool                // Can the scalar be expressed in the single quoted style?\n\t\tblock_allowed         bool                // Can the scalar be expressed in the literal or folded styles?\n\t\tstyle                 yaml_scalar_style_t // The output style.\n\t}\n\n\t// Dumper stuff\n\n\topened bool // If the stream was already opened?\n\tclosed bool // If the stream was already closed?\n\n\t// The information associated with the document nodes.\n\tanchors *struct {\n\t\treferences int  // The number of references.\n\t\tanchor     int  // The anchor id.\n\t\tserialized bool // If the node has been emitted?\n\t}\n\n\tlast_anchor_id int // The last assigned anchor id.\n\n\tdocument *yaml_document_t // The currently emitted document.\n}\n"
  },
  {
    "path": "vendor/gopkg.in/yaml.v2/yamlprivateh.go",
    "content": "package yaml\n\nconst (\n\t// The size of the input raw buffer.\n\tinput_raw_buffer_size = 512\n\n\t// The size of the input buffer.\n\t// It should be possible to decode the whole raw buffer.\n\tinput_buffer_size = input_raw_buffer_size * 3\n\n\t// The size of the output buffer.\n\toutput_buffer_size = 128\n\n\t// The size of the output raw buffer.\n\t// It should be possible to encode the whole output buffer.\n\toutput_raw_buffer_size = (output_buffer_size*2 + 2)\n\n\t// The size of other stacks and queues.\n\tinitial_stack_size  = 16\n\tinitial_queue_size  = 16\n\tinitial_string_size = 16\n)\n\n// Check if the character at the specified position is an alphabetical\n// character, a digit, '_', or '-'.\nfunc is_alpha(b []byte, i int) bool {\n\treturn b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'Z' || b[i] >= 'a' && b[i] <= 'z' || b[i] == '_' || b[i] == '-'\n}\n\n// Check if the character at the specified position is a digit.\nfunc is_digit(b []byte, i int) bool {\n\treturn b[i] >= '0' && b[i] <= '9'\n}\n\n// Get the value of a digit.\nfunc as_digit(b []byte, i int) int {\n\treturn int(b[i]) - '0'\n}\n\n// Check if the character at the specified position is a hex-digit.\nfunc is_hex(b []byte, i int) bool {\n\treturn b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'F' || b[i] >= 'a' && b[i] <= 'f'\n}\n\n// Get the value of a hex-digit.\nfunc as_hex(b []byte, i int) int {\n\tbi := b[i]\n\tif bi >= 'A' && bi <= 'F' {\n\t\treturn int(bi) - 'A' + 10\n\t}\n\tif bi >= 'a' && bi <= 'f' {\n\t\treturn int(bi) - 'a' + 10\n\t}\n\treturn int(bi) - '0'\n}\n\n// Check if the character is ASCII.\nfunc is_ascii(b []byte, i int) bool {\n\treturn b[i] <= 0x7F\n}\n\n// Check if the character at the start of the buffer can be printed unescaped.\nfunc is_printable(b []byte, i int) bool {\n\treturn ((b[i] == 0x0A) || // . == #x0A\n\t\t(b[i] >= 0x20 && b[i] <= 0x7E) || // #x20 <= . <= #x7E\n\t\t(b[i] == 0xC2 && b[i+1] >= 0xA0) || // #0xA0 <= . <= #xD7FF\n\t\t(b[i] > 0xC2 && b[i] < 0xED) ||\n\t\t(b[i] == 0xED && b[i+1] < 0xA0) ||\n\t\t(b[i] == 0xEE) ||\n\t\t(b[i] == 0xEF && // #xE000 <= . <= #xFFFD\n\t\t\t!(b[i+1] == 0xBB && b[i+2] == 0xBF) && // && . != #xFEFF\n\t\t\t!(b[i+1] == 0xBF && (b[i+2] == 0xBE || b[i+2] == 0xBF))))\n}\n\n// Check if the character at the specified position is NUL.\nfunc is_z(b []byte, i int) bool {\n\treturn b[i] == 0x00\n}\n\n// Check if the beginning of the buffer is a BOM.\nfunc is_bom(b []byte, i int) bool {\n\treturn b[0] == 0xEF && b[1] == 0xBB && b[2] == 0xBF\n}\n\n// Check if the character at the specified position is space.\nfunc is_space(b []byte, i int) bool {\n\treturn b[i] == ' '\n}\n\n// Check if the character at the specified position is tab.\nfunc is_tab(b []byte, i int) bool {\n\treturn b[i] == '\\t'\n}\n\n// Check if the character at the specified position is blank (space or tab).\nfunc is_blank(b []byte, i int) bool {\n\t//return is_space(b, i) || is_tab(b, i)\n\treturn b[i] == ' ' || b[i] == '\\t'\n}\n\n// Check if the character at the specified position is a line break.\nfunc is_break(b []byte, i int) bool {\n\treturn (b[i] == '\\r' || // CR (#xD)\n\t\tb[i] == '\\n' || // LF (#xA)\n\t\tb[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)\n\t\tb[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)\n\t\tb[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9) // PS (#x2029)\n}\n\nfunc is_crlf(b []byte, i int) bool {\n\treturn b[i] == '\\r' && b[i+1] == '\\n'\n}\n\n// Check if the character is a line break or NUL.\nfunc is_breakz(b []byte, i int) bool {\n\t//return is_break(b, i) || is_z(b, i)\n\treturn (        // is_break:\n\tb[i] == '\\r' || // CR (#xD)\n\t\tb[i] == '\\n' || // LF (#xA)\n\t\tb[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)\n\t\tb[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)\n\t\tb[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029)\n\t\t// is_z:\n\t\tb[i] == 0)\n}\n\n// Check if the character is a line break, space, or NUL.\nfunc is_spacez(b []byte, i int) bool {\n\t//return is_space(b, i) || is_breakz(b, i)\n\treturn ( // is_space:\n\tb[i] == ' ' ||\n\t\t// is_breakz:\n\t\tb[i] == '\\r' || // CR (#xD)\n\t\tb[i] == '\\n' || // LF (#xA)\n\t\tb[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)\n\t\tb[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)\n\t\tb[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029)\n\t\tb[i] == 0)\n}\n\n// Check if the character is a line break, space, tab, or NUL.\nfunc is_blankz(b []byte, i int) bool {\n\t//return is_blank(b, i) || is_breakz(b, i)\n\treturn ( // is_blank:\n\tb[i] == ' ' || b[i] == '\\t' ||\n\t\t// is_breakz:\n\t\tb[i] == '\\r' || // CR (#xD)\n\t\tb[i] == '\\n' || // LF (#xA)\n\t\tb[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)\n\t\tb[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)\n\t\tb[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029)\n\t\tb[i] == 0)\n}\n\n// Determine the width of the character.\nfunc width(b byte) int {\n\t// Don't replace these by a switch without first\n\t// confirming that it is being inlined.\n\tif b&0x80 == 0x00 {\n\t\treturn 1\n\t}\n\tif b&0xE0 == 0xC0 {\n\t\treturn 2\n\t}\n\tif b&0xF0 == 0xE0 {\n\t\treturn 3\n\t}\n\tif b&0xF8 == 0xF0 {\n\t\treturn 4\n\t}\n\treturn 0\n\n}\n"
  }
]