[
  {
    "path": ".github/workflows/release.yaml",
    "content": "# .github/workflows/release.yaml\n\non: release\nname: Build Release\njobs:\n  release-linux-386:\n    name: release linux/386\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@master\n    - name: compile and release\n      uses: ngs/go-release.action@v1.0.1\n      env:\n        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        GOARCH: \"386\"\n        GOOS: linux\n        EXTRA_FILES: \"LICENSE\"\n  release-linux-amd64:\n    name: release linux/amd64\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@master\n    - name: compile and release\n      uses: ngs/go-release.action@v1.0.1\n      env:\n        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        GOARCH: amd64\n        GOOS: linux\n        EXTRA_FILES: \"LICENSE\"\n  release-linux-arm:\n    name: release linux/386\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@master\n    - name: compile and release\n      uses: ngs/go-release.action@v1.0.1\n      env:\n        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        GOARCH: \"arm\"\n        GOOS: linux\n        EXTRA_FILES: \"LICENSE\"\n  release-linux-arm64:\n    name: release linux/amd64\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@master\n    - name: compile and release\n      uses: ngs/go-release.action@v1.0.1\n      env:\n        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        GOARCH: arm64\n        GOOS: linux\n        EXTRA_FILES: \"LICENSE\"\n  release-darwin-amd64:\n    name: release darwin/amd64\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@master\n    - name: compile and release\n      uses: ngs/go-release.action@v1.0.1\n      env:\n        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        GOARCH: amd64\n        GOOS: darwin\n        EXTRA_FILES: \"LICENSE\"\n  release-windows-386:\n    name: release windows/386\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@master\n    - name: compile and release\n      uses: ngs/go-release.action@v1.0.1\n      env:\n        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        GOARCH: \"386\"\n        GOOS: windows\n        EXTRA_FILES: \"LICENSE\"\n  release-windows-amd64:\n    name: release windows/amd64\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@master\n    - name: compile and release\n      uses: ngs/go-release.action@v1.0.1\n      env:\n        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        GOARCH: amd64\n        GOOS: windows\n        EXTRA_FILES: \"LICENSE\"\n"
  },
  {
    "path": ".gitignore",
    "content": "# Ignore bin folder and drive binary\n_release/bin\n\n# vim files\n.*.sw[a-z]\n*.un~\nSession.vim\n.netrwhist\ngdrive\ngdrive.sh\n"
  },
  {
    "path": "Godeps/Godeps.json",
    "content": "{\n\t\"ImportPath\": \"github.com/prasmussen/gdrive\",\n\t\"GoVersion\": \"go1.6\",\n\t\"GodepVersion\": \"v61\",\n\t\"Deps\": [\n\t\t{\n\t\t\t\"ImportPath\": \"github.com/sabhiram/go-git-ignore\",\n\t\t\t\"Rev\": \"228fcfa2a06e870a3ef238d54c45ea847f492a37\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"github.com/soniakeys/graph\",\n\t\t\t\"Comment\": \"svg-v0-58-gc265d96\",\n\t\t\t\"Rev\": \"c265d9676750b13b9520ba4ad4f8359fa1aed9fd\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"golang.org/x/net/context\",\n\t\t\t\"Rev\": \"fb93926129b8ec0056f2f458b1f519654814edf0\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"golang.org/x/net/context/ctxhttp\",\n\t\t\t\"Rev\": \"fb93926129b8ec0056f2f458b1f519654814edf0\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"golang.org/x/oauth2\",\n\t\t\t\"Rev\": \"7e9cd5d59563851383f8f81a7fbb01213709387c\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"golang.org/x/oauth2/internal\",\n\t\t\t\"Rev\": \"7e9cd5d59563851383f8f81a7fbb01213709387c\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"google.golang.org/api/drive/v3\",\n\t\t\t\"Rev\": \"9737cc9e103c00d06a8f3993361dec083df3d252\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"google.golang.org/api/gensupport\",\n\t\t\t\"Rev\": \"9737cc9e103c00d06a8f3993361dec083df3d252\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"google.golang.org/api/googleapi\",\n\t\t\t\"Rev\": \"9737cc9e103c00d06a8f3993361dec083df3d252\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"google.golang.org/api/googleapi/internal/uritemplates\",\n\t\t\t\"Rev\": \"9737cc9e103c00d06a8f3993361dec083df3d252\"\n\t\t}\n\t]\n}\n"
  },
  {
    "path": "Godeps/Readme",
    "content": "This directory tree is generated automatically by godep.\n\nPlease do not edit.\n\nSee https://github.com/tools/godep for more information.\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License\n\nCopyright (c) 2013 Petter Rasmussen\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\n"
  },
  {
    "path": "README.md",
    "content": "## IMPORTANT\nThis repository is not maintained anymore. [Gdrive 3](https://github.com/glotlabs/gdrive) is its successor.\n\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n```\n\n## Prerequisites\nNone, binaries are statically linked.\nIf you want to compile from source you need the [go toolchain](http://golang.org/doc/install).\nVersion 1.5 or higher.\n\n## Installation\n### With [Homebrew](http://brew.sh) on Mac\n```\nbrew install gdrive\n```\n### Other\nDownload `gdrive` from one of the [links in the latest release](https://github.com/prasmussen/gdrive/releases).\nThe first time gdrive is launched (i.e. run `gdrive about` in your\nterminal not just `gdrive`), you will be prompted for a verification code.\nThe code is obtained by following the printed url and authenticating with the\ngoogle account for the drive you want access to. This will create a token file\ninside the .gdrive folder in your home directory. Note that anyone with access\nto this file will also have access to your google drive.\nIf you want to manage multiple drives you can use the global `--config` flag\nor set the environment variable `GDRIVE_CONFIG_DIR`.\nExample: `GDRIVE_CONFIG_DIR=\"/home/user/.gdrive-secondary\" gdrive list`\nYou will be prompted for a new verification code if the folder does not exist.\n\n## Compile from source\n```bash\ngo get github.com/prasmussen/gdrive\n```\nThe gdrive binary should now be available at `$GOPATH/bin/gdrive`\n\n\n### Syncing\nGdrive supports basic syncing. It only syncs one way at the time and works\nmore like rsync than e.g. dropbox. Files that are synced to google drive\nare tagged with an appProperty so that the files on drive can be traversed\nfaster. This means that you can't upload files with `gdrive upload` into\na sync directory as the files would be missing the sync tag, and would be\nignored by the sync commands.\nThe current implementation is slow and uses a lot of memory if you are\nsyncing many files. Currently only one file is uploaded at the time,\nthe speed can be improved in the future by uploading several files concurrently.\nTo learn more see usage and the examples below.\n\n### Service Account\nFor server to server communication, where user interaction is not a viable option, \nis it possible to use a service account, as described in this [Google document](https://developers.google.com/identity/protocols/OAuth2ServiceAccount).\nIf you want to use a service account, instead of being interactively prompted for\nauthentication, you need to use the `--service-account <serviceAccountCredentials>` \nglobal option, where `serviceAccountCredentials` is a file in JSON format obtained\nthrough the Google API Console, and its location is relative to the config dir. \n\n#### .gdriveignore\nPlacing a .gdriveignore in the root of your sync directory can be used to\nskip certain files from being synced. .gdriveignore follows the same\nrules as [.gitignore](https://git-scm.com/docs/gitignore), except that gdrive only reads the .gdriveignore file in the root of the sync directory, not ones in any subdirectories.\n\n\n## Usage\n```\ngdrive [global] list [options]                                 List files\ngdrive [global] download [options] <fileId>                    Download file or directory\ngdrive [global] download query [options] <query>               Download all files and directories matching query\ngdrive [global] upload [options] <path>                        Upload file or directory\ngdrive [global] upload - [options] <name>                      Upload file from stdin\ngdrive [global] update [options] <fileId> <path>               Update file, this creates a new revision of the file\ngdrive [global] info [options] <fileId>                        Show file info\ngdrive [global] mkdir [options] <name>                         Create directory\ngdrive [global] share [options] <fileId>                       Share file or directory\ngdrive [global] share list <fileId>                            List files permissions\ngdrive [global] share revoke <fileId> <permissionId>           Revoke permission\ngdrive [global] delete [options] <fileId>                      Delete file or directory\ngdrive [global] sync list [options]                            List all syncable directories on drive\ngdrive [global] sync content [options] <fileId>                List content of syncable directory\ngdrive [global] sync download [options] <fileId> <path>        Sync drive directory to local directory\ngdrive [global] sync upload [options] <path> <fileId>          Sync local directory to drive\ngdrive [global] changes [options]                              List file changes\ngdrive [global] revision list [options] <fileId>               List file revisions\ngdrive [global] revision download [options] <fileId> <revId>   Download revision\ngdrive [global] revision delete <fileId> <revId>               Delete file revision\ngdrive [global] import [options] <path>                        Upload and convert file to a google document, see 'about import' for available conversions\ngdrive [global] export [options] <fileId>                      Export a google document\ngdrive [global] about [options]                                Google drive metadata, quota usage\ngdrive [global] about import                                   Show supported import formats\ngdrive [global] about export                                   Show supported export formats\ngdrive version                                                 Print application version\ngdrive help                                                    Print help\ngdrive help <command>                                          Print command help\ngdrive help <command> <subcommand>                             Print subcommand help\n```\n\n#### List files\n```\ngdrive [global] list [options]\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n\noptions:\n  -m, --max <maxFiles>       Max files to list, default: 30\n  -q, --query <query>        Default query: \"trashed = false and 'me' in owners\". See https://developers.google.com/drive/search-parameters\n  --order <sortOrder>        Sort order. See https://godoc.org/google.golang.org/api/drive/v3#FilesListCall.OrderBy\n  --name-width <nameWidth>   Width of name column, default: 40, minimum: 9, use 0 for full width\n  --absolute                 Show absolute path to file (will only show path from first parent)\n  --no-header                Dont print the header\n  --bytes                    Size in bytes\n```\n\nList file in subdirectory\n\n\n```\n./gdrive list --query \" 'IdOfTheParentFolder' in parents\"\n```\n\n#### Download file or directory\n```\ngdrive [global] download [options] <fileId>\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n  \noptions:\n  -f, --force           Overwrite existing file\n  -r, --recursive       Download directory recursively, documents will be skipped\n  --path <path>         Download path\n  --delete              Delete remote file when download is successful\n  --no-progress         Hide progress\n  --stdout              Write file content to stdout\n  --timeout <timeout>   Set timeout in seconds, use 0 for no timeout. Timeout is reached when no data is transferred in set amount of seconds, default: 300\n```\n\n#### Download all files and directories matching query\n```\ngdrive [global] download query [options] <query>\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n  \noptions:\n  -f, --force       Overwrite existing file\n  -r, --recursive   Download directories recursively, documents will be skipped\n  --path <path>     Download path\n  --no-progress     Hide progress\n```\n\n#### Upload file or directory\n```\ngdrive [global] upload [options] <path>\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n  \noptions:\n  -r, --recursive               Upload directory recursively\n  -p, --parent <parent>         Parent id, used to upload file to a specific directory, can be specified multiple times to give many parents\n  --name <name>                 Filename\n  --description <description>   File description\n  --no-progress                 Hide progress\n  --mime <mime>                 Force mime type\n  --share                       Share file\n  --delete                      Delete local file when upload is successful\n  --timeout <timeout>           Set timeout in seconds, use 0 for no timeout. Timeout is reached when no data is transferred in set amount of seconds, default: 300\n  --chunksize <chunksize>       Set chunk size in bytes, default: 8388608\n```\n\n#### Upload file from stdin\n```\ngdrive [global] upload - [options] <name>\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n  \noptions:\n  -p, --parent <parent>         Parent id, used to upload file to a specific directory, can be specified multiple times to give many parents\n  --chunksize <chunksize>       Set chunk size in bytes, default: 8388608\n  --description <description>   File description\n  --mime <mime>                 Force mime type\n  --share                       Share file\n  --timeout <timeout>           Set timeout in seconds, use 0 for no timeout. Timeout is reached when no data is transferred in set amount of seconds, default: 300\n  --no-progress                 Hide progress\n```\n\n#### Update file, this creates a new revision of the file\n```\ngdrive [global] update [options] <fileId> <path>\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n  \noptions:\n  -p, --parent <parent>         Parent id, used to upload file to a specific directory, can be specified multiple times to give many parents\n  --name <name>                 Filename\n  --description <description>   File description\n  --no-progress                 Hide progress\n  --mime <mime>                 Force mime type\n  --timeout <timeout>           Set timeout in seconds, use 0 for no timeout. Timeout is reached when no data is transferred in set amount of seconds, default: 300\n  --chunksize <chunksize>       Set chunk size in bytes, default: 8388608\n```\n\n#### Show file info\n```\ngdrive [global] info [options] <fileId>\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n  \noptions:\n  --bytes   Show size in bytes\n```\n\n#### Create directory\n```\ngdrive [global] mkdir [options] <name>\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n  \noptions:\n  -p, --parent <parent>         Parent id of created directory, can be specified multiple times to give many parents\n  --description <description>   Directory description\n```\n\n#### Share file or directory\n```\ngdrive [global] share [options] <fileId>\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n  \noptions:\n  --role <role>     Share role: owner/writer/commenter/reader, default: reader\n  --type <type>     Share type: user/group/domain/anyone, default: anyone\n  --email <email>   The email address of the user or group to share the file with. Requires 'user' or 'group' as type\n  --discoverable    Make file discoverable by search engines\n  --revoke          Delete all sharing permissions (owner roles will be skipped)\n```\n\n#### List files permissions\n```\ngdrive [global] share list <fileId>\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n```\n\n#### Revoke permission\n```\ngdrive [global] share revoke <fileId> <permissionId>\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n```\n\n#### Delete file or directory\n```\ngdrive [global] delete [options] <fileId>\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n  \noptions:\n  -r, --recursive   Delete directory and all it's content\n```\n\n#### List all syncable directories on drive\n```\ngdrive [global] sync list [options]\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n  \noptions:\n  --no-header   Dont print the header\n```\n\n#### List content of syncable directory\n```\ngdrive [global] sync content [options] <fileId>\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n  \noptions:\n  --order <sortOrder>        Sort order. See https://godoc.org/google.golang.org/api/drive/v3#FilesListCall.OrderBy\n  --path-width <pathWidth>   Width of path column, default: 60, minimum: 9, use 0 for full width\n  --no-header                Dont print the header\n  --bytes                    Size in bytes\n```\n\n#### Sync drive directory to local directory\n```\ngdrive [global] sync download [options] <fileId> <path>\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n  \noptions:\n  --keep-remote         Keep remote file when a conflict is encountered\n  --keep-local          Keep local file when a conflict is encountered\n  --keep-largest        Keep largest file when a conflict is encountered\n  --delete-extraneous   Delete extraneous local files\n  --dry-run             Show what would have been transferred\n  --no-progress         Hide progress\n  --timeout <timeout>   Set timeout in seconds, use 0 for no timeout. Timeout is reached when no data is transferred in set amount of seconds, default: 300\n```\n\n#### Sync local directory to drive\n```\ngdrive [global] sync upload [options] <path> <fileId>\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n  \noptions:\n  --keep-remote             Keep remote file when a conflict is encountered\n  --keep-local              Keep local file when a conflict is encountered\n  --keep-largest            Keep largest file when a conflict is encountered\n  --delete-extraneous       Delete extraneous remote files\n  --dry-run                 Show what would have been transferred\n  --no-progress             Hide progress\n  --timeout <timeout>       Set timeout in seconds, use 0 for no timeout. Timeout is reached when no data is transferred in set amount of seconds, default: 300\n  --chunksize <chunksize>   Set chunk size in bytes, default: 8388608\n```\n\n#### List file changes\n```\ngdrive [global] changes [options]\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n  \noptions:\n  -m, --max <maxChanges>     Max changes to list, default: 100\n  --since <pageToken>        Page token to start listing changes from\n  --now                      Get latest page token\n  --name-width <nameWidth>   Width of name column, default: 40, minimum: 9, use 0 for full width\n  --no-header                Dont print the header\n```\n\n#### List file revisions\n```\ngdrive [global] revision list [options] <fileId>\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n  \noptions:\n  --name-width <nameWidth>   Width of name column, default: 40, minimum: 9, use 0 for full width\n  --no-header                Dont print the header\n  --bytes                    Size in bytes\n```\n\n#### Download revision\n```\ngdrive [global] revision download [options] <fileId> <revId>\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n  \noptions:\n  -f, --force           Overwrite existing file\n  --no-progress         Hide progress\n  --stdout              Write file content to stdout\n  --path <path>         Download path\n  --timeout <timeout>   Set timeout in seconds, use 0 for no timeout. Timeout is reached when no data is transferred in set amount of seconds, default: 300\n```\n\n#### Delete file revision\n```\ngdrive [global] revision delete <fileId> <revId>\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n```\n\n#### Upload and convert file to a google document, see 'about import' for available conversions\n```\ngdrive [global] import [options] <path>\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n  \noptions:\n  -p, --parent <parent>   Parent id, used to upload file to a specific directory, can be specified multiple times to give many parents\n  --no-progress           Hide progress\n```\n\n#### Export a google document\n```\ngdrive [global] export [options] <fileId>\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n  \noptions:\n  -f, --force     Overwrite existing file\n  --mime <mime>   Mime type of exported file\n  --print-mimes   Print available mime types for given file\n```\n\n#### Google drive metadata, quota usage\n```\ngdrive [global] about [options]\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n  \noptions:\n  --bytes   Show size in bytes\n```\n\n#### Show supported import formats\n```\ngdrive [global] about import\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n```\n\n#### Show supported export formats\n```\ngdrive [global] about export\n\nglobal:\n  -c, --config <configDir>         Application path, default: /Users/<user>/.gdrive\n  --refresh-token <refreshToken>   Oauth refresh token used to get access token (for advanced users)\n  --access-token <accessToken>     Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\n  --service-account <accountFile>  Oauth service account filename, used for server to server communication without user interaction (file is relative to config dir)\n```\n\n\n## Examples\n#### List files\n```\n$ gdrive list\nId                             Name                    Type   Size     Created\n0B3X9GlR6EmbnZ3gyeGw4d3ozbUk   drive-windows-x64.exe   bin    6.6 MB   2015-07-18 16:43:58\n0B3X9GlR6EmbnTXlSc1FqV1dvSTQ   drive-windows-386.exe   bin    5.2 MB   2015-07-18 16:43:53\n0B3X9GlR6EmbnVjIzMDRqck1aekE   drive-osx-x64           bin    6.5 MB   2015-07-18 16:43:50\n0B3X9GlR6EmbnbEpXdlhza25zT1U   drive-osx-386           bin    5.2 MB   2015-07-18 16:43:41\n0B3X9GlR6Embnb095MGxEYmJhY2c   drive-linux-x64         bin    6.5 MB   2015-07-18 16:43:38\n```\n\n#### List largest files\n```\n$ gdrive list --query \"name contains 'gdrive'\" --order \"quotaBytesUsed desc\" -m 3\nId                             Name                     Type   Size     Created\n0B3X9GlR6EmbnZXpDRG1xblM2LTg   gdrive-linux-mips64      bin    8.5 MB   2016-02-22 21:07:04\n0B3X9GlR6EmbnNW5CTV8xdFkxTjg   gdrive-linux-mips64le    bin    8.5 MB   2016-02-22 21:07:07\n0B3X9GlR6EmbnZ1NGS25FdEVlWEk   gdrive-osx-x64           bin    8.3 MB   2016-02-21 20:22:13\n```\n\n#### Upload file\n```\n$ gdrive upload gdrive-osx-x64\nUploading gdrive-osx-x64\nUploaded 0B3X9GlR6EmbnZ1NGS25FdEVlWEk at 3.8 MB/s, total 8.3 MB\n```\n\n#### Make directory\n```\n$ gdrive mkdir gdrive-bin\nDirectory 0B3X9GlR6EmbnY1RLVTk5VUtOVkk created\n```\n\n#### Upload file to directory\n```\n$ gdrive upload --parent 0B3X9GlR6EmbnY1RLVTk5VUtOVkk gdrive-osx-x64\nUploading gdrive-osx-x64\nUploaded 0B3X9GlR6EmbnNTk0SkV0bm5Hd0E at 2.5 MB/s, total 8.3 MB\n```\n\n#### Download file\n```\n$ gdrive download 0B3X9GlR6EmbnZ1NGS25FdEVlWEk\nDownloading gdrive-osx-x64 -> gdrive-osx-x64\nDownloaded 0B3X9GlR6EmbnZ1NGS25FdEVlWEk at 8.3 MB/s, total 8.3 MB\n```\n\n#### Share a file\n```\n$ gdrive share 0B3X9GlR6EmbnNTk0SkV0bm5Hd0E\nGranted reader permission to anyone\n```\n\n#### Pipe content directly to google drive\n```\n$ echo \"Hello World\" | gdrive upload - hello.txt\nUploading hello.txt\nUploaded 0B3X9GlR6EmbnaXVrOUpIcWlUS0E at 8.0 B/s, total 12.0 B\n```\n\n#### Print file to stdout\n```\n$ gdrive download --stdout 0B3X9GlR6EmbnaXVrOUpIcWlUS0E\nHello World\n```\n\n#### Get file info\n```\n$ gdrive info 0B3X9GlR6EmbnNTk0SkV0bm5Hd0E\nId: 0B3X9GlR6EmbnNTk0SkV0bm5Hd0E\nName: gdrive-osx-x64\nPath: gdrive-bin/gdrive-osx-x64\nMime: application/octet-stream\nSize: 8.3 MB\nCreated: 2016-02-21 20:47:04\nModified: 2016-02-21 20:47:04\nMd5sum: b607f29231a3b2d16098c4212516470f\nShared: True\nParents: 0B3X9GlR6EmbnY1RLVTk5VUtOVkk\nViewUrl: https://drive.google.com/file/d/0B3X9GlR6EmbnNTk0SkV0bm5Hd0E/view?usp=drivesdk\nDownloadUrl: https://docs.google.com/uc?id=0B3X9GlR6EmbnNTk0SkV0bm5Hd0E&export=download\n```\n\n#### Update file (create new revision)\n```\n$ gdrive update 0B3X9GlR6EmbnNTk0SkV0bm5Hd0E gdrive-osx-x64\nUploading gdrive-osx-x64\nUpdated 0B3X9GlR6EmbnNTk0SkV0bm5Hd0E at 2.0 MB/s, total 8.3 MB\n```\n\n#### List file revisions\n```\n$ gdrive revision list 0B3X9GlR6EmbnNTk0SkV0bm5Hd0E\nId                                                    Name             Size     Modified              KeepForever\n0B3X9GlR6EmbnOFlHSTZQNWJWMGN2ckZucC9VaEUwczV1cUNrPQ   gdrive-osx-x64   8.3 MB   2016-02-21 20:47:04   False\n0B3X9GlR6EmbndVEwMlZCUldGWUlPb2lTS25rOFo1L2t6c2ZVPQ   gdrive-osx-x64   8.3 MB   2016-02-21 21:12:09   False\n```\n\n#### Download revision\n```\n$ gdrive revision download 0B3X9GlR6EmbnNTk0SkV0bm5Hd0E 0B3X9GlR6EmbnOFlHSTZQNWJWMGN2ckZucC9VaEUwczV1cUNrPQ\nDownloading gdrive-osx-x64 -> gdrive-osx-x64\nDownload complete, rate: 8.3 MB/s, total size: 8.3 MB\n```\n\n#### Export google doc as docx\n```\n$ gdrive export --mime application/vnd.openxmlformats-officedocument.wordprocessingml.document 1Kt5A8X7X2RQrEi5t6Y9W1LayRc4hyrFiG63y2dIJEvk\nExported 'foo.docx' with mime type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'\n```\n\n#### Import csv as google spreadsheet\n```\n$ gdrive import foo.csv\nImported 1mTl3DjIvap4tpTX_oMkDcbDT8ShtiGJRlozTfkXpeko with mime type: 'application/vnd.google-apps.spreadsheet'\n```\n\n#### Syncing directory to drive\n```\n# Create directory on drive\n$ gdrive mkdir drive-bin\nDirectory 0B3X9GlR6EmbnOEd6cEh6bU9XZWM created\n\n# Sync to drive\n$ gdrive sync upload _release/bin 0B3X9GlR6EmbnOEd6cEh6bU9XZWM\nStarting sync...\nCollecting local and remote file information...\nFound 32 local files and 0 remote files\n\n6 remote directories are missing\n[0001/0006] Creating directory drive-bin/bsd\n[0002/0006] Creating directory drive-bin/linux\n[0003/0006] Creating directory drive-bin/osx\n[0004/0006] Creating directory drive-bin/plan9\n[0005/0006] Creating directory drive-bin/solaris\n[0006/0006] Creating directory drive-bin/windows\n\n26 remote files are missing\n[0001/0026] Uploading bsd/gdrive-dragonfly-x64 -> drive-bin/bsd/gdrive-dragonfly-x64\n[0002/0026] Uploading bsd/gdrive-freebsd-386 -> drive-bin/bsd/gdrive-freebsd-386\n[0003/0026] Uploading bsd/gdrive-freebsd-arm -> drive-bin/bsd/gdrive-freebsd-arm\n[0004/0026] Uploading bsd/gdrive-freebsd-x64 -> drive-bin/bsd/gdrive-freebsd-x64\n[0005/0026] Uploading bsd/gdrive-netbsd-386 -> drive-bin/bsd/gdrive-netbsd-386\n[0006/0026] Uploading bsd/gdrive-netbsd-arm -> drive-bin/bsd/gdrive-netbsd-arm\n[0007/0026] Uploading bsd/gdrive-netbsd-x64 -> drive-bin/bsd/gdrive-netbsd-x64\n[0008/0026] Uploading bsd/gdrive-openbsd-386 -> drive-bin/bsd/gdrive-openbsd-386\n[0009/0026] Uploading bsd/gdrive-openbsd-arm -> drive-bin/bsd/gdrive-openbsd-arm\n[0010/0026] Uploading bsd/gdrive-openbsd-x64 -> drive-bin/bsd/gdrive-openbsd-x64\n[0011/0026] Uploading linux/gdrive-linux-386 -> drive-bin/linux/gdrive-linux-386\n[0012/0026] Uploading linux/gdrive-linux-arm -> drive-bin/linux/gdrive-linux-arm\n[0013/0026] Uploading linux/gdrive-linux-arm64 -> drive-bin/linux/gdrive-linux-arm64\n[0014/0026] Uploading linux/gdrive-linux-mips64 -> drive-bin/linux/gdrive-linux-mips64\n[0015/0026] Uploading linux/gdrive-linux-mips64le -> drive-bin/linux/gdrive-linux-mips64le\n[0016/0026] Uploading linux/gdrive-linux-ppc64 -> drive-bin/linux/gdrive-linux-ppc64\n[0017/0026] Uploading linux/gdrive-linux-ppc64le -> drive-bin/linux/gdrive-linux-ppc64le\n[0018/0026] Uploading linux/gdrive-linux-x64 -> drive-bin/linux/gdrive-linux-x64\n[0019/0026] Uploading osx/gdrive-osx-386 -> drive-bin/osx/gdrive-osx-386\n[0020/0026] Uploading osx/gdrive-osx-arm -> drive-bin/osx/gdrive-osx-arm\n[0021/0026] Uploading osx/gdrive-osx-x64 -> drive-bin/osx/gdrive-osx-x64\n[0022/0026] Uploading plan9/gdrive-plan9-386 -> drive-bin/plan9/gdrive-plan9-386\n[0023/0026] Uploading plan9/gdrive-plan9-x64 -> drive-bin/plan9/gdrive-plan9-x64\n[0024/0026] Uploading solaris/gdrive-solaris-x64 -> drive-bin/solaris/gdrive-solaris-x64\n[0025/0026] Uploading windows/gdrive-windows-386.exe -> drive-bin/windows/gdrive-windows-386.exe\n[0026/0026] Uploading windows/gdrive-windows-x64.exe -> drive-bin/windows/gdrive-windows-x64.exe\nSync finished in 1m18.891946279s\n\n# Add new local file\n$ echo \"google drive binaries\" > _release/bin/readme.txt\n\n# Sync again\n$ gdrive sync upload _release/bin 0B3X9GlR6EmbnOEd6cEh6bU9XZWM\nStarting sync...\nCollecting local and remote file information...\nFound 33 local files and 32 remote files\n\n1 remote files are missing\n[0001/0001] Uploading readme.txt -> drive-bin/readme.txt\nSync finished in 2.201339535s\n\n# Modify local file\n$ echo \"for all platforms\" >> _release/bin/readme.txt\n\n# Sync again\n$ gdrive sync upload _release/bin 0B3X9GlR6EmbnOEd6cEh6bU9XZWM\nStarting sync...\nCollecting local and remote file information...\nFound 33 local files and 33 remote files\n\n1 local files has changed\n[0001/0001] Updating readme.txt -> drive-bin/readme.txt\nSync finished in 1.890244258s\n```\n\n#### List content of sync directory\n```\n$ gdrive sync content 0B3X9GlR6EmbnOEd6cEh6bU9XZWM\nId                             Path                             Type   Size     Modified\n0B3X9GlR6EmbnMldxMFV1UGVMTlE   bsd                              dir             2016-02-21 22:54:00\n0B3X9GlR6EmbnM05sQ3hVUnJnOXc   bsd/gdrive-dragonfly-x64         bin    7.8 MB   2016-02-21 22:54:14\n0B3X9GlR6EmbnVy1KXzA4dlU5RVE   bsd/gdrive-freebsd-386           bin    6.1 MB   2016-02-21 22:54:18\n0B3X9GlR6Embnb29QQkFtSlRiZnc   bsd/gdrive-freebsd-arm           bin    6.1 MB   2016-02-21 22:54:20\n0B3X9GlR6EmbnMkFQYVpSaHhHTXM   bsd/gdrive-freebsd-x64           bin    7.8 MB   2016-02-21 22:54:23\n0B3X9GlR6EmbnVmJRMl9hUDloVU0   bsd/gdrive-netbsd-386            bin    6.1 MB   2016-02-21 22:54:25\n0B3X9GlR6EmbnLVlTZWpxOEF4Q2s   bsd/gdrive-netbsd-arm            bin    6.1 MB   2016-02-21 22:54:28\n0B3X9GlR6EmbnOENUZmh3anJmNG8   bsd/gdrive-netbsd-x64            bin    7.8 MB   2016-02-21 22:54:30\n0B3X9GlR6EmbnWTRoQ2ZVQXRfQlU   bsd/gdrive-openbsd-386           bin    6.1 MB   2016-02-21 22:54:32\n0B3X9GlR6EmbncEtlN3ZuQ0VUWms   bsd/gdrive-openbsd-arm           bin    6.1 MB   2016-02-21 22:54:35\n0B3X9GlR6EmbnMlFLY1ptNEFyZWc   bsd/gdrive-openbsd-x64           bin    7.8 MB   2016-02-21 22:54:38\n0B3X9GlR6EmbncGtSajQyNzloVEE   linux                            dir             2016-02-21 22:54:01\n0B3X9GlR6EmbnMWVudkJmb1NZdmM   linux/gdrive-linux-386           bin    6.1 MB   2016-02-21 22:54:40\n0B3X9GlR6Embnbnpla1R2VHV5T2M   linux/gdrive-linux-arm           bin    6.1 MB   2016-02-21 22:54:42\n0B3X9GlR6EmbnM0s2cU1YWkNJSjA   linux/gdrive-linux-arm64         bin    7.7 MB   2016-02-21 22:54:45\n0B3X9GlR6EmbnNU9NNi1TdDc4S2c   linux/gdrive-linux-mips64        bin    8.5 MB   2016-02-21 22:54:47\n0B3X9GlR6EmbnSmdQNjRKZ2dWV1U   linux/gdrive-linux-mips64le      bin    8.5 MB   2016-02-21 22:54:50\n0B3X9GlR6EmbnS0g0OVgxMHY5Z3c   linux/gdrive-linux-ppc64         bin    7.8 MB   2016-02-21 22:54:52\n0B3X9GlR6EmbneVp6ZXRpR3FhWlU   linux/gdrive-linux-ppc64le       bin    7.8 MB   2016-02-21 22:54:54\n0B3X9GlR6EmbnczdJT195dFVxdU0   linux/gdrive-linux-x64           bin    7.8 MB   2016-02-21 22:54:57\n0B3X9GlR6EmbnTXZXeDRnSDdVS1E   osx                              dir             2016-02-21 22:54:02\n0B3X9GlR6EmbnWnRheXJNR0pUMU0   osx/gdrive-osx-386               bin    6.6 MB   2016-02-21 22:54:59\n0B3X9GlR6EmbnRzNqMWFXdDR1Rms   osx/gdrive-osx-arm               bin    6.6 MB   2016-02-21 22:55:01\n0B3X9GlR6EmbnaDlVWTZDd0JIeEU   osx/gdrive-osx-x64               bin    8.3 MB   2016-02-21 22:55:04\n0B3X9GlR6EmbnWW84UFBvbHlURXM   plan9                            dir             2016-02-21 22:54:02\n0B3X9GlR6EmbnTmc0a2RNdDZDRUU   plan9/gdrive-plan9-386           bin    5.8 MB   2016-02-21 22:55:07\n0B3X9GlR6EmbnT1pYZ2p4Sk9FVFk   plan9/gdrive-plan9-x64           bin    7.4 MB   2016-02-21 22:55:10\n0B3X9GlR6EmbnbnZnXzlYVHoxdk0   readme.txt                       bin    40.0 B   2016-02-21 22:59:56\n0B3X9GlR6EmbnSWF1QUlta3RnaGc   solaris                          dir             2016-02-21 22:54:03\n0B3X9GlR6EmbnaWFOV0YxSGs5Znc   solaris/gdrive-solaris-x64       bin    7.7 MB   2016-02-21 22:55:13\n0B3X9GlR6EmbnNE5ySkEzbWQ4Qms   windows                          dir             2016-02-21 22:54:03\n0B3X9GlR6EmbnX1RIT2w1TWZYWFU   windows/gdrive-windows-386.exe   bin    6.1 MB   2016-02-21 22:55:15\n0B3X9GlR6EmbndmVMU05POGRPS3c   windows/gdrive-windows-x64.exe   bin    7.8 MB   2016-02-21 22:55:18\n```\n"
  },
  {
    "path": "_release/build-all.sh",
    "content": "#!/bin/bash\n\nAPP_NAME=\"gdrive\"\nPLATFORMS=\"darwin/386 darwin/amd64 darwin/arm darwin/arm64 dragonfly/amd64 freebsd/386 freebsd/amd64 freebsd/arm linux/386 linux/amd64 linux/arm linux/arm64 linux/ppc64 linux/ppc64le linux/mips64 linux/mips64le linux/rpi netbsd/386 netbsd/amd64 netbsd/arm openbsd/386 openbsd/amd64 openbsd/arm plan9/386 plan9/amd64 solaris/amd64 windows/386 windows/amd64\"\n\nBIN_PATH=\"_release/bin\"\n\n# Initialize bin dir\nmkdir -p $BIN_PATH\nrm $BIN_PATH/* 2> /dev/null\n\n# Build binary for each platform\nfor PLATFORM in $PLATFORMS; do\n    GOOS=${PLATFORM%/*}\n    GOARCH=${PLATFORM#*/}\n    BIN_NAME=\"${APP_NAME}-${GOOS/darwin/osx}-${GOARCH/amd64/x64}\"\n\n    if [ $GOOS == \"windows\" ]; then\n        BIN_NAME=\"${BIN_NAME}.exe\"\n    fi\n\n    # Raspberrypi seems to need arm5 binaries\n    if [ $GOARCH == \"rpi\" ]; then\n        export GOARM=5\n        GOARCH=\"arm\"\n    else\n        unset GOARM\n    fi\n\n    export GOOS=$GOOS\n    export GOARCH=$GOARCH\n\n    echo \"Building $BIN_NAME\"\n    go build -ldflags '-w -s' -o ${BIN_PATH}/${BIN_NAME}\ndone\n\necho \"All done\"\n"
  },
  {
    "path": "_release/print_usage_markdown.sh",
    "content": "#!/bin/bash\n\necho '## Usage'\necho '```'\ngdrive help | tail -n+3\necho '```'\n\nIFS=$'\\n'\n\nhelp=$(gdrive help | grep global | sed -E 's/ \\[[^]]+\\]//g' | sed -E 's/ <[^>]+>//g' | sed -E 's/ {2,}.+//' | sed -E 's/^gdrive //')\n\nfor args in $help; do\n    cmd=\"gdrive help $args\"\n    echo\n    eval $cmd | sed -e '1s/^/#### /' | sed -e $'1s/$/\\\\\\n```/' | sed -e 's/pii/<user>/'\n    echo '```'\ndone\n"
  },
  {
    "path": "_release/upload.sh",
    "content": "#!/usr/local/bin/bash\n\n# Grab application version\nVERSION=$(_release/bin/gdrive-osx-x64 version | awk 'NR==1 {print $2}')\n\ndeclare -a filenames\nfilenames=(\n    \"gdrive-osx-x64\"\n    \"gdrive-osx-386\"\n    \"gdrive-osx-arm\"\n    \"gdrive-linux-x64\"\n    \"gdrive-linux-386\"\n    \"gdrive-linux-rpi\"\n    \"gdrive-linux-arm64\"\n    \"gdrive-linux-arm\"\n    \"gdrive-linux-mips64\"\n    \"gdrive-linux-mips64le\"\n    \"gdrive-linux-ppc64\"\n    \"gdrive-linux-ppc64le\"\n    \"gdrive-windows-386.exe\"\n    \"gdrive-windows-x64.exe\"\n    \"gdrive-dragonfly-x64\"\n    \"gdrive-freebsd-x64\"\n    \"gdrive-freebsd-386\"\n    \"gdrive-freebsd-arm\"\n    \"gdrive-netbsd-x64\"\n    \"gdrive-netbsd-386\"\n    \"gdrive-netbsd-arm\"\n    \"gdrive-openbsd-x64\"\n    \"gdrive-openbsd-386\"\n    \"gdrive-openbsd-arm\"\n    \"gdrive-solaris-x64\"\n    \"gdrive-plan9-x64\"\n    \"gdrive-plan9-386\"\n)\n\n# Note: associative array requires bash 4+\ndeclare -A descriptions\ndescriptions=(\n    [\"gdrive-osx-x64\"]=\"OS X 64-bit\"\n    [\"gdrive-osx-386\"]=\"OS X 32-bit\"\n    [\"gdrive-osx-arm\"]=\"OS X arm\"\n    [\"gdrive-linux-x64\"]=\"Linux 64-bit\"\n    [\"gdrive-linux-386\"]=\"Linux 32-bit\"\n    [\"gdrive-linux-rpi\"]=\"Linux Raspberry Pi\"\n    [\"gdrive-linux-arm64\"]=\"Linux arm 64-bit\"\n    [\"gdrive-linux-arm\"]=\"Linux arm 32-bit\"\n    [\"gdrive-linux-mips64\"]=\"Linux mips 64-bit\"\n    [\"gdrive-linux-mips64le\"]=\"Linux mips 64-bit le\"\n    [\"gdrive-linux-ppc64\"]=\"Linux PPC 64-bit\"\n    [\"gdrive-linux-ppc64le\"]=\"Linux PPC 64-bit le\"\n    [\"gdrive-windows-386.exe\"]=\"Window 32-bit\"\n    [\"gdrive-windows-x64.exe\"]=\"Windows 64-bit\"\n    [\"gdrive-dragonfly-x64\"]=\"DragonFly BSD 64-bit\"\n    [\"gdrive-freebsd-x64\"]=\"FreeBSD 64-bit\"\n    [\"gdrive-freebsd-386\"]=\"FreeBSD 32-bit\"\n    [\"gdrive-freebsd-arm\"]=\"FreeBSD arm\"\n    [\"gdrive-netbsd-x64\"]=\"NetBSD 64-bit\"\n    [\"gdrive-netbsd-386\"]=\"NetBSD 32-bit\"\n    [\"gdrive-netbsd-arm\"]=\"NetBSD arm\"\n    [\"gdrive-openbsd-x64\"]=\"OpenBSD 64-bit\"\n    [\"gdrive-openbsd-386\"]=\"OpenBSD 32-bit\"\n    [\"gdrive-openbsd-arm\"]=\"OpenBSD arm\"\n    [\"gdrive-solaris-x64\"]=\"Solaris 64-bit\"\n    [\"gdrive-plan9-x64\"]=\"Plan9 64-bit\"\n    [\"gdrive-plan9-386\"]=\"Plan9 32-bit\"\n)\n\n# Markdown helpers\nHEADER='### Downloads\n| Filename               | Version | Description        | Shasum                                   |\n|:-----------------------|:--------|:-------------------|:-----------------------------------------|'\n\nROW_TEMPLATE=\"| [{{name}}]({{url}}) | $VERSION | {{description}} | {{sha}} |\"\n\n\n# Print header\necho \"$HEADER\"\n\nfor name in ${filenames[@]}; do\n    bin_path=\"_release/bin/$name\"\n\n    # Upload file\n    url=$(gdrive upload --share $bin_path | awk '/https/ {print $7}')\n\n    # Shasum\n    sha=\"$(shasum -b $bin_path | awk '{print $1}')\"\n\n    # Filename\n    name=\"$(basename $bin_path)\"\n\n    # Render markdown row\n    row=${ROW_TEMPLATE//\"{{name}}\"/$name}\n    row=${row//\"{{url}}\"/$url}\n    row=${row//\"{{description}}\"/${descriptions[$name]}}\n    row=${row//\"{{sha}}\"/$sha}\n\n    # Print row\n    echo \"$row\"\ndone\n"
  },
  {
    "path": "auth/file_source.go",
    "content": "package auth\n\nimport (\n\t\"encoding/json\"\n\t\"golang.org/x/oauth2\"\n\t\"io/ioutil\"\n\t\"os\"\n)\n\nfunc FileSource(path string, token *oauth2.Token, conf *oauth2.Config) oauth2.TokenSource {\n\treturn &fileSource{\n\t\ttokenPath:   path,\n\t\ttokenSource: conf.TokenSource(oauth2.NoContext, token),\n\t}\n}\n\ntype fileSource struct {\n\ttokenPath   string\n\ttokenSource oauth2.TokenSource\n}\n\nfunc (self *fileSource) Token() (*oauth2.Token, error) {\n\ttoken, err := self.tokenSource.Token()\n\tif err != nil {\n\t\treturn token, err\n\t}\n\n\t// Save token to file\n\tSaveToken(self.tokenPath, token)\n\n\treturn token, nil\n}\n\nfunc ReadFile(path string) ([]byte, bool, error) {\n\tif !fileExists(path) {\n\t\treturn nil, false, nil\n\t}\n\n\tcontent, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, true, err\n\t}\n\treturn content, true, nil\n}\n\n\nfunc ReadToken(path string) (*oauth2.Token, bool, error) {\n\n\tcontent, exists, err := ReadFile(path)\n\tif err != nil || exists == false {\n\t\treturn nil, exists, err\n\t}\n\n\ttoken := &oauth2.Token{}\n\treturn token, exists, json.Unmarshal(content, token)\n}\n\nfunc SaveToken(path string, token *oauth2.Token) error {\n\tdata, err := json.MarshalIndent(token, \"\", \"  \")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err = mkdir(path); err != nil {\n\t\treturn err\n\t}\n\n\t// Write to temp file first\n\ttmpFile := path + \".tmp\"\n\terr = ioutil.WriteFile(tmpFile, data, 0600)\n\tif err != nil {\n\t\tos.Remove(tmpFile)\n\t\treturn err\n\t}\n\n\t// Move file to correct path\n\treturn os.Rename(tmpFile, path)\n}\n"
  },
  {
    "path": "auth/oauth.go",
    "content": "package auth\n\nimport (\n\t\"fmt\"\n\t\"golang.org/x/oauth2\"\n\t\"golang.org/x/oauth2/google\"\n\t\"net/http\"\n\t\"time\"\n)\n\ntype authCodeFn func(string) func() string\n\nfunc NewFileSourceClient(clientId, clientSecret, tokenFile string, authFn authCodeFn) (*http.Client, error) {\n\tconf := getConfig(clientId, clientSecret)\n\n\t// Read cached token\n\ttoken, exists, err := ReadToken(tokenFile)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to read token: %s\", err)\n\t}\n\n\t// Require auth code if token file does not exist\n\t// or refresh token is missing\n\tif !exists || token.RefreshToken == \"\" {\n\t\tauthUrl := conf.AuthCodeURL(\"state\", oauth2.AccessTypeOffline)\n\t\tauthCode := authFn(authUrl)()\n\t\ttoken, err = conf.Exchange(oauth2.NoContext, authCode)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Failed to exchange auth code for token: %s\", err)\n\t\t}\n\t}\n\n\treturn oauth2.NewClient(\n\t\toauth2.NoContext,\n\t\tFileSource(tokenFile, token, conf),\n\t), nil\n}\n\nfunc NewRefreshTokenClient(clientId, clientSecret, refreshToken string) *http.Client {\n\tconf := getConfig(clientId, clientSecret)\n\n\ttoken := &oauth2.Token{\n\t\tTokenType:    \"Bearer\",\n\t\tRefreshToken: refreshToken,\n\t\tExpiry:       time.Now(),\n\t}\n\n\treturn oauth2.NewClient(\n\t\toauth2.NoContext,\n\t\tconf.TokenSource(oauth2.NoContext, token),\n\t)\n}\n\nfunc NewAccessTokenClient(clientId, clientSecret, accessToken string) *http.Client {\n\tconf := getConfig(clientId, clientSecret)\n\n\ttoken := &oauth2.Token{\n\t\tTokenType:   \"Bearer\",\n\t\tAccessToken: accessToken,\n\t}\n\n\treturn oauth2.NewClient(\n\t\toauth2.NoContext,\n\t\tconf.TokenSource(oauth2.NoContext, token),\n\t)\n}\n\nfunc NewServiceAccountClient(serviceAccountFile string) (*http.Client, error) {\n\tcontent, exists, err := ReadFile(serviceAccountFile)\n\tif(!exists) {\n\t\treturn nil, fmt.Errorf(\"Service account filename %q not found\", serviceAccountFile)\n\t}\n\n\tif(err != nil) {\n\t\treturn nil, err\n\t}\n\n\tconf, err := google.JWTConfigFromJSON(content, \"https://www.googleapis.com/auth/drive\")\n\tif(err != nil) {\n\t\treturn nil, err\n\t}\n\treturn conf.Client(oauth2.NoContext), nil\n}\n\nfunc getConfig(clientId, clientSecret string) *oauth2.Config {\n\treturn &oauth2.Config{\n\t\tClientID:     clientId,\n\t\tClientSecret: clientSecret,\n\t\tScopes:       []string{\"https://www.googleapis.com/auth/drive\"},\n\t\tRedirectURL:  \"urn:ietf:wg:oauth:2.0:oob\",\n\t\tEndpoint: oauth2.Endpoint{\n\t\t\tAuthURL:  \"https://accounts.google.com/o/oauth2/auth\",\n\t\t\tTokenURL: \"https://accounts.google.com/o/oauth2/token\",\n\t\t},\n\t}\n}\n"
  },
  {
    "path": "auth/util.go",
    "content": "package auth\n\nimport (\n\t\"os\"\n\t\"path/filepath\"\n)\n\nfunc mkdir(path string) error {\n\tdir := filepath.Dir(path)\n\tif fileExists(dir) {\n\t\treturn nil\n\t}\n\treturn os.Mkdir(dir, 0700)\n}\n\nfunc fileExists(path string) bool {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true\n\t}\n\treturn false\n}\n"
  },
  {
    "path": "cli/context.go",
    "content": "package cli\n\ntype Context struct {\n\targs     Arguments\n\thandlers []*Handler\n}\n\nfunc (self Context) Args() Arguments {\n\treturn self.args\n}\n\nfunc (self Context) Handlers() []*Handler {\n\treturn self.handlers\n}\n\ntype Arguments map[string]interface{}\n\nfunc (self Arguments) String(key string) string {\n\treturn self[key].(string)\n}\n\nfunc (self Arguments) Int64(key string) int64 {\n\treturn self[key].(int64)\n}\n\nfunc (self Arguments) Bool(key string) bool {\n\treturn self[key].(bool)\n}\n\nfunc (self Arguments) StringSlice(key string) []string {\n\treturn self[key].([]string)\n}\n"
  },
  {
    "path": "cli/flags.go",
    "content": "package cli\n\ntype Flag interface {\n\tGetPatterns() []string\n\tGetName() string\n\tGetDescription() string\n\tGetParser() Parser\n}\n\nfunc getFlagParser(flags []Flag) Parser {\n\tvar parsers []Parser\n\n\tfor _, flag := range flags {\n\t\tparsers = append(parsers, flag.GetParser())\n\t}\n\n\treturn FlagParser{parsers}\n}\n\ntype BoolFlag struct {\n\tPatterns     []string\n\tName         string\n\tDescription  string\n\tDefaultValue bool\n\tOmitValue    bool\n}\n\nfunc (self BoolFlag) GetName() string {\n\treturn self.Name\n}\n\nfunc (self BoolFlag) GetPatterns() []string {\n\treturn self.Patterns\n}\n\nfunc (self BoolFlag) GetDescription() string {\n\treturn self.Description\n}\n\nfunc (self BoolFlag) GetParser() Parser {\n\tvar parsers []Parser\n\tfor _, p := range self.Patterns {\n\t\tparsers = append(parsers, BoolFlagParser{\n\t\t\tpattern:      p,\n\t\t\tkey:          self.Name,\n\t\t\tomitValue:    self.OmitValue,\n\t\t\tdefaultValue: self.DefaultValue,\n\t\t})\n\t}\n\n\tif len(parsers) == 1 {\n\t\treturn parsers[0]\n\t}\n\treturn ShortCircuitParser{parsers}\n}\n\ntype StringFlag struct {\n\tPatterns     []string\n\tName         string\n\tDescription  string\n\tDefaultValue string\n}\n\nfunc (self StringFlag) GetName() string {\n\treturn self.Name\n}\n\nfunc (self StringFlag) GetPatterns() []string {\n\treturn self.Patterns\n}\n\nfunc (self StringFlag) GetDescription() string {\n\treturn self.Description\n}\n\nfunc (self StringFlag) GetParser() Parser {\n\tvar parsers []Parser\n\tfor _, p := range self.Patterns {\n\t\tparsers = append(parsers, StringFlagParser{\n\t\t\tpattern:      p,\n\t\t\tkey:          self.Name,\n\t\t\tdefaultValue: self.DefaultValue,\n\t\t})\n\t}\n\n\tif len(parsers) == 1 {\n\t\treturn parsers[0]\n\t}\n\treturn ShortCircuitParser{parsers}\n}\n\ntype IntFlag struct {\n\tPatterns     []string\n\tName         string\n\tDescription  string\n\tDefaultValue int64\n}\n\nfunc (self IntFlag) GetName() string {\n\treturn self.Name\n}\n\nfunc (self IntFlag) GetPatterns() []string {\n\treturn self.Patterns\n}\n\nfunc (self IntFlag) GetDescription() string {\n\treturn self.Description\n}\n\nfunc (self IntFlag) GetParser() Parser {\n\tvar parsers []Parser\n\tfor _, p := range self.Patterns {\n\t\tparsers = append(parsers, IntFlagParser{\n\t\t\tpattern:      p,\n\t\t\tkey:          self.Name,\n\t\t\tdefaultValue: self.DefaultValue,\n\t\t})\n\t}\n\n\tif len(parsers) == 1 {\n\t\treturn parsers[0]\n\t}\n\treturn ShortCircuitParser{parsers}\n}\n\ntype StringSliceFlag struct {\n\tPatterns     []string\n\tName         string\n\tDescription  string\n\tDefaultValue []string\n}\n\nfunc (self StringSliceFlag) GetName() string {\n\treturn self.Name\n}\n\nfunc (self StringSliceFlag) GetPatterns() []string {\n\treturn self.Patterns\n}\n\nfunc (self StringSliceFlag) GetDescription() string {\n\treturn self.Description\n}\n\nfunc (self StringSliceFlag) GetParser() Parser {\n\tvar parsers []Parser\n\tfor _, p := range self.Patterns {\n\t\tparsers = append(parsers, StringSliceFlagParser{\n\t\t\tpattern:      p,\n\t\t\tkey:          self.Name,\n\t\t\tdefaultValue: self.DefaultValue,\n\t\t})\n\t}\n\n\tif len(parsers) == 1 {\n\t\treturn parsers[0]\n\t}\n\treturn ShortCircuitParser{parsers}\n}\n"
  },
  {
    "path": "cli/handler.go",
    "content": "package cli\n\nimport (\n\t\"regexp\"\n\t\"strings\"\n)\n\nfunc NewFlagGroup(name string, flags ...Flag) FlagGroup {\n\treturn FlagGroup{\n\t\tName:  name,\n\t\tFlags: flags,\n\t}\n}\n\ntype FlagGroup struct {\n\tName  string\n\tFlags []Flag\n}\n\ntype FlagGroups []FlagGroup\n\nfunc (groups FlagGroups) getFlags(name string) []Flag {\n\tfor _, group := range groups {\n\t\tif group.Name == name {\n\t\t\treturn group.Flags\n\t\t}\n\t}\n\n\treturn nil\n}\n\nvar handlers []*Handler\n\ntype Handler struct {\n\tPattern     string\n\tFlagGroups  FlagGroups\n\tCallback    func(Context)\n\tDescription string\n}\n\nfunc (self *Handler) getParser() Parser {\n\tvar parsers []Parser\n\n\tfor _, pattern := range self.SplitPattern() {\n\t\tif isFlagGroup(pattern) {\n\t\t\tgroupName := flagGroupName(pattern)\n\t\t\tflags := self.FlagGroups.getFlags(groupName)\n\t\t\tparsers = append(parsers, getFlagParser(flags))\n\t\t} else if isCaptureGroup(pattern) {\n\t\t\tparsers = append(parsers, CaptureGroupParser{pattern})\n\t\t} else {\n\t\t\tparsers = append(parsers, EqualParser{pattern})\n\t\t}\n\t}\n\n\treturn CompleteParser{parsers}\n}\n\n// Split on spaces but ignore spaces inside <...> and [...]\nfunc (self *Handler) SplitPattern() []string {\n\tre := regexp.MustCompile(`(<[^>]+>|\\[[^\\]]+]|\\S+)`)\n\tmatches := []string{}\n\n\tfor _, value := range re.FindAllStringSubmatch(self.Pattern, -1) {\n\t\tmatches = append(matches, value[1])\n\t}\n\n\treturn matches\n}\n\nfunc SetHandlers(h []*Handler) {\n\thandlers = h\n}\n\nfunc AddHandler(pattern string, groups FlagGroups, callback func(Context), desc string) {\n\thandlers = append(handlers, &Handler{\n\t\tPattern:     pattern,\n\t\tFlagGroups:  groups,\n\t\tCallback:    callback,\n\t\tDescription: desc,\n\t})\n}\n\nfunc findHandler(args []string) *Handler {\n\tfor _, h := range handlers {\n\t\tif _, ok := h.getParser().Match(args); ok {\n\t\t\treturn h\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc Handle(args []string) bool {\n\th := findHandler(args)\n\tif h == nil {\n\t\treturn false\n\t}\n\n\t_, data := h.getParser().Capture(args)\n\tctx := Context{\n\t\targs:     data,\n\t\thandlers: handlers,\n\t}\n\th.Callback(ctx)\n\treturn true\n}\n\nfunc isCaptureGroup(arg string) bool {\n\treturn strings.HasPrefix(arg, \"<\") && strings.HasSuffix(arg, \">\")\n}\n\nfunc isFlagGroup(arg string) bool {\n\treturn strings.HasPrefix(arg, \"[\") && strings.HasSuffix(arg, \"]\")\n}\n\nfunc flagGroupName(s string) string {\n\treturn s[1 : len(s)-1]\n}\n"
  },
  {
    "path": "cli/parser.go",
    "content": "package cli\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n)\n\ntype Parser interface {\n\tMatch([]string) ([]string, bool)\n\tCapture([]string) ([]string, map[string]interface{})\n}\n\ntype EqualParser struct {\n\tvalue string\n}\n\nfunc (self EqualParser) Match(values []string) ([]string, bool) {\n\tif len(values) == 0 {\n\t\treturn values, false\n\t}\n\n\tif self.value == values[0] {\n\t\treturn values[1:], true\n\t}\n\n\treturn values, false\n}\n\nfunc (self EqualParser) Capture(values []string) ([]string, map[string]interface{}) {\n\tremainingValues, _ := self.Match(values)\n\treturn remainingValues, nil\n}\n\nfunc (self EqualParser) String() string {\n\treturn fmt.Sprintf(\"EqualParser '%s'\", self.value)\n}\n\ntype CaptureGroupParser struct {\n\tvalue string\n}\n\nfunc (self CaptureGroupParser) Match(values []string) ([]string, bool) {\n\tif len(values) == 0 {\n\t\treturn values, false\n\t}\n\n\treturn values[1:], true\n}\n\nfunc (self CaptureGroupParser) key() string {\n\treturn self.value[1 : len(self.value)-1]\n}\n\nfunc (self CaptureGroupParser) Capture(values []string) ([]string, map[string]interface{}) {\n\tif remainingValues, ok := self.Match(values); ok {\n\t\treturn remainingValues, map[string]interface{}{self.key(): values[0]}\n\t}\n\n\treturn values, nil\n}\n\nfunc (self CaptureGroupParser) String() string {\n\treturn fmt.Sprintf(\"CaptureGroupParser '%s'\", self.value)\n}\n\ntype BoolFlagParser struct {\n\tpattern      string\n\tkey          string\n\tomitValue    bool\n\tdefaultValue bool\n}\n\nfunc (self BoolFlagParser) Match(values []string) ([]string, bool) {\n\tif self.omitValue {\n\t\treturn flagKeyMatch(self.pattern, values, 0)\n\t}\n\n\tremaining, value, ok := flagKeyValueMatch(self.pattern, values, 0)\n\tif !ok {\n\t\treturn remaining, false\n\t}\n\n\t// Check that value is a valid boolean\n\tif _, err := strconv.ParseBool(value); err != nil {\n\t\treturn remaining, false\n\t}\n\n\treturn remaining, true\n}\n\nfunc (self BoolFlagParser) Capture(values []string) ([]string, map[string]interface{}) {\n\tif self.omitValue {\n\t\tremaining, ok := flagKeyMatch(self.pattern, values, 0)\n\t\treturn remaining, map[string]interface{}{self.key: ok}\n\t}\n\n\tremaining, value, ok := flagKeyValueMatch(self.pattern, values, 0)\n\tif !ok {\n\t\treturn remaining, map[string]interface{}{self.key: self.defaultValue}\n\t}\n\n\tb, _ := strconv.ParseBool(value)\n\treturn remaining, map[string]interface{}{self.key: b}\n}\n\nfunc (self BoolFlagParser) String() string {\n\treturn fmt.Sprintf(\"BoolFlagParser '%s'\", self.pattern)\n}\n\ntype StringFlagParser struct {\n\tpattern      string\n\tkey          string\n\tdefaultValue string\n}\n\nfunc (self StringFlagParser) Match(values []string) ([]string, bool) {\n\tremaining, _, ok := flagKeyValueMatch(self.pattern, values, 0)\n\treturn remaining, ok\n}\n\nfunc (self StringFlagParser) Capture(values []string) ([]string, map[string]interface{}) {\n\tremaining, value, ok := flagKeyValueMatch(self.pattern, values, 0)\n\tif !ok {\n\t\treturn remaining, map[string]interface{}{self.key: self.defaultValue}\n\t}\n\n\treturn remaining, map[string]interface{}{self.key: value}\n}\n\nfunc (self StringFlagParser) String() string {\n\treturn fmt.Sprintf(\"StringFlagParser '%s'\", self.pattern)\n}\n\ntype IntFlagParser struct {\n\tpattern      string\n\tkey          string\n\tdefaultValue int64\n}\n\nfunc (self IntFlagParser) Match(values []string) ([]string, bool) {\n\tremaining, value, ok := flagKeyValueMatch(self.pattern, values, 0)\n\tif !ok {\n\t\treturn remaining, false\n\t}\n\n\t// Check that value is a valid integer\n\tif _, err := strconv.ParseInt(value, 10, 64); err != nil {\n\t\treturn remaining, false\n\t}\n\n\treturn remaining, true\n}\n\nfunc (self IntFlagParser) Capture(values []string) ([]string, map[string]interface{}) {\n\tremaining, value, ok := flagKeyValueMatch(self.pattern, values, 0)\n\tif !ok {\n\t\treturn remaining, map[string]interface{}{self.key: self.defaultValue}\n\t}\n\n\tn, _ := strconv.ParseInt(value, 10, 64)\n\treturn remaining, map[string]interface{}{self.key: n}\n}\n\nfunc (self IntFlagParser) String() string {\n\treturn fmt.Sprintf(\"IntFlagParser '%s'\", self.pattern)\n}\n\ntype StringSliceFlagParser struct {\n\tpattern      string\n\tkey          string\n\tdefaultValue []string\n}\n\nfunc (self StringSliceFlagParser) Match(values []string) ([]string, bool) {\n\tif len(values) < 2 {\n\t\treturn values, false\n\t}\n\n\tvar remainingValues []string\n\n\tfor i := 0; i < len(values); i++ {\n\t\tif values[i] == self.pattern && i+1 < len(values) {\n\t\t\ti++\n\t\t\tcontinue\n\t\t}\n\t\tremainingValues = append(remainingValues, values[i])\n\t}\n\n\treturn remainingValues, len(values) != len(remainingValues)\n}\n\nfunc (self StringSliceFlagParser) Capture(values []string) ([]string, map[string]interface{}) {\n\tremainingValues, ok := self.Match(values)\n\tif !ok {\n\t\treturn values, map[string]interface{}{self.key: self.defaultValue}\n\t}\n\n\tvar captured []string\n\n\tfor i := 0; i < len(values); i++ {\n\t\tif values[i] == self.pattern && i+1 < len(values) {\n\t\t\tcaptured = append(captured, values[i+1])\n\t\t}\n\t}\n\n\treturn remainingValues, map[string]interface{}{self.key: captured}\n}\n\nfunc (self StringSliceFlagParser) String() string {\n\treturn fmt.Sprintf(\"StringSliceFlagParser '%s'\", self.pattern)\n}\n\ntype FlagParser struct {\n\tparsers []Parser\n}\n\nfunc (self FlagParser) Match(values []string) ([]string, bool) {\n\tremainingValues := values\n\n\tfor _, parser := range self.parsers {\n\t\tremainingValues, _ = parser.Match(remainingValues)\n\t}\n\treturn remainingValues, true\n}\n\nfunc (self FlagParser) Capture(values []string) ([]string, map[string]interface{}) {\n\tcaptured := map[string]interface{}{}\n\tremainingValues := values\n\n\tfor _, parser := range self.parsers {\n\t\tvar data map[string]interface{}\n\t\tremainingValues, data = parser.Capture(remainingValues)\n\t\tfor key, value := range data {\n\t\t\tcaptured[key] = value\n\t\t}\n\t}\n\n\treturn remainingValues, captured\n}\n\nfunc (self FlagParser) String() string {\n\treturn fmt.Sprintf(\"FlagParser %v\", self.parsers)\n}\n\ntype ShortCircuitParser struct {\n\tparsers []Parser\n}\n\nfunc (self ShortCircuitParser) Match(values []string) ([]string, bool) {\n\tremainingValues := values\n\n\tfor _, parser := range self.parsers {\n\t\tvar ok bool\n\t\tremainingValues, ok = parser.Match(remainingValues)\n\t\tif ok {\n\t\t\treturn remainingValues, true\n\t\t}\n\t}\n\n\treturn remainingValues, false\n}\n\nfunc (self ShortCircuitParser) Capture(values []string) ([]string, map[string]interface{}) {\n\tif len(self.parsers) == 0 {\n\t\treturn values, nil\n\t}\n\n\tfor _, parser := range self.parsers {\n\t\tif _, ok := parser.Match(values); ok {\n\t\t\treturn parser.Capture(values)\n\t\t}\n\t}\n\n\t// No parsers matched at this point,\n\t// just return the capture value of the first one\n\treturn self.parsers[0].Capture(values)\n}\n\nfunc (self ShortCircuitParser) String() string {\n\treturn fmt.Sprintf(\"ShortCircuitParser %v\", self.parsers)\n}\n\ntype CompleteParser struct {\n\tparsers []Parser\n}\n\nfunc (self CompleteParser) Match(values []string) ([]string, bool) {\n\tremainingValues := copySlice(values)\n\n\tfor _, parser := range self.parsers {\n\t\tvar ok bool\n\t\tremainingValues, ok = parser.Match(remainingValues)\n\t\tif !ok {\n\t\t\treturn remainingValues, false\n\t\t}\n\t}\n\n\treturn remainingValues, len(remainingValues) == 0\n}\n\nfunc (self CompleteParser) Capture(values []string) ([]string, map[string]interface{}) {\n\tremainingValues := copySlice(values)\n\tdata := map[string]interface{}{}\n\n\tfor _, parser := range self.parsers {\n\t\tvar captured map[string]interface{}\n\t\tremainingValues, captured = parser.Capture(remainingValues)\n\t\tfor key, value := range captured {\n\t\t\tdata[key] = value\n\t\t}\n\t}\n\n\treturn remainingValues, data\n}\n\nfunc (self CompleteParser) String() string {\n\treturn fmt.Sprintf(\"CompleteParser %v\", self.parsers)\n}\n\nfunc flagKeyValueMatch(key string, values []string, index int) ([]string, string, bool) {\n\tif index > len(values)-2 {\n\t\treturn values, \"\", false\n\t}\n\n\tif values[index] == key {\n\t\tvalue := values[index+1]\n\t\tremaining := append(copySlice(values[:index]), values[index+2:]...)\n\t\treturn remaining, value, true\n\t}\n\n\treturn flagKeyValueMatch(key, values, index+1)\n}\n\nfunc flagKeyMatch(key string, values []string, index int) ([]string, bool) {\n\tif index > len(values)-1 {\n\t\treturn values, false\n\t}\n\n\tif values[index] == key {\n\t\tremaining := append(copySlice(values[:index]), values[index+1:]...)\n\t\treturn remaining, true\n\t}\n\n\treturn flagKeyMatch(key, values, index+1)\n}\n\nfunc copySlice(a []string) []string {\n\tb := make([]string, len(a))\n\tcopy(b, a)\n\treturn b\n}\n"
  },
  {
    "path": "compare.go",
    "content": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"github.com/prasmussen/gdrive/drive\"\n\t\"os\"\n)\n\nconst MinCacheFileSize = 5 * 1024 * 1024\n\ntype Md5Comparer struct{}\n\nfunc (self Md5Comparer) Changed(local *drive.LocalFile, remote *drive.RemoteFile) bool {\n\treturn remote.Md5() != md5sum(local.AbsPath())\n}\n\ntype CachedFileInfo struct {\n\tSize     int64  `json:\"size\"`\n\tModified int64  `json:\"modified\"`\n\tMd5      string `json:\"md5\"`\n}\n\nfunc NewCachedMd5Comparer(path string) CachedMd5Comparer {\n\tcache := map[string]*CachedFileInfo{}\n\n\tf, err := os.Open(path)\n\tif err == nil {\n\t\tjson.NewDecoder(f).Decode(&cache)\n\t}\n\tf.Close()\n\treturn CachedMd5Comparer{path, cache}\n}\n\ntype CachedMd5Comparer struct {\n\tpath  string\n\tcache map[string]*CachedFileInfo\n}\n\nfunc (self CachedMd5Comparer) Changed(local *drive.LocalFile, remote *drive.RemoteFile) bool {\n\treturn remote.Md5() != self.md5(local)\n}\n\nfunc (self CachedMd5Comparer) md5(local *drive.LocalFile) string {\n\t// See if file exist in cache\n\tcached, found := self.cache[local.AbsPath()]\n\n\t// If found and modification time and size has not changed, return cached md5\n\tif found && local.Modified().UnixNano() == cached.Modified && local.Size() == cached.Size {\n\t\treturn cached.Md5\n\t}\n\n\t// Calculate new md5 sum\n\tmd5 := md5sum(local.AbsPath())\n\n\t// Cache file info if file meets size criteria\n\tif local.Size() > MinCacheFileSize {\n\t\tself.cacheAdd(local, md5)\n\t\tself.persist()\n\t}\n\n\treturn md5\n}\n\nfunc (self CachedMd5Comparer) cacheAdd(lf *drive.LocalFile, md5 string) {\n\tself.cache[lf.AbsPath()] = &CachedFileInfo{\n\t\tSize:     lf.Size(),\n\t\tModified: lf.Modified().UnixNano(),\n\t\tMd5:      md5,\n\t}\n}\n\nfunc (self CachedMd5Comparer) persist() {\n\twriteJson(self.path, self.cache)\n}\n"
  },
  {
    "path": "drive/about.go",
    "content": "package drive\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"text/tabwriter\"\n)\n\ntype AboutArgs struct {\n\tOut         io.Writer\n\tSizeInBytes bool\n}\n\nfunc (self *Drive) About(args AboutArgs) (err error) {\n\tabout, err := self.service.About.Get().Fields(\"maxImportSizes\", \"maxUploadSize\", \"storageQuota\", \"user\").Do()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to get about: %s\", err)\n\t}\n\n\tuser := about.User\n\tquota := about.StorageQuota\n\n\tfmt.Fprintf(args.Out, \"User: %s, %s\\n\", user.DisplayName, user.EmailAddress)\n\tfmt.Fprintf(args.Out, \"Used: %s\\n\", formatSize(quota.Usage, args.SizeInBytes))\n\tfmt.Fprintf(args.Out, \"Free: %s\\n\", formatSize(quota.Limit-quota.Usage, args.SizeInBytes))\n\tfmt.Fprintf(args.Out, \"Total: %s\\n\", formatSize(quota.Limit, args.SizeInBytes))\n\tfmt.Fprintf(args.Out, \"Max upload size: %s\\n\", formatSize(about.MaxUploadSize, args.SizeInBytes))\n\treturn\n}\n\ntype AboutImportArgs struct {\n\tOut io.Writer\n}\n\nfunc (self *Drive) AboutImport(args AboutImportArgs) (err error) {\n\tabout, err := self.service.About.Get().Fields(\"importFormats\").Do()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to get about: %s\", err)\n\t}\n\tprintAboutFormats(args.Out, about.ImportFormats)\n\treturn\n}\n\ntype AboutExportArgs struct {\n\tOut io.Writer\n}\n\nfunc (self *Drive) AboutExport(args AboutExportArgs) (err error) {\n\tabout, err := self.service.About.Get().Fields(\"exportFormats\").Do()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to get about: %s\", err)\n\t}\n\tprintAboutFormats(args.Out, about.ExportFormats)\n\treturn\n}\n\nfunc printAboutFormats(out io.Writer, formats map[string][]string) {\n\tw := new(tabwriter.Writer)\n\tw.Init(out, 0, 0, 3, ' ', 0)\n\n\tfmt.Fprintln(w, \"From\\tTo\")\n\n\tfor from, toFormats := range formats {\n\t\tfmt.Fprintf(w, \"%s\\t%s\\n\", from, formatList(toFormats))\n\t}\n\n\tw.Flush()\n}\n"
  },
  {
    "path": "drive/changes.go",
    "content": "package drive\n\nimport (\n\t\"fmt\"\n\t\"google.golang.org/api/drive/v3\"\n\t\"io\"\n\t\"text/tabwriter\"\n)\n\ntype ListChangesArgs struct {\n\tOut        io.Writer\n\tPageToken  string\n\tMaxChanges int64\n\tNow        bool\n\tNameWidth  int64\n\tSkipHeader bool\n}\n\nfunc (self *Drive) ListChanges(args ListChangesArgs) error {\n\tif args.Now {\n\t\tpageToken, err := self.GetChangesStartPageToken()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfmt.Fprintf(args.Out, \"Page token: %s\\n\", pageToken)\n\t\treturn nil\n\t}\n\n\tchangeList, err := self.service.Changes.List(args.PageToken).PageSize(args.MaxChanges).RestrictToMyDrive(true).Fields(\"newStartPageToken\", \"nextPageToken\", \"changes(fileId,removed,time,file(id,name,md5Checksum,mimeType,createdTime,modifiedTime))\").Do()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed listing changes: %s\", err)\n\t}\n\n\tPrintChanges(PrintChangesArgs{\n\t\tOut:        args.Out,\n\t\tChangeList: changeList,\n\t\tNameWidth:  int(args.NameWidth),\n\t\tSkipHeader: args.SkipHeader,\n\t})\n\n\treturn nil\n}\n\nfunc (self *Drive) GetChangesStartPageToken() (string, error) {\n\tres, err := self.service.Changes.GetStartPageToken().Do()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Failed getting start page token: %s\", err)\n\t}\n\n\treturn res.StartPageToken, nil\n}\n\ntype PrintChangesArgs struct {\n\tOut        io.Writer\n\tChangeList *drive.ChangeList\n\tNameWidth  int\n\tSkipHeader bool\n}\n\nfunc PrintChanges(args PrintChangesArgs) {\n\tw := new(tabwriter.Writer)\n\tw.Init(args.Out, 0, 0, 3, ' ', 0)\n\n\tif !args.SkipHeader {\n\t\tfmt.Fprintln(w, \"Id\\tName\\tAction\\tTime\")\n\t}\n\n\tfor _, c := range args.ChangeList.Changes {\n\t\tvar name string\n\t\tvar action string\n\n\t\tif c.Removed {\n\t\t\taction = \"remove\"\n\t\t} else {\n\t\t\tname = c.File.Name\n\t\t\taction = \"update\"\n\t\t}\n\n\t\tfmt.Fprintf(w, \"%s\\t%s\\t%s\\t%s\\n\",\n\t\t\tc.FileId,\n\t\t\ttruncateString(name, args.NameWidth),\n\t\t\taction,\n\t\t\tformatDatetime(c.Time),\n\t\t)\n\t}\n\n\tif len(args.ChangeList.Changes) > 0 {\n\t\tw.Flush()\n\t\tpageToken, hasMore := nextChangesPageToken(args.ChangeList)\n\t\tfmt.Fprintf(args.Out, \"\\nToken: %s, more: %t\\n\", pageToken, hasMore)\n\t} else {\n\t\tfmt.Fprintln(args.Out, \"No changes\")\n\t}\n}\n\nfunc nextChangesPageToken(cl *drive.ChangeList) (string, bool) {\n\tif cl.NextPageToken != \"\" {\n\t\treturn cl.NextPageToken, true\n\t}\n\n\treturn cl.NewStartPageToken, false\n}\n"
  },
  {
    "path": "drive/delete.go",
    "content": "package drive\n\nimport (\n\t\"fmt\"\n\t\"io\"\n)\n\ntype DeleteArgs struct {\n\tOut       io.Writer\n\tId        string\n\tRecursive bool\n}\n\nfunc (self *Drive) Delete(args DeleteArgs) error {\n\tf, err := self.service.Files.Get(args.Id).Fields(\"name\", \"mimeType\").Do()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to get file: %s\", err)\n\t}\n\n\tif isDir(f) && !args.Recursive {\n\t\treturn fmt.Errorf(\"'%s' is a directory, use the 'recursive' flag to delete directories\", f.Name)\n\t}\n\n\terr = self.service.Files.Delete(args.Id).Do()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to delete file: %s\", err)\n\t}\n\n\tfmt.Fprintf(args.Out, \"Deleted '%s'\\n\", f.Name)\n\treturn nil\n}\n\nfunc (self *Drive) deleteFile(fileId string) error {\n\terr := self.service.Files.Delete(fileId).Do()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to delete file: %s\", err)\n\t}\n\treturn nil\n}\n"
  },
  {
    "path": "drive/download.go",
    "content": "package drive\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"time\"\n\n\t\"google.golang.org/api/drive/v3\"\n\t\"google.golang.org/api/googleapi\"\n)\n\ntype DownloadArgs struct {\n\tOut       io.Writer\n\tProgress  io.Writer\n\tId        string\n\tPath      string\n\tForce     bool\n\tSkip      bool\n\tRecursive bool\n\tDelete    bool\n\tStdout    bool\n\tTimeout   time.Duration\n}\n\nfunc (self *Drive) Download(args DownloadArgs) error {\n\tif args.Recursive {\n\t\treturn self.downloadRecursive(args)\n\t}\n\n\tf, err := self.service.Files.Get(args.Id).Fields(\"id\", \"name\", \"size\", \"mimeType\", \"md5Checksum\").Do()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to get file: %s\", err)\n\t}\n\n\tif isDir(f) {\n\t\treturn fmt.Errorf(\"'%s' is a directory, use --recursive to download directories\", f.Name)\n\t}\n\n\tif !isBinary(f) {\n\t\treturn fmt.Errorf(\"'%s' is a google document and must be exported, see the export command\", f.Name)\n\t}\n\n\tbytes, rate, err := self.downloadBinary(f, args)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !args.Stdout {\n\t\tfmt.Fprintf(args.Out, \"Downloaded %s at %s/s, total %s\\n\", f.Id, formatSize(rate, false), formatSize(bytes, false))\n\t}\n\n\tif args.Delete {\n\t\terr = self.deleteFile(args.Id)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to delete file: %s\", err)\n\t\t}\n\n\t\tif !args.Stdout {\n\t\t\tfmt.Fprintf(args.Out, \"Removed %s\\n\", args.Id)\n\t\t}\n\t}\n\treturn err\n}\n\ntype DownloadQueryArgs struct {\n\tOut       io.Writer\n\tProgress  io.Writer\n\tQuery     string\n\tPath      string\n\tForce     bool\n\tSkip      bool\n\tRecursive bool\n}\n\nfunc (self *Drive) DownloadQuery(args DownloadQueryArgs) error {\n\tlistArgs := listAllFilesArgs{\n\t\tquery:  args.Query,\n\t\tfields: []googleapi.Field{\"nextPageToken\", \"files(id,name,mimeType,size,md5Checksum)\"},\n\t}\n\tfiles, err := self.listAllFiles(listArgs)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to list files: %s\", err)\n\t}\n\n\tdownloadArgs := DownloadArgs{\n\t\tOut:      args.Out,\n\t\tProgress: args.Progress,\n\t\tPath:     args.Path,\n\t\tForce:    args.Force,\n\t\tSkip:     args.Skip,\n\t}\n\n\tfor _, f := range files {\n\t\tif isDir(f) && args.Recursive {\n\t\t\terr = self.downloadDirectory(f, downloadArgs)\n\t\t} else if isBinary(f) {\n\t\t\t_, _, err = self.downloadBinary(f, downloadArgs)\n\t\t}\n\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (self *Drive) downloadRecursive(args DownloadArgs) error {\n\tf, err := self.service.Files.Get(args.Id).Fields(\"id\", \"name\", \"size\", \"mimeType\", \"md5Checksum\").Do()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to get file: %s\", err)\n\t}\n\n\tif isDir(f) {\n\t\treturn self.downloadDirectory(f, args)\n\t} else if isBinary(f) {\n\t\t_, _, err = self.downloadBinary(f, args)\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\nfunc (self *Drive) downloadBinary(f *drive.File, args DownloadArgs) (int64, int64, error) {\n\t// Get timeout reader wrapper and context\n\ttimeoutReaderWrapper, ctx := getTimeoutReaderWrapperContext(args.Timeout)\n\n\tres, err := self.service.Files.Get(f.Id).Context(ctx).Download()\n\tif err != nil {\n\t\tif isTimeoutError(err) {\n\t\t\treturn 0, 0, fmt.Errorf(\"Failed to download file: timeout, no data was transferred for %v\", args.Timeout)\n\t\t}\n\t\treturn 0, 0, fmt.Errorf(\"Failed to download file: %s\", err)\n\t}\n\n\t// Close body on function exit\n\tdefer res.Body.Close()\n\n\t// Path to file\n\tfpath := filepath.Join(args.Path, f.Name)\n\n\tif !args.Stdout {\n\t\tfmt.Fprintf(args.Out, \"Downloading %s -> %s\\n\", f.Name, fpath)\n\t}\n\n\treturn self.saveFile(saveFileArgs{\n\t\tout:           args.Out,\n\t\tbody:          timeoutReaderWrapper(res.Body),\n\t\tcontentLength: res.ContentLength,\n\t\tfpath:         fpath,\n\t\tforce:         args.Force,\n\t\tskip:          args.Skip,\n\t\tstdout:        args.Stdout,\n\t\tprogress:      args.Progress,\n\t})\n}\n\ntype saveFileArgs struct {\n\tout           io.Writer\n\tbody          io.Reader\n\tcontentLength int64\n\tfpath         string\n\tforce         bool\n\tskip          bool\n\tstdout        bool\n\tprogress      io.Writer\n}\n\nfunc (self *Drive) saveFile(args saveFileArgs) (int64, int64, error) {\n\t// Wrap response body in progress reader\n\tsrcReader := getProgressReader(args.body, args.progress, args.contentLength)\n\n\tif args.stdout {\n\t\t// Write file content to stdout\n\t\t_, err := io.Copy(args.out, srcReader)\n\t\treturn 0, 0, err\n\t}\n\n\t// Check if file exists to force\n\tif !args.skip && !args.force && fileExists(args.fpath) {\n\t\treturn 0, 0, fmt.Errorf(\"File '%s' already exists, use --force to overwrite or --skip to skip\", args.fpath)\n\t}\n\n\t//Check if file exists to skip\n\tif args.skip && fileExists(args.fpath) {\n\t\tfmt.Printf(\"File '%s' already exists, skipping\\n\", args.fpath)\n\t\treturn 0, 0, nil\n\t}\n\n\t// Ensure any parent directories exists\n\tif err := mkdir(args.fpath); err != nil {\n\t\treturn 0, 0, err\n\t}\n\n\t// Download to tmp file\n\ttmpPath := args.fpath + \".incomplete\"\n\n\t// Create new file\n\toutFile, err := os.Create(tmpPath)\n\tif err != nil {\n\t\treturn 0, 0, fmt.Errorf(\"Unable to create new file: %s\", err)\n\t}\n\n\tstarted := time.Now()\n\n\t// Save file to disk\n\tbytes, err := io.Copy(outFile, srcReader)\n\tif err != nil {\n\t\toutFile.Close()\n\t\tos.Remove(tmpPath)\n\t\treturn 0, 0, fmt.Errorf(\"Failed saving file: %s\", err)\n\t}\n\n\t// Calculate average download rate\n\trate := calcRate(bytes, started, time.Now())\n\n\t// Close File\n\toutFile.Close()\n\n\t// Rename tmp file to proper filename\n\treturn bytes, rate, os.Rename(tmpPath, args.fpath)\n}\n\nfunc (self *Drive) downloadDirectory(parent *drive.File, args DownloadArgs) error {\n\tlistArgs := listAllFilesArgs{\n\t\tquery:  fmt.Sprintf(\"'%s' in parents\", parent.Id),\n\t\tfields: []googleapi.Field{\"nextPageToken\", \"files(id,name)\"},\n\t}\n\tfiles, err := self.listAllFiles(listArgs)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed listing files: %s\", err)\n\t}\n\n\tnewPath := filepath.Join(args.Path, parent.Name)\n\n\tfor _, f := range files {\n\t\t// Copy args and update changed fields\n\t\tnewArgs := args\n\t\tnewArgs.Path = newPath\n\t\tnewArgs.Id = f.Id\n\t\tnewArgs.Stdout = false\n\n\t\terr = self.downloadRecursive(newArgs)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc isDir(f *drive.File) bool {\n\treturn f.MimeType == DirectoryMimeType\n}\n\nfunc isBinary(f *drive.File) bool {\n\treturn f.Md5Checksum != \"\"\n}\n"
  },
  {
    "path": "drive/drive.go",
    "content": "package drive\n\nimport (\n\t\"google.golang.org/api/drive/v3\"\n\t\"net/http\"\n)\n\ntype Drive struct {\n\tservice *drive.Service\n}\n\nfunc New(client *http.Client) (*Drive, error) {\n\tservice, err := drive.New(client)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &Drive{service}, nil\n}\n"
  },
  {
    "path": "drive/errors.go",
    "content": "package drive\n\nimport (\n\t\"golang.org/x/net/context\"\n\t\"google.golang.org/api/googleapi\"\n\t\"time\"\n)\n\nconst MaxErrorRetries = 5\n\nfunc isBackendOrRateLimitError(err error) bool {\n\treturn isBackendError(err) || isRateLimitError(err)\n}\n\nfunc isBackendError(err error) bool {\n\tif err == nil {\n\t\treturn false\n\t}\n\n\tae, ok := err.(*googleapi.Error)\n\treturn ok && ae.Code >= 500 && ae.Code <= 599\n}\n\nfunc isRateLimitError(err error) bool {\n\tif err == nil {\n\t\treturn false\n\t}\n\n\tae, ok := err.(*googleapi.Error)\n\treturn ok && ae.Code == 403\n}\n\nfunc isTimeoutError(err error) bool {\n\treturn err == context.Canceled\n}\n\nfunc exponentialBackoffSleep(try int) {\n\tseconds := pow(2, try)\n\ttime.Sleep(time.Duration(seconds) * time.Second)\n}\n"
  },
  {
    "path": "drive/export.go",
    "content": "package drive\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"mime\"\n\t\"os\"\n)\n\nvar DefaultExportMime = map[string]string{\n\t\"application/vnd.google-apps.form\":         \"application/zip\",\n\t\"application/vnd.google-apps.document\":     \"application/pdf\",\n\t\"application/vnd.google-apps.drawing\":      \"image/svg+xml\",\n\t\"application/vnd.google-apps.spreadsheet\":  \"text/csv\",\n\t\"application/vnd.google-apps.script\":       \"application/vnd.google-apps.script+json\",\n\t\"application/vnd.google-apps.presentation\": \"application/pdf\",\n}\n\ntype ExportArgs struct {\n\tOut        io.Writer\n\tId         string\n\tPrintMimes bool\n\tMime       string\n\tForce      bool\n}\n\nfunc (self *Drive) Export(args ExportArgs) error {\n\tf, err := self.service.Files.Get(args.Id).Fields(\"name\", \"mimeType\").Do()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to get file: %s\", err)\n\t}\n\n\tif args.PrintMimes {\n\t\treturn self.printMimes(args.Out, f.MimeType)\n\t}\n\n\texportMime, err := getExportMime(args.Mime, f.MimeType)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfilename := getExportFilename(f.Name, exportMime)\n\n\tres, err := self.service.Files.Export(args.Id, exportMime).Download()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to download file: %s\", err)\n\t}\n\n\t// Close body on function exit\n\tdefer res.Body.Close()\n\n\t// Check if file exists\n\tif !args.Force && fileExists(filename) {\n\t\treturn fmt.Errorf(\"File '%s' already exists, use --force to overwrite\", filename)\n\t}\n\n\t// Create new file\n\toutFile, err := os.Create(filename)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Unable to create new file '%s': %s\", filename, err)\n\t}\n\n\t// Close file on function exit\n\tdefer outFile.Close()\n\n\t// Save file to disk\n\t_, err = io.Copy(outFile, res.Body)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed saving file: %s\", err)\n\t}\n\n\tfmt.Fprintf(args.Out, \"Exported '%s' with mime type: '%s'\\n\", filename, exportMime)\n\treturn nil\n}\n\nfunc (self *Drive) printMimes(out io.Writer, mimeType string) error {\n\tabout, err := self.service.About.Get().Fields(\"exportFormats\").Do()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to get about: %s\", err)\n\t}\n\n\tmimes, ok := about.ExportFormats[mimeType]\n\tif !ok {\n\t\treturn fmt.Errorf(\"File with type '%s' cannot be exported\", mimeType)\n\t}\n\n\tfmt.Fprintf(out, \"Available mime types: %s\\n\", formatList(mimes))\n\treturn nil\n}\n\nfunc getExportMime(userMime, fileMime string) (string, error) {\n\tif userMime != \"\" {\n\t\treturn userMime, nil\n\t}\n\n\tdefaultMime, ok := DefaultExportMime[fileMime]\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"File with type '%s' does not have a default export mime, and can probably not be exported\", fileMime)\n\t}\n\n\treturn defaultMime, nil\n}\n\nfunc getExportFilename(name, mimeType string) string {\n\textensions, err := mime.ExtensionsByType(mimeType)\n\tif err != nil || len(extensions) == 0 {\n\t\treturn name\n\t}\n\n\treturn name + extensions[0]\n}\n"
  },
  {
    "path": "drive/import.go",
    "content": "package drive\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"mime\"\n\t\"path/filepath\"\n\t\"strings\"\n)\n\ntype ImportArgs struct {\n\tOut      io.Writer\n\tMime     string\n\tProgress io.Writer\n\tPath     string\n\tParents  []string\n}\n\nfunc (self *Drive) Import(args ImportArgs) error {\n\tfromMime := args.Mime\n\tif fromMime == \"\" {\n\t\tfromMime = getMimeType(args.Path)\n\t}\n\tif fromMime == \"\" {\n\t\treturn fmt.Errorf(\"Could not determine mime type of file, use --mime\")\n\t}\n\n\tabout, err := self.service.About.Get().Fields(\"importFormats\").Do()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to get about: %s\", err)\n\t}\n\n\ttoMimes, ok := about.ImportFormats[fromMime]\n\tif !ok || len(toMimes) == 0 {\n\t\treturn fmt.Errorf(\"Mime type '%s' is not supported for import\", fromMime)\n\t}\n\n\tf, _, err := self.uploadFile(UploadArgs{\n\t\tOut:      ioutil.Discard,\n\t\tProgress: args.Progress,\n\t\tPath:     args.Path,\n\t\tParents:  args.Parents,\n\t\tMime:     toMimes[0],\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Fprintf(args.Out, \"Imported %s with mime type: '%s'\\n\", f.Id, toMimes[0])\n\treturn nil\n}\n\nfunc getMimeType(path string) string {\n\tt := mime.TypeByExtension(filepath.Ext(path))\n\treturn strings.Split(t, \";\")[0]\n}\n"
  },
  {
    "path": "drive/info.go",
    "content": "package drive\n\nimport (\n\t\"fmt\"\n\t\"google.golang.org/api/drive/v3\"\n\t\"io\"\n)\n\ntype FileInfoArgs struct {\n\tOut         io.Writer\n\tId          string\n\tSizeInBytes bool\n}\n\nfunc (self *Drive) Info(args FileInfoArgs) error {\n\tf, err := self.service.Files.Get(args.Id).Fields(\"id\", \"name\", \"size\", \"createdTime\", \"modifiedTime\", \"md5Checksum\", \"mimeType\", \"parents\", \"shared\", \"description\", \"webContentLink\", \"webViewLink\").Do()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to get file: %s\", err)\n\t}\n\n\tpathfinder := self.newPathfinder()\n\tabsPath, err := pathfinder.absPath(f)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tPrintFileInfo(PrintFileInfoArgs{\n\t\tOut:         args.Out,\n\t\tFile:        f,\n\t\tPath:        absPath,\n\t\tSizeInBytes: args.SizeInBytes,\n\t})\n\n\treturn nil\n}\n\ntype PrintFileInfoArgs struct {\n\tOut         io.Writer\n\tFile        *drive.File\n\tPath        string\n\tSizeInBytes bool\n}\n\nfunc PrintFileInfo(args PrintFileInfoArgs) {\n\tf := args.File\n\n\titems := []kv{\n\t\tkv{\"Id\", f.Id},\n\t\tkv{\"Name\", f.Name},\n\t\tkv{\"Path\", args.Path},\n\t\tkv{\"Description\", f.Description},\n\t\tkv{\"Mime\", f.MimeType},\n\t\tkv{\"Size\", formatSize(f.Size, args.SizeInBytes)},\n\t\tkv{\"Created\", formatDatetime(f.CreatedTime)},\n\t\tkv{\"Modified\", formatDatetime(f.ModifiedTime)},\n\t\tkv{\"Md5sum\", f.Md5Checksum},\n\t\tkv{\"Shared\", formatBool(f.Shared)},\n\t\tkv{\"Parents\", formatList(f.Parents)},\n\t\tkv{\"ViewUrl\", f.WebViewLink},\n\t\tkv{\"DownloadUrl\", f.WebContentLink},\n\t}\n\n\tfor _, item := range items {\n\t\tif item.value != \"\" {\n\t\t\tfmt.Fprintf(args.Out, \"%s: %s\\n\", item.key, item.value)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "drive/list.go",
    "content": "package drive\n\nimport (\n\t\"fmt\"\n\t\"golang.org/x/net/context\"\n\t\"google.golang.org/api/drive/v3\"\n\t\"google.golang.org/api/googleapi\"\n\t\"io\"\n\t\"text/tabwriter\"\n)\n\ntype ListFilesArgs struct {\n\tOut         io.Writer\n\tMaxFiles    int64\n\tNameWidth   int64\n\tQuery       string\n\tSortOrder   string\n\tSkipHeader  bool\n\tSizeInBytes bool\n\tAbsPath     bool\n}\n\nfunc (self *Drive) List(args ListFilesArgs) (err error) {\n\tlistArgs := listAllFilesArgs{\n\t\tquery:     args.Query,\n\t\tfields:    []googleapi.Field{\"nextPageToken\", \"files(id,name,md5Checksum,mimeType,size,createdTime,parents)\"},\n\t\tsortOrder: args.SortOrder,\n\t\tmaxFiles:  args.MaxFiles,\n\t}\n\tfiles, err := self.listAllFiles(listArgs)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to list files: %s\", err)\n\t}\n\n\tpathfinder := self.newPathfinder()\n\n\tif args.AbsPath {\n\t\t// Replace name with absolute path\n\t\tfor _, f := range files {\n\t\t\tf.Name, err = pathfinder.absPath(f)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tPrintFileList(PrintFileListArgs{\n\t\tOut:         args.Out,\n\t\tFiles:       files,\n\t\tNameWidth:   int(args.NameWidth),\n\t\tSkipHeader:  args.SkipHeader,\n\t\tSizeInBytes: args.SizeInBytes,\n\t})\n\n\treturn\n}\n\ntype listAllFilesArgs struct {\n\tquery     string\n\tfields    []googleapi.Field\n\tsortOrder string\n\tmaxFiles  int64\n}\n\nfunc (self *Drive) listAllFiles(args listAllFilesArgs) ([]*drive.File, error) {\n\tvar files []*drive.File\n\n\tvar pageSize int64\n\tif args.maxFiles > 0 && args.maxFiles < 1000 {\n\t\tpageSize = args.maxFiles\n\t} else {\n\t\tpageSize = 1000\n\t}\n\n\tcontrolledStop := fmt.Errorf(\"Controlled stop\")\n\n\terr := self.service.Files.List().Q(args.query).Fields(args.fields...).OrderBy(args.sortOrder).PageSize(pageSize).Pages(context.TODO(), func(fl *drive.FileList) error {\n\t\tfiles = append(files, fl.Files...)\n\n\t\t// Stop when we have all the files we need\n\t\tif args.maxFiles > 0 && len(files) >= int(args.maxFiles) {\n\t\t\treturn controlledStop\n\t\t}\n\n\t\treturn nil\n\t})\n\n\tif err != nil && err != controlledStop {\n\t\treturn nil, err\n\t}\n\n\tif args.maxFiles > 0 {\n\t\tn := min(len(files), int(args.maxFiles))\n\t\treturn files[:n], nil\n\t}\n\n\treturn files, nil\n}\n\ntype PrintFileListArgs struct {\n\tOut         io.Writer\n\tFiles       []*drive.File\n\tNameWidth   int\n\tSkipHeader  bool\n\tSizeInBytes bool\n}\n\nfunc PrintFileList(args PrintFileListArgs) {\n\tw := new(tabwriter.Writer)\n\tw.Init(args.Out, 0, 0, 3, ' ', 0)\n\n\tif !args.SkipHeader {\n\t\tfmt.Fprintln(w, \"Id\\tName\\tType\\tSize\\tCreated\")\n\t}\n\n\tfor _, f := range args.Files {\n\t\tfmt.Fprintf(w, \"%s\\t%s\\t%s\\t%s\\t%s\\n\",\n\t\t\tf.Id,\n\t\t\ttruncateString(f.Name, args.NameWidth),\n\t\t\tfiletype(f),\n\t\t\tformatSize(f.Size, args.SizeInBytes),\n\t\t\tformatDatetime(f.CreatedTime),\n\t\t)\n\t}\n\n\tw.Flush()\n}\n\nfunc filetype(f *drive.File) string {\n\tif isDir(f) {\n\t\treturn \"dir\"\n\t} else if isBinary(f) {\n\t\treturn \"bin\"\n\t}\n\treturn \"doc\"\n}\n"
  },
  {
    "path": "drive/mkdir.go",
    "content": "package drive\n\nimport (\n\t\"fmt\"\n\t\"google.golang.org/api/drive/v3\"\n\t\"io\"\n)\n\nconst DirectoryMimeType = \"application/vnd.google-apps.folder\"\n\ntype MkdirArgs struct {\n\tOut         io.Writer\n\tName        string\n\tDescription string\n\tParents     []string\n}\n\nfunc (self *Drive) Mkdir(args MkdirArgs) error {\n\tf, err := self.mkdir(args)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Fprintf(args.Out, \"Directory %s created\\n\", f.Id)\n\treturn nil\n}\n\nfunc (self *Drive) mkdir(args MkdirArgs) (*drive.File, error) {\n\tdstFile := &drive.File{\n\t\tName:        args.Name,\n\t\tDescription: args.Description,\n\t\tMimeType:    DirectoryMimeType,\n\t}\n\n\t// Set parent folders\n\tdstFile.Parents = args.Parents\n\n\t// Create directory\n\tf, err := self.service.Files.Create(dstFile).Do()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to create directory: %s\", err)\n\t}\n\n\treturn f, nil\n}\n"
  },
  {
    "path": "drive/path.go",
    "content": "package drive\n\nimport (\n\t\"fmt\"\n\t\"google.golang.org/api/drive/v3\"\n\t\"path/filepath\"\n)\n\nfunc (self *Drive) newPathfinder() *remotePathfinder {\n\treturn &remotePathfinder{\n\t\tservice: self.service.Files,\n\t\tfiles:   make(map[string]*drive.File),\n\t}\n}\n\ntype remotePathfinder struct {\n\tservice *drive.FilesService\n\tfiles   map[string]*drive.File\n}\n\nfunc (self *remotePathfinder) absPath(f *drive.File) (string, error) {\n\tname := f.Name\n\n\tif len(f.Parents) == 0 {\n\t\treturn name, nil\n\t}\n\n\tvar path []string\n\n\tfor {\n\t\tparent, err := self.getParent(f.Parents[0])\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\n\t\t// Stop when we find the root dir\n\t\tif len(parent.Parents) == 0 {\n\t\t\tbreak\n\t\t}\n\n\t\tpath = append([]string{parent.Name}, path...)\n\t\tf = parent\n\t}\n\n\tpath = append(path, name)\n\treturn filepath.Join(path...), nil\n}\n\nfunc (self *remotePathfinder) getParent(id string) (*drive.File, error) {\n\t// Check cache\n\tif f, ok := self.files[id]; ok {\n\t\treturn f, nil\n\t}\n\n\t// Fetch file from drive\n\tf, err := self.service.Get(id).Fields(\"id\", \"name\", \"parents\").Do()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to get file: %s\", err)\n\t}\n\n\t// Save in cache\n\tself.files[f.Id] = f\n\n\treturn f, nil\n}\n"
  },
  {
    "path": "drive/progress.go",
    "content": "package drive\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"time\"\n)\n\nconst MaxDrawInterval = time.Second * 1\nconst MaxRateInterval = time.Second * 3\n\nfunc getProgressReader(r io.Reader, w io.Writer, size int64) io.Reader {\n\t// Don't wrap reader if output is discarded or size is too small\n\tif w == ioutil.Discard || (size > 0 && size < 1024*1024) {\n\t\treturn r\n\t}\n\n\treturn &Progress{\n\t\tReader: r,\n\t\tWriter: w,\n\t\tSize:   size,\n\t}\n}\n\ntype Progress struct {\n\tWriter       io.Writer\n\tReader       io.Reader\n\tSize         int64\n\tprogress     int64\n\trate         int64\n\trateProgress int64\n\trateUpdated  time.Time\n\tupdated      time.Time\n\tdone         bool\n}\n\nfunc (self *Progress) Read(p []byte) (int, error) {\n\t// Read\n\tn, err := self.Reader.Read(p)\n\n\tnow := time.Now()\n\tisLast := err != nil\n\n\t// Increment progress\n\tnewProgress := self.progress + int64(n)\n\tself.progress = newProgress\n\n\t// Initialize rate state\n\tif self.rateUpdated.IsZero() {\n\t\tself.rateUpdated = now\n\t\tself.rateProgress = newProgress\n\t}\n\n\t// Update rate every x seconds\n\tif self.rateUpdated.Add(MaxRateInterval).Before(now) {\n\t\tself.rate = calcRate(newProgress-self.rateProgress, self.rateUpdated, now)\n\t\tself.rateUpdated = now\n\t\tself.rateProgress = newProgress\n\t}\n\n\t// Draw progress every x seconds\n\tif self.updated.Add(MaxDrawInterval).Before(now) || isLast {\n\t\tself.draw(isLast)\n\t\tself.updated = now\n\t}\n\n\t// Mark as done if error occurs\n\tself.done = isLast\n\n\treturn n, err\n}\n\nfunc (self *Progress) draw(isLast bool) {\n\tif self.done {\n\t\treturn\n\t}\n\n\tself.clear()\n\n\t// Print progress\n\tfmt.Fprintf(self.Writer, \"%s\", formatSize(self.progress, false))\n\n\t// Print total size\n\tif self.Size > 0 {\n\t\tfmt.Fprintf(self.Writer, \"/%s\", formatSize(self.Size, false))\n\t}\n\n\t// Print rate\n\tif self.rate > 0 {\n\t\tfmt.Fprintf(self.Writer, \", Rate: %s/s\", formatSize(self.rate, false))\n\t}\n\n\tif isLast {\n\t\tself.clear()\n\t}\n}\n\nfunc (self *Progress) clear() {\n\tfmt.Fprintf(self.Writer, \"\\r%50s\\r\", \"\")\n}\n"
  },
  {
    "path": "drive/revision_delete.go",
    "content": "package drive\n\nimport (\n\t\"fmt\"\n\t\"io\"\n)\n\ntype DeleteRevisionArgs struct {\n\tOut        io.Writer\n\tFileId     string\n\tRevisionId string\n}\n\nfunc (self *Drive) DeleteRevision(args DeleteRevisionArgs) (err error) {\n\trev, err := self.service.Revisions.Get(args.FileId, args.RevisionId).Fields(\"originalFilename\").Do()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to get revision: %s\", err)\n\t}\n\n\tif rev.OriginalFilename == \"\" {\n\t\treturn fmt.Errorf(\"Deleting revisions for this file type is not supported\")\n\t}\n\n\terr = self.service.Revisions.Delete(args.FileId, args.RevisionId).Do()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to delete revision\", err)\n\t}\n\n\tfmt.Fprintf(args.Out, \"Deleted revision '%s'\\n\", args.RevisionId)\n\treturn\n}\n"
  },
  {
    "path": "drive/revision_download.go",
    "content": "package drive\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"path/filepath\"\n\t\"time\"\n)\n\ntype DownloadRevisionArgs struct {\n\tOut        io.Writer\n\tProgress   io.Writer\n\tFileId     string\n\tRevisionId string\n\tPath       string\n\tForce      bool\n\tStdout     bool\n\tTimeout    time.Duration\n}\n\nfunc (self *Drive) DownloadRevision(args DownloadRevisionArgs) (err error) {\n\tgetRev := self.service.Revisions.Get(args.FileId, args.RevisionId)\n\n\trev, err := getRev.Fields(\"originalFilename\").Do()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to get file: %s\", err)\n\t}\n\n\tif rev.OriginalFilename == \"\" {\n\t\treturn fmt.Errorf(\"Download is not supported for this file type\")\n\t}\n\n\t// Get timeout reader wrapper and context\n\ttimeoutReaderWrapper, ctx := getTimeoutReaderWrapperContext(args.Timeout)\n\n\tres, err := getRev.Context(ctx).Download()\n\tif err != nil {\n\t\tif isTimeoutError(err) {\n\t\t\treturn fmt.Errorf(\"Failed to download file: timeout, no data was transferred for %v\", args.Timeout)\n\t\t}\n\t\treturn fmt.Errorf(\"Failed to download file: %s\", err)\n\t}\n\n\t// Close body on function exit\n\tdefer res.Body.Close()\n\n\t// Discard other output if file is written to stdout\n\tout := args.Out\n\tif args.Stdout {\n\t\tout = ioutil.Discard\n\t}\n\n\t// Path to file\n\tfpath := filepath.Join(args.Path, rev.OriginalFilename)\n\n\tfmt.Fprintf(out, \"Downloading %s -> %s\\n\", rev.OriginalFilename, fpath)\n\n\tbytes, rate, err := self.saveFile(saveFileArgs{\n\t\tout:           args.Out,\n\t\tbody:          timeoutReaderWrapper(res.Body),\n\t\tcontentLength: res.ContentLength,\n\t\tfpath:         fpath,\n\t\tforce:         args.Force,\n\t\tstdout:        args.Stdout,\n\t\tprogress:      args.Progress,\n\t})\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Fprintf(out, \"Download complete, rate: %s/s, total size: %s\\n\", formatSize(rate, false), formatSize(bytes, false))\n\treturn nil\n}\n"
  },
  {
    "path": "drive/revision_list.go",
    "content": "package drive\n\nimport (\n\t\"fmt\"\n\t\"google.golang.org/api/drive/v3\"\n\t\"io\"\n\t\"text/tabwriter\"\n)\n\ntype ListRevisionsArgs struct {\n\tOut         io.Writer\n\tId          string\n\tNameWidth   int64\n\tSkipHeader  bool\n\tSizeInBytes bool\n}\n\nfunc (self *Drive) ListRevisions(args ListRevisionsArgs) (err error) {\n\trevList, err := self.service.Revisions.List(args.Id).Fields(\"revisions(id,keepForever,size,modifiedTime,originalFilename)\").Do()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed listing revisions: %s\", err)\n\t}\n\n\tPrintRevisionList(PrintRevisionListArgs{\n\t\tOut:         args.Out,\n\t\tRevisions:   revList.Revisions,\n\t\tNameWidth:   int(args.NameWidth),\n\t\tSkipHeader:  args.SkipHeader,\n\t\tSizeInBytes: args.SizeInBytes,\n\t})\n\n\treturn\n}\n\ntype PrintRevisionListArgs struct {\n\tOut         io.Writer\n\tRevisions   []*drive.Revision\n\tNameWidth   int\n\tSkipHeader  bool\n\tSizeInBytes bool\n}\n\nfunc PrintRevisionList(args PrintRevisionListArgs) {\n\tw := new(tabwriter.Writer)\n\tw.Init(args.Out, 0, 0, 3, ' ', 0)\n\n\tif !args.SkipHeader {\n\t\tfmt.Fprintln(w, \"Id\\tName\\tSize\\tModified\\tKeepForever\")\n\t}\n\n\tfor _, rev := range args.Revisions {\n\t\tfmt.Fprintf(w, \"%s\\t%s\\t%s\\t%s\\t%s\\n\",\n\t\t\trev.Id,\n\t\t\ttruncateString(rev.OriginalFilename, args.NameWidth),\n\t\t\tformatSize(rev.Size, args.SizeInBytes),\n\t\t\tformatDatetime(rev.ModifiedTime),\n\t\t\tformatBool(rev.KeepForever),\n\t\t)\n\t}\n\n\tw.Flush()\n}\n"
  },
  {
    "path": "drive/share.go",
    "content": "package drive\n\nimport (\n\t\"fmt\"\n\t\"google.golang.org/api/drive/v3\"\n\t\"io\"\n\t\"text/tabwriter\"\n)\n\ntype ShareArgs struct {\n\tOut          io.Writer\n\tFileId       string\n\tRole         string\n\tType         string\n\tEmail        string\n\tDomain       string\n\tDiscoverable bool\n}\n\nfunc (self *Drive) Share(args ShareArgs) error {\n\tpermission := &drive.Permission{\n\t\tAllowFileDiscovery: args.Discoverable,\n\t\tRole:               args.Role,\n\t\tType:               args.Type,\n\t\tEmailAddress:       args.Email,\n\t\tDomain:             args.Domain,\n\t}\n\n\t_, err := self.service.Permissions.Create(args.FileId, permission).Do()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to share file: %s\", err)\n\t}\n\n\tfmt.Fprintf(args.Out, \"Granted %s permission to %s\\n\", args.Role, args.Type)\n\treturn nil\n}\n\ntype RevokePermissionArgs struct {\n\tOut          io.Writer\n\tFileId       string\n\tPermissionId string\n}\n\nfunc (self *Drive) RevokePermission(args RevokePermissionArgs) error {\n\terr := self.service.Permissions.Delete(args.FileId, args.PermissionId).Do()\n\tif err != nil {\n\t\tfmt.Errorf(\"Failed to revoke permission: %s\", err)\n\t\treturn err\n\t}\n\n\tfmt.Fprintf(args.Out, \"Permission revoked\\n\")\n\treturn nil\n}\n\ntype ListPermissionsArgs struct {\n\tOut    io.Writer\n\tFileId string\n}\n\nfunc (self *Drive) ListPermissions(args ListPermissionsArgs) error {\n\tpermList, err := self.service.Permissions.List(args.FileId).Fields(\"permissions(id,role,type,domain,emailAddress,allowFileDiscovery)\").Do()\n\tif err != nil {\n\t\tfmt.Errorf(\"Failed to list permissions: %s\", err)\n\t\treturn err\n\t}\n\n\tprintPermissions(printPermissionsArgs{\n\t\tout:         args.Out,\n\t\tpermissions: permList.Permissions,\n\t})\n\treturn nil\n}\n\nfunc (self *Drive) shareAnyoneReader(fileId string) error {\n\tpermission := &drive.Permission{\n\t\tRole: \"reader\",\n\t\tType: \"anyone\",\n\t}\n\n\t_, err := self.service.Permissions.Create(fileId, permission).Do()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to share file: %s\", err)\n\t}\n\n\treturn nil\n}\n\ntype printPermissionsArgs struct {\n\tout         io.Writer\n\tpermissions []*drive.Permission\n}\n\nfunc printPermissions(args printPermissionsArgs) {\n\tw := new(tabwriter.Writer)\n\tw.Init(args.out, 0, 0, 3, ' ', 0)\n\n\tfmt.Fprintln(w, \"Id\\tType\\tRole\\tEmail\\tDomain\\tDiscoverable\")\n\n\tfor _, p := range args.permissions {\n\t\tfmt.Fprintf(w, \"%s\\t%s\\t%s\\t%s\\t%s\\t%s\\n\",\n\t\t\tp.Id,\n\t\t\tp.Type,\n\t\t\tp.Role,\n\t\t\tp.EmailAddress,\n\t\t\tp.Domain,\n\t\t\tformatBool(p.AllowFileDiscovery),\n\t\t)\n\t}\n\n\tw.Flush()\n}\n"
  },
  {
    "path": "drive/sync.go",
    "content": "package drive\n\nimport (\n\t\"fmt\"\n\t\"github.com/sabhiram/go-gitignore\"\n\t\"github.com/soniakeys/graph\"\n\t\"google.golang.org/api/drive/v3\"\n\t\"google.golang.org/api/googleapi\"\n\t\"io\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\t\"text/tabwriter\"\n\t\"time\"\n)\n\nconst DefaultIgnoreFile = \".gdriveignore\"\n\ntype ModTime int\n\nconst (\n\tLocalLastModified ModTime = iota\n\tRemoteLastModified\n\tEqualModifiedTime\n)\n\ntype LargestSize int\n\nconst (\n\tLocalLargestSize LargestSize = iota\n\tRemoteLargestSize\n\tEqualSize\n)\n\ntype ConflictResolution int\n\nconst (\n\tNoResolution ConflictResolution = iota\n\tKeepLocal\n\tKeepRemote\n\tKeepLargest\n)\n\nfunc (self *Drive) prepareSyncFiles(localPath string, root *drive.File, cmp FileComparer) (*syncFiles, error) {\n\tlocalCh := make(chan struct {\n\t\tfiles []*LocalFile\n\t\terr   error\n\t})\n\tremoteCh := make(chan struct {\n\t\tfiles []*RemoteFile\n\t\terr   error\n\t})\n\n\tgo func() {\n\t\tfiles, err := prepareLocalFiles(localPath)\n\t\tlocalCh <- struct {\n\t\t\tfiles []*LocalFile\n\t\t\terr   error\n\t\t}{files, err}\n\t}()\n\n\tgo func() {\n\t\tfiles, err := self.prepareRemoteFiles(root, \"\")\n\t\tremoteCh <- struct {\n\t\t\tfiles []*RemoteFile\n\t\t\terr   error\n\t\t}{files, err}\n\t}()\n\n\tlocal := <-localCh\n\tif local.err != nil {\n\t\treturn nil, local.err\n\t}\n\n\tremote := <-remoteCh\n\tif remote.err != nil {\n\t\treturn nil, remote.err\n\t}\n\n\treturn &syncFiles{\n\t\troot:    &RemoteFile{file: root},\n\t\tlocal:   local.files,\n\t\tremote:  remote.files,\n\t\tcompare: cmp,\n\t}, nil\n}\n\nfunc (self *Drive) isSyncFile(id string) (bool, error) {\n\tf, err := self.service.Files.Get(id).Fields(\"appProperties\").Do()\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"Failed to get file: %s\", err)\n\t}\n\n\t_, ok := f.AppProperties[\"sync\"]\n\treturn ok, nil\n}\n\nfunc prepareLocalFiles(root string) ([]*LocalFile, error) {\n\tvar files []*LocalFile\n\n\t// Get absolute root path\n\tabsRootPath, err := filepath.Abs(root)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Prepare ignorer\n\tshouldIgnore, err := prepareIgnorer(filepath.Join(absRootPath, DefaultIgnoreFile))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = filepath.Walk(absRootPath, func(absPath 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 root directory\n\t\tif absPath == absRootPath {\n\t\t\treturn nil\n\t\t}\n\n\t\t// Skip files that are not a directory or regular file\n\t\tif !info.IsDir() && !info.Mode().IsRegular() {\n\t\t\treturn nil\n\t\t}\n\n\t\t// Get relative path from root\n\t\trelPath, err := filepath.Rel(absRootPath, absPath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Skip file if it is ignored by ignore file\n\t\tif shouldIgnore(relPath) {\n\t\t\treturn nil\n\t\t}\n\n\t\tfiles = append(files, &LocalFile{\n\t\t\tabsPath: absPath,\n\t\t\trelPath: relPath,\n\t\t\tinfo:    info,\n\t\t})\n\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to prepare local files: %s\", err)\n\t}\n\n\treturn files, err\n}\n\nfunc (self *Drive) prepareRemoteFiles(rootDir *drive.File, sortOrder string) ([]*RemoteFile, error) {\n\t// Find all files which has rootDir as root\n\tlistArgs := listAllFilesArgs{\n\t\tquery:     fmt.Sprintf(\"appProperties has {key='syncRootId' and value='%s'}\", rootDir.Id),\n\t\tfields:    []googleapi.Field{\"nextPageToken\", \"files(id,name,parents,md5Checksum,mimeType,size,modifiedTime)\"},\n\t\tsortOrder: sortOrder,\n\t}\n\tfiles, err := self.listAllFiles(listArgs)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed listing files: %s\", err)\n\t}\n\n\tif err := checkFiles(files); err != nil {\n\t\treturn nil, err\n\t}\n\n\trelPaths, err := prepareRemoteRelPaths(rootDir, files)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar remoteFiles []*RemoteFile\n\tfor _, f := range files {\n\t\trelPath, ok := relPaths[f.Id]\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"File %s does not have a valid parent\", f.Id)\n\t\t}\n\t\tremoteFiles = append(remoteFiles, &RemoteFile{\n\t\t\trelPath: relPath,\n\t\t\tfile:    f,\n\t\t})\n\t}\n\n\treturn remoteFiles, nil\n}\n\nfunc prepareRemoteRelPaths(root *drive.File, files []*drive.File) (map[string]string, error) {\n\t// The tree only holds integer values so we use\n\t// maps to lookup file by index and index by file id\n\tindexLookup := map[string]graph.NI{}\n\tfileLookup := map[graph.NI]*drive.File{}\n\n\t// All files includes root dir\n\tallFiles := append([]*drive.File{root}, files...)\n\n\t// Prepare lookup maps\n\tfor i, f := range allFiles {\n\t\tindexLookup[f.Id] = graph.NI(i)\n\t\tfileLookup[graph.NI(i)] = f\n\t}\n\n\t// This will hold 'parent index' -> 'file index' relationships\n\tpathEnds := make([]graph.PathEnd, len(allFiles))\n\n\t// Prepare parent -> file relationships\n\tfor i, f := range allFiles {\n\t\tif f == root {\n\t\t\tpathEnds[i] = graph.PathEnd{From: -1}\n\t\t\tcontinue\n\t\t}\n\n\t\t// Lookup index of parent\n\t\tparentIdx, found := indexLookup[f.Parents[0]]\n\t\tif !found {\n\t\t\treturn nil, fmt.Errorf(\"Could not find parent of %s (%s)\", f.Id, f.Name)\n\t\t}\n\t\tpathEnds[i] = graph.PathEnd{From: parentIdx}\n\t}\n\n\t// Create parent pointer tree and calculate path lengths\n\ttree := &graph.FromList{Paths: pathEnds}\n\ttree.RecalcLeaves()\n\ttree.RecalcLen()\n\n\t// This will hold a map of file id => relative path\n\tpaths := map[string]string{}\n\n\t// Find relative path from root for all files\n\tfor _, f := range allFiles {\n\t\tif f == root {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Find nodes between root and file\n\t\tnodes := tree.PathTo(indexLookup[f.Id], nil)\n\n\t\t// This will hold the name of all paths between root and\n\t\t// file (exluding root and including file itself)\n\t\tpathNames := []string{}\n\n\t\t// Lookup file for each node and grab name\n\t\tfor _, n := range nodes {\n\t\t\tfile := fileLookup[n]\n\t\t\tif file == root {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tpathNames = append(pathNames, file.Name)\n\t\t}\n\n\t\t// Join path names to form relative path and add to map\n\t\tpaths[f.Id] = filepath.Join(pathNames...)\n\t}\n\n\treturn paths, nil\n}\n\nfunc checkFiles(files []*drive.File) error {\n\tuniq := map[string]string{}\n\n\tfor _, f := range files {\n\t\t// Ensure all files have exactly one parent\n\t\tif len(f.Parents) != 1 {\n\t\t\treturn fmt.Errorf(\"File %s does not have exacly one parent\", f.Id)\n\t\t}\n\n\t\t// Ensure that there are no duplicate files\n\t\tuniqKey := f.Name + f.Parents[0]\n\t\tif dupeId, isDupe := uniq[uniqKey]; isDupe {\n\t\t\treturn fmt.Errorf(\"Found name collision between %s and %s\", f.Id, dupeId)\n\t\t}\n\t\tuniq[uniqKey] = f.Id\n\t}\n\n\treturn nil\n}\n\ntype LocalFile struct {\n\tabsPath string\n\trelPath string\n\tinfo    os.FileInfo\n}\n\ntype RemoteFile struct {\n\trelPath string\n\tfile    *drive.File\n}\n\ntype changedFile struct {\n\tlocal  *LocalFile\n\tremote *RemoteFile\n}\n\ntype syncFiles struct {\n\troot    *RemoteFile\n\tlocal   []*LocalFile\n\tremote  []*RemoteFile\n\tcompare FileComparer\n}\n\ntype FileComparer interface {\n\tChanged(*LocalFile, *RemoteFile) bool\n}\n\nfunc (self LocalFile) AbsPath() string {\n\treturn self.absPath\n}\n\nfunc (self LocalFile) Size() int64 {\n\treturn self.info.Size()\n}\n\nfunc (self LocalFile) Modified() time.Time {\n\treturn self.info.ModTime()\n}\n\nfunc (self RemoteFile) Md5() string {\n\treturn self.file.Md5Checksum\n}\n\nfunc (self RemoteFile) Size() int64 {\n\treturn self.file.Size\n}\n\nfunc (self RemoteFile) Modified() time.Time {\n\tt, _ := time.Parse(time.RFC3339, self.file.ModifiedTime)\n\treturn t\n}\n\nfunc (self *changedFile) compareModTime() ModTime {\n\tlocalTime := self.local.Modified()\n\tremoteTime := self.remote.Modified()\n\n\tif localTime.After(remoteTime) {\n\t\treturn LocalLastModified\n\t}\n\n\tif remoteTime.After(localTime) {\n\t\treturn RemoteLastModified\n\t}\n\n\treturn EqualModifiedTime\n}\n\nfunc (self *changedFile) compareSize() LargestSize {\n\tlocalSize := self.local.Size()\n\tremoteSize := self.remote.Size()\n\n\tif localSize > remoteSize {\n\t\treturn LocalLargestSize\n\t}\n\n\tif remoteSize > localSize {\n\t\treturn RemoteLargestSize\n\t}\n\n\treturn EqualSize\n}\n\nfunc (self *syncFiles) filterMissingRemoteDirs() []*LocalFile {\n\tvar files []*LocalFile\n\n\tfor _, lf := range self.local {\n\t\tif lf.info.IsDir() && !self.existsRemote(lf) {\n\t\t\tfiles = append(files, lf)\n\t\t}\n\t}\n\n\treturn files\n}\n\nfunc (self *syncFiles) filterMissingLocalDirs() []*RemoteFile {\n\tvar files []*RemoteFile\n\n\tfor _, rf := range self.remote {\n\t\tif isDir(rf.file) && !self.existsLocal(rf) {\n\t\t\tfiles = append(files, rf)\n\t\t}\n\t}\n\n\treturn files\n}\n\nfunc (self *syncFiles) filterMissingRemoteFiles() []*LocalFile {\n\tvar files []*LocalFile\n\n\tfor _, lf := range self.local {\n\t\tif !lf.info.IsDir() && !self.existsRemote(lf) {\n\t\t\tfiles = append(files, lf)\n\t\t}\n\t}\n\n\treturn files\n}\n\nfunc (self *syncFiles) filterMissingLocalFiles() []*RemoteFile {\n\tvar files []*RemoteFile\n\n\tfor _, rf := range self.remote {\n\t\tif !isDir(rf.file) && !self.existsLocal(rf) {\n\t\t\tfiles = append(files, rf)\n\t\t}\n\t}\n\n\treturn files\n}\n\nfunc (self *syncFiles) filterChangedLocalFiles() []*changedFile {\n\tvar files []*changedFile\n\n\tfor _, lf := range self.local {\n\t\t// Skip directories\n\t\tif lf.info.IsDir() {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Skip files that don't exist on drive\n\t\trf, found := self.findRemoteByPath(lf.relPath)\n\t\tif !found {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Check if file has changed\n\t\tif self.compare.Changed(lf, rf) {\n\t\t\tfiles = append(files, &changedFile{\n\t\t\t\tlocal:  lf,\n\t\t\t\tremote: rf,\n\t\t\t})\n\t\t}\n\t}\n\n\treturn files\n}\n\nfunc (self *syncFiles) filterChangedRemoteFiles() []*changedFile {\n\tvar files []*changedFile\n\n\tfor _, rf := range self.remote {\n\t\t// Skip directories\n\t\tif isDir(rf.file) {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Skip local files that don't exist\n\t\tlf, found := self.findLocalByPath(rf.relPath)\n\t\tif !found {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Check if file has changed\n\t\tif self.compare.Changed(lf, rf) {\n\t\t\tfiles = append(files, &changedFile{\n\t\t\t\tlocal:  lf,\n\t\t\t\tremote: rf,\n\t\t\t})\n\t\t}\n\t}\n\n\treturn files\n}\n\nfunc (self *syncFiles) filterExtraneousRemoteFiles() []*RemoteFile {\n\tvar files []*RemoteFile\n\n\tfor _, rf := range self.remote {\n\t\tif !self.existsLocal(rf) {\n\t\t\tfiles = append(files, rf)\n\t\t}\n\t}\n\n\treturn files\n}\n\nfunc (self *syncFiles) filterExtraneousLocalFiles() []*LocalFile {\n\tvar files []*LocalFile\n\n\tfor _, lf := range self.local {\n\t\tif !self.existsRemote(lf) {\n\t\t\tfiles = append(files, lf)\n\t\t}\n\t}\n\n\treturn files\n}\n\nfunc (self *syncFiles) existsRemote(lf *LocalFile) bool {\n\t_, found := self.findRemoteByPath(lf.relPath)\n\treturn found\n}\n\nfunc (self *syncFiles) existsLocal(rf *RemoteFile) bool {\n\t_, found := self.findLocalByPath(rf.relPath)\n\treturn found\n}\n\nfunc (self *syncFiles) findRemoteByPath(relPath string) (*RemoteFile, bool) {\n\tif relPath == \".\" {\n\t\treturn self.root, true\n\t}\n\n\tfor _, rf := range self.remote {\n\t\tif relPath == rf.relPath {\n\t\t\treturn rf, true\n\t\t}\n\t}\n\n\treturn nil, false\n}\n\nfunc (self *syncFiles) findLocalByPath(relPath string) (*LocalFile, bool) {\n\tfor _, lf := range self.local {\n\t\tif relPath == lf.relPath {\n\t\t\treturn lf, true\n\t\t}\n\t}\n\n\treturn nil, false\n}\n\nfunc findLocalConflicts(files []*changedFile) []*changedFile {\n\tvar conflicts []*changedFile\n\n\tfor _, cf := range files {\n\t\tif cf.compareModTime() == LocalLastModified {\n\t\t\tconflicts = append(conflicts, cf)\n\t\t}\n\t}\n\n\treturn conflicts\n}\n\nfunc findRemoteConflicts(files []*changedFile) []*changedFile {\n\tvar conflicts []*changedFile\n\n\tfor _, cf := range files {\n\t\tif cf.compareModTime() == RemoteLastModified {\n\t\t\tconflicts = append(conflicts, cf)\n\t\t}\n\t}\n\n\treturn conflicts\n}\n\ntype byLocalPathLength []*LocalFile\n\nfunc (self byLocalPathLength) Len() int {\n\treturn len(self)\n}\n\nfunc (self byLocalPathLength) Swap(i, j int) {\n\tself[i], self[j] = self[j], self[i]\n}\n\nfunc (self byLocalPathLength) Less(i, j int) bool {\n\treturn pathLength(self[i].relPath) < pathLength(self[j].relPath)\n}\n\ntype byRemotePathLength []*RemoteFile\n\nfunc (self byRemotePathLength) Len() int {\n\treturn len(self)\n}\n\nfunc (self byRemotePathLength) Swap(i, j int) {\n\tself[i], self[j] = self[j], self[i]\n}\n\nfunc (self byRemotePathLength) Less(i, j int) bool {\n\treturn pathLength(self[i].relPath) < pathLength(self[j].relPath)\n}\n\ntype byRemotePath []*RemoteFile\n\nfunc (self byRemotePath) Len() int {\n\treturn len(self)\n}\n\nfunc (self byRemotePath) Swap(i, j int) {\n\tself[i], self[j] = self[j], self[i]\n}\n\nfunc (self byRemotePath) Less(i, j int) bool {\n\treturn strings.ToLower(self[i].relPath) < strings.ToLower(self[j].relPath)\n}\n\ntype ignoreFunc func(string) bool\n\nfunc prepareIgnorer(path string) (ignoreFunc, error) {\n\tacceptAll := func(string) bool {\n\t\treturn false\n\t}\n\n\tif !fileExists(path) {\n\t\treturn acceptAll, nil\n\t}\n\n\tignorer, err := ignore.CompileIgnoreFile(path)\n\tif err != nil {\n\t\treturn acceptAll, fmt.Errorf(\"Failed to prepare ignorer: %s\", err)\n\t}\n\n\treturn ignorer.MatchesPath, nil\n}\n\nfunc formatConflicts(conflicts []*changedFile, out io.Writer) {\n\tw := new(tabwriter.Writer)\n\tw.Init(out, 0, 0, 3, ' ', 0)\n\n\tfmt.Fprintln(w, \"Path\\tSize Local\\tSize Remote\\tModified Local\\tModified Remote\")\n\n\tfor _, cf := range conflicts {\n\t\tfmt.Fprintf(w, \"%s\\t%s\\t%s\\t%s\\t%s\\n\",\n\t\t\ttruncateString(cf.local.relPath, 60),\n\t\t\tformatSize(cf.local.Size(), false),\n\t\t\tformatSize(cf.remote.Size(), false),\n\t\t\tcf.local.Modified().Local().Format(\"Jan _2 2006 15:04:05.000\"),\n\t\t\tcf.remote.Modified().Local().Format(\"Jan _2 2006 15:04:05.000\"),\n\t\t)\n\t}\n\n\tw.Flush()\n}\n"
  },
  {
    "path": "drive/sync_download.go",
    "content": "package drive\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"google.golang.org/api/drive/v3\"\n\t\"google.golang.org/api/googleapi\"\n\t\"io\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"sort\"\n\t\"time\"\n)\n\ntype DownloadSyncArgs struct {\n\tOut              io.Writer\n\tProgress         io.Writer\n\tRootId           string\n\tPath             string\n\tDryRun           bool\n\tDeleteExtraneous bool\n\tTimeout          time.Duration\n\tResolution       ConflictResolution\n\tComparer         FileComparer\n}\n\nfunc (self *Drive) DownloadSync(args DownloadSyncArgs) error {\n\tfmt.Fprintln(args.Out, \"Starting sync...\")\n\tstarted := time.Now()\n\n\t// Get remote root dir\n\trootDir, err := self.getSyncRoot(args.RootId)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Fprintln(args.Out, \"Collecting file information...\")\n\tfiles, err := self.prepareSyncFiles(args.Path, rootDir, args.Comparer)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Find changed files\n\tchangedFiles := files.filterChangedRemoteFiles()\n\n\tfmt.Fprintf(args.Out, \"Found %d local files and %d remote files\\n\", len(files.local), len(files.remote))\n\n\t// Ensure that we don't overwrite any local changes\n\tif args.Resolution == NoResolution {\n\t\terr = ensureNoLocalModifications(changedFiles)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Conflict detected!\\nThe following files have changed and the local file are newer than it's remote counterpart:\\n\\n%s\\nNo conflict resolution was given, aborting...\", err)\n\t\t}\n\t}\n\n\t// Create missing directories\n\terr = self.createMissingLocalDirs(files, args)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Download missing files\n\terr = self.downloadMissingFiles(files, args)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Download files that has changed\n\terr = self.downloadChangedFiles(changedFiles, args)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Delete extraneous local files\n\tif args.DeleteExtraneous {\n\t\terr = self.deleteExtraneousLocalFiles(files, args)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tfmt.Fprintf(args.Out, \"Sync finished in %s\\n\", time.Since(started))\n\n\treturn nil\n}\n\nfunc (self *Drive) getSyncRoot(rootId string) (*drive.File, error) {\n\tfields := []googleapi.Field{\"id\", \"name\", \"mimeType\", \"appProperties\"}\n\tf, err := self.service.Files.Get(rootId).Fields(fields...).Do()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to find root dir: %s\", err)\n\t}\n\n\t// Ensure file is a directory\n\tif !isDir(f) {\n\t\treturn nil, fmt.Errorf(\"Provided root id is not a directory\")\n\t}\n\n\t// Ensure directory is a proper syncRoot\n\tif _, ok := f.AppProperties[\"syncRoot\"]; !ok {\n\t\treturn nil, fmt.Errorf(\"Provided id is not a sync root directory\")\n\t}\n\n\treturn f, nil\n}\n\nfunc (self *Drive) createMissingLocalDirs(files *syncFiles, args DownloadSyncArgs) error {\n\tmissingDirs := files.filterMissingLocalDirs()\n\tmissingCount := len(missingDirs)\n\n\tif missingCount > 0 {\n\t\tfmt.Fprintf(args.Out, \"\\n%d local directories are missing\\n\", missingCount)\n\t}\n\n\t// Sort directories so that the dirs with the shortest path comes first\n\tsort.Sort(byRemotePathLength(missingDirs))\n\n\tfor i, rf := range missingDirs {\n\t\tabsPath, err := filepath.Abs(filepath.Join(args.Path, rf.relPath))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to determine local absolute path: %s\", err)\n\t\t}\n\t\tfmt.Fprintf(args.Out, \"[%04d/%04d] Creating directory %s\\n\", i+1, missingCount, filepath.Join(filepath.Base(args.Path), rf.relPath))\n\n\t\tif args.DryRun {\n\t\t\tcontinue\n\t\t}\n\n\t\tos.MkdirAll(absPath, 0775)\n\t}\n\n\treturn nil\n}\n\nfunc (self *Drive) downloadMissingFiles(files *syncFiles, args DownloadSyncArgs) error {\n\tmissingFiles := files.filterMissingLocalFiles()\n\tmissingCount := len(missingFiles)\n\n\tif missingCount > 0 {\n\t\tfmt.Fprintf(args.Out, \"\\n%d local files are missing\\n\", missingCount)\n\t}\n\n\tfor i, rf := range missingFiles {\n\t\tabsPath, err := filepath.Abs(filepath.Join(args.Path, rf.relPath))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to determine local absolute path: %s\", err)\n\t\t}\n\t\tfmt.Fprintf(args.Out, \"[%04d/%04d] Downloading %s -> %s\\n\", i+1, missingCount, rf.relPath, filepath.Join(filepath.Base(args.Path), rf.relPath))\n\n\t\terr = self.downloadRemoteFile(rf.file.Id, absPath, args, 0)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (self *Drive) downloadChangedFiles(changedFiles []*changedFile, args DownloadSyncArgs) error {\n\tchangedCount := len(changedFiles)\n\n\tif changedCount > 0 {\n\t\tfmt.Fprintf(args.Out, \"\\n%d remote files has changed\\n\", changedCount)\n\t}\n\n\tfor i, cf := range changedFiles {\n\t\tif skip, reason := checkLocalConflict(cf, args.Resolution); skip {\n\t\t\tfmt.Fprintf(args.Out, \"[%04d/%04d] Skipping %s (%s)\\n\", i+1, changedCount, cf.remote.relPath, reason)\n\t\t\tcontinue\n\t\t}\n\n\t\tabsPath, err := filepath.Abs(filepath.Join(args.Path, cf.remote.relPath))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to determine local absolute path: %s\", err)\n\t\t}\n\t\tfmt.Fprintf(args.Out, \"[%04d/%04d] Downloading %s -> %s\\n\", i+1, changedCount, cf.remote.relPath, filepath.Join(filepath.Base(args.Path), cf.remote.relPath))\n\n\t\terr = self.downloadRemoteFile(cf.remote.file.Id, absPath, args, 0)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (self *Drive) downloadRemoteFile(id, fpath string, args DownloadSyncArgs, try int) error {\n\tif args.DryRun {\n\t\treturn nil\n\t}\n\n\t// Get timeout reader wrapper and context\n\ttimeoutReaderWrapper, ctx := getTimeoutReaderWrapperContext(args.Timeout)\n\n\tres, err := self.service.Files.Get(id).Context(ctx).Download()\n\tif err != nil {\n\t\tif isBackendOrRateLimitError(err) && try < MaxErrorRetries {\n\t\t\texponentialBackoffSleep(try)\n\t\t\ttry++\n\t\t\treturn self.downloadRemoteFile(id, fpath, args, try)\n\t\t} else if isTimeoutError(err) {\n\t\t\treturn fmt.Errorf(\"Failed to download file: timeout, no data was transferred for %v\", args.Timeout)\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"Failed to download file: %s\", err)\n\t\t}\n\t}\n\n\t// Close body on function exit\n\tdefer res.Body.Close()\n\n\t// Wrap response body in progress reader\n\tprogressReader := getProgressReader(res.Body, args.Progress, res.ContentLength)\n\n\t// Wrap reader in timeout reader\n\treader := timeoutReaderWrapper(progressReader)\n\n\t// Ensure any parent directories exists\n\tif err = mkdir(fpath); err != nil {\n\t\treturn err\n\t}\n\n\t// Download to tmp file\n\ttmpPath := fpath + \".incomplete\"\n\n\t// Create new file\n\toutFile, err := os.Create(tmpPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Unable to create local file: %s\", err)\n\t}\n\n\t// Save file to disk\n\t_, err = io.Copy(outFile, reader)\n\tif err != nil {\n\t\toutFile.Close()\n\t\tif try < MaxErrorRetries {\n\t\t\texponentialBackoffSleep(try)\n\t\t\ttry++\n\t\t\treturn self.downloadRemoteFile(id, fpath, args, try)\n\t\t} else {\n\t\t\tos.Remove(tmpPath)\n\t\t\treturn fmt.Errorf(\"Download was interrupted: %s\", err)\n\t\t}\n\t}\n\n\t// Close file\n\toutFile.Close()\n\n\t// Rename tmp file to proper filename\n\treturn os.Rename(tmpPath, fpath)\n}\n\nfunc (self *Drive) deleteExtraneousLocalFiles(files *syncFiles, args DownloadSyncArgs) error {\n\textraneousFiles := files.filterExtraneousLocalFiles()\n\textraneousCount := len(extraneousFiles)\n\n\tif extraneousCount > 0 {\n\t\tfmt.Fprintf(args.Out, \"\\n%d local files are extraneous\\n\", extraneousCount)\n\t}\n\n\t// Sort files so that the files with the longest path comes first\n\tsort.Sort(sort.Reverse(byLocalPathLength(extraneousFiles)))\n\n\tfor i, lf := range extraneousFiles {\n\t\tfmt.Fprintf(args.Out, \"[%04d/%04d] Deleting %s\\n\", i+1, extraneousCount, lf.absPath)\n\n\t\tif args.DryRun {\n\t\t\tcontinue\n\t\t}\n\n\t\terr := os.Remove(lf.absPath)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to delete local file: %s\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc checkLocalConflict(cf *changedFile, resolution ConflictResolution) (bool, string) {\n\t// No conflict unless local file was last modified\n\tif cf.compareModTime() != LocalLastModified {\n\t\treturn false, \"\"\n\t}\n\n\t// Don't skip if want to keep the remote file\n\tif resolution == KeepRemote {\n\t\treturn false, \"\"\n\t}\n\n\t// Skip if we want to keep the local file\n\tif resolution == KeepLocal {\n\t\treturn true, \"conflicting file, keeping local file\"\n\t}\n\n\tif resolution == KeepLargest {\n\t\tlargest := cf.compareSize()\n\n\t\t// Skip if the local file is largest\n\t\tif largest == LocalLargestSize {\n\t\t\treturn true, \"conflicting file, local file is largest, keeping local\"\n\t\t}\n\n\t\t// Don't skip if the remote file is largest\n\t\tif largest == RemoteLargestSize {\n\t\t\treturn false, \"\"\n\t\t}\n\n\t\t// Keep local if both files have the same size\n\t\tif largest == EqualSize {\n\t\t\treturn true, \"conflicting file, file sizes are equal, keeping local\"\n\t\t}\n\t}\n\n\t// The conditionals above should cover all cases,\n\t// unless the programmer did something wrong,\n\t// in which case we default to being non-destructive and skip the file\n\treturn true, \"conflicting file, unhandled case\"\n}\n\nfunc ensureNoLocalModifications(files []*changedFile) error {\n\tconflicts := findLocalConflicts(files)\n\tif len(conflicts) == 0 {\n\t\treturn nil\n\t}\n\n\tbuffer := bytes.NewBufferString(\"\")\n\tformatConflicts(conflicts, buffer)\n\treturn fmt.Errorf(buffer.String())\n}\n"
  },
  {
    "path": "drive/sync_list.go",
    "content": "package drive\n\nimport (\n\t\"fmt\"\n\t\"google.golang.org/api/drive/v3\"\n\t\"google.golang.org/api/googleapi\"\n\t\"io\"\n\t\"sort\"\n\t\"text/tabwriter\"\n)\n\ntype ListSyncArgs struct {\n\tOut        io.Writer\n\tSkipHeader bool\n}\n\nfunc (self *Drive) ListSync(args ListSyncArgs) error {\n\tlistArgs := listAllFilesArgs{\n\t\tquery:  \"appProperties has {key='syncRoot' and value='true'}\",\n\t\tfields: []googleapi.Field{\"nextPageToken\", \"files(id,name,mimeType,createdTime)\"},\n\t}\n\tfiles, err := self.listAllFiles(listArgs)\n\tif err != nil {\n\t\treturn err\n\t}\n\tprintSyncDirectories(files, args)\n\treturn nil\n}\n\ntype ListRecursiveSyncArgs struct {\n\tOut         io.Writer\n\tRootId      string\n\tSkipHeader  bool\n\tPathWidth   int64\n\tSizeInBytes bool\n\tSortOrder   string\n}\n\nfunc (self *Drive) ListRecursiveSync(args ListRecursiveSyncArgs) error {\n\trootDir, err := self.getSyncRoot(args.RootId)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfiles, err := self.prepareRemoteFiles(rootDir, args.SortOrder)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tprintSyncDirContent(files, args)\n\treturn nil\n}\n\nfunc printSyncDirectories(files []*drive.File, args ListSyncArgs) {\n\tw := new(tabwriter.Writer)\n\tw.Init(args.Out, 0, 0, 3, ' ', 0)\n\n\tif !args.SkipHeader {\n\t\tfmt.Fprintln(w, \"Id\\tName\\tCreated\")\n\t}\n\n\tfor _, f := range files {\n\t\tfmt.Fprintf(w, \"%s\\t%s\\t%s\\n\",\n\t\t\tf.Id,\n\t\t\tf.Name,\n\t\t\tformatDatetime(f.CreatedTime),\n\t\t)\n\t}\n\n\tw.Flush()\n}\n\nfunc printSyncDirContent(files []*RemoteFile, args ListRecursiveSyncArgs) {\n\tif args.SortOrder == \"\" {\n\t\t// Sort files by path\n\t\tsort.Sort(byRemotePath(files))\n\t}\n\n\tw := new(tabwriter.Writer)\n\tw.Init(args.Out, 0, 0, 3, ' ', 0)\n\n\tif !args.SkipHeader {\n\t\tfmt.Fprintln(w, \"Id\\tPath\\tType\\tSize\\tModified\")\n\t}\n\n\tfor _, rf := range files {\n\t\tfmt.Fprintf(w, \"%s\\t%s\\t%s\\t%s\\t%s\\n\",\n\t\t\trf.file.Id,\n\t\t\ttruncateString(rf.relPath, int(args.PathWidth)),\n\t\t\tfiletype(rf.file),\n\t\t\tformatSize(rf.file.Size, args.SizeInBytes),\n\t\t\tformatDatetime(rf.file.ModifiedTime),\n\t\t)\n\t}\n\n\tw.Flush()\n}\n"
  },
  {
    "path": "drive/sync_upload.go",
    "content": "package drive\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"google.golang.org/api/drive/v3\"\n\t\"google.golang.org/api/googleapi\"\n\t\"io\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"sort\"\n\t\"time\"\n)\n\ntype UploadSyncArgs struct {\n\tOut              io.Writer\n\tProgress         io.Writer\n\tPath             string\n\tRootId           string\n\tDryRun           bool\n\tDeleteExtraneous bool\n\tChunkSize        int64\n\tTimeout          time.Duration\n\tResolution       ConflictResolution\n\tComparer         FileComparer\n}\n\nfunc (self *Drive) UploadSync(args UploadSyncArgs) error {\n\tif args.ChunkSize > intMax()-1 {\n\t\treturn fmt.Errorf(\"Chunk size is to big, max chunk size for this computer is %d\", intMax()-1)\n\t}\n\n\tfmt.Fprintln(args.Out, \"Starting sync...\")\n\tstarted := time.Now()\n\n\t// Create root directory if it does not exist\n\trootDir, err := self.prepareSyncRoot(args)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Fprintln(args.Out, \"Collecting local and remote file information...\")\n\tfiles, err := self.prepareSyncFiles(args.Path, rootDir, args.Comparer)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Find missing and changed files\n\tchangedFiles := files.filterChangedLocalFiles()\n\tmissingFiles := files.filterMissingRemoteFiles()\n\n\tfmt.Fprintf(args.Out, \"Found %d local files and %d remote files\\n\", len(files.local), len(files.remote))\n\n\t// Ensure that there is enough free space on drive\n\tif ok, msg := self.checkRemoteFreeSpace(missingFiles, changedFiles); !ok {\n\t\treturn fmt.Errorf(msg)\n\t}\n\n\t// Ensure that we don't overwrite any remote changes\n\tif args.Resolution == NoResolution {\n\t\terr = ensureNoRemoteModifications(changedFiles)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Conflict detected!\\nThe following files have changed and the remote file are newer than it's local counterpart:\\n\\n%s\\nNo conflict resolution was given, aborting...\", err)\n\t\t}\n\t}\n\n\t// Create missing directories\n\tfiles, err = self.createMissingRemoteDirs(files, args)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Upload missing files\n\terr = self.uploadMissingFiles(missingFiles, files, args)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Update modified files\n\terr = self.updateChangedFiles(changedFiles, rootDir, args)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Delete extraneous files on drive\n\tif args.DeleteExtraneous {\n\t\terr = self.deleteExtraneousRemoteFiles(files, args)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tfmt.Fprintf(args.Out, \"Sync finished in %s\\n\", time.Since(started))\n\n\treturn nil\n}\n\nfunc (self *Drive) prepareSyncRoot(args UploadSyncArgs) (*drive.File, error) {\n\tfields := []googleapi.Field{\"id\", \"name\", \"mimeType\", \"appProperties\"}\n\tf, err := self.service.Files.Get(args.RootId).Fields(fields...).Do()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to find root dir: %s\", err)\n\t}\n\n\t// Ensure file is a directory\n\tif !isDir(f) {\n\t\treturn nil, fmt.Errorf(\"Provided root id is not a directory\")\n\t}\n\n\t// Return directory if syncRoot property is already set\n\tif _, ok := f.AppProperties[\"syncRoot\"]; ok {\n\t\treturn f, nil\n\t}\n\n\t// This is the first time this directory have been used for sync\n\t// Check if the directory is empty\n\tisEmpty, err := self.dirIsEmpty(f.Id)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to check if root dir is empty: %s\", err)\n\t}\n\n\t// Ensure that the directory is empty\n\tif !isEmpty {\n\t\treturn nil, fmt.Errorf(\"Root directory is not empty, the initial sync requires an empty directory\")\n\t}\n\n\t// Update directory with syncRoot property\n\tdstFile := &drive.File{\n\t\tAppProperties: map[string]string{\"sync\": \"true\", \"syncRoot\": \"true\"},\n\t}\n\n\tf, err = self.service.Files.Update(f.Id, dstFile).Fields(fields...).Do()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to update root directory: %s\", err)\n\t}\n\n\treturn f, nil\n}\n\nfunc (self *Drive) createMissingRemoteDirs(files *syncFiles, args UploadSyncArgs) (*syncFiles, error) {\n\tmissingDirs := files.filterMissingRemoteDirs()\n\tmissingCount := len(missingDirs)\n\n\tif missingCount > 0 {\n\t\tfmt.Fprintf(args.Out, \"\\n%d remote directories are missing\\n\", missingCount)\n\t}\n\n\t// Sort directories so that the dirs with the shortest path comes first\n\tsort.Sort(byLocalPathLength(missingDirs))\n\n\tfor i, lf := range missingDirs {\n\t\tparentPath := parentFilePath(lf.relPath)\n\t\tparent, ok := files.findRemoteByPath(parentPath)\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"Could not find remote directory with path '%s'\", parentPath)\n\t\t}\n\n\t\tfmt.Fprintf(args.Out, \"[%04d/%04d] Creating directory %s\\n\", i+1, missingCount, filepath.Join(files.root.file.Name, lf.relPath))\n\n\t\tf, err := self.createMissingRemoteDir(createMissingRemoteDirArgs{\n\t\t\tname:     lf.info.Name(),\n\t\t\tparentId: parent.file.Id,\n\t\t\trootId:   args.RootId,\n\t\t\tdryRun:   args.DryRun,\n\t\t\ttry:      0,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tfiles.remote = append(files.remote, &RemoteFile{\n\t\t\trelPath: lf.relPath,\n\t\t\tfile:    f,\n\t\t})\n\t}\n\n\treturn files, nil\n}\n\ntype createMissingRemoteDirArgs struct {\n\tname     string\n\tparentId string\n\trootId   string\n\tdryRun   bool\n\ttry      int\n}\n\nfunc (self *Drive) uploadMissingFiles(missingFiles []*LocalFile, files *syncFiles, args UploadSyncArgs) error {\n\tmissingCount := len(missingFiles)\n\n\tif missingCount > 0 {\n\t\tfmt.Fprintf(args.Out, \"\\n%d remote files are missing\\n\", missingCount)\n\t}\n\n\tfor i, lf := range missingFiles {\n\t\tparentPath := parentFilePath(lf.relPath)\n\t\tparent, ok := files.findRemoteByPath(parentPath)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"Could not find remote directory with path '%s'\", parentPath)\n\t\t}\n\n\t\tfmt.Fprintf(args.Out, \"[%04d/%04d] Uploading %s -> %s\\n\", i+1, missingCount, lf.relPath, filepath.Join(files.root.file.Name, lf.relPath))\n\n\t\terr := self.uploadMissingFile(parent.file.Id, lf, args, 0)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (self *Drive) updateChangedFiles(changedFiles []*changedFile, root *drive.File, args UploadSyncArgs) error {\n\tchangedCount := len(changedFiles)\n\n\tif changedCount > 0 {\n\t\tfmt.Fprintf(args.Out, \"\\n%d local files has changed\\n\", changedCount)\n\t}\n\n\tfor i, cf := range changedFiles {\n\t\tif skip, reason := checkRemoteConflict(cf, args.Resolution); skip {\n\t\t\tfmt.Fprintf(args.Out, \"[%04d/%04d] Skipping %s (%s)\\n\", i+1, changedCount, cf.local.relPath, reason)\n\t\t\tcontinue\n\t\t}\n\n\t\tfmt.Fprintf(args.Out, \"[%04d/%04d] Updating %s -> %s\\n\", i+1, changedCount, cf.local.relPath, filepath.Join(root.Name, cf.local.relPath))\n\n\t\terr := self.updateChangedFile(cf, args, 0)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (self *Drive) deleteExtraneousRemoteFiles(files *syncFiles, args UploadSyncArgs) error {\n\textraneousFiles := files.filterExtraneousRemoteFiles()\n\textraneousCount := len(extraneousFiles)\n\n\tif extraneousCount > 0 {\n\t\tfmt.Fprintf(args.Out, \"\\n%d remote files are extraneous\\n\", extraneousCount)\n\t}\n\n\t// Sort files so that the files with the longest path comes first\n\tsort.Sort(sort.Reverse(byRemotePathLength(extraneousFiles)))\n\n\tfor i, rf := range extraneousFiles {\n\t\tfmt.Fprintf(args.Out, \"[%04d/%04d] Deleting %s\\n\", i+1, extraneousCount, filepath.Join(files.root.file.Name, rf.relPath))\n\n\t\terr := self.deleteRemoteFile(rf, args, 0)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (self *Drive) createMissingRemoteDir(args createMissingRemoteDirArgs) (*drive.File, error) {\n\tdstFile := &drive.File{\n\t\tName:          args.name,\n\t\tMimeType:      DirectoryMimeType,\n\t\tParents:       []string{args.parentId},\n\t\tAppProperties: map[string]string{\"sync\": \"true\", \"syncRootId\": args.rootId},\n\t}\n\n\tif args.dryRun {\n\t\treturn dstFile, nil\n\t}\n\n\tf, err := self.service.Files.Create(dstFile).Do()\n\tif err != nil {\n\t\tif isBackendOrRateLimitError(err) && args.try < MaxErrorRetries {\n\t\t\texponentialBackoffSleep(args.try)\n\t\t\targs.try++\n\t\t\treturn self.createMissingRemoteDir(args)\n\t\t} else {\n\t\t\treturn nil, fmt.Errorf(\"Failed to create directory: %s\", err)\n\t\t}\n\t}\n\n\treturn f, nil\n}\n\nfunc (self *Drive) uploadMissingFile(parentId string, lf *LocalFile, args UploadSyncArgs, try int) error {\n\tif args.DryRun {\n\t\treturn nil\n\t}\n\n\tsrcFile, err := os.Open(lf.absPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to open file: %s\", err)\n\t}\n\n\t// Close file on function exit\n\tdefer srcFile.Close()\n\n\t// Instantiate drive file\n\tdstFile := &drive.File{\n\t\tName:          lf.info.Name(),\n\t\tParents:       []string{parentId},\n\t\tAppProperties: map[string]string{\"sync\": \"true\", \"syncRootId\": args.RootId},\n\t}\n\n\t// Chunk size option\n\tchunkSize := googleapi.ChunkSize(int(args.ChunkSize))\n\n\t// Wrap file in progress reader\n\tprogressReader := getProgressReader(srcFile, args.Progress, lf.info.Size())\n\n\t// Wrap reader in timeout reader\n\treader, ctx := getTimeoutReaderContext(progressReader, args.Timeout)\n\n\t_, err = self.service.Files.Create(dstFile).Fields(\"id\", \"name\", \"size\", \"md5Checksum\").Context(ctx).Media(reader, chunkSize).Do()\n\tif err != nil {\n\t\tif isBackendOrRateLimitError(err) && try < MaxErrorRetries {\n\t\t\texponentialBackoffSleep(try)\n\t\t\ttry++\n\t\t\treturn self.uploadMissingFile(parentId, lf, args, try)\n\t\t} else if isTimeoutError(err) {\n\t\t\treturn fmt.Errorf(\"Failed to upload file: timeout, no data was transferred for %v\", args.Timeout)\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"Failed to upload file: %s\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (self *Drive) updateChangedFile(cf *changedFile, args UploadSyncArgs, try int) error {\n\tif args.DryRun {\n\t\treturn nil\n\t}\n\n\tsrcFile, err := os.Open(cf.local.absPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to open file: %s\", err)\n\t}\n\n\t// Close file on function exit\n\tdefer srcFile.Close()\n\n\t// Instantiate drive file\n\tdstFile := &drive.File{}\n\n\t// Chunk size option\n\tchunkSize := googleapi.ChunkSize(int(args.ChunkSize))\n\n\t// Wrap file in progress reader\n\tprogressReader := getProgressReader(srcFile, args.Progress, cf.local.info.Size())\n\n\t// Wrap reader in timeout reader\n\treader, ctx := getTimeoutReaderContext(progressReader, args.Timeout)\n\n\t_, err = self.service.Files.Update(cf.remote.file.Id, dstFile).Context(ctx).Media(reader, chunkSize).Do()\n\tif err != nil {\n\t\tif isBackendOrRateLimitError(err) && try < MaxErrorRetries {\n\t\t\texponentialBackoffSleep(try)\n\t\t\ttry++\n\t\t\treturn self.updateChangedFile(cf, args, try)\n\t\t} else if isTimeoutError(err) {\n\t\t\treturn fmt.Errorf(\"Failed to upload file: timeout, no data was transferred for %v\", args.Timeout)\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"Failed to update file: %s\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (self *Drive) deleteRemoteFile(rf *RemoteFile, args UploadSyncArgs, try int) error {\n\tif args.DryRun {\n\t\treturn nil\n\t}\n\n\terr := self.service.Files.Delete(rf.file.Id).Do()\n\tif err != nil {\n\t\tif isBackendOrRateLimitError(err) && try < MaxErrorRetries {\n\t\t\texponentialBackoffSleep(try)\n\t\t\ttry++\n\t\t\treturn self.deleteRemoteFile(rf, args, try)\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"Failed to delete file: %s\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (self *Drive) dirIsEmpty(id string) (bool, error) {\n\tquery := fmt.Sprintf(\"'%s' in parents\", id)\n\tfileList, err := self.service.Files.List().Q(query).Do()\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"Empty dir check failed: \", err)\n\t}\n\n\treturn len(fileList.Files) == 0, nil\n}\n\nfunc checkRemoteConflict(cf *changedFile, resolution ConflictResolution) (bool, string) {\n\t// No conflict unless remote file was last modified\n\tif cf.compareModTime() != RemoteLastModified {\n\t\treturn false, \"\"\n\t}\n\n\t// Don't skip if want to keep the local file\n\tif resolution == KeepLocal {\n\t\treturn false, \"\"\n\t}\n\n\t// Skip if we want to keep the remote file\n\tif resolution == KeepRemote {\n\t\treturn true, \"conflicting file, keeping remote file\"\n\t}\n\n\tif resolution == KeepLargest {\n\t\tlargest := cf.compareSize()\n\n\t\t// Skip if the remote file is largest\n\t\tif largest == RemoteLargestSize {\n\t\t\treturn true, \"conflicting file, remote file is largest, keeping remote\"\n\t\t}\n\n\t\t// Don't skip if the local file is largest\n\t\tif largest == LocalLargestSize {\n\t\t\treturn false, \"\"\n\t\t}\n\n\t\t// Keep remote if both files have the same size\n\t\tif largest == EqualSize {\n\t\t\treturn true, \"conflicting file, file sizes are equal, keeping remote\"\n\t\t}\n\t}\n\n\t// The conditionals above should cover all cases,\n\t// unless the programmer did something wrong,\n\t// in which case we default to being non-destructive and skip the file\n\treturn true, \"conflicting file, unhandled case\"\n}\n\nfunc ensureNoRemoteModifications(files []*changedFile) error {\n\tconflicts := findRemoteConflicts(files)\n\tif len(conflicts) == 0 {\n\t\treturn nil\n\t}\n\n\tbuffer := bytes.NewBufferString(\"\")\n\tformatConflicts(conflicts, buffer)\n\treturn fmt.Errorf(buffer.String())\n}\n\nfunc (self *Drive) checkRemoteFreeSpace(missingFiles []*LocalFile, changedFiles []*changedFile) (bool, string) {\n\tabout, err := self.service.About.Get().Fields(\"storageQuota\").Do()\n\tif err != nil {\n\t\treturn false, fmt.Sprintf(\"Failed to determine free space: %s\", err)\n\t}\n\n\tquota := about.StorageQuota\n\tif quota.Limit == 0 {\n\t\treturn true, \"\"\n\t}\n\n\tfreeSpace := quota.Limit - quota.Usage\n\n\tvar totalSize int64\n\n\tfor _, lf := range missingFiles {\n\t\ttotalSize += lf.Size()\n\t}\n\n\tfor _, cf := range changedFiles {\n\t\ttotalSize += cf.local.Size()\n\t}\n\n\tif totalSize > freeSpace {\n\t\treturn false, fmt.Sprintf(\"Not enough free space, have %s need %s\", formatSize(freeSpace, false), formatSize(totalSize, false))\n\t}\n\n\treturn true, \"\"\n}\n"
  },
  {
    "path": "drive/timeout_reader.go",
    "content": "package drive\n\nimport (\n\t\"golang.org/x/net/context\"\n\t\"io\"\n\t\"sync\"\n\t\"time\"\n)\n\nconst TimeoutTimerInterval = time.Second * 10\n\ntype timeoutReaderWrapper func(io.Reader) io.Reader\n\nfunc getTimeoutReaderWrapperContext(timeout time.Duration) (timeoutReaderWrapper, context.Context) {\n\tctx, cancel := context.WithCancel(context.TODO())\n\twrapper := func(r io.Reader) io.Reader {\n\t\t// Return untouched reader if timeout is 0\n\t\tif timeout == 0 {\n\t\t\treturn r\n\t\t}\n\n\t\treturn getTimeoutReader(r, cancel, timeout)\n\t}\n\treturn wrapper, ctx\n}\n\nfunc getTimeoutReaderContext(r io.Reader, timeout time.Duration) (io.Reader, context.Context) {\n\tctx, cancel := context.WithCancel(context.TODO())\n\n\t// Return untouched reader if timeout is 0\n\tif timeout == 0 {\n\t\treturn r, ctx\n\t}\n\n\treturn getTimeoutReader(r, cancel, timeout), ctx\n}\n\nfunc getTimeoutReader(r io.Reader, cancel context.CancelFunc, timeout time.Duration) io.Reader {\n\treturn &TimeoutReader{\n\t\treader:         r,\n\t\tcancel:         cancel,\n\t\tmutex:          &sync.Mutex{},\n\t\tmaxIdleTimeout: timeout,\n\t}\n}\n\ntype TimeoutReader struct {\n\treader         io.Reader\n\tcancel         context.CancelFunc\n\tlastActivity   time.Time\n\ttimer          *time.Timer\n\tmutex          *sync.Mutex\n\tmaxIdleTimeout time.Duration\n\tdone           bool\n}\n\nfunc (self *TimeoutReader) Read(p []byte) (int, error) {\n\tif self.timer == nil {\n\t\tself.startTimer()\n\t}\n\n\tself.mutex.Lock()\n\n\t// Read\n\tn, err := self.reader.Read(p)\n\n\tself.lastActivity = time.Now()\n\tself.done = (err != nil)\n\n\tself.mutex.Unlock()\n\n\tif self.done {\n\t\tself.stopTimer()\n\t}\n\n\treturn n, err\n}\n\nfunc (self *TimeoutReader) startTimer() {\n\tself.mutex.Lock()\n\tdefer self.mutex.Unlock()\n\n\tif !self.done {\n\t\tself.timer = time.AfterFunc(TimeoutTimerInterval, self.timeout)\n\t}\n}\n\nfunc (self *TimeoutReader) stopTimer() {\n\tself.mutex.Lock()\n\tdefer self.mutex.Unlock()\n\n\tif self.timer != nil {\n\t\tself.timer.Stop()\n\t}\n}\n\nfunc (self *TimeoutReader) timeout() {\n\tself.mutex.Lock()\n\n\tif self.done {\n\t\tself.mutex.Unlock()\n\t\treturn\n\t}\n\n\tif time.Since(self.lastActivity) > self.maxIdleTimeout {\n\t\tself.cancel()\n\t\tself.mutex.Unlock()\n\t\treturn\n\t}\n\n\tself.mutex.Unlock()\n\tself.startTimer()\n}\n"
  },
  {
    "path": "drive/update.go",
    "content": "package drive\n\nimport (\n\t\"fmt\"\n\t\"google.golang.org/api/drive/v3\"\n\t\"google.golang.org/api/googleapi\"\n\t\"io\"\n\t\"mime\"\n\t\"path/filepath\"\n\t\"time\"\n)\n\ntype UpdateArgs struct {\n\tOut         io.Writer\n\tProgress    io.Writer\n\tId          string\n\tPath        string\n\tName        string\n\tDescription string\n\tParents     []string\n\tMime        string\n\tRecursive   bool\n\tChunkSize   int64\n\tTimeout     time.Duration\n}\n\nfunc (self *Drive) Update(args UpdateArgs) error {\n\tsrcFile, srcFileInfo, err := openFile(args.Path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to open file: %s\", err)\n\t}\n\n\tdefer srcFile.Close()\n\n\t// Instantiate empty drive file\n\tdstFile := &drive.File{Description: args.Description}\n\n\t// Use provided file name or use filename\n\tif args.Name == \"\" {\n\t\tdstFile.Name = filepath.Base(srcFileInfo.Name())\n\t} else {\n\t\tdstFile.Name = args.Name\n\t}\n\n\t// Set provided mime type or get type based on file extension\n\tif args.Mime == \"\" {\n\t\tdstFile.MimeType = mime.TypeByExtension(filepath.Ext(dstFile.Name))\n\t} else {\n\t\tdstFile.MimeType = args.Mime\n\t}\n\n\t// Set parent folders\n\tdstFile.Parents = args.Parents\n\n\t// Chunk size option\n\tchunkSize := googleapi.ChunkSize(int(args.ChunkSize))\n\n\t// Wrap file in progress reader\n\tprogressReader := getProgressReader(srcFile, args.Progress, srcFileInfo.Size())\n\n\t// Wrap reader in timeout reader\n\treader, ctx := getTimeoutReaderContext(progressReader, args.Timeout)\n\n\tfmt.Fprintf(args.Out, \"Uploading %s\\n\", args.Path)\n\tstarted := time.Now()\n\n\tf, err := self.service.Files.Update(args.Id, dstFile).Fields(\"id\", \"name\", \"size\").Context(ctx).Media(reader, chunkSize).Do()\n\tif err != nil {\n\t\tif isTimeoutError(err) {\n\t\t\treturn fmt.Errorf(\"Failed to upload file: timeout, no data was transferred for %v\", args.Timeout)\n\t\t}\n\t\treturn fmt.Errorf(\"Failed to upload file: %s\", err)\n\t}\n\n\t// Calculate average upload rate\n\trate := calcRate(f.Size, started, time.Now())\n\n\tfmt.Fprintf(args.Out, \"Updated %s at %s/s, total %s\\n\", f.Id, formatSize(rate, false), formatSize(f.Size, false))\n\treturn nil\n}\n"
  },
  {
    "path": "drive/upload.go",
    "content": "package drive\n\nimport (\n\t\"fmt\"\n\t\"google.golang.org/api/drive/v3\"\n\t\"google.golang.org/api/googleapi\"\n\t\"io\"\n\t\"mime\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"time\"\n)\n\ntype UploadArgs struct {\n\tOut         io.Writer\n\tProgress    io.Writer\n\tPath        string\n\tName        string\n\tDescription string\n\tParents     []string\n\tMime        string\n\tRecursive   bool\n\tShare       bool\n\tDelete      bool\n\tChunkSize   int64\n\tTimeout     time.Duration\n}\n\nfunc (self *Drive) Upload(args UploadArgs) error {\n\tif args.ChunkSize > intMax()-1 {\n\t\treturn fmt.Errorf(\"Chunk size is to big, max chunk size for this computer is %d\", intMax()-1)\n\t}\n\n\t// Ensure that none of the parents are sync dirs\n\tfor _, parent := range args.Parents {\n\t\tisSyncDir, err := self.isSyncFile(parent)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif isSyncDir {\n\t\t\treturn fmt.Errorf(\"%s is a sync directory, use 'sync upload' instead\", parent)\n\t\t}\n\t}\n\n\tif args.Recursive {\n\t\treturn self.uploadRecursive(args)\n\t}\n\n\tinfo, err := os.Stat(args.Path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed stat file: %s\", err)\n\t}\n\n\tif info.IsDir() {\n\t\treturn fmt.Errorf(\"'%s' is a directory, use --recursive to upload directories\", info.Name())\n\t}\n\n\tf, rate, err := self.uploadFile(args)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Fprintf(args.Out, \"Uploaded %s at %s/s, total %s\\n\", f.Id, formatSize(rate, false), formatSize(f.Size, false))\n\n\tif args.Share {\n\t\terr = self.shareAnyoneReader(f.Id)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfmt.Fprintf(args.Out, \"File is readable by anyone at %s\\n\", f.WebContentLink)\n\t}\n\n\tif args.Delete {\n\t\terr = os.Remove(args.Path)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to delete file: %s\", err)\n\t\t}\n\t\tfmt.Fprintf(args.Out, \"Removed %s\\n\", args.Path)\n\t}\n\n\treturn nil\n}\n\nfunc (self *Drive) uploadRecursive(args UploadArgs) error {\n\tinfo, err := os.Stat(args.Path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed stat file: %s\", err)\n\t}\n\n\tif info.IsDir() {\n\t\targs.Name = \"\"\n\t\treturn self.uploadDirectory(args)\n\t} else if info.Mode().IsRegular() {\n\t\t_, _, err := self.uploadFile(args)\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\nfunc (self *Drive) uploadDirectory(args UploadArgs) error {\n\tsrcFile, srcFileInfo, err := openFile(args.Path)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Close file on function exit\n\tdefer srcFile.Close()\n\n\tfmt.Fprintf(args.Out, \"Creating directory %s\\n\", srcFileInfo.Name())\n\t// Make directory on drive\n\tf, err := self.mkdir(MkdirArgs{\n\t\tOut:         args.Out,\n\t\tName:        srcFileInfo.Name(),\n\t\tParents:     args.Parents,\n\t\tDescription: args.Description,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Read files from directory\n\tnames, err := srcFile.Readdirnames(0)\n\tif err != nil && err != io.EOF {\n\t\treturn fmt.Errorf(\"Failed reading directory: %s\", err)\n\t}\n\n\tfor _, name := range names {\n\t\t// Copy args and set new path and parents\n\t\tnewArgs := args\n\t\tnewArgs.Path = filepath.Join(args.Path, name)\n\t\tnewArgs.Parents = []string{f.Id}\n\t\tnewArgs.Description = \"\"\n\n\t\t// Upload\n\t\terr = self.uploadRecursive(newArgs)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (self *Drive) uploadFile(args UploadArgs) (*drive.File, int64, error) {\n\tsrcFile, srcFileInfo, err := openFile(args.Path)\n\tif err != nil {\n\t\treturn nil, 0, err\n\t}\n\n\t// Close file on function exit\n\tdefer srcFile.Close()\n\n\t// Instantiate empty drive file\n\tdstFile := &drive.File{Description: args.Description}\n\n\t// Use provided file name or use filename\n\tif args.Name == \"\" {\n\t\tdstFile.Name = filepath.Base(srcFileInfo.Name())\n\t} else {\n\t\tdstFile.Name = args.Name\n\t}\n\n\t// Set provided mime type or get type based on file extension\n\tif args.Mime == \"\" {\n\t\tdstFile.MimeType = mime.TypeByExtension(filepath.Ext(dstFile.Name))\n\t} else {\n\t\tdstFile.MimeType = args.Mime\n\t}\n\n\t// Set parent folders\n\tdstFile.Parents = args.Parents\n\n\t// Chunk size option\n\tchunkSize := googleapi.ChunkSize(int(args.ChunkSize))\n\n\t// Wrap file in progress reader\n\tprogressReader := getProgressReader(srcFile, args.Progress, srcFileInfo.Size())\n\n\t// Wrap reader in timeout reader\n\treader, ctx := getTimeoutReaderContext(progressReader, args.Timeout)\n\n\tfmt.Fprintf(args.Out, \"Uploading %s\\n\", args.Path)\n\tstarted := time.Now()\n\n\tf, err := self.service.Files.Create(dstFile).Fields(\"id\", \"name\", \"size\", \"md5Checksum\", \"webContentLink\").Context(ctx).Media(reader, chunkSize).Do()\n\tif err != nil {\n\t\tif isTimeoutError(err) {\n\t\t\treturn nil, 0, fmt.Errorf(\"Failed to upload file: timeout, no data was transferred for %v\", args.Timeout)\n\t\t}\n\t\treturn nil, 0, fmt.Errorf(\"Failed to upload file: %s\", err)\n\t}\n\n\t// Calculate average upload rate\n\trate := calcRate(f.Size, started, time.Now())\n\n\treturn f, rate, nil\n}\n\ntype UploadStreamArgs struct {\n\tOut         io.Writer\n\tIn          io.Reader\n\tName        string\n\tDescription string\n\tParents     []string\n\tMime        string\n\tShare       bool\n\tChunkSize   int64\n\tProgress    io.Writer\n\tTimeout     time.Duration\n}\n\nfunc (self *Drive) UploadStream(args UploadStreamArgs) error {\n\tif args.ChunkSize > intMax()-1 {\n\t\treturn fmt.Errorf(\"Chunk size is to big, max chunk size for this computer is %d\", intMax()-1)\n\t}\n\n\t// Instantiate empty drive file\n\tdstFile := &drive.File{Name: args.Name, Description: args.Description}\n\n\t// Set mime type if provided\n\tif args.Mime != \"\" {\n\t\tdstFile.MimeType = args.Mime\n\t}\n\n\t// Set parent folders\n\tdstFile.Parents = args.Parents\n\n\t// Chunk size option\n\tchunkSize := googleapi.ChunkSize(int(args.ChunkSize))\n\n\t// Wrap file in progress reader\n\tprogressReader := getProgressReader(args.In, args.Progress, 0)\n\n\t// Wrap reader in timeout reader\n\treader, ctx := getTimeoutReaderContext(progressReader, args.Timeout)\n\n\tfmt.Fprintf(args.Out, \"Uploading %s\\n\", dstFile.Name)\n\tstarted := time.Now()\n\n\tf, err := self.service.Files.Create(dstFile).Fields(\"id\", \"name\", \"size\", \"webContentLink\").Context(ctx).Media(reader, chunkSize).Do()\n\tif err != nil {\n\t\tif isTimeoutError(err) {\n\t\t\treturn fmt.Errorf(\"Failed to upload file: timeout, no data was transferred for %v\", args.Timeout)\n\t\t}\n\t\treturn fmt.Errorf(\"Failed to upload file: %s\", err)\n\t}\n\n\t// Calculate average upload rate\n\trate := calcRate(f.Size, started, time.Now())\n\n\tfmt.Fprintf(args.Out, \"Uploaded %s at %s/s, total %s\\n\", f.Id, formatSize(rate, false), formatSize(f.Size, false))\n\tif args.Share {\n\t\terr = self.shareAnyoneReader(f.Id)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfmt.Fprintf(args.Out, \"File is readable by anyone at %s\\n\", f.WebContentLink)\n\t}\n\treturn nil\n}\n"
  },
  {
    "path": "drive/util.go",
    "content": "package drive\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n\t\"unicode/utf8\"\n)\n\ntype kv struct {\n\tkey   string\n\tvalue string\n}\n\nfunc formatList(a []string) string {\n\treturn strings.Join(a, \", \")\n}\n\nfunc formatSize(bytes int64, forceBytes bool) string {\n\tif bytes == 0 {\n\t\treturn \"\"\n\t}\n\n\tif forceBytes {\n\t\treturn fmt.Sprintf(\"%v B\", bytes)\n\t}\n\n\tunits := []string{\"B\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\"}\n\n\tvar i int\n\tvalue := float64(bytes)\n\n\tfor value > 1000 {\n\t\tvalue /= 1000\n\t\ti++\n\t}\n\treturn fmt.Sprintf(\"%.1f %s\", value, units[i])\n}\n\nfunc calcRate(bytes int64, start, end time.Time) int64 {\n\tseconds := float64(end.Sub(start).Seconds())\n\tif seconds < 1.0 {\n\t\treturn bytes\n\t}\n\treturn round(float64(bytes) / seconds)\n}\n\nfunc round(n float64) int64 {\n\tif n < 0 {\n\t\treturn int64(math.Ceil(n - 0.5))\n\t}\n\treturn int64(math.Floor(n + 0.5))\n}\n\nfunc formatBool(b bool) string {\n\treturn strings.Title(strconv.FormatBool(b))\n}\n\nfunc formatDatetime(iso string) string {\n\tt, err := time.Parse(time.RFC3339, iso)\n\tif err != nil {\n\t\treturn iso\n\t}\n\tlocal := t.Local()\n\tyear, month, day := local.Date()\n\thour, min, sec := local.Clock()\n\treturn fmt.Sprintf(\"%04d-%02d-%02d %02d:%02d:%02d\", year, month, day, hour, min, sec)\n}\n\n// Truncates string to given max length, and inserts ellipsis into\n// the middle of the string to signify that the string has been truncated\nfunc truncateString(str string, maxRunes int) string {\n\tindicator := \"...\"\n\n\t// Number of runes in string\n\truneCount := utf8.RuneCountInString(str)\n\n\t// Return input string if length of input string is less than max length\n\t// Input string is also returned if max length is less than 9 which is the minmal supported length\n\tif runeCount <= maxRunes || maxRunes < 9 {\n\t\treturn str\n\t}\n\n\t// Number of remaining runes to be removed\n\tremaining := (runeCount - maxRunes) + utf8.RuneCountInString(indicator)\n\n\tvar truncated string\n\tvar skip bool\n\n\tfor leftOffset, char := range str {\n\t\trightOffset := runeCount - (leftOffset + remaining)\n\n\t\t// Start skipping chars when the left and right offsets are equal\n\t\t// Or in the case where we wont be able to do an even split: when the left offset is larger than the right offset\n\t\tif leftOffset == rightOffset || (leftOffset > rightOffset && !skip) {\n\t\t\tskip = true\n\t\t\ttruncated += indicator\n\t\t}\n\n\t\tif skip && remaining > 0 {\n\t\t\t// Skip char and decrement the remaining skip counter\n\t\t\tremaining--\n\t\t\tcontinue\n\t\t}\n\n\t\t// Add char to result string\n\t\ttruncated += string(char)\n\t}\n\n\t// Return truncated string\n\treturn truncated\n}\n\nfunc fileExists(path string) bool {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc mkdir(path string) error {\n\tdir := filepath.Dir(path)\n\tif fileExists(dir) {\n\t\treturn nil\n\t}\n\treturn os.MkdirAll(dir, 0775)\n}\n\nfunc intMax() int64 {\n\treturn 1<<(strconv.IntSize-1) - 1\n}\n\nfunc pathLength(path string) int {\n\treturn strings.Count(path, string(os.PathSeparator))\n}\n\nfunc parentFilePath(path string) string {\n\tdir, _ := filepath.Split(path)\n\treturn filepath.Dir(dir)\n}\n\nfunc pow(x int, y int) int {\n\tf := math.Pow(float64(x), float64(y))\n\treturn int(f)\n}\n\nfunc min(x int, y int) int {\n\tn := math.Min(float64(x), float64(y))\n\treturn int(n)\n}\n\nfunc openFile(path string) (*os.File, os.FileInfo, error) {\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"Failed to open file: %s\", err)\n\t}\n\n\tinfo, err := f.Stat()\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"Failed getting file metadata: %s\", err)\n\t}\n\n\treturn f, info, nil\n}\n"
  },
  {
    "path": "gdrive.go",
    "content": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\n\t\"github.com/prasmussen/gdrive/cli\"\n)\n\nconst Name = \"gdrive\"\nconst Version = \"2.1.1\"\n\nconst DefaultMaxFiles = 30\nconst DefaultMaxChanges = 100\nconst DefaultNameWidth = 40\nconst DefaultPathWidth = 60\nconst DefaultUploadChunkSize = 8 * 1024 * 1024\nconst DefaultTimeout = 5 * 60\nconst DefaultQuery = \"trashed = false and 'me' in owners\"\nconst DefaultShareRole = \"reader\"\nconst DefaultShareType = \"anyone\"\n\nvar DefaultConfigDir = GetDefaultConfigDir()\n\nfunc main() {\n\tglobalFlags := []cli.Flag{\n\t\tcli.StringFlag{\n\t\t\tName:         \"configDir\",\n\t\t\tPatterns:     []string{\"-c\", \"--config\"},\n\t\t\tDescription:  fmt.Sprintf(\"Application path, default: %s\", DefaultConfigDir),\n\t\t\tDefaultValue: DefaultConfigDir,\n\t\t},\n\t\tcli.StringFlag{\n\t\t\tName:        \"refreshToken\",\n\t\t\tPatterns:    []string{\"--refresh-token\"},\n\t\t\tDescription: \"Oauth refresh token used to get access token (for advanced users)\",\n\t\t},\n\t\tcli.StringFlag{\n\t\t\tName:        \"accessToken\",\n\t\t\tPatterns:    []string{\"--access-token\"},\n\t\t\tDescription: \"Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users)\",\n\t\t},\n\t\tcli.StringFlag{\n\t\t\tName:        \"serviceAccount\",\n\t\t\tPatterns:    []string{\"--service-account\"},\n\t\t\tDescription: \"Oauth service account filename, used for server to server communication without user interaction (filename path is relative to config dir)\",\n\t\t},\n\t}\n\n\thandlers := []*cli.Handler{\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] list [options]\",\n\t\t\tDescription: \"List files\",\n\t\t\tCallback:    listHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t\tcli.NewFlagGroup(\"options\",\n\t\t\t\t\tcli.IntFlag{\n\t\t\t\t\t\tName:         \"maxFiles\",\n\t\t\t\t\t\tPatterns:     []string{\"-m\", \"--max\"},\n\t\t\t\t\t\tDescription:  fmt.Sprintf(\"Max files to list, default: %d\", DefaultMaxFiles),\n\t\t\t\t\t\tDefaultValue: DefaultMaxFiles,\n\t\t\t\t\t},\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName:         \"query\",\n\t\t\t\t\t\tPatterns:     []string{\"-q\", \"--query\"},\n\t\t\t\t\t\tDescription:  fmt.Sprintf(`Default query: \"%s\". See https://developers.google.com/drive/search-parameters`, DefaultQuery),\n\t\t\t\t\t\tDefaultValue: DefaultQuery,\n\t\t\t\t\t},\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName:        \"sortOrder\",\n\t\t\t\t\t\tPatterns:    []string{\"--order\"},\n\t\t\t\t\t\tDescription: \"Sort order. See https://godoc.org/google.golang.org/api/drive/v3#FilesListCall.OrderBy\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.IntFlag{\n\t\t\t\t\t\tName:         \"nameWidth\",\n\t\t\t\t\t\tPatterns:     []string{\"--name-width\"},\n\t\t\t\t\t\tDescription:  fmt.Sprintf(\"Width of name column, default: %d, minimum: 9, use 0 for full width\", DefaultNameWidth),\n\t\t\t\t\t\tDefaultValue: DefaultNameWidth,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"absPath\",\n\t\t\t\t\t\tPatterns:    []string{\"--absolute\"},\n\t\t\t\t\t\tDescription: \"Show absolute path to file (will only show path from first parent)\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"skipHeader\",\n\t\t\t\t\t\tPatterns:    []string{\"--no-header\"},\n\t\t\t\t\t\tDescription: \"Dont print the header\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"sizeInBytes\",\n\t\t\t\t\t\tPatterns:    []string{\"--bytes\"},\n\t\t\t\t\t\tDescription: \"Size in bytes\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] download [options] <fileId>\",\n\t\t\tDescription: \"Download file or directory\",\n\t\t\tCallback:    downloadHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t\tcli.NewFlagGroup(\"options\",\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"force\",\n\t\t\t\t\t\tPatterns:    []string{\"-f\", \"--force\"},\n\t\t\t\t\t\tDescription: \"Overwrite existing file\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"skip\",\n\t\t\t\t\t\tPatterns:    []string{\"-s\", \"--skip\"},\n\t\t\t\t\t\tDescription: \"Skip existing files\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"recursive\",\n\t\t\t\t\t\tPatterns:    []string{\"-r\", \"--recursive\"},\n\t\t\t\t\t\tDescription: \"Download directory recursively, documents will be skipped\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName:        \"path\",\n\t\t\t\t\t\tPatterns:    []string{\"--path\"},\n\t\t\t\t\t\tDescription: \"Download path\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"delete\",\n\t\t\t\t\t\tPatterns:    []string{\"--delete\"},\n\t\t\t\t\t\tDescription: \"Delete remote file when download is successful\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"noProgress\",\n\t\t\t\t\t\tPatterns:    []string{\"--no-progress\"},\n\t\t\t\t\t\tDescription: \"Hide progress\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"stdout\",\n\t\t\t\t\t\tPatterns:    []string{\"--stdout\"},\n\t\t\t\t\t\tDescription: \"Write file content to stdout\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.IntFlag{\n\t\t\t\t\t\tName:         \"timeout\",\n\t\t\t\t\t\tPatterns:     []string{\"--timeout\"},\n\t\t\t\t\t\tDescription:  fmt.Sprintf(\"Set timeout in seconds, use 0 for no timeout. Timeout is reached when no data is transferred in set amount of seconds, default: %d\", DefaultTimeout),\n\t\t\t\t\t\tDefaultValue: DefaultTimeout,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] download query [options] <query>\",\n\t\t\tDescription: \"Download all files and directories matching query\",\n\t\t\tCallback:    downloadQueryHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t\tcli.NewFlagGroup(\"options\",\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"force\",\n\t\t\t\t\t\tPatterns:    []string{\"-f\", \"--force\"},\n\t\t\t\t\t\tDescription: \"Overwrite existing file\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"skip\",\n\t\t\t\t\t\tPatterns:    []string{\"-s\", \"--skip\"},\n\t\t\t\t\t\tDescription: \"Skip existing files\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"recursive\",\n\t\t\t\t\t\tPatterns:    []string{\"-r\", \"--recursive\"},\n\t\t\t\t\t\tDescription: \"Download directories recursively, documents will be skipped\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName:        \"path\",\n\t\t\t\t\t\tPatterns:    []string{\"--path\"},\n\t\t\t\t\t\tDescription: \"Download path\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"noProgress\",\n\t\t\t\t\t\tPatterns:    []string{\"--no-progress\"},\n\t\t\t\t\t\tDescription: \"Hide progress\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] upload [options] <path>\",\n\t\t\tDescription: \"Upload file or directory\",\n\t\t\tCallback:    uploadHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t\tcli.NewFlagGroup(\"options\",\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"recursive\",\n\t\t\t\t\t\tPatterns:    []string{\"-r\", \"--recursive\"},\n\t\t\t\t\t\tDescription: \"Upload directory recursively\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.StringSliceFlag{\n\t\t\t\t\t\tName:        \"parent\",\n\t\t\t\t\t\tPatterns:    []string{\"-p\", \"--parent\"},\n\t\t\t\t\t\tDescription: \"Parent id, used to upload file to a specific directory, can be specified multiple times to give many parents\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName:        \"name\",\n\t\t\t\t\t\tPatterns:    []string{\"--name\"},\n\t\t\t\t\t\tDescription: \"Filename\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName:        \"description\",\n\t\t\t\t\t\tPatterns:    []string{\"--description\"},\n\t\t\t\t\t\tDescription: \"File description\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"noProgress\",\n\t\t\t\t\t\tPatterns:    []string{\"--no-progress\"},\n\t\t\t\t\t\tDescription: \"Hide progress\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName:        \"mime\",\n\t\t\t\t\t\tPatterns:    []string{\"--mime\"},\n\t\t\t\t\t\tDescription: \"Force mime type\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"share\",\n\t\t\t\t\t\tPatterns:    []string{\"--share\"},\n\t\t\t\t\t\tDescription: \"Share file\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"delete\",\n\t\t\t\t\t\tPatterns:    []string{\"--delete\"},\n\t\t\t\t\t\tDescription: \"Delete local file when upload is successful\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.IntFlag{\n\t\t\t\t\t\tName:         \"timeout\",\n\t\t\t\t\t\tPatterns:     []string{\"--timeout\"},\n\t\t\t\t\t\tDescription:  fmt.Sprintf(\"Set timeout in seconds, use 0 for no timeout. Timeout is reached when no data is transferred in set amount of seconds, default: %d\", DefaultTimeout),\n\t\t\t\t\t\tDefaultValue: DefaultTimeout,\n\t\t\t\t\t},\n\t\t\t\t\tcli.IntFlag{\n\t\t\t\t\t\tName:         \"chunksize\",\n\t\t\t\t\t\tPatterns:     []string{\"--chunksize\"},\n\t\t\t\t\t\tDescription:  fmt.Sprintf(\"Set chunk size in bytes, default: %d\", DefaultUploadChunkSize),\n\t\t\t\t\t\tDefaultValue: DefaultUploadChunkSize,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] upload - [options] <name>\",\n\t\t\tDescription: \"Upload file from stdin\",\n\t\t\tCallback:    uploadStdinHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t\tcli.NewFlagGroup(\"options\",\n\t\t\t\t\tcli.StringSliceFlag{\n\t\t\t\t\t\tName:        \"parent\",\n\t\t\t\t\t\tPatterns:    []string{\"-p\", \"--parent\"},\n\t\t\t\t\t\tDescription: \"Parent id, used to upload file to a specific directory, can be specified multiple times to give many parents\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.IntFlag{\n\t\t\t\t\t\tName:         \"chunksize\",\n\t\t\t\t\t\tPatterns:     []string{\"--chunksize\"},\n\t\t\t\t\t\tDescription:  fmt.Sprintf(\"Set chunk size in bytes, default: %d\", DefaultUploadChunkSize),\n\t\t\t\t\t\tDefaultValue: DefaultUploadChunkSize,\n\t\t\t\t\t},\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName:        \"description\",\n\t\t\t\t\t\tPatterns:    []string{\"--description\"},\n\t\t\t\t\t\tDescription: \"File description\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName:        \"mime\",\n\t\t\t\t\t\tPatterns:    []string{\"--mime\"},\n\t\t\t\t\t\tDescription: \"Force mime type\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"share\",\n\t\t\t\t\t\tPatterns:    []string{\"--share\"},\n\t\t\t\t\t\tDescription: \"Share file\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.IntFlag{\n\t\t\t\t\t\tName:         \"timeout\",\n\t\t\t\t\t\tPatterns:     []string{\"--timeout\"},\n\t\t\t\t\t\tDescription:  fmt.Sprintf(\"Set timeout in seconds, use 0 for no timeout. Timeout is reached when no data is transferred in set amount of seconds, default: %d\", DefaultTimeout),\n\t\t\t\t\t\tDefaultValue: DefaultTimeout,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"noProgress\",\n\t\t\t\t\t\tPatterns:    []string{\"--no-progress\"},\n\t\t\t\t\t\tDescription: \"Hide progress\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] update [options] <fileId> <path>\",\n\t\t\tDescription: \"Update file, this creates a new revision of the file\",\n\t\t\tCallback:    updateHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t\tcli.NewFlagGroup(\"options\",\n\t\t\t\t\tcli.StringSliceFlag{\n\t\t\t\t\t\tName:        \"parent\",\n\t\t\t\t\t\tPatterns:    []string{\"-p\", \"--parent\"},\n\t\t\t\t\t\tDescription: \"Parent id, used to upload file to a specific directory, can be specified multiple times to give many parents\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName:        \"name\",\n\t\t\t\t\t\tPatterns:    []string{\"--name\"},\n\t\t\t\t\t\tDescription: \"Filename\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName:        \"description\",\n\t\t\t\t\t\tPatterns:    []string{\"--description\"},\n\t\t\t\t\t\tDescription: \"File description\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"noProgress\",\n\t\t\t\t\t\tPatterns:    []string{\"--no-progress\"},\n\t\t\t\t\t\tDescription: \"Hide progress\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName:        \"mime\",\n\t\t\t\t\t\tPatterns:    []string{\"--mime\"},\n\t\t\t\t\t\tDescription: \"Force mime type\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.IntFlag{\n\t\t\t\t\t\tName:         \"timeout\",\n\t\t\t\t\t\tPatterns:     []string{\"--timeout\"},\n\t\t\t\t\t\tDescription:  fmt.Sprintf(\"Set timeout in seconds, use 0 for no timeout. Timeout is reached when no data is transferred in set amount of seconds, default: %d\", DefaultTimeout),\n\t\t\t\t\t\tDefaultValue: DefaultTimeout,\n\t\t\t\t\t},\n\t\t\t\t\tcli.IntFlag{\n\t\t\t\t\t\tName:         \"chunksize\",\n\t\t\t\t\t\tPatterns:     []string{\"--chunksize\"},\n\t\t\t\t\t\tDescription:  fmt.Sprintf(\"Set chunk size in bytes, default: %d\", DefaultUploadChunkSize),\n\t\t\t\t\t\tDefaultValue: DefaultUploadChunkSize,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] info [options] <fileId>\",\n\t\t\tDescription: \"Show file info\",\n\t\t\tCallback:    infoHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t\tcli.NewFlagGroup(\"options\",\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"sizeInBytes\",\n\t\t\t\t\t\tPatterns:    []string{\"--bytes\"},\n\t\t\t\t\t\tDescription: \"Show size in bytes\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] mkdir [options] <name>\",\n\t\t\tDescription: \"Create directory\",\n\t\t\tCallback:    mkdirHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t\tcli.NewFlagGroup(\"options\",\n\t\t\t\t\tcli.StringSliceFlag{\n\t\t\t\t\t\tName:        \"parent\",\n\t\t\t\t\t\tPatterns:    []string{\"-p\", \"--parent\"},\n\t\t\t\t\t\tDescription: \"Parent id of created directory, can be specified multiple times to give many parents\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName:        \"description\",\n\t\t\t\t\t\tPatterns:    []string{\"--description\"},\n\t\t\t\t\t\tDescription: \"Directory description\",\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] share [options] <fileId>\",\n\t\t\tDescription: \"Share file or directory\",\n\t\t\tCallback:    shareHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t\tcli.NewFlagGroup(\"options\",\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName:         \"role\",\n\t\t\t\t\t\tPatterns:     []string{\"--role\"},\n\t\t\t\t\t\tDescription:  fmt.Sprintf(\"Share role: owner/writer/commenter/reader, default: %s\", DefaultShareRole),\n\t\t\t\t\t\tDefaultValue: DefaultShareRole,\n\t\t\t\t\t},\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName:         \"type\",\n\t\t\t\t\t\tPatterns:     []string{\"--type\"},\n\t\t\t\t\t\tDescription:  fmt.Sprintf(\"Share type: user/group/domain/anyone, default: %s\", DefaultShareType),\n\t\t\t\t\t\tDefaultValue: DefaultShareType,\n\t\t\t\t\t},\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName:        \"email\",\n\t\t\t\t\t\tPatterns:    []string{\"--email\"},\n\t\t\t\t\t\tDescription: \"The email address of the user or group to share the file with. Requires 'user' or 'group' as type\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName:        \"domain\",\n\t\t\t\t\t\tPatterns:    []string{\"--domain\"},\n\t\t\t\t\t\tDescription: \"The name of Google Apps domain. Requires 'domain' as type\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"discoverable\",\n\t\t\t\t\t\tPatterns:    []string{\"--discoverable\"},\n\t\t\t\t\t\tDescription: \"Make file discoverable by search engines\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"revoke\",\n\t\t\t\t\t\tPatterns:    []string{\"--revoke\"},\n\t\t\t\t\t\tDescription: \"Delete all sharing permissions (owner roles will be skipped)\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] share list <fileId>\",\n\t\t\tDescription: \"List files permissions\",\n\t\t\tCallback:    shareListHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] share revoke <fileId> <permissionId>\",\n\t\t\tDescription: \"Revoke permission\",\n\t\t\tCallback:    shareRevokeHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] delete [options] <fileId>\",\n\t\t\tDescription: \"Delete file or directory\",\n\t\t\tCallback:    deleteHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t\tcli.NewFlagGroup(\"options\",\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"recursive\",\n\t\t\t\t\t\tPatterns:    []string{\"-r\", \"--recursive\"},\n\t\t\t\t\t\tDescription: \"Delete directory and all it's content\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] sync list [options]\",\n\t\t\tDescription: \"List all syncable directories on drive\",\n\t\t\tCallback:    listSyncHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t\tcli.NewFlagGroup(\"options\",\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"skipHeader\",\n\t\t\t\t\t\tPatterns:    []string{\"--no-header\"},\n\t\t\t\t\t\tDescription: \"Dont print the header\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] sync content [options] <fileId>\",\n\t\t\tDescription: \"List content of syncable directory\",\n\t\t\tCallback:    listRecursiveSyncHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t\tcli.NewFlagGroup(\"options\",\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName:        \"sortOrder\",\n\t\t\t\t\t\tPatterns:    []string{\"--order\"},\n\t\t\t\t\t\tDescription: \"Sort order. See https://godoc.org/google.golang.org/api/drive/v3#FilesListCall.OrderBy\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.IntFlag{\n\t\t\t\t\t\tName:         \"pathWidth\",\n\t\t\t\t\t\tPatterns:     []string{\"--path-width\"},\n\t\t\t\t\t\tDescription:  fmt.Sprintf(\"Width of path column, default: %d, minimum: 9, use 0 for full width\", DefaultPathWidth),\n\t\t\t\t\t\tDefaultValue: DefaultPathWidth,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"skipHeader\",\n\t\t\t\t\t\tPatterns:    []string{\"--no-header\"},\n\t\t\t\t\t\tDescription: \"Dont print the header\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"sizeInBytes\",\n\t\t\t\t\t\tPatterns:    []string{\"--bytes\"},\n\t\t\t\t\t\tDescription: \"Size in bytes\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] sync download [options] <fileId> <path>\",\n\t\t\tDescription: \"Sync drive directory to local directory\",\n\t\t\tCallback:    downloadSyncHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t\tcli.NewFlagGroup(\"options\",\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"keepRemote\",\n\t\t\t\t\t\tPatterns:    []string{\"--keep-remote\"},\n\t\t\t\t\t\tDescription: \"Keep remote file when a conflict is encountered\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"keepLocal\",\n\t\t\t\t\t\tPatterns:    []string{\"--keep-local\"},\n\t\t\t\t\t\tDescription: \"Keep local file when a conflict is encountered\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"keepLargest\",\n\t\t\t\t\t\tPatterns:    []string{\"--keep-largest\"},\n\t\t\t\t\t\tDescription: \"Keep largest file when a conflict is encountered\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"deleteExtraneous\",\n\t\t\t\t\t\tPatterns:    []string{\"--delete-extraneous\"},\n\t\t\t\t\t\tDescription: \"Delete extraneous local files\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"dryRun\",\n\t\t\t\t\t\tPatterns:    []string{\"--dry-run\"},\n\t\t\t\t\t\tDescription: \"Show what would have been transferred\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"noProgress\",\n\t\t\t\t\t\tPatterns:    []string{\"--no-progress\"},\n\t\t\t\t\t\tDescription: \"Hide progress\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.IntFlag{\n\t\t\t\t\t\tName:         \"timeout\",\n\t\t\t\t\t\tPatterns:     []string{\"--timeout\"},\n\t\t\t\t\t\tDescription:  fmt.Sprintf(\"Set timeout in seconds, use 0 for no timeout. Timeout is reached when no data is transferred in set amount of seconds, default: %d\", DefaultTimeout),\n\t\t\t\t\t\tDefaultValue: DefaultTimeout,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] sync upload [options] <path> <fileId>\",\n\t\t\tDescription: \"Sync local directory to drive\",\n\t\t\tCallback:    uploadSyncHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t\tcli.NewFlagGroup(\"options\",\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"keepRemote\",\n\t\t\t\t\t\tPatterns:    []string{\"--keep-remote\"},\n\t\t\t\t\t\tDescription: \"Keep remote file when a conflict is encountered\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"keepLocal\",\n\t\t\t\t\t\tPatterns:    []string{\"--keep-local\"},\n\t\t\t\t\t\tDescription: \"Keep local file when a conflict is encountered\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"keepLargest\",\n\t\t\t\t\t\tPatterns:    []string{\"--keep-largest\"},\n\t\t\t\t\t\tDescription: \"Keep largest file when a conflict is encountered\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"deleteExtraneous\",\n\t\t\t\t\t\tPatterns:    []string{\"--delete-extraneous\"},\n\t\t\t\t\t\tDescription: \"Delete extraneous remote files\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"dryRun\",\n\t\t\t\t\t\tPatterns:    []string{\"--dry-run\"},\n\t\t\t\t\t\tDescription: \"Show what would have been transferred\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"noProgress\",\n\t\t\t\t\t\tPatterns:    []string{\"--no-progress\"},\n\t\t\t\t\t\tDescription: \"Hide progress\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.IntFlag{\n\t\t\t\t\t\tName:         \"timeout\",\n\t\t\t\t\t\tPatterns:     []string{\"--timeout\"},\n\t\t\t\t\t\tDescription:  fmt.Sprintf(\"Set timeout in seconds, use 0 for no timeout. Timeout is reached when no data is transferred in set amount of seconds, default: %d\", DefaultTimeout),\n\t\t\t\t\t\tDefaultValue: DefaultTimeout,\n\t\t\t\t\t},\n\t\t\t\t\tcli.IntFlag{\n\t\t\t\t\t\tName:         \"chunksize\",\n\t\t\t\t\t\tPatterns:     []string{\"--chunksize\"},\n\t\t\t\t\t\tDescription:  fmt.Sprintf(\"Set chunk size in bytes, default: %d\", DefaultUploadChunkSize),\n\t\t\t\t\t\tDefaultValue: DefaultUploadChunkSize,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] changes [options]\",\n\t\t\tDescription: \"List file changes\",\n\t\t\tCallback:    listChangesHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t\tcli.NewFlagGroup(\"options\",\n\t\t\t\t\tcli.IntFlag{\n\t\t\t\t\t\tName:         \"maxChanges\",\n\t\t\t\t\t\tPatterns:     []string{\"-m\", \"--max\"},\n\t\t\t\t\t\tDescription:  fmt.Sprintf(\"Max changes to list, default: %d\", DefaultMaxChanges),\n\t\t\t\t\t\tDefaultValue: DefaultMaxChanges,\n\t\t\t\t\t},\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName:         \"pageToken\",\n\t\t\t\t\t\tPatterns:     []string{\"--since\"},\n\t\t\t\t\t\tDescription:  fmt.Sprintf(\"Page token to start listing changes from\"),\n\t\t\t\t\t\tDefaultValue: \"1\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"now\",\n\t\t\t\t\t\tPatterns:    []string{\"--now\"},\n\t\t\t\t\t\tDescription: fmt.Sprintf(\"Get latest page token\"),\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.IntFlag{\n\t\t\t\t\t\tName:         \"nameWidth\",\n\t\t\t\t\t\tPatterns:     []string{\"--name-width\"},\n\t\t\t\t\t\tDescription:  fmt.Sprintf(\"Width of name column, default: %d, minimum: 9, use 0 for full width\", DefaultNameWidth),\n\t\t\t\t\t\tDefaultValue: DefaultNameWidth,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"skipHeader\",\n\t\t\t\t\t\tPatterns:    []string{\"--no-header\"},\n\t\t\t\t\t\tDescription: \"Dont print the header\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] revision list [options] <fileId>\",\n\t\t\tDescription: \"List file revisions\",\n\t\t\tCallback:    listRevisionsHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t\tcli.NewFlagGroup(\"options\",\n\t\t\t\t\tcli.IntFlag{\n\t\t\t\t\t\tName:         \"nameWidth\",\n\t\t\t\t\t\tPatterns:     []string{\"--name-width\"},\n\t\t\t\t\t\tDescription:  fmt.Sprintf(\"Width of name column, default: %d, minimum: 9, use 0 for full width\", DefaultNameWidth),\n\t\t\t\t\t\tDefaultValue: DefaultNameWidth,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"skipHeader\",\n\t\t\t\t\t\tPatterns:    []string{\"--no-header\"},\n\t\t\t\t\t\tDescription: \"Dont print the header\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"sizeInBytes\",\n\t\t\t\t\t\tPatterns:    []string{\"--bytes\"},\n\t\t\t\t\t\tDescription: \"Size in bytes\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] revision download [options] <fileId> <revId>\",\n\t\t\tDescription: \"Download revision\",\n\t\t\tCallback:    downloadRevisionHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t\tcli.NewFlagGroup(\"options\",\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"force\",\n\t\t\t\t\t\tPatterns:    []string{\"-f\", \"--force\"},\n\t\t\t\t\t\tDescription: \"Overwrite existing file\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"noProgress\",\n\t\t\t\t\t\tPatterns:    []string{\"--no-progress\"},\n\t\t\t\t\t\tDescription: \"Hide progress\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"stdout\",\n\t\t\t\t\t\tPatterns:    []string{\"--stdout\"},\n\t\t\t\t\t\tDescription: \"Write file content to stdout\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName:        \"path\",\n\t\t\t\t\t\tPatterns:    []string{\"--path\"},\n\t\t\t\t\t\tDescription: \"Download path\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.IntFlag{\n\t\t\t\t\t\tName:         \"timeout\",\n\t\t\t\t\t\tPatterns:     []string{\"--timeout\"},\n\t\t\t\t\t\tDescription:  fmt.Sprintf(\"Set timeout in seconds, use 0 for no timeout. Timeout is reached when no data is transferred in set amount of seconds, default: %d\", DefaultTimeout),\n\t\t\t\t\t\tDefaultValue: DefaultTimeout,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] revision delete <fileId> <revId>\",\n\t\t\tDescription: \"Delete file revision\",\n\t\t\tCallback:    deleteRevisionHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] import [options] <path>\",\n\t\t\tDescription: \"Upload and convert file to a google document, see 'about import' for available conversions\",\n\t\t\tCallback:    importHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t\tcli.NewFlagGroup(\"options\",\n\t\t\t\t\tcli.StringSliceFlag{\n\t\t\t\t\t\tName:        \"parent\",\n\t\t\t\t\t\tPatterns:    []string{\"-p\", \"--parent\"},\n\t\t\t\t\t\tDescription: \"Parent id, used to upload file to a specific directory, can be specified multiple times to give many parents\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"noProgress\",\n\t\t\t\t\t\tPatterns:    []string{\"--no-progress\"},\n\t\t\t\t\t\tDescription: \"Hide progress\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName:        \"mime\",\n\t\t\t\t\t\tPatterns:    []string{\"--mime\"},\n\t\t\t\t\t\tDescription: \"Mime type of imported file\",\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] export [options] <fileId>\",\n\t\t\tDescription: \"Export a google document\",\n\t\t\tCallback:    exportHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t\tcli.NewFlagGroup(\"options\",\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"force\",\n\t\t\t\t\t\tPatterns:    []string{\"-f\", \"--force\"},\n\t\t\t\t\t\tDescription: \"Overwrite existing file\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t\tcli.StringFlag{\n\t\t\t\t\t\tName:        \"mime\",\n\t\t\t\t\t\tPatterns:    []string{\"--mime\"},\n\t\t\t\t\t\tDescription: \"Mime type of exported file\",\n\t\t\t\t\t},\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"printMimes\",\n\t\t\t\t\t\tPatterns:    []string{\"--print-mimes\"},\n\t\t\t\t\t\tDescription: \"Print available mime types for given file\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] about [options]\",\n\t\t\tDescription: \"Google drive metadata, quota usage\",\n\t\t\tCallback:    aboutHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t\tcli.NewFlagGroup(\"options\",\n\t\t\t\t\tcli.BoolFlag{\n\t\t\t\t\t\tName:        \"sizeInBytes\",\n\t\t\t\t\t\tPatterns:    []string{\"--bytes\"},\n\t\t\t\t\t\tDescription: \"Show size in bytes\",\n\t\t\t\t\t\tOmitValue:   true,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] about import\",\n\t\t\tDescription: \"Show supported import formats\",\n\t\t\tCallback:    aboutImportHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"[global] about export\",\n\t\t\tDescription: \"Show supported export formats\",\n\t\t\tCallback:    aboutExportHandler,\n\t\t\tFlagGroups: cli.FlagGroups{\n\t\t\t\tcli.NewFlagGroup(\"global\", globalFlags...),\n\t\t\t},\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"version\",\n\t\t\tDescription: \"Print application version\",\n\t\t\tCallback:    printVersion,\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"help\",\n\t\t\tDescription: \"Print help\",\n\t\t\tCallback:    printHelp,\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"help <command>\",\n\t\t\tDescription: \"Print command help\",\n\t\t\tCallback:    printCommandHelp,\n\t\t},\n\t\t&cli.Handler{\n\t\t\tPattern:     \"help <command> <subcommand>\",\n\t\t\tDescription: \"Print subcommand help\",\n\t\t\tCallback:    printSubCommandHelp,\n\t\t},\n\t}\n\n\tcli.SetHandlers(handlers)\n\n\tif ok := cli.Handle(os.Args[1:]); !ok {\n\t\tExitF(\"No valid arguments given, use '%s help' to see available commands\", Name)\n\t}\n}\n"
  },
  {
    "path": "handlers_drive.go",
    "content": "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"net/http\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"time\"\n\n\t\"github.com/prasmussen/gdrive/auth\"\n\t\"github.com/prasmussen/gdrive/cli\"\n\t\"github.com/prasmussen/gdrive/drive\"\n)\n\nconst ClientId = \"367116221053-7n0vf5akeru7on6o2fjinrecpdoe99eg.apps.googleusercontent.com\"\nconst ClientSecret = \"1qsNodXNaWq1mQuBjUjmvhoO\"\nconst TokenFilename = \"token_v2.json\"\nconst DefaultCacheFileName = \"file_cache.json\"\n\nfunc listHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\terr := newDrive(args).List(drive.ListFilesArgs{\n\t\tOut:         os.Stdout,\n\t\tMaxFiles:    args.Int64(\"maxFiles\"),\n\t\tNameWidth:   args.Int64(\"nameWidth\"),\n\t\tQuery:       args.String(\"query\"),\n\t\tSortOrder:   args.String(\"sortOrder\"),\n\t\tSkipHeader:  args.Bool(\"skipHeader\"),\n\t\tSizeInBytes: args.Bool(\"sizeInBytes\"),\n\t\tAbsPath:     args.Bool(\"absPath\"),\n\t})\n\tcheckErr(err)\n}\n\nfunc listChangesHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\terr := newDrive(args).ListChanges(drive.ListChangesArgs{\n\t\tOut:        os.Stdout,\n\t\tPageToken:  args.String(\"pageToken\"),\n\t\tMaxChanges: args.Int64(\"maxChanges\"),\n\t\tNow:        args.Bool(\"now\"),\n\t\tNameWidth:  args.Int64(\"nameWidth\"),\n\t\tSkipHeader: args.Bool(\"skipHeader\"),\n\t})\n\tcheckErr(err)\n}\n\nfunc downloadHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\tcheckDownloadArgs(args)\n\terr := newDrive(args).Download(drive.DownloadArgs{\n\t\tOut:       os.Stdout,\n\t\tId:        args.String(\"fileId\"),\n\t\tForce:     args.Bool(\"force\"),\n\t\tSkip:      args.Bool(\"skip\"),\n\t\tPath:      args.String(\"path\"),\n\t\tDelete:    args.Bool(\"delete\"),\n\t\tRecursive: args.Bool(\"recursive\"),\n\t\tStdout:    args.Bool(\"stdout\"),\n\t\tProgress:  progressWriter(args.Bool(\"noProgress\")),\n\t\tTimeout:   durationInSeconds(args.Int64(\"timeout\")),\n\t})\n\tcheckErr(err)\n}\n\nfunc downloadQueryHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\terr := newDrive(args).DownloadQuery(drive.DownloadQueryArgs{\n\t\tOut:       os.Stdout,\n\t\tQuery:     args.String(\"query\"),\n\t\tForce:     args.Bool(\"force\"),\n\t\tSkip:      args.Bool(\"skip\"),\n\t\tRecursive: args.Bool(\"recursive\"),\n\t\tPath:      args.String(\"path\"),\n\t\tProgress:  progressWriter(args.Bool(\"noProgress\")),\n\t})\n\tcheckErr(err)\n}\n\nfunc downloadSyncHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\tcachePath := filepath.Join(args.String(\"configDir\"), DefaultCacheFileName)\n\terr := newDrive(args).DownloadSync(drive.DownloadSyncArgs{\n\t\tOut:              os.Stdout,\n\t\tProgress:         progressWriter(args.Bool(\"noProgress\")),\n\t\tPath:             args.String(\"path\"),\n\t\tRootId:           args.String(\"fileId\"),\n\t\tDryRun:           args.Bool(\"dryRun\"),\n\t\tDeleteExtraneous: args.Bool(\"deleteExtraneous\"),\n\t\tTimeout:          durationInSeconds(args.Int64(\"timeout\")),\n\t\tResolution:       conflictResolution(args),\n\t\tComparer:         NewCachedMd5Comparer(cachePath),\n\t})\n\tcheckErr(err)\n}\n\nfunc downloadRevisionHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\terr := newDrive(args).DownloadRevision(drive.DownloadRevisionArgs{\n\t\tOut:        os.Stdout,\n\t\tFileId:     args.String(\"fileId\"),\n\t\tRevisionId: args.String(\"revId\"),\n\t\tForce:      args.Bool(\"force\"),\n\t\tStdout:     args.Bool(\"stdout\"),\n\t\tPath:       args.String(\"path\"),\n\t\tProgress:   progressWriter(args.Bool(\"noProgress\")),\n\t\tTimeout:    durationInSeconds(args.Int64(\"timeout\")),\n\t})\n\tcheckErr(err)\n}\n\nfunc uploadHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\tcheckUploadArgs(args)\n\terr := newDrive(args).Upload(drive.UploadArgs{\n\t\tOut:         os.Stdout,\n\t\tProgress:    progressWriter(args.Bool(\"noProgress\")),\n\t\tPath:        args.String(\"path\"),\n\t\tName:        args.String(\"name\"),\n\t\tDescription: args.String(\"description\"),\n\t\tParents:     args.StringSlice(\"parent\"),\n\t\tMime:        args.String(\"mime\"),\n\t\tRecursive:   args.Bool(\"recursive\"),\n\t\tShare:       args.Bool(\"share\"),\n\t\tDelete:      args.Bool(\"delete\"),\n\t\tChunkSize:   args.Int64(\"chunksize\"),\n\t\tTimeout:     durationInSeconds(args.Int64(\"timeout\")),\n\t})\n\tcheckErr(err)\n}\n\nfunc uploadStdinHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\terr := newDrive(args).UploadStream(drive.UploadStreamArgs{\n\t\tOut:         os.Stdout,\n\t\tIn:          os.Stdin,\n\t\tName:        args.String(\"name\"),\n\t\tDescription: args.String(\"description\"),\n\t\tParents:     args.StringSlice(\"parent\"),\n\t\tMime:        args.String(\"mime\"),\n\t\tShare:       args.Bool(\"share\"),\n\t\tChunkSize:   args.Int64(\"chunksize\"),\n\t\tTimeout:     durationInSeconds(args.Int64(\"timeout\")),\n\t\tProgress:    progressWriter(args.Bool(\"noProgress\")),\n\t})\n\tcheckErr(err)\n}\n\nfunc uploadSyncHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\tcachePath := filepath.Join(args.String(\"configDir\"), DefaultCacheFileName)\n\terr := newDrive(args).UploadSync(drive.UploadSyncArgs{\n\t\tOut:              os.Stdout,\n\t\tProgress:         progressWriter(args.Bool(\"noProgress\")),\n\t\tPath:             args.String(\"path\"),\n\t\tRootId:           args.String(\"fileId\"),\n\t\tDryRun:           args.Bool(\"dryRun\"),\n\t\tDeleteExtraneous: args.Bool(\"deleteExtraneous\"),\n\t\tChunkSize:        args.Int64(\"chunksize\"),\n\t\tTimeout:          durationInSeconds(args.Int64(\"timeout\")),\n\t\tResolution:       conflictResolution(args),\n\t\tComparer:         NewCachedMd5Comparer(cachePath),\n\t})\n\tcheckErr(err)\n}\n\nfunc updateHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\terr := newDrive(args).Update(drive.UpdateArgs{\n\t\tOut:         os.Stdout,\n\t\tId:          args.String(\"fileId\"),\n\t\tPath:        args.String(\"path\"),\n\t\tName:        args.String(\"name\"),\n\t\tDescription: args.String(\"description\"),\n\t\tParents:     args.StringSlice(\"parent\"),\n\t\tMime:        args.String(\"mime\"),\n\t\tProgress:    progressWriter(args.Bool(\"noProgress\")),\n\t\tChunkSize:   args.Int64(\"chunksize\"),\n\t\tTimeout:     durationInSeconds(args.Int64(\"timeout\")),\n\t})\n\tcheckErr(err)\n}\n\nfunc infoHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\terr := newDrive(args).Info(drive.FileInfoArgs{\n\t\tOut:         os.Stdout,\n\t\tId:          args.String(\"fileId\"),\n\t\tSizeInBytes: args.Bool(\"sizeInBytes\"),\n\t})\n\tcheckErr(err)\n}\n\nfunc importHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\terr := newDrive(args).Import(drive.ImportArgs{\n\t\tMime:     args.String(\"mime\"),\n\t\tOut:      os.Stdout,\n\t\tPath:     args.String(\"path\"),\n\t\tParents:  args.StringSlice(\"parent\"),\n\t\tProgress: progressWriter(args.Bool(\"noProgress\")),\n\t})\n\tcheckErr(err)\n}\n\nfunc exportHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\terr := newDrive(args).Export(drive.ExportArgs{\n\t\tOut:        os.Stdout,\n\t\tId:         args.String(\"fileId\"),\n\t\tMime:       args.String(\"mime\"),\n\t\tPrintMimes: args.Bool(\"printMimes\"),\n\t\tForce:      args.Bool(\"force\"),\n\t})\n\tcheckErr(err)\n}\n\nfunc listRevisionsHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\terr := newDrive(args).ListRevisions(drive.ListRevisionsArgs{\n\t\tOut:         os.Stdout,\n\t\tId:          args.String(\"fileId\"),\n\t\tNameWidth:   args.Int64(\"nameWidth\"),\n\t\tSizeInBytes: args.Bool(\"sizeInBytes\"),\n\t\tSkipHeader:  args.Bool(\"skipHeader\"),\n\t})\n\tcheckErr(err)\n}\n\nfunc mkdirHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\terr := newDrive(args).Mkdir(drive.MkdirArgs{\n\t\tOut:         os.Stdout,\n\t\tName:        args.String(\"name\"),\n\t\tDescription: args.String(\"description\"),\n\t\tParents:     args.StringSlice(\"parent\"),\n\t})\n\tcheckErr(err)\n}\n\nfunc shareHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\terr := newDrive(args).Share(drive.ShareArgs{\n\t\tOut:          os.Stdout,\n\t\tFileId:       args.String(\"fileId\"),\n\t\tRole:         args.String(\"role\"),\n\t\tType:         args.String(\"type\"),\n\t\tEmail:        args.String(\"email\"),\n\t\tDomain:       args.String(\"domain\"),\n\t\tDiscoverable: args.Bool(\"discoverable\"),\n\t})\n\tcheckErr(err)\n}\n\nfunc shareListHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\terr := newDrive(args).ListPermissions(drive.ListPermissionsArgs{\n\t\tOut:    os.Stdout,\n\t\tFileId: args.String(\"fileId\"),\n\t})\n\tcheckErr(err)\n}\n\nfunc shareRevokeHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\terr := newDrive(args).RevokePermission(drive.RevokePermissionArgs{\n\t\tOut:          os.Stdout,\n\t\tFileId:       args.String(\"fileId\"),\n\t\tPermissionId: args.String(\"permissionId\"),\n\t})\n\tcheckErr(err)\n}\n\nfunc deleteHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\terr := newDrive(args).Delete(drive.DeleteArgs{\n\t\tOut:       os.Stdout,\n\t\tId:        args.String(\"fileId\"),\n\t\tRecursive: args.Bool(\"recursive\"),\n\t})\n\tcheckErr(err)\n}\n\nfunc listSyncHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\terr := newDrive(args).ListSync(drive.ListSyncArgs{\n\t\tOut:        os.Stdout,\n\t\tSkipHeader: args.Bool(\"skipHeader\"),\n\t})\n\tcheckErr(err)\n}\n\nfunc listRecursiveSyncHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\terr := newDrive(args).ListRecursiveSync(drive.ListRecursiveSyncArgs{\n\t\tOut:         os.Stdout,\n\t\tRootId:      args.String(\"fileId\"),\n\t\tSkipHeader:  args.Bool(\"skipHeader\"),\n\t\tPathWidth:   args.Int64(\"pathWidth\"),\n\t\tSizeInBytes: args.Bool(\"sizeInBytes\"),\n\t\tSortOrder:   args.String(\"sortOrder\"),\n\t})\n\tcheckErr(err)\n}\n\nfunc deleteRevisionHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\terr := newDrive(args).DeleteRevision(drive.DeleteRevisionArgs{\n\t\tOut:        os.Stdout,\n\t\tFileId:     args.String(\"fileId\"),\n\t\tRevisionId: args.String(\"revId\"),\n\t})\n\tcheckErr(err)\n}\n\nfunc aboutHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\terr := newDrive(args).About(drive.AboutArgs{\n\t\tOut:         os.Stdout,\n\t\tSizeInBytes: args.Bool(\"sizeInBytes\"),\n\t})\n\tcheckErr(err)\n}\n\nfunc aboutImportHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\terr := newDrive(args).AboutImport(drive.AboutImportArgs{\n\t\tOut: os.Stdout,\n\t})\n\tcheckErr(err)\n}\n\nfunc aboutExportHandler(ctx cli.Context) {\n\targs := ctx.Args()\n\terr := newDrive(args).AboutExport(drive.AboutExportArgs{\n\t\tOut: os.Stdout,\n\t})\n\tcheckErr(err)\n}\n\nfunc getOauthClient(args cli.Arguments) (*http.Client, error) {\n\tif args.String(\"refreshToken\") != \"\" && args.String(\"accessToken\") != \"\" {\n\t\tExitF(\"Access token not needed when refresh token is provided\")\n\t}\n\n\tif args.String(\"refreshToken\") != \"\" {\n\t\treturn auth.NewRefreshTokenClient(ClientId, ClientSecret, args.String(\"refreshToken\")), nil\n\t}\n\n\tif args.String(\"accessToken\") != \"\" {\n\t\treturn auth.NewAccessTokenClient(ClientId, ClientSecret, args.String(\"accessToken\")), nil\n\t}\n\n\tconfigDir := getConfigDir(args)\n\n\tif args.String(\"serviceAccount\") != \"\" {\n\t\tserviceAccountPath := ConfigFilePath(configDir, args.String(\"serviceAccount\"))\n\t\tserviceAccountClient, err := auth.NewServiceAccountClient(serviceAccountPath)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn serviceAccountClient, nil\n\t}\n\n\ttokenPath := ConfigFilePath(configDir, TokenFilename)\n\treturn auth.NewFileSourceClient(ClientId, ClientSecret, tokenPath, authCodePrompt)\n}\n\nfunc getConfigDir(args cli.Arguments) string {\n\t// Use dir from environment var if present\n\tif os.Getenv(\"GDRIVE_CONFIG_DIR\") != \"\" {\n\t\treturn os.Getenv(\"GDRIVE_CONFIG_DIR\")\n\t}\n\treturn args.String(\"configDir\")\n}\n\nfunc newDrive(args cli.Arguments) *drive.Drive {\n\toauth, err := getOauthClient(args)\n\tif err != nil {\n\t\tExitF(\"Failed getting oauth client: %s\", err.Error())\n\t}\n\n\tclient, err := drive.New(oauth)\n\tif err != nil {\n\t\tExitF(\"Failed getting drive: %s\", err.Error())\n\t}\n\n\treturn client\n}\n\nfunc authCodePrompt(url string) func() string {\n\treturn func() string {\n\t\tfmt.Println(\"Authentication needed\")\n\t\tfmt.Println(\"Go to the following url in your browser:\")\n\t\tfmt.Printf(\"%s\\n\\n\", url)\n\t\tfmt.Print(\"Enter verification code: \")\n\n\t\tvar code string\n\t\tif _, err := fmt.Scan(&code); err != nil {\n\t\t\tfmt.Printf(\"Failed reading code: %s\", err.Error())\n\t\t}\n\t\treturn code\n\t}\n}\n\nfunc progressWriter(discard bool) io.Writer {\n\tif discard {\n\t\treturn ioutil.Discard\n\t}\n\treturn os.Stderr\n}\n\nfunc durationInSeconds(seconds int64) time.Duration {\n\treturn time.Second * time.Duration(seconds)\n}\n\nfunc conflictResolution(args cli.Arguments) drive.ConflictResolution {\n\tkeepLocal := args.Bool(\"keepLocal\")\n\tkeepRemote := args.Bool(\"keepRemote\")\n\tkeepLargest := args.Bool(\"keepLargest\")\n\n\tif (keepLocal && keepRemote) || (keepLocal && keepLargest) || (keepRemote && keepLargest) {\n\t\tExitF(\"Only one conflict resolution flag can be given\")\n\t}\n\n\tif keepLocal {\n\t\treturn drive.KeepLocal\n\t}\n\n\tif keepRemote {\n\t\treturn drive.KeepRemote\n\t}\n\n\tif keepLargest {\n\t\treturn drive.KeepLargest\n\t}\n\n\treturn drive.NoResolution\n}\n\nfunc checkUploadArgs(args cli.Arguments) {\n\tif args.Bool(\"recursive\") && args.Bool(\"delete\") {\n\t\tExitF(\"--delete is not allowed for recursive uploads\")\n\t}\n\n\tif args.Bool(\"recursive\") && args.Bool(\"share\") {\n\t\tExitF(\"--share is not allowed for recursive uploads\")\n\t}\n}\n\nfunc checkDownloadArgs(args cli.Arguments) {\n\tif args.Bool(\"recursive\") && args.Bool(\"delete\") {\n\t\tExitF(\"--delete is not allowed for recursive downloads\")\n\t}\n}\n"
  },
  {
    "path": "handlers_meta.go",
    "content": "package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/prasmussen/gdrive/cli\"\n\t\"os\"\n\t\"runtime\"\n\t\"strings\"\n\t\"text/tabwriter\"\n)\n\nfunc printVersion(ctx cli.Context) {\n\tfmt.Printf(\"%s: %s\\n\", Name, Version)\n\tfmt.Printf(\"Golang: %s\\n\", runtime.Version())\n\tfmt.Printf(\"OS/Arch: %s/%s\\n\", runtime.GOOS, runtime.GOARCH)\n}\n\nfunc printHelp(ctx cli.Context) {\n\tw := new(tabwriter.Writer)\n\tw.Init(os.Stdout, 0, 0, 3, ' ', 0)\n\n\tfmt.Fprintf(w, \"%s usage:\\n\\n\", Name)\n\n\tfor _, h := range ctx.Handlers() {\n\t\tfmt.Fprintf(w, \"%s %s\\t%s\\n\", Name, h.Pattern, h.Description)\n\t}\n\n\tw.Flush()\n}\n\nfunc printCommandHelp(ctx cli.Context) {\n\targs := ctx.Args()\n\tprintCommandPrefixHelp(ctx, args.String(\"command\"))\n}\n\nfunc printSubCommandHelp(ctx cli.Context) {\n\targs := ctx.Args()\n\tprintCommandPrefixHelp(ctx, args.String(\"command\"), args.String(\"subcommand\"))\n}\n\nfunc printCommandPrefixHelp(ctx cli.Context, prefix ...string) {\n\thandler := getHandler(ctx.Handlers(), prefix)\n\n\tif handler == nil {\n\t\tExitF(\"Command not found\")\n\t}\n\n\tw := new(tabwriter.Writer)\n\tw.Init(os.Stdout, 0, 0, 3, ' ', 0)\n\n\tfmt.Fprintf(w, \"%s\\n\", handler.Description)\n\tfmt.Fprintf(w, \"%s %s\\n\", Name, handler.Pattern)\n\tfor _, group := range handler.FlagGroups {\n\t\tfmt.Fprintf(w, \"\\n%s:\\n\", group.Name)\n\t\tfor _, flag := range group.Flags {\n\t\t\tboolFlag, isBool := flag.(cli.BoolFlag)\n\t\t\tif isBool && boolFlag.OmitValue {\n\t\t\t\tfmt.Fprintf(w, \"  %s\\t%s\\n\", strings.Join(flag.GetPatterns(), \", \"), flag.GetDescription())\n\t\t\t} else {\n\t\t\t\tfmt.Fprintf(w, \"  %s <%s>\\t%s\\n\", strings.Join(flag.GetPatterns(), \", \"), flag.GetName(), flag.GetDescription())\n\t\t\t}\n\t\t}\n\t}\n\n\tw.Flush()\n}\n\nfunc getHandler(handlers []*cli.Handler, prefix []string) *cli.Handler {\n\tfor _, h := range handlers {\n\t\tpattern := stripOptionals(h.SplitPattern())\n\n\t\tif len(prefix) > len(pattern) {\n\t\t\tcontinue\n\t\t}\n\n\t\tif equal(prefix, pattern[:len(prefix)]) {\n\t\t\treturn h\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// Strip optional groups (<...>) from pattern\nfunc stripOptionals(pattern []string) []string {\n\tnewArgs := []string{}\n\n\tfor _, arg := range pattern {\n\t\tif strings.HasPrefix(arg, \"[\") && strings.HasSuffix(arg, \"]\") {\n\t\t\tcontinue\n\t\t}\n\t\tnewArgs = append(newArgs, arg)\n\t}\n\treturn newArgs\n}\n"
  },
  {
    "path": "util.go",
    "content": "package main\n\nimport (\n\t\"crypto/md5\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"runtime\"\n)\n\nfunc GetDefaultConfigDir() string {\n\treturn filepath.Join(Homedir(), \".gdrive\")\n}\n\nfunc ConfigFilePath(basePath, name string) string {\n\treturn filepath.Join(basePath, name)\n}\n\nfunc Homedir() string {\n\tif runtime.GOOS == \"windows\" {\n\t\treturn os.Getenv(\"APPDATA\")\n\t}\n\treturn os.Getenv(\"HOME\")\n}\n\nfunc equal(a, b []string) bool {\n\tif a == nil && b == nil {\n\t\treturn true\n\t}\n\n\tif a == nil || b == nil {\n\t\treturn false\n\t}\n\n\tif len(a) != len(b) {\n\t\treturn false\n\t}\n\n\tfor i := range a {\n\t\tif a[i] != b[i] {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}\n\nfunc ExitF(format string, a ...interface{}) {\n\tfmt.Fprintf(os.Stderr, format, a...)\n\tfmt.Println(\"\")\n\tos.Exit(1)\n}\n\nfunc checkErr(err error) {\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tos.Exit(1)\n\t}\n}\n\nfunc writeJson(path string, data interface{}) error {\n\ttmpFile := path + \".tmp\"\n\tf, err := os.Create(tmpFile)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = json.NewEncoder(f).Encode(data)\n\tf.Close()\n\tif err != nil {\n\t\tos.Remove(tmpFile)\n\t\treturn err\n\t}\n\n\treturn os.Rename(tmpFile, path)\n}\n\nfunc md5sum(path string) string {\n\th := md5.New()\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\tdefer f.Close()\n\n\tio.Copy(h, f)\n\treturn fmt.Sprintf(\"%x\", h.Sum(nil))\n}\n"
  },
  {
    "path": "vendor/github.com/sabhiram/go-git-ignore/.gitignore",
    "content": "# Package test fixtures\ntest_fixtures\n\n# 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\n"
  },
  {
    "path": "vendor/github.com/sabhiram/go-git-ignore/.travis.yml",
    "content": "language: go\n\ngo:\n  - 1.3\n  - tip\n\nenv:\n  - \"PATH=$HOME/gopath/bin:$PATH\"\n\nbefore_install:\n  - go get github.com/stretchr/testify/assert\n  - go get github.com/axw/gocov/gocov\n  - go get github.com/mattn/goveralls\n  - if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi\n\nscript:\n  - go test -v -covermode=count -coverprofile=coverage.out\n  - goveralls -coverprofile=coverage.out -service travis-ci -repotoken $COVERALLS_TOKEN\n"
  },
  {
    "path": "vendor/github.com/sabhiram/go-git-ignore/LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2015 Shaba Abhiram\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\n"
  },
  {
    "path": "vendor/github.com/sabhiram/go-git-ignore/README.md",
    "content": "# go-git-ignore\n\n[![Build Status](https://travis-ci.org/sabhiram/go-git-ignore.svg)](https://travis-ci.org/sabhiram/go-git-ignore) [![Coverage Status](https://coveralls.io/repos/sabhiram/go-git-ignore/badge.png?branch=master)](https://coveralls.io/r/sabhiram/go-git-ignore?branch=master)\n\nA gitignore parser for `Go`\n\n## Install\n\n```shell\ngo get github.com/sabhiram/go-git-ignore\n```\n\n## Usage\n\n```shell\nTODO\n```\n"
  },
  {
    "path": "vendor/github.com/sabhiram/go-git-ignore/ignore.go",
    "content": "/*\nignore is a library which returns a new ignorer object which can\ntest against various paths. This is particularly useful when trying\nto filter files based on a .gitignore document\n\nThe rules for parsing the input file are the same as the ones listed\nin the Git docs here: http://git-scm.com/docs/gitignore\n\nThe summarized version of the same has been copied here:\n\n    1. A blank line matches no files, so it can serve as a separator\n       for readability.\n    2. A line starting with # serves as a comment. Put a backslash (\"\\\")\n       in front of the first hash for patterns that begin with a hash.\n    3. Trailing spaces are ignored unless they are quoted with backslash (\"\\\").\n    4. An optional prefix \"!\" which negates the pattern; any matching file\n       excluded by a previous pattern will become included again. It is not\n       possible to re-include a file if a parent directory of that file is\n       excluded. Git doesn’t list excluded directories for performance reasons,\n       so any patterns on contained files have no effect, no matter where they\n       are defined. Put a backslash (\"\\\") in front of the first \"!\" for\n       patterns that begin with a literal \"!\", for example, \"\\!important!.txt\".\n    5. If the pattern ends with a slash, it is removed for the purpose of the\n       following description, but it would only find a match with a directory.\n       In other words, foo/ will match a directory foo and paths underneath it,\n       but will not match a regular file or a symbolic link foo (this is\n       consistent with the way how pathspec works in general in Git).\n    6. If the pattern does not contain a slash /, Git treats it as a shell glob\n       pattern and checks for a match against the pathname relative to the\n       location of the .gitignore file (relative to the toplevel of the work\n       tree if not from a .gitignore file).\n    7. Otherwise, Git treats the pattern as a shell glob suitable for\n       consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the\n       pattern will not match a / in the pathname. For example,\n       \"Documentation/*.html\" matches \"Documentation/git.html\" but not\n       \"Documentation/ppc/ppc.html\" or \"tools/perf/Documentation/perf.html\".\n    8. A leading slash matches the beginning of the pathname. For example,\n       \"/*.c\" matches \"cat-file.c\" but not \"mozilla-sha1/sha1.c\".\n    9. Two consecutive asterisks (\"**\") in patterns matched against full\n       pathname may have special meaning:\n        i.   A leading \"**\" followed by a slash means match in all directories.\n             For example, \"** /foo\" matches file or directory \"foo\" anywhere,\n             the same as pattern \"foo\". \"** /foo/bar\" matches file or directory\n             \"bar\" anywhere that is directly under directory \"foo\".\n        ii.  A trailing \"/**\" matches everything inside. For example, \"abc/**\"\n             matches all files inside directory \"abc\", relative to the location\n             of the .gitignore file, with infinite depth.\n        iii. A slash followed by two consecutive asterisks then a slash matches\n             zero or more directories. For example, \"a/** /b\" matches \"a/b\",\n             \"a/x/b\", \"a/x/y/b\" and so on.\n        iv.  Other consecutive asterisks are considered invalid. */\npackage ignore\n\nimport (\n\t\"io/ioutil\"\n\t\"os\"\n\t\"regexp\"\n\t\"strings\"\n)\n\n// An IgnoreParser is an interface which exposes two methods:\n//   MatchesPath() - Returns true if the path is targeted by the patterns compiled in the GitIgnore structure\ntype IgnoreParser interface {\n\tIncludesPath(f string) bool\n\tIgnoresPath(f string) bool\n\tMatchesPath(f string) bool\n}\n\n// GitIgnore is a struct which contains a slice of regexp.Regexp\n// patterns\ntype GitIgnore struct {\n\tpatterns []*regexp.Regexp // List of regexp patterns which this ignore file applies\n\tnegate   []bool           // List of booleans which determine if the pattern is negated\n}\n\n// This function pretty much attempts to mimic the parsing rules\n// listed above at the start of this file\nfunc getPatternFromLine(line string) (*regexp.Regexp, bool) {\n\t// Trim OS-specific carriage returns.\n\tline = strings.TrimRight(line, \"\\r\")\n\n\t// Strip comments [Rule 2]\n\tif strings.HasPrefix(line, `#`) {\n\t\treturn nil, false\n\t}\n\n\t// Trim string [Rule 3]\n\t// TODO: Handle [Rule 3], when the \" \" is escaped with a \\\n\tline = strings.Trim(line, \" \")\n\n\t// Exit for no-ops and return nil which will prevent us from\n\t// appending a pattern against this line\n\tif line == \"\" {\n\t\treturn nil, false\n\t}\n\n\t// TODO: Handle [Rule 4] which negates the match for patterns leading with \"!\"\n\tnegatePattern := false\n\tif line[0] == '!' {\n\t\tnegatePattern = true\n\t\tline = line[1:]\n\t}\n\n\t// Handle [Rule 2, 4], when # or ! is escaped with a \\\n\t// Handle [Rule 4] once we tag negatePattern, strip the leading ! char\n\tif regexp.MustCompile(`^(\\#|\\!)`).MatchString(line) {\n\t\tline = line[1:]\n\t}\n\n\t// If we encounter a foo/*.blah in a folder, prepend the / char\n\tif regexp.MustCompile(`([^\\/+])/.*\\*\\.`).MatchString(line) && line[0] != '/' {\n\t\tline = \"/\" + line\n\t}\n\n\t// Handle escaping the \".\" char\n\tline = regexp.MustCompile(`\\.`).ReplaceAllString(line, `\\.`)\n\n\tmagicStar := \"#$~\"\n\n\t// Handle \"/**/\" usage\n\tif strings.HasPrefix(line, \"/**/\") {\n\t\tline = line[1:]\n\t}\n\tline = regexp.MustCompile(`/\\*\\*/`).ReplaceAllString(line, `(/|/.+/)`)\n\tline = regexp.MustCompile(`\\*\\*/`).ReplaceAllString(line, `(|.`+magicStar+`/)`)\n\tline = regexp.MustCompile(`/\\*\\*`).ReplaceAllString(line, `(|/.`+magicStar+`)`)\n\n\t// Handle escaping the \"*\" char\n\tline = regexp.MustCompile(`\\\\\\*`).ReplaceAllString(line, `\\`+magicStar)\n\tline = regexp.MustCompile(`\\*`).ReplaceAllString(line, `([^/]*)`)\n\n\t// Handle escaping the \"?\" char\n\tline = strings.Replace(line, \"?\", `\\?`, -1)\n\n\tline = strings.Replace(line, magicStar, \"*\", -1)\n\n\t// Temporary regex\n\tvar expr = \"\"\n\tif strings.HasSuffix(line, \"/\") {\n\t\texpr = line + \"(|.*)$\"\n\t} else {\n\t\texpr = line + \"(|/.*)$\"\n\t}\n\tif strings.HasPrefix(expr, \"/\") {\n\t\texpr = \"^(|/)\" + expr[1:]\n\t} else {\n\t\texpr = \"^(|.*/)\" + expr\n\t}\n\tpattern, _ := regexp.Compile(expr)\n\n\treturn pattern, negatePattern\n}\n\n// Accepts a variadic set of strings, and returns a GitIgnore object which\n// converts and appends the lines in the input to regexp.Regexp patterns\n// held within the GitIgnore objects \"patterns\" field\nfunc CompileIgnoreLines(lines ...string) (*GitIgnore, error) {\n\tg := new(GitIgnore)\n\tfor _, line := range lines {\n\t\tpattern, negatePattern := getPatternFromLine(line)\n\t\tif pattern != nil {\n\t\t\tg.patterns = append(g.patterns, pattern)\n\t\t\tg.negate = append(g.negate, negatePattern)\n\t\t}\n\t}\n\treturn g, nil\n}\n\n// Accepts a ignore file as the input, parses the lines out of the file\n// and invokes the CompileIgnoreLines method\nfunc CompileIgnoreFile(fpath string) (*GitIgnore, error) {\n\tbuffer, error := ioutil.ReadFile(fpath)\n\tif error == nil {\n\t\ts := strings.Split(string(buffer), \"\\n\")\n\t\treturn CompileIgnoreLines(s...)\n\t}\n\treturn nil, error\n}\n\n// MatchesPath is an interface function for the IgnoreParser interface.\n// It returns true if the given GitIgnore structure would target a given\n// path string \"f\"\nfunc (g GitIgnore) MatchesPath(f string) bool {\n\t// Replace OS-specific path separator.\n\tf = strings.Replace(f, string(os.PathSeparator), \"/\", -1)\n\n\tmatchesPath := false\n\tfor idx, pattern := range g.patterns {\n\t\tif pattern.MatchString(f) {\n\t\t\t// If this is a regular target (not negated with a gitignore exclude \"!\" etc)\n\t\t\tif !g.negate[idx] {\n\t\t\t\tmatchesPath = true\n\t\t\t\t// Negated pattern, and matchesPath is already set\n\t\t\t} else if matchesPath {\n\t\t\t\tmatchesPath = false\n\t\t\t}\n\t\t}\n\t}\n\treturn matchesPath\n}\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/.gitignore",
    "content": "*.dot\n\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/.travis.yml",
    "content": "sudo: false\nlanguage: go\n# update travis.sh when changing version number here\ngo:\n - 1.2.1\n - 1.6\ninstall: go get -t ./...\nscript: ./travis.sh\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/adj.go",
    "content": "// Copyright 2014 Sonia Keys\n// License MIT: https://opensource.org/licenses/MIT\n\npackage graph\n\n// adj.go contains methods on AdjacencyList and LabeledAdjacencyList.\n//\n// AdjacencyList methods are placed first and are alphabetized.\n// LabeledAdjacencyList methods follow, also alphabetized.\n// Only exported methods need be alphabetized; non-exported methods can\n// be left near their use.\n\nimport (\n\t\"math\"\n\t\"sort\"\n)\n\n// HasParallelSort identifies if a graph contains parallel arcs, multiple arcs\n// that lead from a node to the same node.\n//\n// If the graph has parallel arcs, the results fr and to represent an example\n// where there are parallel arcs from node fr to node to.\n//\n// If there are no parallel arcs, the method returns false -1 -1.\n//\n// Multiple loops on a node count as parallel arcs.\n//\n// \"Sort\" in the method name indicates that sorting is used to detect parallel\n// arcs.  Compared to method HasParallelMap, this may give better performance\n// for small or sparse graphs but will have asymtotically worse performance for\n// large dense graphs.\nfunc (g AdjacencyList) HasParallelSort() (has bool, fr, to NI) {\n\tvar t NodeList\n\tfor n, to := range g {\n\t\tif len(to) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\t// different code in the labeled version, so no code gen.\n\t\tt = append(t[:0], to...)\n\t\tsort.Sort(t)\n\t\tt0 := t[0]\n\t\tfor _, to := range t[1:] {\n\t\t\tif to == t0 {\n\t\t\t\treturn true, NI(n), t0\n\t\t\t}\n\t\t\tt0 = to\n\t\t}\n\t}\n\treturn false, -1, -1\n}\n\n// IsUndirected returns true if g represents an undirected graph.\n//\n// Returns true when all non-loop arcs are paired in reciprocal pairs.\n// Otherwise returns false and an example unpaired arc.\nfunc (g AdjacencyList) IsUndirected() (u bool, from, to NI) {\n\t// similar code in dot/writeUndirected\n\tunpaired := make(AdjacencyList, len(g))\n\tfor fr, to := range g {\n\tarc: // for each arc in g\n\t\tfor _, to := range to {\n\t\t\tif to == NI(fr) {\n\t\t\t\tcontinue // loop\n\t\t\t}\n\t\t\t// search unpaired arcs\n\t\t\tut := unpaired[to]\n\t\t\tfor i, u := range ut {\n\t\t\t\tif u == NI(fr) { // found reciprocal\n\t\t\t\t\tlast := len(ut) - 1\n\t\t\t\t\tut[i] = ut[last]\n\t\t\t\t\tunpaired[to] = ut[:last]\n\t\t\t\t\tcontinue arc\n\t\t\t\t}\n\t\t\t}\n\t\t\t// reciprocal not found\n\t\t\tunpaired[fr] = append(unpaired[fr], to)\n\t\t}\n\t}\n\tfor fr, to := range unpaired {\n\t\tif len(to) > 0 {\n\t\t\treturn false, NI(fr), to[0]\n\t\t}\n\t}\n\treturn true, -1, -1\n}\n\n// Edgelist constructs the edge list rerpresentation of a graph.\n//\n// An edge is returned for each arc of the graph.  For undirected graphs\n// this includes reciprocal edges.\n//\n// See also WeightedEdgeList method.\nfunc (g LabeledAdjacencyList) EdgeList() (el []LabeledEdge) {\n\tfor fr, to := range g {\n\t\tfor _, to := range to {\n\t\t\tel = append(el, LabeledEdge{Edge{NI(fr), to.To}, to.Label})\n\t\t}\n\t}\n\treturn\n}\n\n// FloydWarshall finds all pairs shortest distances for a simple weighted\n// graph without negative cycles.\n//\n// In result array d, d[i][j] will be the shortest distance from node i\n// to node j.  Any diagonal element < 0 indicates a negative cycle exists.\n//\n// If g is an undirected graph with no negative edge weights, the result\n// array will be a distance matrix, for example as used by package\n// github.com/soniakeys/cluster.\nfunc (g LabeledAdjacencyList) FloydWarshall(w WeightFunc) (d [][]float64) {\n\td = newFWd(len(g))\n\tfor fr, to := range g {\n\t\tfor _, to := range to {\n\t\t\td[fr][to.To] = w(to.Label)\n\t\t}\n\t}\n\tsolveFW(d)\n\treturn\n}\n\n// little helper function, makes a blank matrix for FloydWarshall.\nfunc newFWd(n int) [][]float64 {\n\td := make([][]float64, n)\n\tfor i := range d {\n\t\tdi := make([]float64, n)\n\t\tfor j := range di {\n\t\t\tif j != i {\n\t\t\t\tdi[j] = math.Inf(1)\n\t\t\t}\n\t\t}\n\t\td[i] = di\n\t}\n\treturn d\n}\n\n// Floyd Warshall solver, once the matrix d is initialized by arc weights.\nfunc solveFW(d [][]float64) {\n\tfor k, dk := range d {\n\t\tfor _, di := range d {\n\t\t\tdik := di[k]\n\t\t\tfor j := range d {\n\t\t\t\tif d2 := dik + dk[j]; d2 < di[j] {\n\t\t\t\t\tdi[j] = d2\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n// HasArcLabel returns true if g has any arc from node fr to node to\n// with label l.\n//\n// Also returned is the index within the slice of arcs from node fr.\n// If no arc from fr to to is present, HasArcLabel returns false, -1.\nfunc (g LabeledAdjacencyList) HasArcLabel(fr, to NI, l LI) (bool, int) {\n\tt := Half{to, l}\n\tfor x, h := range g[fr] {\n\t\tif h == t {\n\t\t\treturn true, x\n\t\t}\n\t}\n\treturn false, -1\n}\n\n// HasParallelSort identifies if a graph contains parallel arcs, multiple arcs\n// that lead from a node to the same node.\n//\n// If the graph has parallel arcs, the results fr and to represent an example\n// where there are parallel arcs from node fr to node to.\n//\n// If there are no parallel arcs, the method returns -1 -1.\n//\n// Multiple loops on a node count as parallel arcs.\n//\n// \"Sort\" in the method name indicates that sorting is used to detect parallel\n// arcs.  Compared to method HasParallelMap, this may give better performance\n// for small or sparse graphs but will have asymtotically worse performance for\n// large dense graphs.\nfunc (g LabeledAdjacencyList) HasParallelSort() (has bool, fr, to NI) {\n\tvar t NodeList\n\tfor n, to := range g {\n\t\tif len(to) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\t// slightly different code needed here compared to AdjacencyList\n\t\tt = t[:0]\n\t\tfor _, to := range to {\n\t\t\tt = append(t, to.To)\n\t\t}\n\t\tsort.Sort(t)\n\t\tt0 := t[0]\n\t\tfor _, to := range t[1:] {\n\t\t\tif to == t0 {\n\t\t\t\treturn true, NI(n), t0\n\t\t\t}\n\t\t\tt0 = to\n\t\t}\n\t}\n\treturn false, -1, -1\n}\n\n// IsUndirected returns true if g represents an undirected graph.\n//\n// Returns true when all non-loop arcs are paired in reciprocal pairs with\n// matching labels.  Otherwise returns false and an example unpaired arc.\n//\n// Note the requirement that reciprocal pairs have matching labels is\n// an additional test not present in the otherwise equivalent unlabeled version\n// of IsUndirected.\nfunc (g LabeledAdjacencyList) IsUndirected() (u bool, from NI, to Half) {\n\tunpaired := make(LabeledAdjacencyList, len(g))\n\tfor fr, to := range g {\n\tarc: // for each arc in g\n\t\tfor _, to := range to {\n\t\t\tif to.To == NI(fr) {\n\t\t\t\tcontinue // loop\n\t\t\t}\n\t\t\t// search unpaired arcs\n\t\t\tut := unpaired[to.To]\n\t\t\tfor i, u := range ut {\n\t\t\t\tif u.To == NI(fr) && u.Label == to.Label { // found reciprocal\n\t\t\t\t\tlast := len(ut) - 1\n\t\t\t\t\tut[i] = ut[last]\n\t\t\t\t\tunpaired[to.To] = ut[:last]\n\t\t\t\t\tcontinue arc\n\t\t\t\t}\n\t\t\t}\n\t\t\t// reciprocal not found\n\t\t\tunpaired[fr] = append(unpaired[fr], to)\n\t\t}\n\t}\n\tfor fr, to := range unpaired {\n\t\tif len(to) > 0 {\n\t\t\treturn false, NI(fr), to[0]\n\t\t}\n\t}\n\treturn true, -1, to\n}\n\n// NegativeArc returns true if the receiver graph contains a negative arc.\nfunc (g LabeledAdjacencyList) NegativeArc(w WeightFunc) bool {\n\tfor _, nbs := range g {\n\t\tfor _, nb := range nbs {\n\t\t\tif w(nb.Label) < 0 {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\n// Unlabeled constructs the unlabeled graph corresponding to g.\nfunc (g LabeledAdjacencyList) Unlabeled() AdjacencyList {\n\ta := make(AdjacencyList, len(g))\n\tfor n, nbs := range g {\n\t\tto := make([]NI, len(nbs))\n\t\tfor i, nb := range nbs {\n\t\t\tto[i] = nb.To\n\t\t}\n\t\ta[n] = to\n\t}\n\treturn a\n}\n\n// WeightedEdgeList constructs a WeightedEdgeList object from a\n// LabeledAdjacencyList.\n//\n// Internally it calls g.EdgeList() to obtain the Edges member.\n// See LabeledAdjacencyList.EdgeList().\nfunc (g LabeledAdjacencyList) WeightedEdgeList(w WeightFunc) *WeightedEdgeList {\n\treturn &WeightedEdgeList{\n\t\tOrder:      len(g),\n\t\tWeightFunc: w,\n\t\tEdges:      g.EdgeList(),\n\t}\n}\n\n// WeightedInDegree computes the weighted in-degree of each node in g\n// for a given weight function w.\n//\n// The weighted in-degree of a node is the sum of weights of arcs going to\n// the node.\n//\n// A weighted degree of a node is often termed the \"strength\" of a node.\n//\n// See note for undirected graphs at LabeledAdjacencyList.WeightedOutDegree.\nfunc (g LabeledAdjacencyList) WeightedInDegree(w WeightFunc) []float64 {\n\tind := make([]float64, len(g))\n\tfor _, to := range g {\n\t\tfor _, to := range to {\n\t\t\tind[to.To] += w(to.Label)\n\t\t}\n\t}\n\treturn ind\n}\n\n// WeightedOutDegree computes the weighted out-degree of the specified node\n// for a given weight function w.\n//\n// The weighted out-degree of a node is the sum of weights of arcs going from\n// the node.\n//\n// A weighted degree of a node is often termed the \"strength\" of a node.\n//\n// Note for undirected graphs, the WeightedOutDegree result for a node will\n// equal the WeightedInDegree for the node.  You can use WeightedInDegree if\n// you have need for the weighted degrees of all nodes or use WeightedOutDegree\n// to compute the weighted degrees of individual nodes.  In either case loops\n// are counted just once, unlike the (unweighted) UndirectedDegree methods.\nfunc (g LabeledAdjacencyList) WeightedOutDegree(n NI, w WeightFunc) (d float64) {\n\tfor _, to := range g[n] {\n\t\td += w(to.Label)\n\t}\n\treturn\n}\n\n// More about loops and strength:  I didn't see consensus on this especially\n// in the case of undirected graphs.  Some sources said to add in-degree and\n// out-degree, which would seemingly double both loops and non-loops.\n// Some said to double loops.  Some said sum the edge weights and had no\n// comment on loops.  R of course makes everything an option.  The meaning\n// of \"strength\" where loops exist is unclear.  So while I could write an\n// UndirectedWeighted degree function that doubles loops but not edges,\n// I'm going to just leave this for now.\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/adj_RO.go",
    "content": "// Copyright 2014 Sonia Keys\n// License MIT: http://opensource.org/licenses/MIT\n\npackage graph\n\n// adj_RO.go is code generated from adj_cg.go by directives in graph.go.\n// Editing adj_cg.go is okay.\n// DO NOT EDIT adj_RO.go.  The RO is for Read Only.\n\nimport (\n\t\"math/rand\"\n\t\"time\"\n)\n\n// ArcSize returns the number of arcs in g.\n//\n// Note that for an undirected graph without loops, the number of undirected\n// edges -- the traditional meaning of graph size -- will be ArcSize()/2.\n// On the other hand, if g is an undirected graph that has or may have loops,\n// g.ArcSize()/2 is not a meaningful quantity.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g AdjacencyList) ArcSize() int {\n\tm := 0\n\tfor _, to := range g {\n\t\tm += len(to)\n\t}\n\treturn m\n}\n\n// BoundsOk validates that all arcs in g stay within the slice bounds of g.\n//\n// BoundsOk returns true when no arcs point outside the bounds of g.\n// Otherwise it returns false and an example arc that points outside of g.\n//\n// Most methods of this package assume the BoundsOk condition and may\n// panic when they encounter an arc pointing outside of the graph.  This\n// function can be used to validate a graph when the BoundsOk condition\n// is unknown.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g AdjacencyList) BoundsOk() (ok bool, fr NI, to NI) {\n\tfor fr, to := range g {\n\t\tfor _, to := range to {\n\t\t\tif to < 0 || to >= NI(len(g)) {\n\t\t\t\treturn false, NI(fr), to\n\t\t\t}\n\t\t}\n\t}\n\treturn true, -1, to\n}\n\n// BreadthFirst traverses a directed or undirected graph in breadth first order.\n//\n// Argument start is the start node for the traversal.  If r is nil, nodes are\n// visited in deterministic order.  If a random number generator is supplied,\n// nodes at each level are visited in random order.\n//\n// Argument f can be nil if you have no interest in the FromList path result.\n// If FromList f is non-nil, the method populates f.Paths and sets f.MaxLen.\n// It does not set f.Leaves.  For convenience argument f can be a zero value\n// FromList.  If f.Paths is nil, the FromList is initialized first.  If f.Paths\n// is non-nil however, the FromList is  used as is.  The method uses a value of\n// PathEnd.Len == 0 to indentify unvisited nodes.  Existing non-zero values\n// will limit the traversal.\n//\n// Traversal calls the visitor function v for each node starting with node\n// start.  If v returns true, traversal continues.  If v returns false, the\n// traversal terminates immediately.  PathEnd Len and From values are updated\n// before calling the visitor function.\n//\n// On return f.Paths and f.MaxLen are set but not f.Leaves.\n//\n// Returned is the number of nodes visited and ok = true if the traversal\n// ran to completion or ok = false if it was terminated by the visitor\n// function returning false.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g AdjacencyList) BreadthFirst(start NI, r *rand.Rand, f *FromList, v OkNodeVisitor) (visited int, ok bool) {\n\tswitch {\n\tcase f == nil:\n\t\te := NewFromList(len(g))\n\t\tf = &e\n\tcase f.Paths == nil:\n\t\t*f = NewFromList(len(g))\n\t}\n\trp := f.Paths\n\t// the frontier consists of nodes all at the same level\n\tfrontier := []NI{start}\n\tlevel := 1\n\t// assign path when node is put on frontier,\n\trp[start] = PathEnd{Len: level, From: -1}\n\tfor {\n\t\tf.MaxLen = level\n\t\tlevel++\n\t\tvar next []NI\n\t\tif r == nil {\n\t\t\tfor _, n := range frontier {\n\t\t\t\tvisited++\n\t\t\t\tif !v(n) { // visit nodes as they come off frontier\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tfor _, nb := range g[n] {\n\t\t\t\t\tif rp[nb].Len == 0 {\n\t\t\t\t\t\tnext = append(next, nb)\n\t\t\t\t\t\trp[nb] = PathEnd{From: n, Len: level}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else { // take nodes off frontier at random\n\t\t\tfor _, i := range r.Perm(len(frontier)) {\n\t\t\t\tn := frontier[i]\n\t\t\t\t// remainder of block same as above\n\t\t\t\tvisited++\n\t\t\t\tif !v(n) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tfor _, nb := range g[n] {\n\t\t\t\t\tif rp[nb].Len == 0 {\n\t\t\t\t\t\tnext = append(next, nb)\n\t\t\t\t\t\trp[nb] = PathEnd{From: n, Len: level}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif len(next) == 0 {\n\t\t\tbreak\n\t\t}\n\t\tfrontier = next\n\t}\n\treturn visited, true\n}\n\n// BreadthFirstPath finds a single path from start to end with a minimum\n// number of nodes.\n//\n// Returned is the path as list of nodes.\n// The result is nil if no path was found.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g AdjacencyList) BreadthFirstPath(start, end NI) []NI {\n\tvar f FromList\n\tg.BreadthFirst(start, nil, &f, func(n NI) bool { return n != end })\n\treturn f.PathTo(end, nil)\n}\n\n// Copy makes a deep copy of g.\n// Copy also computes the arc size ma, the number of arcs.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g AdjacencyList) Copy() (c AdjacencyList, ma int) {\n\tc = make(AdjacencyList, len(g))\n\tfor n, to := range g {\n\t\tc[n] = append([]NI{}, to...)\n\t\tma += len(to)\n\t}\n\treturn\n}\n\n// DepthFirst traverses a graph depth first.\n//\n// As it traverses it calls visitor function v for each node.  If v returns\n// false at any point, the traversal is terminated immediately and DepthFirst\n// returns false.  Otherwise DepthFirst returns true.\n//\n// DepthFirst uses argument bm is used as a bitmap to guide the traversal.\n// For a complete traversal, bm should be 0 initially.  During the\n// traversal, bits are set corresponding to each node visited.\n// The bit is set before calling the visitor function.\n//\n// Argument bm can be nil if you have no need for it.\n// In this case a bitmap is created internally for one-time use.\n//\n// Alternatively v can be nil.  In this case traversal still proceeds and\n// updates the bitmap, which can be a useful result.\n// DepthFirst always returns true in this case.\n//\n// It makes no sense for both bm and v to be nil.  In this case DepthFirst\n// returns false immediately.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g AdjacencyList) DepthFirst(start NI, bm *Bits, v OkNodeVisitor) (ok bool) {\n\tif bm == nil {\n\t\tif v == nil {\n\t\t\treturn false\n\t\t}\n\t\tbm = &Bits{}\n\t}\n\tvar df func(n NI) bool\n\tdf = func(n NI) bool {\n\t\tif bm.Bit(n) == 1 {\n\t\t\treturn true\n\t\t}\n\t\tbm.SetBit(n, 1)\n\t\tif v != nil && !v(n) {\n\t\t\treturn false\n\t\t}\n\t\tfor _, nb := range g[n] {\n\t\t\tif !df(nb) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\treturn df(start)\n}\n\n// DepthFirstRandom traverses a graph depth first, but following arcs in\n// random order among arcs from a single node.\n//\n// If Rand r is nil, the method creates a new source and generator for\n// one-time use.\n//\n// Usage is otherwise like the DepthFirst method.  See DepthFirst.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g AdjacencyList) DepthFirstRandom(start NI, bm *Bits, v OkNodeVisitor, r *rand.Rand) (ok bool) {\n\tif bm == nil {\n\t\tif v == nil {\n\t\t\treturn false\n\t\t}\n\t\tbm = &Bits{}\n\t}\n\tif r == nil {\n\t\tr = rand.New(rand.NewSource(time.Now().UnixNano()))\n\t}\n\tvar df func(n NI) bool\n\tdf = func(n NI) bool {\n\t\tif bm.Bit(n) == 1 {\n\t\t\treturn true\n\t\t}\n\t\tbm.SetBit(n, 1)\n\t\tif v != nil && !v(n) {\n\t\t\treturn false\n\t\t}\n\t\tto := g[n]\n\t\tfor _, i := range r.Perm(len(to)) {\n\t\t\tif !df(to[i]) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\treturn df(start)\n}\n\n// HasArc returns true if g has any arc from node fr to node to.\n//\n// Also returned is the index within the slice of arcs from node fr.\n// If no arc from fr to to is present, HasArc returns false, -1.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g AdjacencyList) HasArc(fr, to NI) (bool, int) {\n\tfor x, h := range g[fr] {\n\t\tif h == to {\n\t\t\treturn true, x\n\t\t}\n\t}\n\treturn false, -1\n}\n\n// HasLoop identifies if a graph contains a loop, an arc that leads from a\n// a node back to the same node.\n//\n// If the graph has a loop, the result is an example node that has a loop.\n//\n// If g contains a loop, the method returns true and an example of a node\n// with a loop.  If there are no loops in g, the method returns false, -1.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g AdjacencyList) HasLoop() (bool, NI) {\n\tfor fr, to := range g {\n\t\tfor _, to := range to {\n\t\t\tif NI(fr) == to {\n\t\t\t\treturn true, to\n\t\t\t}\n\t\t}\n\t}\n\treturn false, -1\n}\n\n// HasParallelMap identifies if a graph contains parallel arcs, multiple arcs\n// that lead from a node to the same node.\n//\n// If the graph has parallel arcs, the method returns true and\n// results fr and to represent an example where there are parallel arcs\n// from node fr to node to.\n//\n// If there are no parallel arcs, the method returns false, -1 -1.\n//\n// Multiple loops on a node count as parallel arcs.\n//\n// \"Map\" in the method name indicates that a Go map is used to detect parallel\n// arcs.  Compared to method HasParallelSort, this gives better asymtotic\n// performance for large dense graphs but may have increased overhead for\n// small or sparse graphs.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g AdjacencyList) HasParallelMap() (has bool, fr, to NI) {\n\tfor n, to := range g {\n\t\tif len(to) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tm := map[NI]struct{}{}\n\t\tfor _, to := range to {\n\t\t\tif _, ok := m[to]; ok {\n\t\t\t\treturn true, NI(n), to\n\t\t\t}\n\t\t\tm[to] = struct{}{}\n\t\t}\n\t}\n\treturn false, -1, -1\n}\n\n// IsSimple checks for loops and parallel arcs.\n//\n// A graph is \"simple\" if it has no loops or parallel arcs.\n//\n// IsSimple returns true, -1 for simple graphs.  If a loop or parallel arc is\n// found, simple returns false and a node that represents a counterexample\n// to the graph being simple.\n//\n// See also separate methods HasLoop and HasParallel.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g AdjacencyList) IsSimple() (ok bool, n NI) {\n\tif lp, n := g.HasLoop(); lp {\n\t\treturn false, n\n\t}\n\tif pa, n, _ := g.HasParallelSort(); pa {\n\t\treturn false, n\n\t}\n\treturn true, -1\n}\n\n// IsolatedNodes returns a bitmap of isolated nodes in receiver graph g.\n//\n// An isolated node is one with no arcs going to or from it.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g AdjacencyList) IsolatedNodes() (i Bits) {\n\ti.SetAll(len(g))\n\tfor fr, to := range g {\n\t\tif len(to) > 0 {\n\t\t\ti.SetBit(NI(fr), 0)\n\t\t\tfor _, to := range to {\n\t\t\t\ti.SetBit(to, 0)\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}\n\n/*\nMaxmimalClique finds a maximal clique containing the node n.\n\nNot sure this is good for anything.  It produces a single maximal clique\nbut there can be multiple maximal cliques containing a given node.\nThis algorithm just returns one of them, not even necessarily the\nlargest one.\n\nfunc (g LabeledAdjacencyList) MaximalClique(n int) []int {\n\tc := []int{n}\n\tvar m bitset.BitSet\n\tm.Set(uint(n))\n\tfor fr, to := range g {\n\t\tif fr == n {\n\t\t\tcontinue\n\t\t}\n\t\tif len(to) < len(c) {\n\t\t\tcontinue\n\t\t}\n\t\tf := 0\n\t\tfor _, to := range to {\n\t\t\tif m.Test(uint(to.To)) {\n\t\t\t\tf++\n\t\t\t\tif f == len(c) {\n\t\t\t\t\tc = append(c, to.To)\n\t\t\t\t\tm.Set(uint(to.To))\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn c\n}\n*/\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/adj_cg.go",
    "content": "// Copyright 2014 Sonia Keys\n// License MIT: http://opensource.org/licenses/MIT\n\npackage graph\n\n// adj_RO.go is code generated from adj_cg.go by directives in graph.go.\n// Editing adj_cg.go is okay.\n// DO NOT EDIT adj_RO.go.  The RO is for Read Only.\n\nimport (\n\t\"math/rand\"\n\t\"time\"\n)\n\n// ArcSize returns the number of arcs in g.\n//\n// Note that for an undirected graph without loops, the number of undirected\n// edges -- the traditional meaning of graph size -- will be ArcSize()/2.\n// On the other hand, if g is an undirected graph that has or may have loops,\n// g.ArcSize()/2 is not a meaningful quantity.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledAdjacencyList) ArcSize() int {\n\tm := 0\n\tfor _, to := range g {\n\t\tm += len(to)\n\t}\n\treturn m\n}\n\n// BoundsOk validates that all arcs in g stay within the slice bounds of g.\n//\n// BoundsOk returns true when no arcs point outside the bounds of g.\n// Otherwise it returns false and an example arc that points outside of g.\n//\n// Most methods of this package assume the BoundsOk condition and may\n// panic when they encounter an arc pointing outside of the graph.  This\n// function can be used to validate a graph when the BoundsOk condition\n// is unknown.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledAdjacencyList) BoundsOk() (ok bool, fr NI, to Half) {\n\tfor fr, to := range g {\n\t\tfor _, to := range to {\n\t\t\tif to.To < 0 || to.To >= NI(len(g)) {\n\t\t\t\treturn false, NI(fr), to\n\t\t\t}\n\t\t}\n\t}\n\treturn true, -1, to\n}\n\n// BreadthFirst traverses a directed or undirected graph in breadth first order.\n//\n// Argument start is the start node for the traversal.  If r is nil, nodes are\n// visited in deterministic order.  If a random number generator is supplied,\n// nodes at each level are visited in random order.\n//\n// Argument f can be nil if you have no interest in the FromList path result.\n// If FromList f is non-nil, the method populates f.Paths and sets f.MaxLen.\n// It does not set f.Leaves.  For convenience argument f can be a zero value\n// FromList.  If f.Paths is nil, the FromList is initialized first.  If f.Paths\n// is non-nil however, the FromList is  used as is.  The method uses a value of\n// PathEnd.Len == 0 to indentify unvisited nodes.  Existing non-zero values\n// will limit the traversal.\n//\n// Traversal calls the visitor function v for each node starting with node\n// start.  If v returns true, traversal continues.  If v returns false, the\n// traversal terminates immediately.  PathEnd Len and From values are updated\n// before calling the visitor function.\n//\n// On return f.Paths and f.MaxLen are set but not f.Leaves.\n//\n// Returned is the number of nodes visited and ok = true if the traversal\n// ran to completion or ok = false if it was terminated by the visitor\n// function returning false.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledAdjacencyList) BreadthFirst(start NI, r *rand.Rand, f *FromList, v OkNodeVisitor) (visited int, ok bool) {\n\tswitch {\n\tcase f == nil:\n\t\te := NewFromList(len(g))\n\t\tf = &e\n\tcase f.Paths == nil:\n\t\t*f = NewFromList(len(g))\n\t}\n\trp := f.Paths\n\t// the frontier consists of nodes all at the same level\n\tfrontier := []NI{start}\n\tlevel := 1\n\t// assign path when node is put on frontier,\n\trp[start] = PathEnd{Len: level, From: -1}\n\tfor {\n\t\tf.MaxLen = level\n\t\tlevel++\n\t\tvar next []NI\n\t\tif r == nil {\n\t\t\tfor _, n := range frontier {\n\t\t\t\tvisited++\n\t\t\t\tif !v(n) { // visit nodes as they come off frontier\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tfor _, nb := range g[n] {\n\t\t\t\t\tif rp[nb.To].Len == 0 {\n\t\t\t\t\t\tnext = append(next, nb.To)\n\t\t\t\t\t\trp[nb.To] = PathEnd{From: n, Len: level}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else { // take nodes off frontier at random\n\t\t\tfor _, i := range r.Perm(len(frontier)) {\n\t\t\t\tn := frontier[i]\n\t\t\t\t// remainder of block same as above\n\t\t\t\tvisited++\n\t\t\t\tif !v(n) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tfor _, nb := range g[n] {\n\t\t\t\t\tif rp[nb.To].Len == 0 {\n\t\t\t\t\t\tnext = append(next, nb.To)\n\t\t\t\t\t\trp[nb.To] = PathEnd{From: n, Len: level}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif len(next) == 0 {\n\t\t\tbreak\n\t\t}\n\t\tfrontier = next\n\t}\n\treturn visited, true\n}\n\n// BreadthFirstPath finds a single path from start to end with a minimum\n// number of nodes.\n//\n// Returned is the path as list of nodes.\n// The result is nil if no path was found.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledAdjacencyList) BreadthFirstPath(start, end NI) []NI {\n\tvar f FromList\n\tg.BreadthFirst(start, nil, &f, func(n NI) bool { return n != end })\n\treturn f.PathTo(end, nil)\n}\n\n// Copy makes a deep copy of g.\n// Copy also computes the arc size ma, the number of arcs.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledAdjacencyList) Copy() (c LabeledAdjacencyList, ma int) {\n\tc = make(LabeledAdjacencyList, len(g))\n\tfor n, to := range g {\n\t\tc[n] = append([]Half{}, to...)\n\t\tma += len(to)\n\t}\n\treturn\n}\n\n// DepthFirst traverses a graph depth first.\n//\n// As it traverses it calls visitor function v for each node.  If v returns\n// false at any point, the traversal is terminated immediately and DepthFirst\n// returns false.  Otherwise DepthFirst returns true.\n//\n// DepthFirst uses argument bm is used as a bitmap to guide the traversal.\n// For a complete traversal, bm should be 0 initially.  During the\n// traversal, bits are set corresponding to each node visited.\n// The bit is set before calling the visitor function.\n//\n// Argument bm can be nil if you have no need for it.\n// In this case a bitmap is created internally for one-time use.\n//\n// Alternatively v can be nil.  In this case traversal still proceeds and\n// updates the bitmap, which can be a useful result.\n// DepthFirst always returns true in this case.\n//\n// It makes no sense for both bm and v to be nil.  In this case DepthFirst\n// returns false immediately.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledAdjacencyList) DepthFirst(start NI, bm *Bits, v OkNodeVisitor) (ok bool) {\n\tif bm == nil {\n\t\tif v == nil {\n\t\t\treturn false\n\t\t}\n\t\tbm = &Bits{}\n\t}\n\tvar df func(n NI) bool\n\tdf = func(n NI) bool {\n\t\tif bm.Bit(n) == 1 {\n\t\t\treturn true\n\t\t}\n\t\tbm.SetBit(n, 1)\n\t\tif v != nil && !v(n) {\n\t\t\treturn false\n\t\t}\n\t\tfor _, nb := range g[n] {\n\t\t\tif !df(nb.To) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\treturn df(start)\n}\n\n// DepthFirstRandom traverses a graph depth first, but following arcs in\n// random order among arcs from a single node.\n//\n// If Rand r is nil, the method creates a new source and generator for\n// one-time use.\n//\n// Usage is otherwise like the DepthFirst method.  See DepthFirst.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledAdjacencyList) DepthFirstRandom(start NI, bm *Bits, v OkNodeVisitor, r *rand.Rand) (ok bool) {\n\tif bm == nil {\n\t\tif v == nil {\n\t\t\treturn false\n\t\t}\n\t\tbm = &Bits{}\n\t}\n\tif r == nil {\n\t\tr = rand.New(rand.NewSource(time.Now().UnixNano()))\n\t}\n\tvar df func(n NI) bool\n\tdf = func(n NI) bool {\n\t\tif bm.Bit(n) == 1 {\n\t\t\treturn true\n\t\t}\n\t\tbm.SetBit(n, 1)\n\t\tif v != nil && !v(n) {\n\t\t\treturn false\n\t\t}\n\t\tto := g[n]\n\t\tfor _, i := range r.Perm(len(to)) {\n\t\t\tif !df(to[i].To) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\treturn df(start)\n}\n\n// HasArc returns true if g has any arc from node fr to node to.\n//\n// Also returned is the index within the slice of arcs from node fr.\n// If no arc from fr to to is present, HasArc returns false, -1.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledAdjacencyList) HasArc(fr, to NI) (bool, int) {\n\tfor x, h := range g[fr] {\n\t\tif h.To == to {\n\t\t\treturn true, x\n\t\t}\n\t}\n\treturn false, -1\n}\n\n// HasLoop identifies if a graph contains a loop, an arc that leads from a\n// a node back to the same node.\n//\n// If the graph has a loop, the result is an example node that has a loop.\n//\n// If g contains a loop, the method returns true and an example of a node\n// with a loop.  If there are no loops in g, the method returns false, -1.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledAdjacencyList) HasLoop() (bool, NI) {\n\tfor fr, to := range g {\n\t\tfor _, to := range to {\n\t\t\tif NI(fr) == to.To {\n\t\t\t\treturn true, to.To\n\t\t\t}\n\t\t}\n\t}\n\treturn false, -1\n}\n\n// HasParallelMap identifies if a graph contains parallel arcs, multiple arcs\n// that lead from a node to the same node.\n//\n// If the graph has parallel arcs, the method returns true and\n// results fr and to represent an example where there are parallel arcs\n// from node fr to node to.\n//\n// If there are no parallel arcs, the method returns false, -1 -1.\n//\n// Multiple loops on a node count as parallel arcs.\n//\n// \"Map\" in the method name indicates that a Go map is used to detect parallel\n// arcs.  Compared to method HasParallelSort, this gives better asymtotic\n// performance for large dense graphs but may have increased overhead for\n// small or sparse graphs.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledAdjacencyList) HasParallelMap() (has bool, fr, to NI) {\n\tfor n, to := range g {\n\t\tif len(to) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tm := map[NI]struct{}{}\n\t\tfor _, to := range to {\n\t\t\tif _, ok := m[to.To]; ok {\n\t\t\t\treturn true, NI(n), to.To\n\t\t\t}\n\t\t\tm[to.To] = struct{}{}\n\t\t}\n\t}\n\treturn false, -1, -1\n}\n\n// IsSimple checks for loops and parallel arcs.\n//\n// A graph is \"simple\" if it has no loops or parallel arcs.\n//\n// IsSimple returns true, -1 for simple graphs.  If a loop or parallel arc is\n// found, simple returns false and a node that represents a counterexample\n// to the graph being simple.\n//\n// See also separate methods HasLoop and HasParallel.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledAdjacencyList) IsSimple() (ok bool, n NI) {\n\tif lp, n := g.HasLoop(); lp {\n\t\treturn false, n\n\t}\n\tif pa, n, _ := g.HasParallelSort(); pa {\n\t\treturn false, n\n\t}\n\treturn true, -1\n}\n\n// IsolatedNodes returns a bitmap of isolated nodes in receiver graph g.\n//\n// An isolated node is one with no arcs going to or from it.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledAdjacencyList) IsolatedNodes() (i Bits) {\n\ti.SetAll(len(g))\n\tfor fr, to := range g {\n\t\tif len(to) > 0 {\n\t\t\ti.SetBit(NI(fr), 0)\n\t\t\tfor _, to := range to {\n\t\t\t\ti.SetBit(to.To, 0)\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}\n\n/*\nMaxmimalClique finds a maximal clique containing the node n.\n\nNot sure this is good for anything.  It produces a single maximal clique\nbut there can be multiple maximal cliques containing a given node.\nThis algorithm just returns one of them, not even necessarily the\nlargest one.\n\nfunc (g LabeledAdjacencyList) MaximalClique(n int) []int {\n\tc := []int{n}\n\tvar m bitset.BitSet\n\tm.Set(uint(n))\n\tfor fr, to := range g {\n\t\tif fr == n {\n\t\t\tcontinue\n\t\t}\n\t\tif len(to) < len(c) {\n\t\t\tcontinue\n\t\t}\n\t\tf := 0\n\t\tfor _, to := range to {\n\t\t\tif m.Test(uint(to.To)) {\n\t\t\t\tf++\n\t\t\t\tif f == len(c) {\n\t\t\t\t\tc = append(c, to.To)\n\t\t\t\t\tm.Set(uint(to.To))\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn c\n}\n*/\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/bits.go",
    "content": "// Copyright 2014 Sonia Keys\n// License MIT: http://opensource.org/licenses/MIT\n\npackage graph\n\nimport (\n\t\"fmt\"\n\t\"math/big\"\n)\n\n// Bits is bitmap, or bitset, intended to store a single bit of information\n// per node of a graph.\n//\n// The current implementation is backed by a big.Int and so is a reference\n// type in the same way a big.Int is.\ntype Bits struct {\n\ti big.Int\n}\n\n// NewBits constructs a Bits value with the bits ns set to 1.\nfunc NewBits(ns ...NI) (b Bits) {\n\tfor _, n := range ns {\n\t\tb.SetBit(n, 1)\n\t}\n\treturn\n}\n\n// AllNot sets n bits of z to the complement of x.\n//\n// It is a convenience method for SetAll followed by AndNot.\nfunc (z *Bits) AllNot(n int, x Bits) {\n\tvar y Bits\n\ty.SetAll(n)\n\tz.AndNot(y, x)\n}\n\n// And sets z = x & y.\nfunc (z *Bits) And(x, y Bits) {\n\tz.i.And(&x.i, &y.i)\n}\n\n// AndNot sets z = x &^ y.\nfunc (z *Bits) AndNot(x, y Bits) {\n\tz.i.AndNot(&x.i, &y.i)\n}\n\n// Bit returns the value of the n'th bit of x.\nfunc (b Bits) Bit(n NI) uint {\n\treturn b.i.Bit(int(n))\n}\n\n// Clear sets all bits to 0.\nfunc (z *Bits) Clear() {\n\t*z = Bits{}\n}\n\n// Format satisfies fmt.Formatter for fmt.Printf and related methods.\n//\n// graph.Bits format exactly like big.Ints.\nfunc (b Bits) Format(s fmt.State, ch rune) {\n\tb.i.Format(s, ch)\n}\n\n// From returns the position of the first 1 bit at or after (from) position n.\n//\n// It returns -1 if there is no one bit at or after position n.\n//\n// This provides one way to iterate over one bits.\n// To iterate over the one bits, call with n = 0 to get the the first\n// one bit, then call with the result + 1 to get successive one bits.\n// Unlike the Iterate method, this technique is stateless and so allows\n// bits to be changed between successive calls.\n//\n// See also Iterate.\n//\n// (From is just a short word that means \"at or after\" here;\n// it has nothing to do with arc direction.)\nfunc (b Bits) From(n NI) NI {\n\twords := b.i.Bits()\n\ti := int(n)\n\tx := i >> wordExp // x now index of word containing bit i.\n\tif x >= len(words) {\n\t\treturn -1\n\t}\n\t// test for 1 in this word at or after n\n\tif wx := words[x] >> (uint(i) & (wordSize - 1)); wx != 0 {\n\t\treturn n + NI(trailingZeros(wx))\n\t}\n\tx++\n\tfor y, wy := range words[x:] {\n\t\tif wy != 0 {\n\t\t\treturn NI((x+y)<<wordExp | trailingZeros(wy))\n\t\t}\n\t}\n\treturn -1\n}\n\n// Iterate calls Visitor v for each bit with a value of 1, in order\n// from lowest bit to highest bit.\n//\n// Iteration continues to the highest bit as long as v returns true.\n// It stops if v returns false.\n//\n// Iterate returns true normally.  It returns false if v returns false.\n//\n// Bit values should not be modified during iteration, by the visitor function\n// for example.  See From for an iteration method that allows modification.\nfunc (b Bits) Iterate(v OkNodeVisitor) bool {\n\tfor x, w := range b.i.Bits() {\n\t\tif w != 0 {\n\t\t\tt := trailingZeros(w)\n\t\t\ti := t // index in w of next 1 bit\n\t\t\tfor {\n\t\t\t\tif !v(NI(x<<wordExp | i)) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tw >>= uint(t + 1)\n\t\t\t\tif w == 0 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tt = trailingZeros(w)\n\t\t\t\ti += 1 + t\n\t\t\t}\n\t\t}\n\t}\n\treturn true\n}\n\n// Or sets z = x | y.\nfunc (z *Bits) Or(x, y Bits) {\n\tz.i.Or(&x.i, &y.i)\n}\n\n// PopCount returns the number of 1 bits.\nfunc (b Bits) PopCount() (c int) {\n\t// algorithm selected to be efficient for sparse bit sets.\n\tfor _, w := range b.i.Bits() {\n\t\tfor w != 0 {\n\t\t\tw &= w - 1\n\t\t\tc++\n\t\t}\n\t}\n\treturn\n}\n\n// Set sets the bits of z to the bits of x.\nfunc (z *Bits) Set(x Bits) {\n\tz.i.Set(&x.i)\n}\n\nvar one = big.NewInt(1)\n\n// SetAll sets z to have n 1 bits.\n//\n// It's useful for initializing z to have a 1 for each node of a graph.\nfunc (z *Bits) SetAll(n int) {\n\tz.i.Sub(z.i.Lsh(one, uint(n)), one)\n}\n\n// SetBit sets the n'th bit to b, where be is a 0 or 1.\nfunc (z *Bits) SetBit(n NI, b uint) {\n\tz.i.SetBit(&z.i, int(n), b)\n}\n\n// Single returns true if b has exactly one 1 bit.\nfunc (b Bits) Single() bool {\n\t// like PopCount, but stop as soon as two are found\n\tc := 0\n\tfor _, w := range b.i.Bits() {\n\t\tfor w != 0 {\n\t\t\tw &= w - 1\n\t\t\tc++\n\t\t\tif c == 2 {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\treturn c == 1\n}\n\n// Slice returns a slice with the positions of each 1 bit.\nfunc (b Bits) Slice() (s []NI) {\n\t// (alternative implementation might use Popcount and make to get the\n\t// exact cap slice up front.  unclear if that would be better.)\n\tb.Iterate(func(n NI) bool {\n\t\ts = append(s, n)\n\t\treturn true\n\t})\n\treturn\n}\n\n// Xor sets z = x ^ y.\nfunc (z *Bits) Xor(x, y Bits) {\n\tz.i.Xor(&x.i, &y.i)\n}\n\n// Zero returns true if there are no 1 bits.\nfunc (b Bits) Zero() bool {\n\treturn len(b.i.Bits()) == 0\n}\n\n// trailingZeros returns the number of trailing 0 bits in v.\n//\n// If v is 0, it returns 0.\nfunc trailingZeros(v big.Word) int {\n\treturn deBruijnBits[v&-v*deBruijnMultiple>>deBruijnShift]\n}\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/bits32.go",
    "content": "// Copyright 2014 Sonia Keys\n// License MIT: http://opensource.org/licenses/MIT\n\n// +build 386 arm\n\npackage graph\n\n// \"word\" here is math/big.Word\nconst (\n\twordSize = 32\n\twordExp  = 5 // 2^5 = 32\n)\n\n// deBruijn magic numbers used in trailingZeros()\n//\n// reference: http://graphics.stanford.edu/~seander/bithacks.html\nconst deBruijnMultiple = 0x077CB531\nconst deBruijnShift = 27\n\nvar deBruijnBits = []int{\n\t0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,\n\t31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9,\n}\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/bits64.go",
    "content": "// Copyright 2014 Sonia Keys\n// License MIT: http://opensource.org/licenses/MIT\n\n// +build !386,!arm\n\npackage graph\n\nconst (\n\twordSize = 64\n\twordExp  = 6 // 2^6 = 64\n)\n\n// reference: http://graphics.stanford.edu/~seander/bithacks.html\nconst deBruijnMultiple = 0x03f79d71b4ca8b09\nconst deBruijnShift = 58\n\nvar deBruijnBits = []int{\n\t0, 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4,\n\t62, 47, 59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5,\n\t63, 55, 48, 27, 60, 41, 37, 16, 46, 35, 44, 21, 52, 32, 23, 11,\n\t54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7, 6,\n}\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/dir.go",
    "content": "// Copyright 2014 Sonia Keys\n// License MIT: http://opensource.org/licenses/MIT\n\npackage graph\n\n// dir.go has methods specific to directed graphs, types Directed and\n// LabeledDirected.\n//\n// Methods on Directed are first, with exported methods alphabetized.\n\nimport \"errors\"\n\n// DAGMaxLenPath finds a maximum length path in a directed acyclic graph.\n//\n// Argument ordering must be a topological ordering of g.\nfunc (g Directed) DAGMaxLenPath(ordering []NI) (path []NI) {\n\t// dynamic programming. visit nodes in reverse order. for each, compute\n\t// longest path as one plus longest of 'to' nodes.\n\t// Visits each arc once.  O(m).\n\t//\n\t// Similar code in label.go\n\tvar n NI\n\tmlp := make([][]NI, len(g.AdjacencyList)) // index by node number\n\tfor i := len(ordering) - 1; i >= 0; i-- {\n\t\tfr := ordering[i] // node number\n\t\tto := g.AdjacencyList[fr]\n\t\tif len(to) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tmt := to[0]\n\t\tfor _, to := range to[1:] {\n\t\t\tif len(mlp[to]) > len(mlp[mt]) {\n\t\t\t\tmt = to\n\t\t\t}\n\t\t}\n\t\tp := append([]NI{mt}, mlp[mt]...)\n\t\tmlp[fr] = p\n\t\tif len(p) > len(path) {\n\t\t\tn = fr\n\t\t\tpath = p\n\t\t}\n\t}\n\treturn append([]NI{n}, path...)\n}\n\n// EulerianCycle finds an Eulerian cycle in a directed multigraph.\n//\n// * If g has no nodes, result is nil, nil.\n//\n// * If g is Eulerian, result is an Eulerian cycle with err = nil.\n// The cycle result is a list of nodes, where the first and last\n// nodes are the same.\n//\n// * Otherwise, result is nil, error\n//\n// Internally, EulerianCycle copies the entire graph g.\n// See EulerianCycleD for a more space efficient version.\nfunc (g Directed) EulerianCycle() ([]NI, error) {\n\tc, m := g.Copy()\n\treturn c.EulerianCycleD(m)\n}\n\n// EulerianCycleD finds an Eulerian cycle in a directed multigraph.\n//\n// EulerianCycleD is destructive on its receiver g.  See EulerianCycle for\n// a non-destructive version.\n//\n// Argument ma must be the correct arc size, or number of arcs in g.\n//\n// * If g has no nodes, result is nil, nil.\n//\n// * If g is Eulerian, result is an Eulerian cycle with err = nil.\n// The cycle result is a list of nodes, where the first and last\n// nodes are the same.\n//\n// * Otherwise, result is nil, error\nfunc (g Directed) EulerianCycleD(ma int) ([]NI, error) {\n\tif len(g.AdjacencyList) == 0 {\n\t\treturn nil, nil\n\t}\n\te := newEulerian(g.AdjacencyList, ma)\n\tfor e.s >= 0 {\n\t\tv := e.top() // v is node that starts cycle\n\t\te.push()\n\t\t// if Eulerian, we'll always come back to starting node\n\t\tif e.top() != v {\n\t\t\treturn nil, errors.New(\"not balanced\")\n\t\t}\n\t\te.keep()\n\t}\n\tif !e.uv.Zero() {\n\t\treturn nil, errors.New(\"not strongly connected\")\n\t}\n\treturn e.p, nil\n}\n\n// EulerianPath finds an Eulerian path in a directed multigraph.\n//\n// * If g has no nodes, result is nil, nil.\n//\n// * If g has an Eulerian path, result is an Eulerian path with err = nil.\n// The path result is a list of nodes, where the first node is start.\n//\n// * Otherwise, result is nil, error\n//\n// Internally, EulerianPath copies the entire graph g.\n// See EulerianPathD for a more space efficient version.\nfunc (g Directed) EulerianPath() ([]NI, error) {\n\tind := g.InDegree()\n\tvar start NI\n\tfor n, to := range g.AdjacencyList {\n\t\tif len(to) > ind[n] {\n\t\t\tstart = NI(n)\n\t\t\tbreak\n\t\t}\n\t}\n\tc, m := g.Copy()\n\treturn c.EulerianPathD(m, start)\n}\n\n// EulerianPathD finds an Eulerian path in a directed multigraph.\n//\n// EulerianPathD is destructive on its receiver g.  See EulerianPath for\n// a non-destructive version.\n//\n// Argument ma must be the correct arc size, or number of arcs in g.\n// Argument start must be a valid start node for the path.\n//\n// * If g has no nodes, result is nil, nil.\n//\n// * If g has an Eulerian path, result is an Eulerian path with err = nil.\n// The path result is a list of nodes, where the first node is start.\n//\n// * Otherwise, result is nil, error\nfunc (g Directed) EulerianPathD(ma int, start NI) ([]NI, error) {\n\tif len(g.AdjacencyList) == 0 {\n\t\treturn nil, nil\n\t}\n\te := newEulerian(g.AdjacencyList, ma)\n\te.p[0] = start\n\t// unlike EulerianCycle, the first path doesn't have be a cycle.\n\te.push()\n\te.keep()\n\tfor e.s >= 0 {\n\t\tstart = e.top()\n\t\te.push()\n\t\t// paths after the first must be cycles though\n\t\t// (as long as there are nodes on the stack)\n\t\tif e.top() != start {\n\t\t\treturn nil, errors.New(\"no Eulerian path\")\n\t\t}\n\t\te.keep()\n\t}\n\tif !e.uv.Zero() {\n\t\treturn nil, errors.New(\"no Eulerian path\")\n\t}\n\treturn e.p, nil\n}\n\n// starting at the node on the top of the stack, follow arcs until stuck.\n// mark nodes visited, push nodes on stack, remove arcs from g.\nfunc (e *eulerian) push() {\n\tfor u := e.top(); ; {\n\t\te.uv.SetBit(u, 0) // reset unvisited bit\n\t\tarcs := e.g[u]\n\t\tif len(arcs) == 0 {\n\t\t\treturn // stuck\n\t\t}\n\t\tw := arcs[0] // follow first arc\n\t\te.s++        // push followed node on stack\n\t\te.p[e.s] = w\n\t\te.g[u] = arcs[1:] // consume arc\n\t\tu = w\n\t}\n}\n\n// like push, but for for undirected graphs.\nfunc (e *eulerian) pushUndir() {\n\tfor u := e.top(); ; {\n\t\te.uv.SetBit(u, 0)\n\t\tarcs := e.g[u]\n\t\tif len(arcs) == 0 {\n\t\t\treturn\n\t\t}\n\t\tw := arcs[0]\n\t\te.s++\n\t\te.p[e.s] = w\n\t\te.g[u] = arcs[1:] // consume arc\n\t\t// here is the only difference, consume reciprocal arc as well:\n\t\ta2 := e.g[w]\n\t\tfor x, rx := range a2 {\n\t\t\tif rx == u { // here it is\n\t\t\t\tlast := len(a2) - 1\n\t\t\t\ta2[x] = a2[last]   // someone else gets the seat\n\t\t\t\te.g[w] = a2[:last] // and it's gone.\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tu = w\n\t}\n}\n\n// starting with the node on top of the stack, move nodes with no arcs.\nfunc (e *eulerian) keep() {\n\tfor e.s >= 0 {\n\t\tn := e.top()\n\t\tif len(e.g[n]) > 0 {\n\t\t\tbreak\n\t\t}\n\t\te.p[e.m] = n\n\t\te.s--\n\t\te.m--\n\t}\n}\n\ntype eulerian struct {\n\tg  AdjacencyList // working copy of graph, it gets consumed\n\tm  int           // number of arcs in g, updated as g is consumed\n\tuv Bits          // unvisited\n\t// low end of p is stack of unfinished nodes\n\t// high end is finished path\n\tp []NI // stack + path\n\ts int  // stack pointer\n}\n\nfunc (e *eulerian) top() NI {\n\treturn e.p[e.s]\n}\n\nfunc newEulerian(g AdjacencyList, m int) *eulerian {\n\te := &eulerian{\n\t\tg: g,\n\t\tm: m,\n\t\tp: make([]NI, m+1),\n\t}\n\te.uv.SetAll(len(g))\n\treturn e\n}\n\n// MaximalNonBranchingPaths finds all paths in a directed graph that are\n// \"maximal\" and \"non-branching\".\n//\n// A non-branching path is one where path nodes other than the first and last\n// have exactly one arc leading to the node and one arc leading from the node,\n// thus there is no possibility to branch away to a different path.\n//\n// A maximal non-branching path cannot be extended to a longer non-branching\n// path by including another node at either end.\n//\n// In the case of a cyclic non-branching path, the first and last elements\n// of the path will be the same node, indicating an isolated cycle.\n//\n// The method calls the emit argument for each path or isolated cycle in g,\n// as long as emit returns true.  If emit returns false,\n// MaximalNonBranchingPaths returns immediately.\nfunc (g Directed) MaximalNonBranchingPaths(emit func([]NI) bool) {\n\tind := g.InDegree()\n\tvar uv Bits\n\tuv.SetAll(len(g.AdjacencyList))\n\tfor v, vTo := range g.AdjacencyList {\n\t\tif !(ind[v] == 1 && len(vTo) == 1) {\n\t\t\tfor _, w := range vTo {\n\t\t\t\tn := []NI{NI(v), w}\n\t\t\t\tuv.SetBit(NI(v), 0)\n\t\t\t\tuv.SetBit(w, 0)\n\t\t\t\twTo := g.AdjacencyList[w]\n\t\t\t\tfor ind[w] == 1 && len(wTo) == 1 {\n\t\t\t\t\tu := wTo[0]\n\t\t\t\t\tn = append(n, u)\n\t\t\t\t\tuv.SetBit(u, 0)\n\t\t\t\t\tw = u\n\t\t\t\t\twTo = g.AdjacencyList[w]\n\t\t\t\t}\n\t\t\t\tif !emit(n) { // n is a path\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t// use uv.From rather than uv.Iterate.\n\t// Iterate doesn't work here because we're modifying uv\n\tfor b := uv.From(0); b >= 0; b = uv.From(b + 1) {\n\t\tv := NI(b)\n\t\tn := []NI{v}\n\t\tfor w := v; ; {\n\t\t\tw = g.AdjacencyList[w][0]\n\t\t\tuv.SetBit(w, 0)\n\t\t\tn = append(n, w)\n\t\t\tif w == v {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !emit(n) { // n is an isolated cycle\n\t\t\treturn\n\t\t}\n\t}\n}\n\n// Undirected returns copy of g augmented as needed to make it undirected.\nfunc (g Directed) Undirected() Undirected {\n\tc, _ := g.AdjacencyList.Copy()                  // start with a copy\n\trw := make(AdjacencyList, len(g.AdjacencyList)) // \"reciprocals wanted\"\n\tfor fr, to := range g.AdjacencyList {\n\tarc: // for each arc in g\n\t\tfor _, to := range to {\n\t\t\tif to == NI(fr) {\n\t\t\t\tcontinue // loop\n\t\t\t}\n\t\t\t// search wanted arcs\n\t\t\twf := rw[fr]\n\t\t\tfor i, w := range wf {\n\t\t\t\tif w == to { // found, remove\n\t\t\t\t\tlast := len(wf) - 1\n\t\t\t\t\twf[i] = wf[last]\n\t\t\t\t\trw[fr] = wf[:last]\n\t\t\t\t\tcontinue arc\n\t\t\t\t}\n\t\t\t}\n\t\t\t// arc not found, add to reciprocal to wanted list\n\t\t\trw[to] = append(rw[to], NI(fr))\n\t\t}\n\t}\n\t// add missing reciprocals\n\tfor fr, to := range rw {\n\t\tc[fr] = append(c[fr], to...)\n\t}\n\treturn Undirected{c}\n}\n\n// StronglyConnectedComponents identifies strongly connected components\n// in a directed graph.\n//\n// Algorithm by David J. Pearce, from \"An Improved Algorithm for Finding the\n// Strongly Connected Components of a Directed Graph\".  It is algorithm 3,\n// PEA_FIND_SCC2 in\n// http://homepages.mcs.vuw.ac.nz/~djp/files/P05.pdf, accessed 22 Feb 2015.\n//\n// Returned is a list of components, each component is a list of nodes.\n/*\nfunc (g Directed) StronglyConnectedComponents() []int {\n\trindex := make([]int, len(g))\n\tS := []int{}\n\tindex := 1\n\tc := len(g) - 1\n\tvisit := func(v int) {\n\t\troot := true\n\t\trindex[v] = index\n\t\tindex++\n\t\tfor _, w := range g[v] {\n\t\t\tif rindex[w] == 0 {\n\t\t\t\tvisit(w)\n\t\t\t}\n\t\t\tif rindex[w] < rindex[v] {\n\t\t\t\trindex[v] = rindex[w]\n\t\t\t\troot = false\n\t\t\t}\n\t\t}\n\t\tif root {\n\t\t\tindex--\n\t\t\tfor top := len(S) - 1; top >= 0 && rindex[v] <= rindex[top]; top-- {\n\t\t\t\tw = rindex[top]\n\t\t\t\tS = S[:top]\n\t\t\t\trindex[w] = c\n\t\t\t\tindex--\n\t\t\t}\n\t\t\trindex[v] = c\n\t\t\tc--\n\t\t} else {\n\t\t\tS = append(S, v)\n\t\t}\n\t}\n\tfor v := range g {\n\t\tif rindex[v] == 0 {\n\t\t\tvisit(v)\n\t\t}\n\t}\n\treturn rindex\n}\n*/\n\n// Transpose constructs a new adjacency list with all arcs reversed.\n//\n// For every arc from->to of g, the result will have an arc to->from.\n// Transpose also counts arcs as it traverses and returns ma the number of arcs\n// in g (equal to the number of arcs in the result.)\nfunc (g Directed) Transpose() (t Directed, ma int) {\n\tta := make(AdjacencyList, len(g.AdjacencyList))\n\tfor n, nbs := range g.AdjacencyList {\n\t\tfor _, nb := range nbs {\n\t\t\tta[nb] = append(ta[nb], NI(n))\n\t\t\tma++\n\t\t}\n\t}\n\treturn Directed{ta}, ma\n}\n\n// DAGMaxLenPath finds a maximum length path in a directed acyclic graph.\n//\n// Length here means number of nodes or arcs, not a sum of arc weights.\n//\n// Argument ordering must be a topological ordering of g.\n//\n// Returned is a node beginning a maximum length path, and a path of arcs\n// starting from that node.\nfunc (g LabeledDirected) DAGMaxLenPath(ordering []NI) (n NI, path []Half) {\n\t// dynamic programming. visit nodes in reverse order. for each, compute\n\t// longest path as one plus longest of 'to' nodes.\n\t// Visits each arc once.  Time complexity O(m).\n\t//\n\t// Similar code in dir.go.\n\tmlp := make([][]Half, len(g.LabeledAdjacencyList)) // index by node number\n\tfor i := len(ordering) - 1; i >= 0; i-- {\n\t\tfr := ordering[i] // node number\n\t\tto := g.LabeledAdjacencyList[fr]\n\t\tif len(to) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tmt := to[0]\n\t\tfor _, to := range to[1:] {\n\t\t\tif len(mlp[to.To]) > len(mlp[mt.To]) {\n\t\t\t\tmt = to\n\t\t\t}\n\t\t}\n\t\tp := append([]Half{mt}, mlp[mt.To]...)\n\t\tmlp[fr] = p\n\t\tif len(p) > len(path) {\n\t\t\tn = fr\n\t\t\tpath = p\n\t\t}\n\t}\n\treturn\n}\n\n// FromListLabels transposes a labeled graph into a FromList and associated\n// list of labels.\n//\n// Receiver g should be connected as a tree or forest.  Specifically no node\n// can have multiple incoming arcs.  If any node n in g has multiple incoming\n// arcs, the method returns (nil, nil, n) where n is a node with multiple\n// incoming arcs.\n//\n// Otherwise (normally) the method populates the From members in a\n// FromList.Path, populates a slice of labels, and returns the FromList,\n// labels, and -1.\n//\n// Other members of the FromList are left as zero values.\n// Use FromList.RecalcLen and FromList.RecalcLeaves as needed.\nfunc (g LabeledDirected) FromListLabels() (*FromList, []LI, NI) {\n\tlabels := make([]LI, len(g.LabeledAdjacencyList))\n\tpaths := make([]PathEnd, len(g.LabeledAdjacencyList))\n\tfor i := range paths {\n\t\tpaths[i].From = -1\n\t}\n\tfor fr, to := range g.LabeledAdjacencyList {\n\t\tfor _, to := range to {\n\t\t\tif paths[to.To].From >= 0 {\n\t\t\t\treturn nil, nil, to.To\n\t\t\t}\n\t\t\tpaths[to.To].From = NI(fr)\n\t\t\tlabels[to.To] = to.Label\n\t\t}\n\t}\n\treturn &FromList{Paths: paths}, labels, -1\n}\n\n// Transpose constructs a new adjacency list that is the transpose of g.\n//\n// For every arc from->to of g, the result will have an arc to->from.\n// Transpose also counts arcs as it traverses and returns ma the number of\n// arcs in g (equal to the number of arcs in the result.)\nfunc (g LabeledDirected) Transpose() (t LabeledDirected, ma int) {\n\tta := make(LabeledAdjacencyList, len(g.LabeledAdjacencyList))\n\tfor n, nbs := range g.LabeledAdjacencyList {\n\t\tfor _, nb := range nbs {\n\t\t\tta[nb.To] = append(ta[nb.To], Half{To: NI(n), Label: nb.Label})\n\t\t\tma++\n\t\t}\n\t}\n\treturn LabeledDirected{ta}, ma\n}\n\n// Undirected returns a new undirected graph derived from g, augmented as\n// needed to make it undirected, with reciprocal arcs having matching labels.\nfunc (g LabeledDirected) Undirected() LabeledUndirected {\n\tc, _ := g.LabeledAdjacencyList.Copy() // start with a copy\n\t// \"reciprocals wanted\"\n\trw := make(LabeledAdjacencyList, len(g.LabeledAdjacencyList))\n\tfor fr, to := range g.LabeledAdjacencyList {\n\tarc: // for each arc in g\n\t\tfor _, to := range to {\n\t\t\tif to.To == NI(fr) {\n\t\t\t\tcontinue // arc is a loop\n\t\t\t}\n\t\t\t// search wanted arcs\n\t\t\twf := rw[fr]\n\t\t\tfor i, w := range wf {\n\t\t\t\tif w == to { // found, remove\n\t\t\t\t\tlast := len(wf) - 1\n\t\t\t\t\twf[i] = wf[last]\n\t\t\t\t\trw[fr] = wf[:last]\n\t\t\t\t\tcontinue arc\n\t\t\t\t}\n\t\t\t}\n\t\t\t// arc not found, add to reciprocal to wanted list\n\t\t\trw[to.To] = append(rw[to.To], Half{To: NI(fr), Label: to.Label})\n\t\t}\n\t}\n\t// add missing reciprocals\n\tfor fr, to := range rw {\n\t\tc[fr] = append(c[fr], to...)\n\t}\n\treturn LabeledUndirected{c}\n}\n\n// Unlabeled constructs the unlabeled directed graph corresponding to g.\nfunc (g LabeledDirected) Unlabeled() Directed {\n\treturn Directed{g.LabeledAdjacencyList.Unlabeled()}\n}\n\n// UnlabeledTranspose constructs a new adjacency list that is the unlabeled\n// transpose of g.\n//\n// For every arc from->to of g, the result will have an arc to->from.\n// Transpose also counts arcs as it traverses and returns ma, the number of\n// arcs in g (equal to the number of arcs in the result.)\n//\n// It is equivalent to g.Unlabeled().Transpose() but constructs the result\n// directly.\nfunc (g LabeledDirected) UnlabeledTranspose() (t Directed, ma int) {\n\tta := make(AdjacencyList, len(g.LabeledAdjacencyList))\n\tfor n, nbs := range g.LabeledAdjacencyList {\n\t\tfor _, nb := range nbs {\n\t\t\tta[nb.To] = append(ta[nb.To], NI(n))\n\t\t\tma++\n\t\t}\n\t}\n\treturn Directed{ta}, ma\n}\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/dir_RO.go",
    "content": "// Copyright 2014 Sonia Keys\n// License MIT: http://opensource.org/licenses/MIT\n\npackage graph\n\n// dir_RO.go is code generated from dir_cg.go by directives in graph.go.\n// Editing dir_cg.go is okay.  It is the code generation source.\n// DO NOT EDIT dir_RO.go.\n// The RO means read only and it is upper case RO to slow you down a bit\n// in case you start to edit the file.\n\n// Balanced returns true if for every node in g, in-degree equals out-degree.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g Directed) Balanced() bool {\n\tfor n, in := range g.InDegree() {\n\t\tif in != len(g.AdjacencyList[n]) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n// Copy makes a deep copy of g.\n// Copy also computes the arc size ma, the number of arcs.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g Directed) Copy() (c Directed, ma int) {\n\tl, s := g.AdjacencyList.Copy()\n\treturn Directed{l}, s\n}\n\n// Cyclic determines if g contains a cycle, a non-empty path from a node\n// back to itself.\n//\n// Cyclic returns true if g contains at least one cycle.  It also returns\n// an example of an arc involved in a cycle.\n// Cyclic returns false if g is acyclic.\n//\n// Also see Topological, which detects cycles.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g Directed) Cyclic() (cyclic bool, fr NI, to NI) {\n\ta := g.AdjacencyList\n\tfr, to = -1, -1\n\tvar temp, perm Bits\n\tvar df func(NI)\n\tdf = func(n NI) {\n\t\tswitch {\n\t\tcase temp.Bit(n) == 1:\n\t\t\tcyclic = true\n\t\t\treturn\n\t\tcase perm.Bit(n) == 1:\n\t\t\treturn\n\t\t}\n\t\ttemp.SetBit(n, 1)\n\t\tfor _, nb := range a[n] {\n\t\t\tdf(nb)\n\t\t\tif cyclic {\n\t\t\t\tif fr < 0 {\n\t\t\t\t\tfr, to = n, nb\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\ttemp.SetBit(n, 0)\n\t\tperm.SetBit(n, 1)\n\t}\n\tfor n := range a {\n\t\tif perm.Bit(NI(n)) == 1 {\n\t\t\tcontinue\n\t\t}\n\t\tif df(NI(n)); cyclic { // short circuit as soon as a cycle is found\n\t\t\tbreak\n\t\t}\n\t}\n\treturn\n}\n\n// FromList transposes a labeled graph into a FromList.\n//\n// Receiver g should be connected as a tree or forest.  Specifically no node\n// can have multiple incoming arcs.  If any node n in g has multiple incoming\n// arcs, the method returns (nil, n) where n is a node with multiple\n// incoming arcs.\n//\n// Otherwise (normally) the method populates the From members in a\n// FromList.Path and returns the FromList and -1.\n//\n// Other members of the FromList are left as zero values.\n// Use FromList.RecalcLen and FromList.RecalcLeaves as needed.\n//\n// Unusual cases are parallel arcs and loops.  A parallel arc represents\n// a case of multiple arcs going to some node and so will lead to a (nil, n)\n// return, even though a graph might be considered a multigraph tree.\n// A single loop on a node that would otherwise be a root node, though,\n// is not a case of multiple incoming arcs and so does not force a (nil, n)\n// result.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g Directed) FromList() (*FromList, NI) {\n\tpaths := make([]PathEnd, len(g.AdjacencyList))\n\tfor i := range paths {\n\t\tpaths[i].From = -1\n\t}\n\tfor fr, to := range g.AdjacencyList {\n\t\tfor _, to := range to {\n\t\t\tif paths[to].From >= 0 {\n\t\t\t\treturn nil, to\n\t\t\t}\n\t\t\tpaths[to].From = NI(fr)\n\t\t}\n\t}\n\treturn &FromList{Paths: paths}, -1\n}\n\n// InDegree computes the in-degree of each node in g\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g Directed) InDegree() []int {\n\tind := make([]int, len(g.AdjacencyList))\n\tfor _, nbs := range g.AdjacencyList {\n\t\tfor _, nb := range nbs {\n\t\t\tind[nb]++\n\t\t}\n\t}\n\treturn ind\n}\n\n// IsTree identifies trees in directed graphs.\n//\n// Return value isTree is true if the subgraph reachable from root is a tree.\n// Further, return value allTree is true if the entire graph g is reachable\n// from root.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g Directed) IsTree(root NI) (isTree, allTree bool) {\n\ta := g.AdjacencyList\n\tvar v Bits\n\tv.SetAll(len(a))\n\tvar df func(NI) bool\n\tdf = func(n NI) bool {\n\t\tif v.Bit(n) == 0 {\n\t\t\treturn false\n\t\t}\n\t\tv.SetBit(n, 0)\n\t\tfor _, to := range a[n] {\n\t\t\tif !df(to) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\tisTree = df(root)\n\treturn isTree, isTree && v.Zero()\n}\n\n// Tarjan identifies strongly connected components in a directed graph using\n// Tarjan's algorithm.\n//\n// The method calls the emit argument for each component identified.  Each\n// component is a list of nodes.  A property of the algorithm is that\n// components are emitted in reverse topological order of the condensation.\n// (See https://en.wikipedia.org/wiki/Strongly_connected_component#Definitions\n// for description of condensation.)\n//\n// There are equivalent labeled and unlabeled versions of this method.\n//\n// See also TarjanForward and TarjanCondensation.\nfunc (g Directed) Tarjan(emit func([]NI) bool) {\n\t// See \"Depth-first search and linear graph algorithms\", Robert Tarjan,\n\t// SIAM J. Comput. Vol. 1, No. 2, June 1972.\n\t//\n\t// Implementation here from Wikipedia pseudocode,\n\t// http://en.wikipedia.org/w/index.php?title=Tarjan%27s_strongly_connected_components_algorithm&direction=prev&oldid=647184742\n\tvar indexed, stacked Bits\n\ta := g.AdjacencyList\n\tindex := make([]int, len(a))\n\tlowlink := make([]int, len(a))\n\tx := 0\n\tvar S []NI\n\tvar sc func(NI) bool\n\tsc = func(n NI) bool {\n\t\tindex[n] = x\n\t\tindexed.SetBit(n, 1)\n\t\tlowlink[n] = x\n\t\tx++\n\t\tS = append(S, n)\n\t\tstacked.SetBit(n, 1)\n\t\tfor _, nb := range a[n] {\n\t\t\tif indexed.Bit(nb) == 0 {\n\t\t\t\tif !sc(nb) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tif lowlink[nb] < lowlink[n] {\n\t\t\t\t\tlowlink[n] = lowlink[nb]\n\t\t\t\t}\n\t\t\t} else if stacked.Bit(nb) == 1 {\n\t\t\t\tif index[nb] < lowlink[n] {\n\t\t\t\t\tlowlink[n] = index[nb]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif lowlink[n] == index[n] {\n\t\t\tvar c []NI\n\t\t\tfor {\n\t\t\t\tlast := len(S) - 1\n\t\t\t\tw := S[last]\n\t\t\t\tS = S[:last]\n\t\t\t\tstacked.SetBit(w, 0)\n\t\t\t\tc = append(c, w)\n\t\t\t\tif w == n {\n\t\t\t\t\tif !emit(c) {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\tfor n := range a {\n\t\tif indexed.Bit(NI(n)) == 0 && !sc(NI(n)) {\n\t\t\treturn\n\t\t}\n\t}\n}\n\n// TarjanForward returns strongly connected components.\n//\n// It returns components in the reverse order of Tarjan, for situations\n// where a forward topological ordering is easier.\nfunc (g Directed) TarjanForward() [][]NI {\n\tvar r [][]NI\n\tg.Tarjan(func(c []NI) bool {\n\t\tr = append(r, c)\n\t\treturn true\n\t})\n\tscc := make([][]NI, len(r))\n\tlast := len(r) - 1\n\tfor i, ci := range r {\n\t\tscc[last-i] = ci\n\t}\n\treturn scc\n}\n\n// TarjanCondensation returns strongly connected components and their\n// condensation graph.\n//\n// Components are ordered in a forward topological ordering.\nfunc (g Directed) TarjanCondensation() (scc [][]NI, cd AdjacencyList) {\n\tscc = g.TarjanForward()\n\tcd = make(AdjacencyList, len(scc))       // return value\n\tcond := make([]NI, len(g.AdjacencyList)) // mapping from g node to cd node\n\tfor cn := NI(len(scc) - 1); cn >= 0; cn-- {\n\t\tc := scc[cn]\n\t\tfor _, n := range c {\n\t\t\tcond[n] = NI(cn) // map g node to cd node\n\t\t}\n\t\tvar tos []NI // list of 'to' nodes\n\t\tvar m Bits   // tos map\n\t\tm.SetBit(cn, 1)\n\t\tfor _, n := range c {\n\t\t\tfor _, to := range g.AdjacencyList[n] {\n\t\t\t\tif ct := cond[to]; m.Bit(ct) == 0 {\n\t\t\t\t\tm.SetBit(ct, 1)\n\t\t\t\t\ttos = append(tos, ct)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcd[cn] = tos\n\t}\n\treturn\n}\n\n// Topological computes a topological ordering of a directed acyclic graph.\n//\n// For an acyclic graph, return value ordering is a permutation of node numbers\n// in topologically sorted order and cycle will be nil.  If the graph is found\n// to be cyclic, ordering will be nil and cycle will be the path of a found\n// cycle.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g Directed) Topological() (ordering, cycle []NI) {\n\ta := g.AdjacencyList\n\tordering = make([]NI, len(a))\n\ti := len(ordering)\n\tvar temp, perm Bits\n\tvar cycleFound bool\n\tvar cycleStart NI\n\tvar df func(NI)\n\tdf = func(n NI) {\n\t\tswitch {\n\t\tcase temp.Bit(n) == 1:\n\t\t\tcycleFound = true\n\t\t\tcycleStart = n\n\t\t\treturn\n\t\tcase perm.Bit(n) == 1:\n\t\t\treturn\n\t\t}\n\t\ttemp.SetBit(n, 1)\n\t\tfor _, nb := range a[n] {\n\t\t\tdf(nb)\n\t\t\tif cycleFound {\n\t\t\t\tif cycleStart >= 0 {\n\t\t\t\t\t// a little hack: orderng won't be needed so repurpose the\n\t\t\t\t\t// slice as cycle.  this is read out in reverse order\n\t\t\t\t\t// as the recursion unwinds.\n\t\t\t\t\tx := len(ordering) - 1 - len(cycle)\n\t\t\t\t\tordering[x] = n\n\t\t\t\t\tcycle = ordering[x:]\n\t\t\t\t\tif n == cycleStart {\n\t\t\t\t\t\tcycleStart = -1\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\ttemp.SetBit(n, 0)\n\t\tperm.SetBit(n, 1)\n\t\ti--\n\t\tordering[i] = n\n\t}\n\tfor n := range a {\n\t\tif perm.Bit(NI(n)) == 1 {\n\t\t\tcontinue\n\t\t}\n\t\tdf(NI(n))\n\t\tif cycleFound {\n\t\t\treturn nil, cycle\n\t\t}\n\t}\n\treturn ordering, nil\n}\n\n// TopologicalKahn computes a topological ordering of a directed acyclic graph.\n//\n// For an acyclic graph, return value ordering is a permutation of node numbers\n// in topologically sorted order and cycle will be nil.  If the graph is found\n// to be cyclic, ordering will be nil and cycle will be the path of a found\n// cycle.\n//\n// This function is based on the algorithm by Arthur Kahn and requires the\n// transpose of g be passed as the argument.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g Directed) TopologicalKahn(tr Directed) (ordering, cycle []NI) {\n\t// code follows Wikipedia pseudocode.\n\tvar L, S []NI\n\t// rem for \"remaining edges,\" this function makes a local copy of the\n\t// in-degrees and consumes that instead of consuming an input.\n\trem := make([]int, len(g.AdjacencyList))\n\tfor n, fr := range tr.AdjacencyList {\n\t\tif len(fr) == 0 {\n\t\t\t// accumulate \"set of all nodes with no incoming edges\"\n\t\t\tS = append(S, NI(n))\n\t\t} else {\n\t\t\t// initialize rem from in-degree\n\t\t\trem[n] = len(fr)\n\t\t}\n\t}\n\tfor len(S) > 0 {\n\t\tlast := len(S) - 1 // \"remove a node n from S\"\n\t\tn := S[last]\n\t\tS = S[:last]\n\t\tL = append(L, n) // \"add n to tail of L\"\n\t\tfor _, m := range g.AdjacencyList[n] {\n\t\t\t// WP pseudo code reads \"for each node m...\" but it means for each\n\t\t\t// node m *remaining in the graph.*  We consume rem rather than\n\t\t\t// the graph, so \"remaining in the graph\" for us means rem[m] > 0.\n\t\t\tif rem[m] > 0 {\n\t\t\t\trem[m]--         // \"remove edge from the graph\"\n\t\t\t\tif rem[m] == 0 { // if \"m has no other incoming edges\"\n\t\t\t\t\tS = append(S, m) // \"insert m into S\"\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t// \"If graph has edges,\" for us means a value in rem is > 0.\n\tfor c, in := range rem {\n\t\tif in > 0 {\n\t\t\t// recover cyclic nodes\n\t\t\tfor _, nb := range g.AdjacencyList[c] {\n\t\t\t\tif rem[nb] > 0 {\n\t\t\t\t\tcycle = append(cycle, NI(c))\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif len(cycle) > 0 {\n\t\treturn nil, cycle\n\t}\n\treturn L, nil\n}\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/dir_cg.go",
    "content": "// Copyright 2014 Sonia Keys\n// License MIT: http://opensource.org/licenses/MIT\n\npackage graph\n\n// dir_RO.go is code generated from dir_cg.go by directives in graph.go.\n// Editing dir_cg.go is okay.  It is the code generation source.\n// DO NOT EDIT dir_RO.go.\n// The RO means read only and it is upper case RO to slow you down a bit\n// in case you start to edit the file.\n\n// Balanced returns true if for every node in g, in-degree equals out-degree.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledDirected) Balanced() bool {\n\tfor n, in := range g.InDegree() {\n\t\tif in != len(g.LabeledAdjacencyList[n]) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n// Copy makes a deep copy of g.\n// Copy also computes the arc size ma, the number of arcs.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledDirected) Copy() (c LabeledDirected, ma int) {\n\tl, s := g.LabeledAdjacencyList.Copy()\n\treturn LabeledDirected{l}, s\n}\n\n// Cyclic determines if g contains a cycle, a non-empty path from a node\n// back to itself.\n//\n// Cyclic returns true if g contains at least one cycle.  It also returns\n// an example of an arc involved in a cycle.\n// Cyclic returns false if g is acyclic.\n//\n// Also see Topological, which detects cycles.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledDirected) Cyclic() (cyclic bool, fr NI, to Half) {\n\ta := g.LabeledAdjacencyList\n\tfr, to.To = -1, -1\n\tvar temp, perm Bits\n\tvar df func(NI)\n\tdf = func(n NI) {\n\t\tswitch {\n\t\tcase temp.Bit(n) == 1:\n\t\t\tcyclic = true\n\t\t\treturn\n\t\tcase perm.Bit(n) == 1:\n\t\t\treturn\n\t\t}\n\t\ttemp.SetBit(n, 1)\n\t\tfor _, nb := range a[n] {\n\t\t\tdf(nb.To)\n\t\t\tif cyclic {\n\t\t\t\tif fr < 0 {\n\t\t\t\t\tfr, to = n, nb\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\ttemp.SetBit(n, 0)\n\t\tperm.SetBit(n, 1)\n\t}\n\tfor n := range a {\n\t\tif perm.Bit(NI(n)) == 1 {\n\t\t\tcontinue\n\t\t}\n\t\tif df(NI(n)); cyclic { // short circuit as soon as a cycle is found\n\t\t\tbreak\n\t\t}\n\t}\n\treturn\n}\n\n// FromList transposes a labeled graph into a FromList.\n//\n// Receiver g should be connected as a tree or forest.  Specifically no node\n// can have multiple incoming arcs.  If any node n in g has multiple incoming\n// arcs, the method returns (nil, n) where n is a node with multiple\n// incoming arcs.\n//\n// Otherwise (normally) the method populates the From members in a\n// FromList.Path and returns the FromList and -1.\n//\n// Other members of the FromList are left as zero values.\n// Use FromList.RecalcLen and FromList.RecalcLeaves as needed.\n//\n// Unusual cases are parallel arcs and loops.  A parallel arc represents\n// a case of multiple arcs going to some node and so will lead to a (nil, n)\n// return, even though a graph might be considered a multigraph tree.\n// A single loop on a node that would otherwise be a root node, though,\n// is not a case of multiple incoming arcs and so does not force a (nil, n)\n// result.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledDirected) FromList() (*FromList, NI) {\n\tpaths := make([]PathEnd, len(g.LabeledAdjacencyList))\n\tfor i := range paths {\n\t\tpaths[i].From = -1\n\t}\n\tfor fr, to := range g.LabeledAdjacencyList {\n\t\tfor _, to := range to {\n\t\t\tif paths[to.To].From >= 0 {\n\t\t\t\treturn nil, to.To\n\t\t\t}\n\t\t\tpaths[to.To].From = NI(fr)\n\t\t}\n\t}\n\treturn &FromList{Paths: paths}, -1\n}\n\n// InDegree computes the in-degree of each node in g\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledDirected) InDegree() []int {\n\tind := make([]int, len(g.LabeledAdjacencyList))\n\tfor _, nbs := range g.LabeledAdjacencyList {\n\t\tfor _, nb := range nbs {\n\t\t\tind[nb.To]++\n\t\t}\n\t}\n\treturn ind\n}\n\n// IsTree identifies trees in directed graphs.\n//\n// Return value isTree is true if the subgraph reachable from root is a tree.\n// Further, return value allTree is true if the entire graph g is reachable\n// from root.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledDirected) IsTree(root NI) (isTree, allTree bool) {\n\ta := g.LabeledAdjacencyList\n\tvar v Bits\n\tv.SetAll(len(a))\n\tvar df func(NI) bool\n\tdf = func(n NI) bool {\n\t\tif v.Bit(n) == 0 {\n\t\t\treturn false\n\t\t}\n\t\tv.SetBit(n, 0)\n\t\tfor _, to := range a[n] {\n\t\t\tif !df(to.To) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\tisTree = df(root)\n\treturn isTree, isTree && v.Zero()\n}\n\n// Tarjan identifies strongly connected components in a directed graph using\n// Tarjan's algorithm.\n//\n// The method calls the emit argument for each component identified.  Each\n// component is a list of nodes.  A property of the algorithm is that\n// components are emitted in reverse topological order of the condensation.\n// (See https://en.wikipedia.org/wiki/Strongly_connected_component#Definitions\n// for description of condensation.)\n//\n// There are equivalent labeled and unlabeled versions of this method.\n//\n// See also TarjanForward and TarjanCondensation.\nfunc (g LabeledDirected) Tarjan(emit func([]NI) bool) {\n\t// See \"Depth-first search and linear graph algorithms\", Robert Tarjan,\n\t// SIAM J. Comput. Vol. 1, No. 2, June 1972.\n\t//\n\t// Implementation here from Wikipedia pseudocode,\n\t// http://en.wikipedia.org/w/index.php?title=Tarjan%27s_strongly_connected_components_algorithm&direction=prev&oldid=647184742\n\tvar indexed, stacked Bits\n\ta := g.LabeledAdjacencyList\n\tindex := make([]int, len(a))\n\tlowlink := make([]int, len(a))\n\tx := 0\n\tvar S []NI\n\tvar sc func(NI) bool\n\tsc = func(n NI) bool {\n\t\tindex[n] = x\n\t\tindexed.SetBit(n, 1)\n\t\tlowlink[n] = x\n\t\tx++\n\t\tS = append(S, n)\n\t\tstacked.SetBit(n, 1)\n\t\tfor _, nb := range a[n] {\n\t\t\tif indexed.Bit(nb.To) == 0 {\n\t\t\t\tif !sc(nb.To) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tif lowlink[nb.To] < lowlink[n] {\n\t\t\t\t\tlowlink[n] = lowlink[nb.To]\n\t\t\t\t}\n\t\t\t} else if stacked.Bit(nb.To) == 1 {\n\t\t\t\tif index[nb.To] < lowlink[n] {\n\t\t\t\t\tlowlink[n] = index[nb.To]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif lowlink[n] == index[n] {\n\t\t\tvar c []NI\n\t\t\tfor {\n\t\t\t\tlast := len(S) - 1\n\t\t\t\tw := S[last]\n\t\t\t\tS = S[:last]\n\t\t\t\tstacked.SetBit(w, 0)\n\t\t\t\tc = append(c, w)\n\t\t\t\tif w == n {\n\t\t\t\t\tif !emit(c) {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\tfor n := range a {\n\t\tif indexed.Bit(NI(n)) == 0 && !sc(NI(n)) {\n\t\t\treturn\n\t\t}\n\t}\n}\n\n// TarjanForward returns strongly connected components.\n//\n// It returns components in the reverse order of Tarjan, for situations\n// where a forward topological ordering is easier.\nfunc (g LabeledDirected) TarjanForward() [][]NI {\n\tvar r [][]NI\n\tg.Tarjan(func(c []NI) bool {\n\t\tr = append(r, c)\n\t\treturn true\n\t})\n\tscc := make([][]NI, len(r))\n\tlast := len(r) - 1\n\tfor i, ci := range r {\n\t\tscc[last-i] = ci\n\t}\n\treturn scc\n}\n\n// TarjanCondensation returns strongly connected components and their\n// condensation graph.\n//\n// Components are ordered in a forward topological ordering.\nfunc (g LabeledDirected) TarjanCondensation() (scc [][]NI, cd AdjacencyList) {\n\tscc = g.TarjanForward()\n\tcd = make(AdjacencyList, len(scc))              // return value\n\tcond := make([]NI, len(g.LabeledAdjacencyList)) // mapping from g node to cd node\n\tfor cn := NI(len(scc) - 1); cn >= 0; cn-- {\n\t\tc := scc[cn]\n\t\tfor _, n := range c {\n\t\t\tcond[n] = NI(cn) // map g node to cd node\n\t\t}\n\t\tvar tos []NI // list of 'to' nodes\n\t\tvar m Bits   // tos map\n\t\tm.SetBit(cn, 1)\n\t\tfor _, n := range c {\n\t\t\tfor _, to := range g.LabeledAdjacencyList[n] {\n\t\t\t\tif ct := cond[to.To]; m.Bit(ct) == 0 {\n\t\t\t\t\tm.SetBit(ct, 1)\n\t\t\t\t\ttos = append(tos, ct)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcd[cn] = tos\n\t}\n\treturn\n}\n\n// Topological computes a topological ordering of a directed acyclic graph.\n//\n// For an acyclic graph, return value ordering is a permutation of node numbers\n// in topologically sorted order and cycle will be nil.  If the graph is found\n// to be cyclic, ordering will be nil and cycle will be the path of a found\n// cycle.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledDirected) Topological() (ordering, cycle []NI) {\n\ta := g.LabeledAdjacencyList\n\tordering = make([]NI, len(a))\n\ti := len(ordering)\n\tvar temp, perm Bits\n\tvar cycleFound bool\n\tvar cycleStart NI\n\tvar df func(NI)\n\tdf = func(n NI) {\n\t\tswitch {\n\t\tcase temp.Bit(n) == 1:\n\t\t\tcycleFound = true\n\t\t\tcycleStart = n\n\t\t\treturn\n\t\tcase perm.Bit(n) == 1:\n\t\t\treturn\n\t\t}\n\t\ttemp.SetBit(n, 1)\n\t\tfor _, nb := range a[n] {\n\t\t\tdf(nb.To)\n\t\t\tif cycleFound {\n\t\t\t\tif cycleStart >= 0 {\n\t\t\t\t\t// a little hack: orderng won't be needed so repurpose the\n\t\t\t\t\t// slice as cycle.  this is read out in reverse order\n\t\t\t\t\t// as the recursion unwinds.\n\t\t\t\t\tx := len(ordering) - 1 - len(cycle)\n\t\t\t\t\tordering[x] = n\n\t\t\t\t\tcycle = ordering[x:]\n\t\t\t\t\tif n == cycleStart {\n\t\t\t\t\t\tcycleStart = -1\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\ttemp.SetBit(n, 0)\n\t\tperm.SetBit(n, 1)\n\t\ti--\n\t\tordering[i] = n\n\t}\n\tfor n := range a {\n\t\tif perm.Bit(NI(n)) == 1 {\n\t\t\tcontinue\n\t\t}\n\t\tdf(NI(n))\n\t\tif cycleFound {\n\t\t\treturn nil, cycle\n\t\t}\n\t}\n\treturn ordering, nil\n}\n\n// TopologicalKahn computes a topological ordering of a directed acyclic graph.\n//\n// For an acyclic graph, return value ordering is a permutation of node numbers\n// in topologically sorted order and cycle will be nil.  If the graph is found\n// to be cyclic, ordering will be nil and cycle will be the path of a found\n// cycle.\n//\n// This function is based on the algorithm by Arthur Kahn and requires the\n// transpose of g be passed as the argument.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledDirected) TopologicalKahn(tr Directed) (ordering, cycle []NI) {\n\t// code follows Wikipedia pseudocode.\n\tvar L, S []NI\n\t// rem for \"remaining edges,\" this function makes a local copy of the\n\t// in-degrees and consumes that instead of consuming an input.\n\trem := make([]int, len(g.LabeledAdjacencyList))\n\tfor n, fr := range tr.AdjacencyList {\n\t\tif len(fr) == 0 {\n\t\t\t// accumulate \"set of all nodes with no incoming edges\"\n\t\t\tS = append(S, NI(n))\n\t\t} else {\n\t\t\t// initialize rem from in-degree\n\t\t\trem[n] = len(fr)\n\t\t}\n\t}\n\tfor len(S) > 0 {\n\t\tlast := len(S) - 1 // \"remove a node n from S\"\n\t\tn := S[last]\n\t\tS = S[:last]\n\t\tL = append(L, n) // \"add n to tail of L\"\n\t\tfor _, m := range g.LabeledAdjacencyList[n] {\n\t\t\t// WP pseudo code reads \"for each node m...\" but it means for each\n\t\t\t// node m *remaining in the graph.*  We consume rem rather than\n\t\t\t// the graph, so \"remaining in the graph\" for us means rem[m] > 0.\n\t\t\tif rem[m.To] > 0 {\n\t\t\t\trem[m.To]--         // \"remove edge from the graph\"\n\t\t\t\tif rem[m.To] == 0 { // if \"m has no other incoming edges\"\n\t\t\t\t\tS = append(S, m.To) // \"insert m into S\"\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t// \"If graph has edges,\" for us means a value in rem is > 0.\n\tfor c, in := range rem {\n\t\tif in > 0 {\n\t\t\t// recover cyclic nodes\n\t\t\tfor _, nb := range g.LabeledAdjacencyList[c] {\n\t\t\t\tif rem[nb.To] > 0 {\n\t\t\t\t\tcycle = append(cycle, NI(c))\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif len(cycle) > 0 {\n\t\treturn nil, cycle\n\t}\n\treturn L, nil\n}\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/doc.go",
    "content": "// Copyright 2014 Sonia Keys\n// License MIT: http://opensource.org/licenses/MIT\n\n// Graph algorithms: Dijkstra, A*, Bellman Ford, Floyd Warshall;\n// Kruskal and Prim minimal spanning tree; topological sort and DAG longest\n// and shortest paths; Eulerian cycle and path; degeneracy and k-cores;\n// Bron Kerbosch clique finding; connected components; and others.\n//\n// This is a graph library of integer indexes.  To use it with application\n// data, you associate data with integer indexes, perform searches or other\n// operations with the library, and then use the integer index results to refer\n// back to your application data.\n//\n// Thus it does not store application data, pointers to application data,\n// or require you to implement an interface on your application data.\n// The idea is to keep the library methods fast and lean.\n//\n// Representation overview\n//\n// The package defines a type for a node index (NI) which is just an integer\n// type.  It defines types for a number of number graph representations using\n// NI.  The fundamental graph type is AdjacencyList, which is the\n// common \"list of lists\" graph representation.  It is a list as a slice\n// with one element for each node of the graph.  Each element is a list\n// itself, a list of neighbor nodes, implemented as an NI slice.  Methods\n// on an AdjacencyList generally work on any representable graph, including\n// directed or undirected graphs, simple graphs or multigraphs.\n//\n// The type Undirected embeds an AdjacencyList adding methods specific to\n// undirected graphs.  Similarly the type Directed adds methods meaningful\n// for directed graphs.\n//\n// Similar to NI, the type LI is a \"label index\" which labels a\n// node-to-neighbor \"arc\" or edge.  Just as an NI can index arbitrary node\n// data, an LI can index arbitrary arc or edge data.  A number of algorithms\n// use a \"weight\" associated with an arc.  This package does not represent\n// weighted arcs explicitly, but instead uses the LI as a more general\n// mechanism allowing not only weights but arbitrary data to be associated\n// with arcs.  While AdjacencyList represents an arc with simply an NI,\n// the type LabeledAdjacencyList uses a type that pairs an NI with an LI.\n// This type is named Half, for half-arc.  (A full arc would represent\n// both ends.)  Types LabeledDirected and LabeledUndirected embed a\n// LabeledAdjacencyList.\n//\n// In contrast to Half, the type Edge represents both ends of an edge (but\n// no label.)  The type LabeledEdge adds the label.  The type WeightedEdgeList\n// bundles a list of LabeledEdges with a WeightFunc.  WeightedEdgeList is\n// currently only used by Kruskal methods.\n//\n// FromList is a compact rooted tree (or forest) respresentation.  Like\n// AdjacencyList and LabeledAdjacencyList, it is a list with one element for\n// each node of the graph.  Each element contains only a single neighbor\n// however, its parent in the tree, the \"from\" node.\n//\n// Code generation\n//\n// A number of methods on AdjacencyList, Directed, and Undirected are\n// applicable to LabeledAdjacencyList, LabeledDirected, and LabeledUndirected\n// simply by ignoring the label.  In these cases code generation provides\n// methods on both types from a single source implementation. These methods\n// are documented with the sentence \"There are equivalent labeled and unlabeled\n// versions of this method\" and examples are provided only for the unlabeled\n// version.\n//\n// Terminology\n//\n// This package uses the term \"node\" rather than \"vertex.\"  It uses \"arc\"\n// to mean a directed edge, and uses \"from\" and \"to\" to refer to the ends\n// of an arc.  It uses \"start\" and \"end\" to refer to endpoints of a search\n// or traversal.\n//\n// The usage of \"to\" and \"from\" is perhaps most strange.  In common speech\n// they are prepositions, but throughout this package they are used as\n// adjectives, for example to refer to the \"from node\" of an arc or the\n// \"to node\".  The type \"FromList\" is named to indicate it stores a list of\n// \"from\" values.\n//\n// A \"half arc\" refers to just one end of an arc, either the to or from end.\n//\n// Two arcs are \"reciprocal\" if they connect two distinct nodes n1 and n2,\n// one arc leading from n1 to n2 and the other arc leading from n2 to n1.\n// Undirected graphs are represented with reciprocal arcs.\n//\n// A node with an arc to itself represents a \"loop.\"  Duplicate arcs, where\n// a node has multiple arcs to another node, are termed \"parallel arcs.\"\n// A graph with no loops or parallel arcs is \"simple.\"  A graph that allows\n// parallel arcs is a \"multigraph\"\n//\n// The \"size\" of a graph traditionally means the number of undirected edges.\n// This package uses \"arc size\" to mean the number of arcs in a graph.  For an\n// undirected graph without loops, arc size is 2 * size.\n//\n// The \"order\" of a graph is the number of nodes.  An \"ordering\" though means\n// an ordered list of nodes.\n//\n// A number of graph search algorithms use a concept of arc \"weights.\"\n// The sum of arc weights along a path is a \"distance.\"  In contrast, the\n// number of nodes in a path, including start and end nodes, is the path's\n// \"length.\"  (Yes, mixing weights and lengths would be nonsense physically,\n// but the terms used here are just distinct terms for abstract values.\n// The actual meaning to an application is likely to be something else\n// entirely and is not relevant within this package.)\n//\n// Finally, this package documentation takes back the word \"object\" in some\n// places to refer to a Go value, especially a value of a type with methods.\n//\n// Shortest path searches\n//\n// This package implements a number of shortest path searches.  Most work\n// with weighted graphs that are directed or undirected, and with graphs\n// that may have loops or parallel arcs.  For weighted graphs, \"shortest\"\n// is defined as the path distance (sum of arc weights) with path length\n// (number of nodes) breaking ties.  If multiple paths have the same minimum\n// distance with the same minimum length, search methods are free to return\n// any of them.\n//\n//  Type name      Description, methods\n//  BreadthFirst   Unweigted arcs, traversal, single path search or all paths.\n//  BreadthFirst2  Direction-optimizing variant of BreadthFirst.\n//  Dijkstra       Non-negative arc weights, single or all paths.\n//  AStar          Non-negative arc weights, heuristic guided, single path.\n//  BellmanFord    Negative arc weights allowed, no negative cycles, all paths.\n//  DAGPath        O(n) algorithm for DAGs, arc weights of any sign.\n//  FloydWarshall  all pairs distances, no negative cycles.\n//\n// These searches typically have one method that is full-featured and\n// then a convenience method with a simpler API targeting a simpler use case.\npackage graph\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/fromlist.go",
    "content": "// Copyright 2014 Sonia Keys\n// License MIT: http://opensource.org/licenses/MIT\n\npackage graph\n\n// FromList represents a rooted tree (or forest) where each node is associated\n// with a half arc identifying an arc \"from\" another node.\n//\n// Other terms for this data structure include \"parent list\",\n// \"predecessor list\", \"in-tree\", \"inverse arborescence\", and\n// \"spaghetti stack.\"\n//\n// The Paths member represents the tree structure.  Leaves and MaxLen are\n// not always needed.  Where Leaves is used it serves as a bitmap where\n// Leaves.Bit(n) == 1 for each leaf n of the tree.  Where MaxLen is used it is\n// provided primarily as a convenience for functions that might want to\n// anticipate the maximum path length that would be encountered traversing\n// the tree.\n//\n// Various graph search methods use a FromList to returns search results.\n// For a start node of a search, From will be -1 and Len will be 1. For other\n// nodes reached by the search, From represents a half arc in a path back to\n// start and Len represents the number of nodes in the path.  For nodes not\n// reached by the search, From will be -1 and Len will be 0.\n//\n// A single FromList can also represent a forest.  In this case paths from\n// all leaves do not return to a single root node, but multiple root nodes.\n//\n// While a FromList generally encodes a tree or forest, it is technically\n// possible to encode a cyclic graph.  A number of FromList methods require\n// the receiver to be acyclic.  Graph methods documented to return a tree or\n// forest will never return a cyclic FromList.  In other cases however,\n// where a FromList is not known to by cyclic, the Cyclic method can be\n// useful to validate the acyclic property.\ntype FromList struct {\n\tPaths  []PathEnd // tree representation\n\tLeaves Bits      // leaves of tree\n\tMaxLen int       // length of longest path, max of all PathEnd.Len values\n}\n\n// PathEnd associates a half arc and a path length.\n//\n// A PathEnd list is an element type of FromList.\ntype PathEnd struct {\n\tFrom NI  // a \"from\" half arc, the node the arc comes from\n\tLen  int // number of nodes in path from start\n}\n\n// NewFromList creates a FromList object of given order.\n//\n// The Paths member is allocated to length n but there is no other\n// initialization.\nfunc NewFromList(n int) FromList {\n\treturn FromList{Paths: make([]PathEnd, n)}\n}\n\n// BoundsOk validates the \"from\" values in the list.\n//\n// Negative values are allowed as they indicate root nodes.\n//\n// BoundsOk returns true when all from values are less than len(t).\n// Otherwise it returns false and a node with a from value >= len(t).\nfunc (f FromList) BoundsOk() (ok bool, n NI) {\n\tfor n, e := range f.Paths {\n\t\tif int(e.From) >= len(f.Paths) {\n\t\t\treturn false, NI(n)\n\t\t}\n\t}\n\treturn true, -1\n}\n\n// CommonStart returns the common start node of minimal paths to a and b.\n//\n// It returns -1 if a and b cannot be traced back to a common node.\n//\n// The method relies on populated PathEnd.Len members.  Use RecalcLen if\n// the Len members are not known to be present and correct.\nfunc (f FromList) CommonStart(a, b NI) NI {\n\tp := f.Paths\n\tif p[a].Len < p[b].Len {\n\t\ta, b = b, a\n\t}\n\tfor bl := p[b].Len; p[a].Len > bl; {\n\t\ta = p[a].From\n\t\tif a < 0 {\n\t\t\treturn -1\n\t\t}\n\t}\n\tfor a != b {\n\t\ta = p[a].From\n\t\tif a < 0 {\n\t\t\treturn -1\n\t\t}\n\t\tb = p[b].From\n\t}\n\treturn a\n}\n\n// Cyclic determines if f contains a cycle, a non-empty path from a node\n// back to itself.\n//\n// Cyclic returns true if g contains at least one cycle.  It also returns\n// an example of a node involved in a cycle.\n//\n// Cyclic returns (false, -1) in the normal case where f is acyclic.\n// Note that the bool is not an \"ok\" return.  A cyclic FromList is usually\n// not okay.\nfunc (f FromList) Cyclic() (cyclic bool, n NI) {\n\tvar vis Bits\n\tp := f.Paths\n\tfor i := range p {\n\t\tvar path Bits\n\t\tfor n := NI(i); vis.Bit(n) == 0; {\n\t\t\tvis.SetBit(n, 1)\n\t\t\tpath.SetBit(n, 1)\n\t\t\tif n = p[n].From; n < 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif path.Bit(n) == 1 {\n\t\t\t\treturn true, n\n\t\t\t}\n\t\t}\n\t}\n\treturn false, -1\n}\n\n// IsolatedNodeBits returns a bitmap of isolated nodes in receiver graph f.\n//\n// An isolated node is one with no arcs going to or from it.\nfunc (f FromList) IsolatedNodes() (iso Bits) {\n\tp := f.Paths\n\tiso.SetAll(len(p))\n\tfor n, e := range p {\n\t\tif e.From >= 0 {\n\t\t\tiso.SetBit(NI(n), 0)\n\t\t\tiso.SetBit(e.From, 0)\n\t\t}\n\t}\n\treturn\n}\n\n// PathTo decodes a FromList, recovering a single path.\n//\n// The path is returned as a list of nodes where the first element will be\n// a root node and the last element will be the specified end node.\n//\n// Only the Paths member of the receiver is used.  Other members of the\n// FromList do not need to be valid, however the MaxLen member can be useful\n// for allocating argument p.\n//\n// Argument p can provide the result slice.  If p has capacity for the result\n// it will be used, otherwise a new slice is created for the result.\n//\n// See also function PathTo.\nfunc (f FromList) PathTo(end NI, p []NI) []NI {\n\treturn PathTo(f.Paths, end, p)\n}\n\n// PathTo decodes a single path from a PathEnd list.\n//\n// A PathEnd list is the main data representation in a FromList.  See FromList.\n//\n// PathTo returns a list of nodes where the first element will be\n// a root node and the last element will be the specified end node.\n//\n// Argument p can provide the result slice.  If p has capacity for the result\n// it will be used, otherwise a new slice is created for the result.\n//\n// See also method FromList.PathTo.\nfunc PathTo(paths []PathEnd, end NI, p []NI) []NI {\n\tn := paths[end].Len\n\tif n == 0 {\n\t\treturn nil\n\t}\n\tif cap(p) >= n {\n\t\tp = p[:n]\n\t} else {\n\t\tp = make([]NI, n)\n\t}\n\tfor {\n\t\tn--\n\t\tp[n] = end\n\t\tif n == 0 {\n\t\t\treturn p\n\t\t}\n\t\tend = paths[end].From\n\t}\n}\n\n// Preorder traverses f calling Visitor v in preorder.\n//\n// Nodes are visited in order such that for any node n with from node fr,\n// fr is visited before n.  Where f represents a tree, the visit ordering\n// corresponds to a preordering, or depth first traversal of the tree.\n// Where f represents a forest, the preorderings of the trees can be\n// intermingled.\n//\n// Leaves must be set correctly first.  Use RecalcLeaves if leaves are not\n// known to be set correctly.  FromList f cannot be cyclic.\n//\n// Traversal continues while v returns true.  It terminates if v returns false.\n// Preorder returns true if it completes without v returning false.  Preorder\n// returns false if traversal is terminated by v returning false.\nfunc (f FromList) Preorder(v OkNodeVisitor) bool {\n\tp := f.Paths\n\tvar done Bits\n\tvar df func(NI) bool\n\tdf = func(n NI) bool {\n\t\tdone.SetBit(n, 1)\n\t\tif fr := p[n].From; fr >= 0 && done.Bit(fr) == 0 {\n\t\t\tdf(fr)\n\t\t}\n\t\treturn v(n)\n\t}\n\tfor n := range f.Paths {\n\t\tp[n].Len = 0\n\t}\n\treturn f.Leaves.Iterate(func(n NI) bool {\n\t\treturn df(n)\n\t})\n}\n\n// RecalcLeaves recomputes the Leaves member of f.\nfunc (f *FromList) RecalcLeaves() {\n\tp := f.Paths\n\tlv := &f.Leaves\n\tlv.SetAll(len(p))\n\tfor n := range f.Paths {\n\t\tif fr := p[n].From; fr >= 0 {\n\t\t\tlv.SetBit(fr, 0)\n\t\t}\n\t}\n}\n\n// RecalcLen recomputes Len for each path end, and recomputes MaxLen.\n//\n// RecalcLen relies on the Leaves member being valid.  If it is not known\n// to be valid, call RecalcLeaves before calling RecalcLen.\nfunc (f *FromList) RecalcLen() {\n\tp := f.Paths\n\tvar setLen func(NI) int\n\tsetLen = func(n NI) int {\n\t\tswitch {\n\t\tcase p[n].Len > 0:\n\t\t\treturn p[n].Len\n\t\tcase p[n].From < 0:\n\t\t\tp[n].Len = 1\n\t\t\treturn 1\n\t\t}\n\t\tl := 1 + setLen(p[n].From)\n\t\tp[n].Len = l\n\t\treturn l\n\t}\n\tfor n := range f.Paths {\n\t\tp[n].Len = 0\n\t}\n\tf.MaxLen = 0\n\tf.Leaves.Iterate(func(n NI) bool {\n\t\tif l := setLen(NI(n)); l > f.MaxLen {\n\t\t\tf.MaxLen = l\n\t\t}\n\t\treturn true\n\t})\n}\n\n// ReRoot reorients the tree containing n to make n the root node.\n//\n// It keeps the tree connected by \"reversing\" the path from n to the old root.\n//\n// After ReRoot, the Leaves and Len members are invalid.\n// Call RecalcLeaves or RecalcLen as needed.\nfunc (f *FromList) ReRoot(n NI) {\n\tp := f.Paths\n\tfr := p[n].From\n\tif fr < 0 {\n\t\treturn\n\t}\n\tp[n].From = -1\n\tfor {\n\t\tff := p[fr].From\n\t\tp[fr].From = n\n\t\tif ff < 0 {\n\t\t\treturn\n\t\t}\n\t\tn = fr\n\t\tfr = ff\n\t}\n}\n\n// Root finds the root of a node in a FromList.\nfunc (f FromList) Root(n NI) NI {\n\tfor p := f.Paths; ; {\n\t\tfr := p[n].From\n\t\tif fr < 0 {\n\t\t\treturn n\n\t\t}\n\t\tn = fr\n\t}\n}\n\n// Transpose constructs the directed graph corresponding to FromList f\n// but with arcs in the opposite direction.  That is, from roots toward leaves.\n//\n// The method relies only on the From member of f.Paths.  Other members of\n// the FromList are not used.\n//\n// See FromList.TransposeRoots for a version that also accumulates and returns\n// information about the roots.\nfunc (f FromList) Transpose() Directed {\n\tg := make(AdjacencyList, len(f.Paths))\n\tfor n, p := range f.Paths {\n\t\tif p.From == -1 {\n\t\t\tcontinue\n\t\t}\n\t\tg[p.From] = append(g[p.From], NI(n))\n\t}\n\treturn Directed{g}\n}\n\n// TransposeLabeled constructs the directed labeled graph corresponding\n// to FromList f but with arcs in the opposite direction.  That is, from\n// roots toward leaves.\n//\n// The argument labels can be nil.  In this case labels are generated matching\n// the path indexes.  This corresponds to the \"to\", or child node.\n//\n// If labels is non-nil, it must be the same length as f.Paths and is used\n// to look up label numbers by the path index.\n//\n// The method relies only on the From member of f.Paths.  Other members of\n// the FromList are not used.\n//\n// See FromList.TransposeLabeledRoots for a version that also accumulates\n// and returns information about the roots.\nfunc (f FromList) TransposeLabeled(labels []LI) LabeledDirected {\n\tg := make(LabeledAdjacencyList, len(f.Paths))\n\tfor n, p := range f.Paths {\n\t\tif p.From == -1 {\n\t\t\tcontinue\n\t\t}\n\t\tl := LI(n)\n\t\tif labels != nil {\n\t\t\tl = labels[n]\n\t\t}\n\t\tg[p.From] = append(g[p.From], Half{NI(n), l})\n\t}\n\treturn LabeledDirected{g}\n}\n\n// TransposeLabeledRoots constructs the labeled directed graph corresponding\n// to FromList f but with arcs in the opposite direction.  That is, from\n// roots toward leaves.\n//\n// TransposeLabeledRoots also returns a count of roots of the resulting forest\n// and a bitmap of the roots.\n//\n// The argument labels can be nil.  In this case labels are generated matching\n// the path indexes.  This corresponds to the \"to\", or child node.\n//\n// If labels is non-nil, it must be the same length as t.Paths and is used\n// to look up label numbers by the path index.\n//\n// The method relies only on the From member of f.Paths.  Other members of\n// the FromList are not used.\n//\n// See FromList.TransposeLabeled for a simpler verstion that returns the\n// forest only.\nfunc (f FromList) TransposeLabeledRoots(labels []LI) (forest LabeledDirected, nRoots int, roots Bits) {\n\tp := f.Paths\n\tnRoots = len(p)\n\troots.SetAll(len(p))\n\tg := make(LabeledAdjacencyList, len(p))\n\tfor i, p := range f.Paths {\n\t\tif p.From == -1 {\n\t\t\tcontinue\n\t\t}\n\t\tl := LI(i)\n\t\tif labels != nil {\n\t\t\tl = labels[i]\n\t\t}\n\t\tn := NI(i)\n\t\tg[p.From] = append(g[p.From], Half{n, l})\n\t\tif roots.Bit(n) == 1 {\n\t\t\troots.SetBit(n, 0)\n\t\t\tnRoots--\n\t\t}\n\t}\n\treturn LabeledDirected{g}, nRoots, roots\n}\n\n// TransposeRoots constructs the directed graph corresponding to FromList f\n// but with arcs in the opposite direction.  That is, from roots toward leaves.\n//\n// TransposeRoots also returns a count of roots of the resulting forest and\n// a bitmap of the roots.\n//\n// The method relies only on the From member of f.Paths.  Other members of\n// the FromList are not used.\n//\n// See FromList.Transpose for a simpler verstion that returns the forest only.\nfunc (f FromList) TransposeRoots() (forest Directed, nRoots int, roots Bits) {\n\tp := f.Paths\n\tnRoots = len(p)\n\troots.SetAll(len(p))\n\tg := make(AdjacencyList, len(p))\n\tfor i, e := range p {\n\t\tif e.From == -1 {\n\t\t\tcontinue\n\t\t}\n\t\tn := NI(i)\n\t\tg[e.From] = append(g[e.From], n)\n\t\tif roots.Bit(n) == 1 {\n\t\t\troots.SetBit(n, 0)\n\t\t\tnRoots--\n\t\t}\n\t}\n\treturn Directed{g}, nRoots, roots\n}\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/graph.go",
    "content": "// Copyright 2014 Sonia Keys\n// License MIT: http://opensource.org/licenses/MIT\n\npackage graph\n\n// graph.go contains type definitions for all graph types and components.\n// Also, go generate directives for source transformations.\n//\n// For readability, the types are defined in a dependency order:\n//\n//  NI\n//  NodeList\n//  AdjacencyList\n//  Directed\n//  Undirected\n//  LI\n//  Half\n//  LabeledAdjacencyList\n//  LabeledDirected\n//  LabeledUndirected\n//  Edge\n//  LabeledEdge\n//  WeightFunc\n//  WeightedEdgeList\n\n//go:generate cp adj_cg.go adj_RO.go\n//go:generate gofmt -r \"LabeledAdjacencyList -> AdjacencyList\" -w adj_RO.go\n//go:generate gofmt -r \"n.To -> n\" -w adj_RO.go\n//go:generate gofmt -r \"Half -> NI\" -w adj_RO.go\n\n//go:generate cp dir_cg.go dir_RO.go\n//go:generate gofmt -r \"LabeledDirected -> Directed\" -w dir_RO.go\n//go:generate gofmt -r \"LabeledAdjacencyList -> AdjacencyList\" -w dir_RO.go\n//go:generate gofmt -r \"n.To -> n\" -w dir_RO.go\n//go:generate gofmt -r \"Half -> NI\" -w dir_RO.go\n\n//go:generate cp undir_cg.go undir_RO.go\n//go:generate gofmt -r \"LabeledUndirected -> Undirected\" -w undir_RO.go\n//go:generate gofmt -r \"LabeledAdjacencyList -> AdjacencyList\" -w undir_RO.go\n//go:generate gofmt -r \"n.To -> n\" -w undir_RO.go\n//go:generate gofmt -r \"Half -> NI\" -w undir_RO.go\n\n// NI is a \"node int\"\n//\n// It is a node number or node ID.  NIs are used extensively as slice indexes.\n// NIs typically account for a significant fraction of the memory footprint of\n// a graph.\ntype NI int32\n\n// NodeList satisfies sort.Interface.\ntype NodeList []NI\n\nfunc (l NodeList) Len() int           { return len(l) }\nfunc (l NodeList) Less(i, j int) bool { return l[i] < l[j] }\nfunc (l NodeList) Swap(i, j int)      { l[i], l[j] = l[j], l[i] }\n\n// An AdjacencyList represents a graph as a list of neighbors for each node.\n// The \"node ID\" of a node is simply it's slice index in the AdjacencyList.\n// For an AdjacencyList g, g[n] represents arcs going from node n to nodes\n// g[n].\n//\n// Adjacency lists are inherently directed but can be used to represent\n// directed or undirected graphs.  See types Directed and Undirected.\ntype AdjacencyList [][]NI\n\n// Directed represents a directed graph.\n//\n// Directed methods generally rely on the graph being directed, specifically\n// that arcs do not have reciprocals.\ntype Directed struct {\n\tAdjacencyList // embedded to include AdjacencyList methods\n}\n\n// Undirected represents an undirected graph.\n//\n// In an undirected graph, for each arc between distinct nodes there is also\n// a reciprocal arc, an arc in the opposite direction.  Loops do not have\n// reciprocals.\n//\n// Undirected methods generally rely on the graph being undirected,\n// specifically that every arc between distinct nodes has a reciprocal.\ntype Undirected struct {\n\tAdjacencyList // embedded to include AdjacencyList methods\n}\n\n// LI is a label integer, used for associating labels with arcs.\ntype LI int32\n\n// Half is a half arc, representing a labeled arc and the \"neighbor\" node\n// that the arc leads to.\n//\n// Halfs can be composed to form a labeled adjacency list.\ntype Half struct {\n\tTo    NI // node ID, usable as a slice index\n\tLabel LI // half-arc ID for application data, often a weight\n}\n\n// A LabeledAdjacencyList represents a graph as a list of neighbors for each\n// node, connected by labeled arcs.\n//\n// Arc labels are not necessarily unique arc IDs.  Different arcs can have\n// the same label.\n//\n// Arc labels are commonly used to assocate a weight with an arc.  Arc labels\n// are general purpose however and can be used to associate arbitrary\n// information with an arc.\n//\n// Methods implementing weighted graph algorithms will commonly take a\n// weight function that turns a label int into a float64 weight.\n//\n// If only a small amount of information -- such as an integer weight or\n// a single printable character -- needs to be associated, it can sometimes\n// be possible to encode the information directly into the label int.  For\n// more generality, some lookup scheme will be needed.\n//\n// In an undirected labeled graph, reciprocal arcs must have identical labels.\n// Note this does not preclude parallel arcs with different labels.\ntype LabeledAdjacencyList [][]Half\n\n// LabeledDirected represents a directed labeled graph.\n//\n// This is the labeled version of Directed.  See types LabeledAdjacencyList\n// and Directed.\ntype LabeledDirected struct {\n\tLabeledAdjacencyList // embedded to include LabeledAdjacencyList methods\n}\n\n// LabeledUndirected represents an undirected labeled graph.\n//\n// This is the labeled version of Undirected.  See types LabeledAdjacencyList\n// and Undirected.\ntype LabeledUndirected struct {\n\tLabeledAdjacencyList // embedded to include LabeledAdjacencyList methods\n}\n\n// Edge is an undirected edge between nodes N1 and N2.\ntype Edge struct{ N1, N2 NI }\n\n// LabeledEdge is an undirected edge with an associated label.\ntype LabeledEdge struct {\n\tEdge\n\tLI\n}\n\n// WeightFunc returns a weight for a given label.\n//\n// WeightFunc is a parameter type for various search functions.  The intent\n// is to return a weight corresponding to an arc label.  The name \"weight\"\n// is an abstract term.  An arc \"weight\" will typically have some application\n// specific meaning other than physical weight.\ntype WeightFunc func(label LI) (weight float64)\n\n// WeightedEdgeList is a graph representation.\n//\n// It is a labeled edge list, with an associated weight function to return\n// a weight given an edge label.\n//\n// Also associated is the order, or number of nodes of the graph.\n// All nodes occurring in the edge list must be strictly less than Order.\n//\n// WeigtedEdgeList sorts by weight, obtained by calling the weight function.\n// If weight computation is expensive, consider supplying a cached or\n// memoized version.\ntype WeightedEdgeList struct {\n\tOrder int\n\tWeightFunc\n\tEdges []LabeledEdge\n}\n\n// Len implements sort.Interface.\nfunc (l WeightedEdgeList) Len() int { return len(l.Edges) }\n\n// Less implements sort.Interface.\nfunc (l WeightedEdgeList) Less(i, j int) bool {\n\treturn l.WeightFunc(l.Edges[i].LI) < l.WeightFunc(l.Edges[j].LI)\n}\n\n// Swap implements sort.Interface.\nfunc (l WeightedEdgeList) Swap(i, j int) {\n\tl.Edges[i], l.Edges[j] = l.Edges[j], l.Edges[i]\n}\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/hacking.md",
    "content": "#Hacking\n\nBasic use of the package is just go get, or git clone; go install.  There are\nno dependencies outside the standard library.\n\nThe primary to-do list is the issue tracker on Github.  I maintained a\njournal on google drive for a while but at some point filed issues for all\nremaining ideas in that document that still seemed relevant.  So currently\nthere is no other roadmap or planning document.\n\nCI is currently on travis-ci.org.  The .travis.yml builds for go 1.2.1\nfollowing https://github.com/soniakeys/graph/issues/49, and it currently builds\nfor go 1.6 as well.  The travis script calls a shell script right away because\nI didn’t see a way to get it to do different steps for the different go\nversions.  For 1.2.1, I just wanted the basic tests.  For a current go version\nsuch as 1.6, there’s a growing list of checks.\n\nThe GOARCH=386 test is for https://github.com/soniakeys/graph/issues/41.\nThe problem is the architecture specific code in bits32.go and bits64.go.\nYes, there are architecture independent algorithms.  There is also assembly\nto access machine instructions.  Anyway, it’s the way it is for now.\n\nIm not big on making go vet happy just for a badge but I really like the\nexample check that I believe appeared with go 1.6.  (I think it will be a\nstandard check with 1.7, so the test script will have to change then.)\n\nhttps://github.com/client9/misspell has been valuable.\n\nAlso I wrote https://github.com/soniakeys/vetc to validate that each source\nfile has copyright/license statement.\n\nThen, it’s not in the ci script, but I wrote https://github.com/soniakeys/rcv\nto put coverage stats in the readme.  Maybe it could be commit hook or\nsomething but for now I’ll try just running it manually now and then.\n\nGo fmt is not in the ci script, but I have at least one editor set up to run\nit on save, so code should stay formatted pretty well.\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/mst.go",
    "content": "// Copyright 2014 Sonia Keys\n// License MIT: http://opensource.org/licenses/MIT\n\npackage graph\n\nimport (\n\t\"container/heap\"\n\t\"sort\"\n)\n\ntype dsElement struct {\n\tfrom NI\n\trank int\n}\n\ntype disjointSet struct {\n\tset []dsElement\n}\n\nfunc newDisjointSet(n int) disjointSet {\n\tset := make([]dsElement, n)\n\tfor i := range set {\n\t\tset[i].from = -1\n\t}\n\treturn disjointSet{set}\n}\n\n// return true if disjoint trees were combined.\n// false if x and y were already in the same tree.\nfunc (ds disjointSet) union(x, y NI) bool {\n\txr := ds.find(x)\n\tyr := ds.find(y)\n\tif xr == yr {\n\t\treturn false\n\t}\n\tswitch xe, ye := &ds.set[xr], &ds.set[yr]; {\n\tcase xe.rank < ye.rank:\n\t\txe.from = yr\n\tcase xe.rank == ye.rank:\n\t\txe.rank++\n\t\tfallthrough\n\tdefault:\n\t\tye.from = xr\n\t}\n\treturn true\n}\n\nfunc (ds disjointSet) find(n NI) NI {\n\t// fast paths for n == root or from root.\n\t// no updates need in these cases.\n\ts := ds.set\n\tfr := s[n].from\n\tif fr < 0 { // n is root\n\t\treturn n\n\t}\n\tn, fr = fr, s[fr].from\n\tif fr < 0 { // n is from root\n\t\treturn n\n\t}\n\t// otherwise updates needed.\n\t// two iterative passes (rather than recursion or stack)\n\t// pass 1: find root\n\tr := fr\n\tfor {\n\t\tf := s[r].from\n\t\tif f < 0 {\n\t\t\tbreak\n\t\t}\n\t\tr = f\n\t}\n\t// pass 2: update froms\n\tfor {\n\t\ts[n].from = r\n\t\tif fr == r {\n\t\t\treturn r\n\t\t}\n\t\tn = fr\n\t\tfr = s[n].from\n\t}\n}\n\n// Kruskal implements Kruskal's algorithm for constructing a minimum spanning\n// forest on an undirected graph.\n//\n// While the input graph is interpreted as undirected, the receiver edge list\n// does not actually need to contain reciprocal arcs.  A property of the\n// algorithm is that arc direction is ignored.  Thus only a single arc out of\n// a reciprocal pair must be present in the edge list.  Reciprocal arcs (and\n// parallel arcs) are allowed though, and do not affect the result.\n//\n// The forest is returned as an undirected graph.\n//\n// Also returned is a total distance for the returned forest.\n//\n// The edge list of the receiver is sorted as a side effect of this method.\n// See KruskalSorted for a version that relies on the edge list being already\n// sorted.\nfunc (l WeightedEdgeList) Kruskal() (g LabeledUndirected, dist float64) {\n\tsort.Sort(l)\n\treturn l.KruskalSorted()\n}\n\n// KruskalSorted implements Kruskal's algorithm for constructing a minimum\n// spanning tree on an undirected graph.\n//\n// While the input graph is interpreted as undirected, the receiver edge list\n// does not actually need to contain reciprocal arcs.  A property of the\n// algorithm is that arc direction is ignored.  Thus only a single arc out of\n// a reciprocal pair must be present in the edge list.  Reciprocal arcs (and\n// parallel arcs) are allowed though, and do not affect the result.\n//\n// When called, the edge list of the receiver must be already sorted by weight.\n// See Kruskal for a version that accepts an unsorted edge list.\n//\n// The forest is returned as an undirected graph.\n//\n// Also returned is a total distance for the returned forest.\nfunc (l WeightedEdgeList) KruskalSorted() (g LabeledUndirected, dist float64) {\n\tds := newDisjointSet(l.Order)\n\tg.LabeledAdjacencyList = make(LabeledAdjacencyList, l.Order)\n\tfor _, e := range l.Edges {\n\t\tif ds.union(e.N1, e.N2) {\n\t\t\tg.AddEdge(Edge{e.N1, e.N2}, e.LI)\n\t\t\tdist += l.WeightFunc(e.LI)\n\t\t}\n\t}\n\treturn\n}\n\n// Prim implements the Jarník-Prim-Dijkstra algorithm for constructing\n// a minimum spanning tree on an undirected graph.\n//\n// Prim computes a minimal spanning tree on the connected component containing\n// the given start node.  The tree is returned in FromList f.  Argument f\n// cannot be a nil pointer although it can point to a zero value FromList.\n//\n// If the passed FromList.Paths has the len of g though, it will be reused.\n// In the case of a graph with multiple connected components, this allows a\n// spanning forest to be accumulated by calling Prim successively on\n// representative nodes of the components.  In this case if leaves for\n// individual trees are of interest, pass a non-nil zero-value for the argument\n// componentLeaves and it will be populated with leaves for the single tree\n// spanned by the call.\n//\n// If argument labels is non-nil, it must have the same length as g and will\n// be populated with labels corresponding to the edges of the tree.\n//\n// Returned are the number of nodes spanned for the single tree (which will be\n// the order of the connected component) and the total spanned distance for the\n// single tree.\nfunc (g LabeledUndirected) Prim(start NI, w WeightFunc, f *FromList, labels []LI, componentLeaves *Bits) (numSpanned int, dist float64) {\n\tal := g.LabeledAdjacencyList\n\tif len(f.Paths) != len(al) {\n\t\t*f = NewFromList(len(al))\n\t}\n\tb := make([]prNode, len(al)) // \"best\"\n\tfor n := range b {\n\t\tb[n].nx = NI(n)\n\t\tb[n].fx = -1\n\t}\n\trp := f.Paths\n\tvar frontier prHeap\n\trp[start] = PathEnd{From: -1, Len: 1}\n\tnumSpanned = 1\n\tfLeaves := &f.Leaves\n\tfLeaves.SetBit(start, 1)\n\tif componentLeaves != nil {\n\t\tcomponentLeaves.SetBit(start, 1)\n\t}\n\tfor a := start; ; {\n\t\tfor _, nb := range al[a] {\n\t\t\tif rp[nb.To].Len > 0 {\n\t\t\t\tcontinue // already in MST, no action\n\t\t\t}\n\t\t\tswitch bp := &b[nb.To]; {\n\t\t\tcase bp.fx == -1: // new node for frontier\n\t\t\t\tbp.from = fromHalf{From: a, Label: nb.Label}\n\t\t\t\tbp.wt = w(nb.Label)\n\t\t\t\theap.Push(&frontier, bp)\n\t\t\tcase w(nb.Label) < bp.wt: // better arc\n\t\t\t\tbp.from = fromHalf{From: a, Label: nb.Label}\n\t\t\t\tbp.wt = w(nb.Label)\n\t\t\t\theap.Fix(&frontier, bp.fx)\n\t\t\t}\n\t\t}\n\t\tif len(frontier) == 0 {\n\t\t\tbreak // done\n\t\t}\n\t\tbp := heap.Pop(&frontier).(*prNode)\n\t\ta = bp.nx\n\t\trp[a].Len = rp[bp.from.From].Len + 1\n\t\trp[a].From = bp.from.From\n\t\tif len(labels) != 0 {\n\t\t\tlabels[a] = bp.from.Label\n\t\t}\n\t\tdist += bp.wt\n\t\tfLeaves.SetBit(bp.from.From, 0)\n\t\tfLeaves.SetBit(a, 1)\n\t\tif componentLeaves != nil {\n\t\t\tcomponentLeaves.SetBit(bp.from.From, 0)\n\t\t\tcomponentLeaves.SetBit(a, 1)\n\t\t}\n\t\tnumSpanned++\n\t}\n\treturn\n}\n\n// fromHalf is a half arc, representing a labeled arc and the \"neighbor\" node\n// that the arc originates from.\n//\n// (This used to be exported when there was a LabeledFromList.  Currently\n// unexported now that it seems to have much more limited use.)\ntype fromHalf struct {\n\tFrom  NI\n\tLabel LI\n}\n\ntype prNode struct {\n\tnx   NI\n\tfrom fromHalf\n\twt   float64 // p.Weight(from.Label)\n\tfx   int\n}\n\ntype prHeap []*prNode\n\nfunc (h prHeap) Len() int           { return len(h) }\nfunc (h prHeap) Less(i, j int) bool { return h[i].wt < h[j].wt }\nfunc (h prHeap) Swap(i, j int) {\n\th[i], h[j] = h[j], h[i]\n\th[i].fx = i\n\th[j].fx = j\n}\nfunc (p *prHeap) Push(x interface{}) {\n\tnd := x.(*prNode)\n\tnd.fx = len(*p)\n\t*p = append(*p, nd)\n}\nfunc (p *prHeap) Pop() interface{} {\n\tr := *p\n\tlast := len(r) - 1\n\t*p = r[:last]\n\treturn r[last]\n}\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/random.go",
    "content": "// Copyright 2016 Sonia Keys\n// License MIT: https://opensource.org/licenses/MIT\n\npackage graph\n\nimport (\n\t\"errors\"\n\t\"math\"\n\t\"math/rand\"\n\t\"time\"\n)\n\n// Euclidean generates a random simple graph on the Euclidean plane.\n//\n// Nodes are associated with coordinates uniformly distributed on a unit\n// square.  Arcs are added between random nodes with a bias toward connecting\n// nearer nodes.\n//\n// Unfortunately the function has a few \"knobs\".\n// The returned graph will have order nNodes and arc size nArcs.  The affinity\n// argument controls the bias toward connecting nearer nodes.  The function\n// selects random pairs of nodes as a candidate arc then rejects the candidate\n// if the nodes fail an affinity test.  Also parallel arcs are rejected.\n// As more affine or denser graphs are requested, rejections increase,\n// increasing run time.  The patience argument controls the number of arc\n// rejections allowed before the function gives up and returns an error.\n// Note that higher affinity will require more patience and that some\n// combinations of nNodes and nArcs cannot be achieved with any amount of\n// patience given that the returned graph must be simple.\n//\n// If Rand r is nil, the method creates a new source and generator for\n// one-time use.\n//\n// Returned is a directed simple graph and associated positions indexed by\n// node number.\n//\n// See also LabeledEuclidean.\nfunc Euclidean(nNodes, nArcs int, affinity float64, patience int, r *rand.Rand) (g Directed, pos []struct{ X, Y float64 }, err error) {\n\ta := make(AdjacencyList, nNodes) // graph\n\t// generate random positions\n\tif r == nil {\n\t\tr = rand.New(rand.NewSource(time.Now().UnixNano()))\n\t}\n\tpos = make([]struct{ X, Y float64 }, nNodes)\n\tfor i := range pos {\n\t\tpos[i].X = r.Float64()\n\t\tpos[i].Y = r.Float64()\n\t}\n\t// arcs\n\tvar tooFar, dup int\narc:\n\tfor i := 0; i < nArcs; {\n\t\tif tooFar == nArcs*patience {\n\t\t\terr = errors.New(\"affinity not found\")\n\t\t\treturn\n\t\t}\n\t\tif dup == nArcs*patience {\n\t\t\terr = errors.New(\"overcrowding\")\n\t\t\treturn\n\t\t}\n\t\tn1 := NI(r.Intn(nNodes))\n\t\tvar n2 NI\n\t\tfor {\n\t\t\tn2 = NI(r.Intn(nNodes))\n\t\t\tif n2 != n1 { // no graph loops\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tc1 := &pos[n1]\n\t\tc2 := &pos[n2]\n\t\tdist := math.Hypot(c2.X-c1.X, c2.Y-c1.Y)\n\t\tif dist*affinity > r.ExpFloat64() { // favor near nodes\n\t\t\ttooFar++\n\t\t\tcontinue\n\t\t}\n\t\tfor _, nb := range a[n1] {\n\t\t\tif nb == n2 { // no parallel arcs\n\t\t\t\tdup++\n\t\t\t\tcontinue arc\n\t\t\t}\n\t\t}\n\t\ta[n1] = append(a[n1], n2)\n\t\ti++\n\t}\n\tg = Directed{a}\n\treturn\n}\n\n// LabeledEuclidean generates a random simple graph on the Euclidean plane.\n//\n// Arc label values in the returned graph g are indexes into the return value\n// wt.  Wt is the Euclidean distance between the from and to nodes of the arc.\n//\n// Otherwise the function arguments and return values are the same as for\n// function Euclidean.  See Euclidean.\nfunc LabeledEuclidean(nNodes, nArcs int, affinity float64, patience int, r *rand.Rand) (g LabeledDirected, pos []struct{ X, Y float64 }, wt []float64, err error) {\n\ta := make(LabeledAdjacencyList, nNodes) // graph\n\twt = make([]float64, nArcs)             // arc weights\n\t// generate random positions\n\tif r == nil {\n\t\tr = rand.New(rand.NewSource(time.Now().UnixNano()))\n\t}\n\tpos = make([]struct{ X, Y float64 }, nNodes)\n\tfor i := range pos {\n\t\tpos[i].X = r.Float64()\n\t\tpos[i].Y = r.Float64()\n\t}\n\t// arcs\n\tvar tooFar, dup int\narc:\n\tfor i := 0; i < nArcs; {\n\t\tif tooFar == nArcs*patience {\n\t\t\terr = errors.New(\"affinity not found\")\n\t\t\treturn\n\t\t}\n\t\tif dup == nArcs*patience {\n\t\t\terr = errors.New(\"overcrowding\")\n\t\t\treturn\n\t\t}\n\t\tn1 := NI(r.Intn(nNodes))\n\t\tvar n2 NI\n\t\tfor {\n\t\t\tn2 = NI(r.Intn(nNodes))\n\t\t\tif n2 != n1 { // no graph loops\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tc1 := &pos[n1]\n\t\tc2 := &pos[n2]\n\t\tdist := math.Hypot(c2.X-c1.X, c2.Y-c1.Y)\n\t\tif dist*affinity > r.ExpFloat64() { // favor near nodes\n\t\t\ttooFar++\n\t\t\tcontinue\n\t\t}\n\t\tfor _, nb := range a[n1] {\n\t\t\tif nb.To == n2 { // no parallel arcs\n\t\t\t\tdup++\n\t\t\t\tcontinue arc\n\t\t\t}\n\t\t}\n\t\twt[i] = dist\n\t\ta[n1] = append(a[n1], Half{n2, LI(i)})\n\t\ti++\n\t}\n\tg = LabeledDirected{a}\n\treturn\n}\n\n// Geometric generates a random geometric graph (RGG) on the Euclidean plane.\n//\n// An RGG is an undirected simple graph.  Nodes are associated with coordinates\n// uniformly distributed on a unit square.  Edges are added between all nodes\n// falling within a specified distance or radius of each other.\n//\n// The resulting number of edges is somewhat random but asymptotically\n// approaches m = πr²n²/2.   The method accumulates and returns the actual\n// number of edges constructed.\n//\n// If Rand r is nil, the method creates a new source and generator for\n// one-time use.\n//\n// See also LabeledGeometric.\nfunc Geometric(nNodes int, radius float64, r *rand.Rand) (g Undirected, pos []struct{ X, Y float64 }, m int) {\n\t// Expected degree is approximately nπr².\n\ta := make(AdjacencyList, nNodes)\n\tif r == nil {\n\t\tr = rand.New(rand.NewSource(time.Now().UnixNano()))\n\t}\n\tpos = make([]struct{ X, Y float64 }, nNodes)\n\tfor i := range pos {\n\t\tpos[i].X = r.Float64()\n\t\tpos[i].Y = r.Float64()\n\t}\n\tfor u, up := range pos {\n\t\tfor v := u + 1; v < len(pos); v++ {\n\t\t\tvp := pos[v]\n\t\t\tif math.Hypot(up.X-vp.X, up.Y-vp.Y) < radius {\n\t\t\t\ta[u] = append(a[u], NI(v))\n\t\t\t\ta[v] = append(a[v], NI(u))\n\t\t\t\tm++\n\t\t\t}\n\t\t}\n\t}\n\tg = Undirected{a}\n\treturn\n}\n\n// LabeledGeometric generates a random geometric graph (RGG) on the Euclidean\n// plane.\n//\n// Edge label values in the returned graph g are indexes into the return value\n// wt.  Wt is the Euclidean distance between nodes of the edge.  The graph\n// size m is len(wt).\n//\n// See Geometric for additional description.\nfunc LabeledGeometric(nNodes int, radius float64, r *rand.Rand) (g LabeledUndirected, pos []struct{ X, Y float64 }, wt []float64) {\n\ta := make(LabeledAdjacencyList, nNodes)\n\tif r == nil {\n\t\tr = rand.New(rand.NewSource(time.Now().UnixNano()))\n\t}\n\tpos = make([]struct{ X, Y float64 }, nNodes)\n\tfor i := range pos {\n\t\tpos[i].X = r.Float64()\n\t\tpos[i].Y = r.Float64()\n\t}\n\tfor u, up := range pos {\n\t\tfor v := u + 1; v < len(pos); v++ {\n\t\t\tvp := pos[v]\n\t\t\tif w := math.Hypot(up.X-vp.X, up.Y-vp.Y); w < radius {\n\t\t\t\ta[u] = append(a[u], Half{NI(v), LI(len(wt))})\n\t\t\t\ta[v] = append(a[v], Half{NI(u), LI(len(wt))})\n\t\t\t\twt = append(wt, w)\n\t\t\t}\n\t\t}\n\t}\n\tg = LabeledUndirected{a}\n\treturn\n}\n\n// KroneckerDirected generates a Kronecker-like random directed graph.\n//\n// The returned graph g is simple and has no isolated nodes but is not\n// necessarily fully connected.  The number of of nodes will be <= 2^scale,\n// and will be near 2^scale for typical values of arcFactor, >= 2.\n// ArcFactor * 2^scale arcs are generated, although loops and duplicate arcs\n// are rejected.\n//\n// If Rand r is nil, the method creates a new source and generator for\n// one-time use.\n//\n// Return value ma is the number of arcs retained in the result graph.\nfunc KroneckerDirected(scale uint, arcFactor float64, r *rand.Rand) (g Directed, ma int) {\n\ta, m := kronecker(scale, arcFactor, true, r)\n\treturn Directed{a}, m\n}\n\n// KroneckerUndirected generates a Kronecker-like random undirected graph.\n//\n// The returned graph g is simple and has no isolated nodes but is not\n// necessarily fully connected.  The number of of nodes will be <= 2^scale,\n// and will be near 2^scale for typical values of edgeFactor, >= 2.\n// EdgeFactor * 2^scale edges are generated, although loops and duplicate edges\n// are rejected.\n//\n// If Rand r is nil, the method creates a new source and generator for\n// one-time use.\n//\n// Return value m is the true number of edges--not arcs--retained in the result\n// graph.\nfunc KroneckerUndirected(scale uint, edgeFactor float64, r *rand.Rand) (g Undirected, m int) {\n\tal, s := kronecker(scale, edgeFactor, false, r)\n\treturn Undirected{al}, s\n}\n\n// Styled after the Graph500 example code.  Not well tested currently.\n// Graph500 example generates undirected only.  No idea if the directed variant\n// here is meaningful or not.\n//\n// note mma returns arc size ma for dir=true, but returns size m for dir=false\nfunc kronecker(scale uint, edgeFactor float64, dir bool, r *rand.Rand) (g AdjacencyList, mma int) {\n\tif r == nil {\n\t\tr = rand.New(rand.NewSource(time.Now().UnixNano()))\n\t}\n\tN := NI(1 << scale)                  // node extent\n\tM := int(edgeFactor*float64(N) + .5) // number of arcs/edges to generate\n\ta, b, c := 0.57, 0.19, 0.19          // initiator probabilities\n\tab := a + b\n\tcNorm := c / (1 - ab)\n\taNorm := a / ab\n\tij := make([][2]NI, M)\n\tvar bm Bits\n\tvar nNodes int\n\tfor k := range ij {\n\t\tvar i, j NI\n\t\tfor b := NI(1); b < N; b <<= 1 {\n\t\t\tif r.Float64() > ab {\n\t\t\t\ti |= b\n\t\t\t\tif r.Float64() > cNorm {\n\t\t\t\t\tj |= b\n\t\t\t\t}\n\t\t\t} else if r.Float64() > aNorm {\n\t\t\t\tj |= b\n\t\t\t}\n\t\t}\n\t\tif bm.Bit(i) == 0 {\n\t\t\tbm.SetBit(i, 1)\n\t\t\tnNodes++\n\t\t}\n\t\tif bm.Bit(j) == 0 {\n\t\t\tbm.SetBit(j, 1)\n\t\t\tnNodes++\n\t\t}\n\t\tr := r.Intn(k + 1) // shuffle edges as they are generated\n\t\tij[k] = ij[r]\n\t\tij[r] = [2]NI{i, j}\n\t}\n\tp := r.Perm(nNodes) // mapping to shuffle IDs of non-isolated nodes\n\tpx := 0\n\trn := make([]NI, N)\n\tfor i := range rn {\n\t\tif bm.Bit(NI(i)) == 1 {\n\t\t\trn[i] = NI(p[px]) // fill lookup table\n\t\t\tpx++\n\t\t}\n\t}\n\tg = make(AdjacencyList, nNodes)\nij:\n\tfor _, e := range ij {\n\t\tif e[0] == e[1] {\n\t\t\tcontinue // skip loops\n\t\t}\n\t\tri, rj := rn[e[0]], rn[e[1]]\n\t\tfor _, nb := range g[ri] {\n\t\t\tif nb == rj {\n\t\t\t\tcontinue ij // skip parallel edges\n\t\t\t}\n\t\t}\n\t\tg[ri] = append(g[ri], rj)\n\t\tmma++\n\t\tif !dir {\n\t\t\tg[rj] = append(g[rj], ri)\n\t\t}\n\t}\n\treturn\n}\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/readme.md",
    "content": "#Graph\n\nA graph library with goals of speed and simplicity, Graph implements\ngraph algorithms on graphs of zero-based integer node IDs.\n\n[![GoDoc](https://godoc.org/github.com/soniakeys/graph?status.svg)](https://godoc.org/github.com/soniakeys/graph) [![Go Walker](http://gowalker.org/api/v1/badge)](https://gowalker.org/github.com/soniakeys/graph) [![GoSearch](http://go-search.org/badge?id=github.com%2Fsoniakeys%2Fgraph)](http://go-search.org/view?id=github.com%2Fsoniakeys%2Fgraph)[![Build Status](https://travis-ci.org/soniakeys/graph.svg?branch=master)](https://travis-ci.org/soniakeys/graph)\n\nStatus, 4 Apr 2016:  The repo has benefitted recently from being included\nin another package.  In response to users of that package, this repo now\nbuilds for 32 bit Windows and ARM, and for Go versions back to 1.2.1.\nThank you all who have filed issues.\n\n###Non-source files of interest\n\nThe directory [tutorials](tutorials) is a work in progress - there are only\na couple of tutorials there yet - but the concept is to provide some topical\nwalk-throughs to supplement godoc.  The source-based godoc documentation\nremains the primary documentation.\n\n* [Dijkstra's algorithm](tutorials/dijkstra.md)\n* [AdjacencyList types](tutorials/adjacencylist.md)\n\nThe directory [bench](bench) is another work in progress.  The concept is\nto present some plots showing benchmark performance approaching some\ntheoretical asymptote.\n\n[hacking.md](hacking.md) has some information about how the library is\ndeveloped, built, and tested.  It might be of interest if for example you\nplan to fork or contribute to the the repository.\n\n###Test coverage\n8 Apr 2016\n```\ngraph          95.3%\ngraph/df       20.7%\ngraph/dot      77.5%\ngraph/treevis  79.4%\n```\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/sssp.go",
    "content": "// Copyright 2013 Sonia Keys\n// License MIT: http://opensource.org/licenses/MIT\n\npackage graph\n\nimport (\n\t\"container/heap\"\n\t\"fmt\"\n\t\"math\"\n)\n\n// rNode holds data for a \"reached\" node\ntype rNode struct {\n\tnx    NI\n\tstate int8    // state constants defined below\n\tf     float64 // \"g+h\", path dist + heuristic estimate\n\tfx    int     // heap.Fix index\n}\n\n// for rNode.state\nconst (\n\tunreached = 0\n\treached   = 1\n\topen      = 1\n\tclosed    = 2\n)\n\ntype openHeap []*rNode\n\n// A Heuristic is defined on a specific end node.  The function\n// returns an estimate of the path distance from node argument\n// \"from\" to the end node.  Two subclasses of heuristics are \"admissible\"\n// and \"monotonic.\"\n//\n// Admissible means the value returned is guaranteed to be less than or\n// equal to the actual shortest path distance from the node to end.\n//\n// An admissible estimate may further be monotonic.\n// Monotonic means that for any neighboring nodes A and B with half arc aB\n// leading from A to B, and for heuristic h defined on some end node, then\n// h(A) <= aB.ArcWeight + h(B).\n//\n// See AStarA for additional notes on implementing heuristic functions for\n// AStar search methods.\ntype Heuristic func(from NI) float64\n\n// Admissible returns true if heuristic h is admissible on graph g relative to\n// the given end node.\n//\n// If h is inadmissible, the string result describes a counter example.\nfunc (h Heuristic) Admissible(g LabeledAdjacencyList, w WeightFunc, end NI) (bool, string) {\n\t// invert graph\n\tinv := make(LabeledAdjacencyList, len(g))\n\tfor from, nbs := range g {\n\t\tfor _, nb := range nbs {\n\t\t\tinv[nb.To] = append(inv[nb.To],\n\t\t\t\tHalf{To: NI(from), Label: nb.Label})\n\t\t}\n\t}\n\t// run dijkstra\n\t// Dijkstra.AllPaths takes a start node but after inverting the graph\n\t// argument end now represents the start node of the inverted graph.\n\tf, dist, _ := inv.Dijkstra(end, -1, w)\n\t// compare h to found shortest paths\n\tfor n := range inv {\n\t\tif f.Paths[n].Len == 0 {\n\t\t\tcontinue // no path, any heuristic estimate is fine.\n\t\t}\n\t\tif !(h(NI(n)) <= dist[n]) {\n\t\t\treturn false, fmt.Sprintf(\"h(%d) = %g, \"+\n\t\t\t\t\"required to be <= found shortest path (%g)\",\n\t\t\t\tn, h(NI(n)), dist[n])\n\t\t}\n\t}\n\treturn true, \"\"\n}\n\n// Monotonic returns true if heuristic h is monotonic on weighted graph g.\n//\n// If h is non-monotonic, the string result describes a counter example.\nfunc (h Heuristic) Monotonic(g LabeledAdjacencyList, w WeightFunc) (bool, string) {\n\t// precompute\n\thv := make([]float64, len(g))\n\tfor n := range g {\n\t\thv[n] = h(NI(n))\n\t}\n\t// iterate over all edges\n\tfor from, nbs := range g {\n\t\tfor _, nb := range nbs {\n\t\t\tarcWeight := w(nb.Label)\n\t\t\tif !(hv[from] <= arcWeight+hv[nb.To]) {\n\t\t\t\treturn false, fmt.Sprintf(\"h(%d) = %g, \"+\n\t\t\t\t\t\"required to be <= arc weight + h(%d) (= %g + %g = %g)\",\n\t\t\t\t\tfrom, hv[from],\n\t\t\t\t\tnb.To, arcWeight, hv[nb.To], arcWeight+hv[nb.To])\n\t\t\t}\n\t\t}\n\t}\n\treturn true, \"\"\n}\n\n// AStarA finds a path between two nodes.\n//\n// AStarA implements both algorithm A and algorithm A*.  The difference in the\n// two algorithms is strictly in the heuristic estimate returned by argument h.\n// If h is an \"admissible\" heuristic estimate, then the algorithm is termed A*,\n// otherwise it is algorithm A.\n//\n// Like Dijkstra's algorithm, AStarA with an admissible heuristic finds the\n// shortest path between start and end.  AStarA generally runs faster than\n// Dijkstra though, by using the heuristic distance estimate.\n//\n// AStarA with an inadmissible heuristic becomes algorithm A.  Algorithm A\n// will find a path, but it is not guaranteed to be the shortest path.\n// The heuristic still guides the search however, so a nearly admissible\n// heuristic is likely to find a very good path, if not the best.  Quality\n// of the path returned degrades gracefully with the quality of the heuristic.\n//\n// The heuristic function h should ideally be fairly inexpensive.  AStarA\n// may call it more than once for the same node, especially as graph density\n// increases.  In some cases it may be worth the effort to memoize or\n// precompute values.\n//\n// Argument g is the graph to be searched, with arc weights returned by w.\n// As usual for AStar, arc weights must be non-negative.\n// Graphs may be directed or undirected.\n//\n// If AStarA finds a path it returns a FromList encoding the path, the arc\n// labels for path nodes, the total path distance, and ok = true.\n// Otherwise it returns ok = false.\nfunc (g LabeledAdjacencyList) AStarA(w WeightFunc, start, end NI, h Heuristic) (f FromList, labels []LI, dist float64, ok bool) {\n\t// NOTE: AStarM is largely duplicate code.\n\n\tf = NewFromList(len(g))\n\tlabels = make([]LI, len(g))\n\td := make([]float64, len(g))\n\tr := make([]rNode, len(g))\n\tfor i := range r {\n\t\tr[i].nx = NI(i)\n\t}\n\t// start node is reached initially\n\tcr := &r[start]\n\tcr.state = reached\n\tcr.f = h(start) // total path estimate is estimate from start\n\trp := f.Paths\n\trp[start] = PathEnd{Len: 1, From: -1} // path length at start is 1 node\n\t// oh is a heap of nodes \"open\" for exploration.  nodes go on the heap\n\t// when they get an initial or new \"g\" path distance, and therefore a\n\t// new \"f\" which serves as priority for exploration.\n\toh := openHeap{cr}\n\tfor len(oh) > 0 {\n\t\tbestPath := heap.Pop(&oh).(*rNode)\n\t\tbestNode := bestPath.nx\n\t\tif bestNode == end {\n\t\t\treturn f, labels, d[end], true\n\t\t}\n\t\tbp := &rp[bestNode]\n\t\tnextLen := bp.Len + 1\n\t\tfor _, nb := range g[bestNode] {\n\t\t\talt := &r[nb.To]\n\t\t\tap := &rp[alt.nx]\n\t\t\t// \"g\" path distance from start\n\t\t\tg := d[bestNode] + w(nb.Label)\n\t\t\tif alt.state == reached {\n\t\t\t\tif g > d[nb.To] {\n\t\t\t\t\t// candidate path to nb is longer than some alternate path\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif g == d[nb.To] && nextLen >= ap.Len {\n\t\t\t\t\t// candidate path has identical length of some alternate\n\t\t\t\t\t// path but it takes no fewer hops.\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\t// cool, we found a better way to get to this node.\n\t\t\t\t// record new path data for this node and\n\t\t\t\t// update alt with new data and make sure it's on the heap.\n\t\t\t\t*ap = PathEnd{From: bestNode, Len: nextLen}\n\t\t\t\tlabels[nb.To] = nb.Label\n\t\t\t\td[nb.To] = g\n\t\t\t\talt.f = g + h(nb.To)\n\t\t\t\tif alt.fx < 0 {\n\t\t\t\t\theap.Push(&oh, alt)\n\t\t\t\t} else {\n\t\t\t\t\theap.Fix(&oh, alt.fx)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// bestNode being reached for the first time.\n\t\t\t\t*ap = PathEnd{From: bestNode, Len: nextLen}\n\t\t\t\tlabels[nb.To] = nb.Label\n\t\t\t\td[nb.To] = g\n\t\t\t\talt.f = g + h(nb.To)\n\t\t\t\talt.state = reached\n\t\t\t\theap.Push(&oh, alt) // and it's now open for exploration\n\t\t\t}\n\t\t}\n\t}\n\treturn // no path\n}\n\n// AStarAPath finds a shortest path using the AStarA algorithm.\n//\n// This is a convenience method with a simpler result than the AStarA method.\n// See documentation on the AStarA method.\n//\n// If a path is found, the non-nil node path is returned with the total path\n// distance.  Otherwise the returned path will be nil.\nfunc (g LabeledAdjacencyList) AStarAPath(start, end NI, h Heuristic, w WeightFunc) ([]NI, float64) {\n\tf, _, d, _ := g.AStarA(w, start, end, h)\n\treturn f.PathTo(end, nil), d\n}\n\n// AStarM is AStarA optimized for monotonic heuristic estimates.\n//\n// Note that this function requires a monotonic heuristic.  Results will\n// not be meaningful if argument h is non-monotonic.\n//\n// See AStarA for general usage.  See Heuristic for notes on monotonicity.\nfunc (g LabeledAdjacencyList) AStarM(w WeightFunc, start, end NI, h Heuristic) (f FromList, labels []LI, dist float64, ok bool) {\n\t// NOTE: AStarM is largely code duplicated from AStarA.\n\t// Differences are noted in comments in this method.\n\n\tf = NewFromList(len(g))\n\tlabels = make([]LI, len(g))\n\td := make([]float64, len(g))\n\tr := make([]rNode, len(g))\n\tfor i := range r {\n\t\tr[i].nx = NI(i)\n\t}\n\tcr := &r[start]\n\n\t// difference from AStarA:\n\t// instead of a bit to mark a reached node, there are two states,\n\t// open and closed. open marks nodes \"open\" for exploration.\n\t// nodes are marked open as they are reached, then marked\n\t// closed as they are found to be on the best path.\n\tcr.state = open\n\n\tcr.f = h(start)\n\trp := f.Paths\n\trp[start] = PathEnd{Len: 1, From: -1}\n\toh := openHeap{cr}\n\tfor len(oh) > 0 {\n\t\tbestPath := heap.Pop(&oh).(*rNode)\n\t\tbestNode := bestPath.nx\n\t\tif bestNode == end {\n\t\t\treturn f, labels, d[end], true\n\t\t}\n\n\t\t// difference from AStarA:\n\t\t// move nodes to closed list as they are found to be best so far.\n\t\tbestPath.state = closed\n\n\t\tbp := &rp[bestNode]\n\t\tnextLen := bp.Len + 1\n\t\tfor _, nb := range g[bestNode] {\n\t\t\talt := &r[nb.To]\n\n\t\t\t// difference from AStarA:\n\t\t\t// Monotonicity means that f cannot be improved.\n\t\t\tif alt.state == closed {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tap := &rp[alt.nx]\n\t\t\tg := d[bestNode] + w(nb.Label)\n\n\t\t\t// difference from AStarA:\n\t\t\t// test for open state, not just reached\n\t\t\tif alt.state == open {\n\n\t\t\t\tif g > d[nb.To] {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif g == d[nb.To] && nextLen >= ap.Len {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\t*ap = PathEnd{From: bestNode, Len: nextLen}\n\t\t\t\tlabels[nb.To] = nb.Label\n\t\t\t\td[nb.To] = g\n\t\t\t\talt.f = g + h(nb.To)\n\n\t\t\t\t// difference from AStarA:\n\t\t\t\t// we know alt was on the heap because we found it marked open\n\t\t\t\theap.Fix(&oh, alt.fx)\n\t\t\t} else {\n\t\t\t\t*ap = PathEnd{From: bestNode, Len: nextLen}\n\t\t\t\tlabels[nb.To] = nb.Label\n\t\t\t\td[nb.To] = g\n\t\t\t\talt.f = g + h(nb.To)\n\n\t\t\t\t// difference from AStarA:\n\t\t\t\t// nodes are opened when first reached\n\t\t\t\talt.state = open\n\t\t\t\theap.Push(&oh, alt)\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}\n\n// AStarMPath finds a shortest path using the AStarM algorithm.\n//\n// This is a convenience method with a simpler result than the AStarM method.\n// See documentation on the AStarM and AStarA methods.\n//\n// If a path is found, the non-nil node path is returned with the total path\n// distance.  Otherwise the returned path will be nil.\nfunc (g LabeledAdjacencyList) AStarMPath(start, end NI, h Heuristic, w WeightFunc) ([]NI, float64) {\n\tf, _, d, _ := g.AStarM(w, start, end, h)\n\treturn f.PathTo(end, nil), d\n}\n\n// implement container/heap\nfunc (h openHeap) Len() int           { return len(h) }\nfunc (h openHeap) Less(i, j int) bool { return h[i].f < h[j].f }\nfunc (h openHeap) Swap(i, j int) {\n\th[i], h[j] = h[j], h[i]\n\th[i].fx = i\n\th[j].fx = j\n}\nfunc (p *openHeap) Push(x interface{}) {\n\th := *p\n\tfx := len(h)\n\th = append(h, x.(*rNode))\n\th[fx].fx = fx\n\t*p = h\n}\n\nfunc (p *openHeap) Pop() interface{} {\n\th := *p\n\tlast := len(h) - 1\n\t*p = h[:last]\n\th[last].fx = -1\n\treturn h[last]\n}\n\n// BellmanFord finds shortest paths from a start node in a weighted directed\n// graph using the Bellman-Ford-Moore algorithm.\n//\n// WeightFunc w must translate arc labels to arc weights.\n// Negative arc weights are allowed but not negative cycles.\n// Loops and parallel arcs are allowed.\n//\n// If the algorithm completes without encountering a negative cycle the method\n// returns shortest paths encoded in a FromList, path distances indexed by\n// node, and return value end = -1.\n//\n// If it encounters a negative cycle reachable from start it returns end >= 0.\n// In this case the cycle can be obtained by calling f.BellmanFordCycle(end).\n//\n// Negative cycles are only detected when reachable from start.  A negative\n// cycle not reachable from start will not prevent the algorithm from finding\n// shortest paths from start.\n//\n// See also NegativeCycle to find a cycle anywhere in the graph, and see\n// HasNegativeCycle for lighter-weight negative cycle detection,\nfunc (g LabeledDirected) BellmanFord(w WeightFunc, start NI) (f FromList, dist []float64, end NI) {\n\ta := g.LabeledAdjacencyList\n\tf = NewFromList(len(a))\n\tdist = make([]float64, len(a))\n\tinf := math.Inf(1)\n\tfor i := range dist {\n\t\tdist[i] = inf\n\t}\n\trp := f.Paths\n\trp[start] = PathEnd{Len: 1, From: -1}\n\tdist[start] = 0\n\tfor _ = range a[1:] {\n\t\timp := false\n\t\tfor from, nbs := range a {\n\t\t\tfp := &rp[from]\n\t\t\td1 := dist[from]\n\t\t\tfor _, nb := range nbs {\n\t\t\t\td2 := d1 + w(nb.Label)\n\t\t\t\tto := &rp[nb.To]\n\t\t\t\t// TODO improve to break ties\n\t\t\t\tif fp.Len > 0 && d2 < dist[nb.To] {\n\t\t\t\t\t*to = PathEnd{From: NI(from), Len: fp.Len + 1}\n\t\t\t\t\tdist[nb.To] = d2\n\t\t\t\t\timp = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif !imp {\n\t\t\tbreak\n\t\t}\n\t}\n\tfor from, nbs := range a {\n\t\td1 := dist[from]\n\t\tfor _, nb := range nbs {\n\t\t\tif d1+w(nb.Label) < dist[nb.To] {\n\t\t\t\t// return nb as end of a path with negative cycle at root\n\t\t\t\treturn f, dist, NI(from)\n\t\t\t}\n\t\t}\n\t}\n\treturn f, dist, -1\n}\n\n// BellmanFordCycle decodes a negative cycle detected by BellmanFord.\n//\n// Receiver f and argument end must be results returned from BellmanFord.\nfunc (f FromList) BellmanFordCycle(end NI) (c []NI) {\n\tp := f.Paths\n\tvar b Bits\n\tfor b.Bit(end) == 0 {\n\t\tb.SetBit(end, 1)\n\t\tend = p[end].From\n\t}\n\tfor b.Bit(end) == 1 {\n\t\tc = append(c, end)\n\t\tb.SetBit(end, 0)\n\t\tend = p[end].From\n\t}\n\tfor i, j := 0, len(c)-1; i < j; i, j = i+1, j-1 {\n\t\tc[i], c[j] = c[j], c[i]\n\t}\n\treturn\n}\n\n// HasNegativeCycle returns true if the graph contains any negative cycle.\n//\n// HasNegativeCycle uses a Bellman-Ford-like algorithm, but finds negative\n// cycles anywhere in the graph.  Also path information is not computed,\n// reducing memory use somewhat compared to BellmanFord.\n//\n// See also NegativeCycle to obtain the cycle, and see BellmanFord for\n// single source shortest path searches.\nfunc (g LabeledDirected) HasNegativeCycle(w WeightFunc) bool {\n\ta := g.LabeledAdjacencyList\n\tdist := make([]float64, len(a))\n\tfor _ = range a[1:] {\n\t\timp := false\n\t\tfor from, nbs := range a {\n\t\t\td1 := dist[from]\n\t\t\tfor _, nb := range nbs {\n\t\t\t\td2 := d1 + w(nb.Label)\n\t\t\t\tif d2 < dist[nb.To] {\n\t\t\t\t\tdist[nb.To] = d2\n\t\t\t\t\timp = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif !imp {\n\t\t\tbreak\n\t\t}\n\t}\n\tfor from, nbs := range a {\n\t\td1 := dist[from]\n\t\tfor _, nb := range nbs {\n\t\t\tif d1+w(nb.Label) < dist[nb.To] {\n\t\t\t\treturn true // negative cycle\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\n// NegativeCycle finds a negative cycle if one exists.\n//\n// NegativeCycle uses a Bellman-Ford-like algorithm, but finds negative\n// cycles anywhere in the graph.  If a negative cycle exists, one will be\n// returned.  The result is nil if no negative cycle exists.\n//\n// See also HasNegativeCycle for lighter-weight cycle detection, and see\n// BellmanFord for single source shortest paths.\nfunc (g LabeledDirected) NegativeCycle(w WeightFunc) (c []NI) {\n\ta := g.LabeledAdjacencyList\n\tf := NewFromList(len(a))\n\tp := f.Paths\n\tfor n := range p {\n\t\tp[n] = PathEnd{From: -1, Len: 1}\n\t}\n\tdist := make([]float64, len(a))\n\tfor _ = range a {\n\t\timp := false\n\t\tfor from, nbs := range a {\n\t\t\tfp := &p[from]\n\t\t\td1 := dist[from]\n\t\t\tfor _, nb := range nbs {\n\t\t\t\td2 := d1 + w(nb.Label)\n\t\t\t\tto := &p[nb.To]\n\t\t\t\tif fp.Len > 0 && d2 < dist[nb.To] {\n\t\t\t\t\t*to = PathEnd{From: NI(from), Len: fp.Len + 1}\n\t\t\t\t\tdist[nb.To] = d2\n\t\t\t\t\timp = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif !imp {\n\t\t\treturn nil\n\t\t}\n\t}\n\tvar vis Bits\na:\n\tfor n := range a {\n\t\tend := NI(n)\n\t\tvar b Bits\n\t\tfor b.Bit(end) == 0 {\n\t\t\tif vis.Bit(end) == 1 {\n\t\t\t\tcontinue a\n\t\t\t}\n\t\t\tvis.SetBit(end, 1)\n\t\t\tb.SetBit(end, 1)\n\t\t\tend = p[end].From\n\t\t\tif end < 0 {\n\t\t\t\tcontinue a\n\t\t\t}\n\t\t}\n\t\tfor b.Bit(end) == 1 {\n\t\t\tc = append(c, end)\n\t\t\tb.SetBit(end, 0)\n\t\t\tend = p[end].From\n\t\t}\n\t\tfor i, j := 0, len(c)-1; i < j; i, j = i+1, j-1 {\n\t\t\tc[i], c[j] = c[j], c[i]\n\t\t}\n\t\treturn c\n\t}\n\treturn nil // no negative cycle\n}\n\n// A NodeVisitor is an argument to some graph traversal methods.\n//\n// Graph traversal methods call the visitor function for each node visited.\n// Argument n is the node being visited.\ntype NodeVisitor func(n NI)\n\n// An OkNodeVisitor function is an argument to some graph traversal methods.\n//\n// Graph traversal methods call the visitor function for each node visited.\n// The argument n is the node being visited.  If the visitor function\n// returns true, the traversal will continue.  If the visitor function\n// returns false, the traversal will terminate immediately.\ntype OkNodeVisitor func(n NI) (ok bool)\n\n// BreadthFirst2 traverses a graph breadth first using a direction\n// optimizing algorithm.\n//\n// The code is experimental and currently seems no faster than the\n// conventional breadth first code.\n//\n// Use AdjacencyList.BreadthFirst instead.\nfunc BreadthFirst2(g, tr AdjacencyList, ma int, start NI, f *FromList, v OkNodeVisitor) int {\n\tif tr == nil {\n\t\tvar d Directed\n\t\td, ma = Directed{g}.Transpose()\n\t\ttr = d.AdjacencyList\n\t}\n\tswitch {\n\tcase f == nil:\n\t\te := NewFromList(len(g))\n\t\tf = &e\n\tcase f.Paths == nil:\n\t\t*f = NewFromList(len(g))\n\t}\n\tif ma <= 0 {\n\t\tma = g.ArcSize()\n\t}\n\trp := f.Paths\n\tlevel := 1\n\trp[start] = PathEnd{Len: level, From: -1}\n\tif !v(start) {\n\t\tf.MaxLen = level\n\t\treturn -1\n\t}\n\tnReached := 1 // accumulated for a return value\n\t// the frontier consists of nodes all at the same level\n\tfrontier := []NI{start}\n\tmf := len(g[start])     // number of arcs leading out from frontier\n\tctb := ma / 10          // threshold change from top-down to bottom-up\n\tk14 := 14 * ma / len(g) // 14 * mean degree\n\tcbt := len(g) / k14     // threshold change from bottom-up to top-down\n\t//\tvar fBits, nextb big.Int\n\tfBits := make([]bool, len(g))\n\tnextb := make([]bool, len(g))\n\tzBits := make([]bool, len(g))\n\tfor {\n\t\t// top down step\n\t\tlevel++\n\t\tvar next []NI\n\t\tfor _, n := range frontier {\n\t\t\tfor _, nb := range g[n] {\n\t\t\t\tif rp[nb].Len == 0 {\n\t\t\t\t\trp[nb] = PathEnd{From: n, Len: level}\n\t\t\t\t\tif !v(nb) {\n\t\t\t\t\t\tf.MaxLen = level\n\t\t\t\t\t\treturn -1\n\t\t\t\t\t}\n\t\t\t\t\tnext = append(next, nb)\n\t\t\t\t\tnReached++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif len(next) == 0 {\n\t\t\tbreak\n\t\t}\n\t\tfrontier = next\n\t\tif mf > ctb {\n\t\t\t// switch to bottom up!\n\t\t} else {\n\t\t\t// stick with top down\n\t\t\tcontinue\n\t\t}\n\t\t// convert frontier representation\n\t\tnf := 0 // number of vertices on the frontier\n\t\tfor _, n := range frontier {\n\t\t\t//\t\t\tfBits.SetBit(&fBits, n, 1)\n\t\t\tfBits[n] = true\n\t\t\tnf++\n\t\t}\n\tbottomUpLoop:\n\t\tlevel++\n\t\tnNext := 0\n\t\tfor n := range tr {\n\t\t\tif rp[n].Len == 0 {\n\t\t\t\tfor _, nb := range tr[n] {\n\t\t\t\t\t//\t\t\t\t\tif fBits.Bit(nb) == 1 {\n\t\t\t\t\tif fBits[nb] {\n\t\t\t\t\t\trp[n] = PathEnd{From: nb, Len: level}\n\t\t\t\t\t\tif !v(nb) {\n\t\t\t\t\t\t\tf.MaxLen = level\n\t\t\t\t\t\t\treturn -1\n\t\t\t\t\t\t}\n\t\t\t\t\t\t//\t\t\t\t\t\tnextb.SetBit(&nextb, n, 1)\n\t\t\t\t\t\tnextb[n] = true\n\t\t\t\t\t\tnReached++\n\t\t\t\t\t\tnNext++\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif nNext == 0 {\n\t\t\tbreak\n\t\t}\n\t\tfBits, nextb = nextb, fBits\n\t\t//\t\tnextb.SetInt64(0)\n\t\tcopy(nextb, zBits)\n\t\tnf = nNext\n\t\tif nf < cbt {\n\t\t\t// switch back to top down!\n\t\t} else {\n\t\t\t// stick with bottom up\n\t\t\tgoto bottomUpLoop\n\t\t}\n\t\t// convert frontier representation\n\t\tmf = 0\n\t\tfrontier = frontier[:0]\n\t\tfor n := range g {\n\t\t\t//\t\t\tif fBits.Bit(n) == 1 {\n\t\t\tif fBits[n] {\n\t\t\t\tfrontier = append(frontier, NI(n))\n\t\t\t\tmf += len(g[n])\n\t\t\t\tfBits[n] = false\n\t\t\t}\n\t\t}\n\t\t//\t\tfBits.SetInt64(0)\n\t}\n\tf.MaxLen = level - 1\n\treturn nReached\n}\n\n// DAGMinDistPath finds a single shortest path.\n//\n// Shortest means minimum sum of arc weights.\n//\n// Returned is the path and distance as returned by FromList.PathTo.\n//\n// This is a convenience method.  See DAGOptimalPaths for more options.\nfunc (g LabeledDirected) DAGMinDistPath(start, end NI, w WeightFunc) ([]NI, float64, error) {\n\treturn g.dagPath(start, end, w, false)\n}\n\n// DAGMaxDistPath finds a single longest path.\n//\n// Longest means maximum sum of arc weights.\n//\n// Returned is the path and distance as returned by FromList.PathTo.\n//\n// This is a convenience method.  See DAGOptimalPaths for more options.\nfunc (g LabeledDirected) DAGMaxDistPath(start, end NI, w WeightFunc) ([]NI, float64, error) {\n\treturn g.dagPath(start, end, w, true)\n}\n\nfunc (g LabeledDirected) dagPath(start, end NI, w WeightFunc, longest bool) ([]NI, float64, error) {\n\to, _ := g.Topological()\n\tif o == nil {\n\t\treturn nil, 0, fmt.Errorf(\"not a DAG\")\n\t}\n\tf, dist, _ := g.DAGOptimalPaths(start, end, o, w, longest)\n\tif f.Paths[end].Len == 0 {\n\t\treturn nil, 0, fmt.Errorf(\"no path from %d to %d\", start, end)\n\t}\n\treturn f.PathTo(end, nil), dist[end], nil\n}\n\n// DAGOptimalPaths finds either longest or shortest distance paths in a\n// directed acyclic graph.\n//\n// Path distance is the sum of arc weights on the path.\n// Negative arc weights are allowed.\n// Where multiple paths exist with the same distance, the path length\n// (number of nodes) is used as a tie breaker.\n//\n// Receiver g must be a directed acyclic graph.  Argument o must be either nil\n// or a topological ordering of g.  If nil, a topologcal ordering is\n// computed internally.  If longest is true, an optimal path is a longest\n// distance path.  Otherwise it is a shortest distance path.\n//\n// Argument start is the start node for paths, end is the end node.  If end\n// is a valid node number, the method returns as soon as the optimal path\n// to end is found.  If end is -1, all optimal paths from start are found.\n//\n// Paths and path distances are encoded in the returned FromList and dist\n// slice.   The number of nodes reached is returned as nReached.\nfunc (g LabeledDirected) DAGOptimalPaths(start, end NI, ordering []NI, w WeightFunc, longest bool) (f FromList, dist []float64, nReached int) {\n\ta := g.LabeledAdjacencyList\n\tf = NewFromList(len(a))\n\tdist = make([]float64, len(a))\n\tif ordering == nil {\n\t\tordering, _ = g.Topological()\n\t}\n\t// search ordering for start\n\to := 0\n\tfor ordering[o] != start {\n\t\to++\n\t}\n\tvar fBetter func(cand, ext float64) bool\n\tvar iBetter func(cand, ext int) bool\n\tif longest {\n\t\tfBetter = func(cand, ext float64) bool { return cand > ext }\n\t\tiBetter = func(cand, ext int) bool { return cand > ext }\n\t} else {\n\t\tfBetter = func(cand, ext float64) bool { return cand < ext }\n\t\tiBetter = func(cand, ext int) bool { return cand < ext }\n\t}\n\tp := f.Paths\n\tp[start] = PathEnd{From: -1, Len: 1}\n\tf.MaxLen = 1\n\tleaves := &f.Leaves\n\tleaves.SetBit(start, 1)\n\tnReached = 1\n\tfor n := start; n != end; n = ordering[o] {\n\t\tif p[n].Len > 0 && len(a[n]) > 0 {\n\t\t\tnDist := dist[n]\n\t\t\tcandLen := p[n].Len + 1 // len for any candidate arc followed from n\n\t\t\tfor _, to := range a[n] {\n\t\t\t\tleaves.SetBit(to.To, 1)\n\t\t\t\tcandDist := nDist + w(to.Label)\n\t\t\t\tswitch {\n\t\t\t\tcase p[to.To].Len == 0: // first path to node to.To\n\t\t\t\t\tnReached++\n\t\t\t\tcase fBetter(candDist, dist[to.To]): // better distance\n\t\t\t\tcase candDist == dist[to.To] && iBetter(candLen, p[to.To].Len): // same distance but better path length\n\t\t\t\tdefault:\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tdist[to.To] = candDist\n\t\t\t\tp[to.To] = PathEnd{From: n, Len: candLen}\n\t\t\t\tif candLen > f.MaxLen {\n\t\t\t\t\tf.MaxLen = candLen\n\t\t\t\t}\n\t\t\t}\n\t\t\tleaves.SetBit(n, 0)\n\t\t}\n\t\to++\n\t\tif o == len(ordering) {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn\n}\n\n// Dijkstra finds shortest paths by Dijkstra's algorithm.\n//\n// Shortest means shortest distance where distance is the\n// sum of arc weights.  Where multiple paths exist with the same distance,\n// a path with the minimum number of nodes is returned.\n//\n// As usual for Dijkstra's algorithm, arc weights must be non-negative.\n// Graphs may be directed or undirected.  Loops and parallel arcs are\n// allowed.\nfunc (g LabeledAdjacencyList) Dijkstra(start, end NI, w WeightFunc) (f FromList, dist []float64, reached int) {\n\tr := make([]tentResult, len(g))\n\tfor i := range r {\n\t\tr[i].nx = NI(i)\n\t}\n\tf = NewFromList(len(g))\n\tdist = make([]float64, len(g))\n\tcurrent := start\n\trp := f.Paths\n\trp[current] = PathEnd{Len: 1, From: -1} // path length at start is 1 node\n\tcr := &r[current]\n\tcr.dist = 0    // distance at start is 0.\n\tcr.done = true // mark start done.  it skips the heap.\n\tnDone := 1     // accumulated for a return value\n\tvar t tent\n\tfor current != end {\n\t\tnextLen := rp[current].Len + 1\n\t\tfor _, nb := range g[current] {\n\t\t\t// d.arcVis++\n\t\t\thr := &r[nb.To]\n\t\t\tif hr.done {\n\t\t\t\tcontinue // skip nodes already done\n\t\t\t}\n\t\t\tdist := cr.dist + w(nb.Label)\n\t\t\tvl := rp[nb.To].Len\n\t\t\tvisited := vl > 0\n\t\t\tif visited {\n\t\t\t\tif dist > hr.dist {\n\t\t\t\t\tcontinue // distance is worse\n\t\t\t\t}\n\t\t\t\t// tie breaker is a nice touch and doesn't seem to\n\t\t\t\t// impact performance much.\n\t\t\t\tif dist == hr.dist && nextLen >= vl {\n\t\t\t\t\tcontinue // distance same, but number of nodes is no better\n\t\t\t\t}\n\t\t\t}\n\t\t\t// the path through current to this node is shortest so far.\n\t\t\t// record new path data for this node and update tentative set.\n\t\t\thr.dist = dist\n\t\t\trp[nb.To].Len = nextLen\n\t\t\trp[nb.To].From = current\n\t\t\tif visited {\n\t\t\t\theap.Fix(&t, hr.fx)\n\t\t\t} else {\n\t\t\t\theap.Push(&t, hr)\n\t\t\t}\n\t\t}\n\t\t//d.ndVis++\n\t\tif len(t) == 0 {\n\t\t\treturn f, dist, nDone // no more reachable nodes. AllPaths normal return\n\t\t}\n\t\t// new current is node with smallest tentative distance\n\t\tcr = heap.Pop(&t).(*tentResult)\n\t\tcr.done = true\n\t\tnDone++\n\t\tcurrent = cr.nx\n\t\tdist[current] = cr.dist // store final distance\n\t}\n\t// normal return for single shortest path search\n\treturn f, dist, -1\n}\n\n// DijkstraPath finds a single shortest path.\n//\n// Returned is the path and distance as returned by FromList.PathTo.\nfunc (g LabeledAdjacencyList) DijkstraPath(start, end NI, w WeightFunc) ([]NI, float64) {\n\tf, dist, _ := g.Dijkstra(start, end, w)\n\treturn f.PathTo(end, nil), dist[end]\n}\n\n// tent implements container/heap\nfunc (t tent) Len() int           { return len(t) }\nfunc (t tent) Less(i, j int) bool { return t[i].dist < t[j].dist }\nfunc (t tent) Swap(i, j int) {\n\tt[i], t[j] = t[j], t[i]\n\tt[i].fx = i\n\tt[j].fx = j\n}\nfunc (s *tent) Push(x interface{}) {\n\tnd := x.(*tentResult)\n\tnd.fx = len(*s)\n\t*s = append(*s, nd)\n}\nfunc (s *tent) Pop() interface{} {\n\tt := *s\n\tlast := len(t) - 1\n\t*s = t[:last]\n\treturn t[last]\n}\n\ntype tentResult struct {\n\tdist float64 // tentative distance, sum of arc weights\n\tnx   NI      // slice index, \"node id\"\n\tfx   int     // heap.Fix index\n\tdone bool\n}\n\ntype tent []*tentResult\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/travis.sh",
    "content": "#!/bin/bash\nset -ex\ngo test ./...\nif [ \"$TRAVIS_GO_VERSION\" = \"1.6\" ]; then\n GOARCH=386 go test ./...\n go tool vet -example .\n go get github.com/client9/misspell/cmd/misspell\n go get github.com/soniakeys/vetc\n misspell -error * */* */*/*\n vetc\nfi\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/undir.go",
    "content": "// Copyright 2014 Sonia Keys\n// License MIT: http://opensource.org/licenses/MIT\n\npackage graph\n\n// undir.go has methods specific to undirected graphs, Undirected and\n// LabeledUndirected.\n\nimport \"errors\"\n\n// AddEdge adds an edge to a graph.\n//\n// It can be useful for constructing undirected graphs.\n//\n// When n1 and n2 are distinct, it adds the arc n1->n2 and the reciprocal\n// n2->n1.  When n1 and n2 are the same, it adds a single arc loop.\n//\n// The pointer receiver allows the method to expand the graph as needed\n// to include the values n1 and n2.  If n1 or n2 happen to be greater than\n// len(*p) the method does not panic, but simply expands the graph.\nfunc (p *Undirected) AddEdge(n1, n2 NI) {\n\t// Similar code in LabeledAdjacencyList.AddEdge.\n\n\t// determine max of the two end points\n\tmax := n1\n\tif n2 > max {\n\t\tmax = n2\n\t}\n\t// expand graph if needed, to include both\n\tg := p.AdjacencyList\n\tif int(max) >= len(g) {\n\t\tp.AdjacencyList = make(AdjacencyList, max+1)\n\t\tcopy(p.AdjacencyList, g)\n\t\tg = p.AdjacencyList\n\t}\n\t// create one half-arc,\n\tg[n1] = append(g[n1], n2)\n\t// and except for loops, create the reciprocal\n\tif n1 != n2 {\n\t\tg[n2] = append(g[n2], n1)\n\t}\n}\n\n// EulerianCycleD for undirected graphs is a bit of an experiment.\n//\n// It is about the same as the directed version, but modified for an undirected\n// multigraph.\n//\n// Parameter m in this case must be the size of the undirected graph -- the\n// number of edges.  Use Undirected.Size if the size is unknown.\n//\n// It works, but contains an extra loop that I think spoils the time\n// complexity.  Probably still pretty fast in practice, but a different\n// graph representation might be better.\nfunc (g Undirected) EulerianCycleD(m int) ([]NI, error) {\n\tif len(g.AdjacencyList) == 0 {\n\t\treturn nil, nil\n\t}\n\te := newEulerian(g.AdjacencyList, m)\n\tfor e.s >= 0 {\n\t\tv := e.top()\n\t\te.pushUndir() // call modified method\n\t\tif e.top() != v {\n\t\t\treturn nil, errors.New(\"not balanced\")\n\t\t}\n\t\te.keep()\n\t}\n\tif !e.uv.Zero() {\n\t\treturn nil, errors.New(\"not strongly connected\")\n\t}\n\treturn e.p, nil\n}\n\n// TarjanBiconnectedComponents decomposes a graph into maximal biconnected\n// components, components for which if any node were removed the component\n// would remain connected.\n//\n// The receiver g must be a simple graph.  The method calls the emit argument\n// for each component identified, as long as emit returns true.  If emit\n// returns false, TarjanBiconnectedComponents returns immediately.\n//\n// See also the eqivalent labeled TarjanBiconnectedComponents.\nfunc (g Undirected) TarjanBiconnectedComponents(emit func([]Edge) bool) {\n\t// Implemented closely to pseudocode in \"Depth-first search and linear\n\t// graph algorithms\", Robert Tarjan, SIAM J. Comput. Vol. 1, No. 2,\n\t// June 1972.\n\t//\n\t// Note Tarjan's \"adjacency structure\" is graph.AdjacencyList,\n\t// His \"adjacency list\" is an element of a graph.AdjacencyList, also\n\t// termed a \"to-list\", \"neighbor list\", or \"child list.\"\n\tnumber := make([]int, len(g.AdjacencyList))\n\tlowpt := make([]int, len(g.AdjacencyList))\n\tvar stack []Edge\n\tvar i int\n\tvar biconnect func(NI, NI) bool\n\tbiconnect = func(v, u NI) bool {\n\t\ti++\n\t\tnumber[v] = i\n\t\tlowpt[v] = i\n\t\tfor _, w := range g.AdjacencyList[v] {\n\t\t\tif number[w] == 0 {\n\t\t\t\tstack = append(stack, Edge{v, w})\n\t\t\t\tif !biconnect(w, v) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tif lowpt[w] < lowpt[v] {\n\t\t\t\t\tlowpt[v] = lowpt[w]\n\t\t\t\t}\n\t\t\t\tif lowpt[w] >= number[v] {\n\t\t\t\t\tvar bcc []Edge\n\t\t\t\t\ttop := len(stack) - 1\n\t\t\t\t\tfor number[stack[top].N1] >= number[w] {\n\t\t\t\t\t\tbcc = append(bcc, stack[top])\n\t\t\t\t\t\tstack = stack[:top]\n\t\t\t\t\t\ttop--\n\t\t\t\t\t}\n\t\t\t\t\tbcc = append(bcc, stack[top])\n\t\t\t\t\tstack = stack[:top]\n\t\t\t\t\ttop--\n\t\t\t\t\tif !emit(bcc) {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if number[w] < number[v] && w != u {\n\t\t\t\tstack = append(stack, Edge{v, w})\n\t\t\t\tif number[w] < lowpt[v] {\n\t\t\t\t\tlowpt[v] = number[w]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\tfor w := range g.AdjacencyList {\n\t\tif number[w] == 0 && !biconnect(NI(w), 0) {\n\t\t\treturn\n\t\t}\n\t}\n}\n\n/* half-baked.  Read the 72 paper.  Maybe revisit at some point.\ntype BiconnectedComponents struct {\n\tGraph  AdjacencyList\n\tStart  int\n\tCuts   big.Int // bitmap of node cuts\n\tFrom   []int   // from-tree\n\tLeaves []int   // leaves of from-tree\n}\n\nfunc NewBiconnectedComponents(g Undirected) *BiconnectedComponents {\n\treturn &BiconnectedComponents{\n\t\tGraph: g,\n\t\tFrom:  make([]int, len(g)),\n\t}\n}\n\nfunc (b *BiconnectedComponents) Find(start int) {\n\tg := b.Graph\n\tdepth := make([]int, len(g))\n\tlow := make([]int, len(g))\n\t// reset from any previous run\n\tb.Cuts.SetInt64(0)\n\tbf := b.From\n\tfor n := range bf {\n\t\tbf[n] = -1\n\t}\n\tb.Leaves = b.Leaves[:0]\n\td := 1 // depth. d > 0 means visited\n\tdepth[start] = d\n\tlow[start] = d\n\td++\n\tvar df func(int, int)\n\tdf = func(from, n int) {\n\t\tbf[n] = from\n\t\tdepth[n] = d\n\t\tdn := d\n\t\tl := d\n\t\td++\n\t\tcut := false\n\t\tleaf := true\n\t\tfor _, nb := range g[n] {\n\t\t\tif depth[nb] == 0 {\n\t\t\t\tleaf = false\n\t\t\t\tdf(n, nb)\n\t\t\t\tif low[nb] < l {\n\t\t\t\t\tl = low[nb]\n\t\t\t\t}\n\t\t\t\tif low[nb] >= dn {\n\t\t\t\t\tcut = true\n\t\t\t\t}\n\t\t\t} else if nb != from && depth[nb] < l {\n\t\t\t\tl = depth[nb]\n\t\t\t}\n\t\t}\n\t\tlow[n] = l\n\t\tif cut {\n\t\t\tb.Cuts.SetBit(&b.Cuts, n, 1)\n\t\t}\n\t\tif leaf {\n\t\t\tb.Leaves = append(b.Leaves, n)\n\t\t}\n\t\td--\n\t}\n\tnbs := g[start]\n\tif len(nbs) == 0 {\n\t\treturn\n\t}\n\tdf(start, nbs[0])\n\tvar rc uint\n\tfor _, nb := range nbs[1:] {\n\t\tif depth[nb] == 0 {\n\t\t\trc = 1\n\t\t\tdf(start, nb)\n\t\t}\n\t}\n\tb.Cuts.SetBit(&b.Cuts, start, rc)\n\treturn\n}\n*/\n\n// AddEdge adds an edge to a labeled graph.\n//\n// It can be useful for constructing undirected graphs.\n//\n// When n1 and n2 are distinct, it adds the arc n1->n2 and the reciprocal\n// n2->n1.  When n1 and n2 are the same, it adds a single arc loop.\n//\n// If the edge already exists in *p, a parallel edge is added.\n//\n// The pointer receiver allows the method to expand the graph as needed\n// to include the values n1 and n2.  If n1 or n2 happen to be greater than\n// len(*p) the method does not panic, but simply expands the graph.\nfunc (p *LabeledUndirected) AddEdge(e Edge, l LI) {\n\t// Similar code in AdjacencyList.AddEdge.\n\n\t// determine max of the two end points\n\tmax := e.N1\n\tif e.N2 > max {\n\t\tmax = e.N2\n\t}\n\t// expand graph if needed, to include both\n\tg := p.LabeledAdjacencyList\n\tif max >= NI(len(g)) {\n\t\tp.LabeledAdjacencyList = make(LabeledAdjacencyList, max+1)\n\t\tcopy(p.LabeledAdjacencyList, g)\n\t\tg = p.LabeledAdjacencyList\n\t}\n\t// create one half-arc,\n\tg[e.N1] = append(g[e.N1], Half{To: e.N2, Label: l})\n\t// and except for loops, create the reciprocal\n\tif e.N1 != e.N2 {\n\t\tg[e.N2] = append(g[e.N2], Half{To: e.N1, Label: l})\n\t}\n}\n\n// TarjanBiconnectedComponents decomposes a graph into maximal biconnected\n// components, components for which if any node were removed the component\n// would remain connected.\n//\n// The receiver g must be a simple graph.  The method calls the emit argument\n// for each component identified, as long as emit returns true.  If emit\n// returns false, TarjanBiconnectedComponents returns immediately.\n//\n// See also the eqivalent unlabeled TarjanBiconnectedComponents.\nfunc (g LabeledUndirected) TarjanBiconnectedComponents(emit func([]LabeledEdge) bool) {\n\t// Implemented closely to pseudocode in \"Depth-first search and linear\n\t// graph algorithms\", Robert Tarjan, SIAM J. Comput. Vol. 1, No. 2,\n\t// June 1972.\n\t//\n\t// Note Tarjan's \"adjacency structure\" is graph.AdjacencyList,\n\t// His \"adjacency list\" is an element of a graph.AdjacencyList, also\n\t// termed a \"to-list\", \"neighbor list\", or \"child list.\"\n\t//\n\t// Nearly identical code in undir.go.\n\tnumber := make([]int, len(g.LabeledAdjacencyList))\n\tlowpt := make([]int, len(g.LabeledAdjacencyList))\n\tvar stack []LabeledEdge\n\tvar i int\n\tvar biconnect func(NI, NI) bool\n\tbiconnect = func(v, u NI) bool {\n\t\ti++\n\t\tnumber[v] = i\n\t\tlowpt[v] = i\n\t\tfor _, w := range g.LabeledAdjacencyList[v] {\n\t\t\tif number[w.To] == 0 {\n\t\t\t\tstack = append(stack, LabeledEdge{Edge{v, w.To}, w.Label})\n\t\t\t\tif !biconnect(w.To, v) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tif lowpt[w.To] < lowpt[v] {\n\t\t\t\t\tlowpt[v] = lowpt[w.To]\n\t\t\t\t}\n\t\t\t\tif lowpt[w.To] >= number[v] {\n\t\t\t\t\tvar bcc []LabeledEdge\n\t\t\t\t\ttop := len(stack) - 1\n\t\t\t\t\tfor number[stack[top].N1] >= number[w.To] {\n\t\t\t\t\t\tbcc = append(bcc, stack[top])\n\t\t\t\t\t\tstack = stack[:top]\n\t\t\t\t\t\ttop--\n\t\t\t\t\t}\n\t\t\t\t\tbcc = append(bcc, stack[top])\n\t\t\t\t\tstack = stack[:top]\n\t\t\t\t\ttop--\n\t\t\t\t\tif !emit(bcc) {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if number[w.To] < number[v] && w.To != u {\n\t\t\t\tstack = append(stack, LabeledEdge{Edge{v, w.To}, w.Label})\n\t\t\t\tif number[w.To] < lowpt[v] {\n\t\t\t\t\tlowpt[v] = number[w.To]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\tfor w := range g.LabeledAdjacencyList {\n\t\tif number[w] == 0 && !biconnect(NI(w), 0) {\n\t\t\treturn\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/undir_RO.go",
    "content": "// Copyright 2014 Sonia Keys\n// License MIT: http://opensource.org/licenses/MIT\n\npackage graph\n\n// undir_RO.go is code generated from undir_cg.go by directives in graph.go.\n// Editing undir_cg.go is okay.  It is the code generation source.\n// DO NOT EDIT undir_RO.go.\n// The RO means read only and it is upper case RO to slow you down a bit\n// in case you start to edit the file.\n\n// Bipartite determines if a connected component of an undirected graph\n// is bipartite, a component where nodes can be partitioned into two sets\n// such that every edge in the component goes from one set to the other.\n//\n// Argument n can be any representative node of the component.\n//\n// If the component is bipartite, Bipartite returns true and a two-coloring\n// of the component.  Each color set is returned as a bitmap.  If the component\n// is not bipartite, Bipartite returns false and a representative odd cycle.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g Undirected) Bipartite(n NI) (b bool, c1, c2 Bits, oc []NI) {\n\tb = true\n\tvar open bool\n\tvar df func(n NI, c1, c2 *Bits)\n\tdf = func(n NI, c1, c2 *Bits) {\n\t\tc1.SetBit(n, 1)\n\t\tfor _, nb := range g.AdjacencyList[n] {\n\t\t\tif c1.Bit(nb) == 1 {\n\t\t\t\tb = false\n\t\t\t\toc = []NI{nb, n}\n\t\t\t\topen = true\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif c2.Bit(nb) == 1 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tdf(nb, c2, c1)\n\t\t\tif b {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tswitch {\n\t\t\tcase !open:\n\t\t\tcase n == oc[0]:\n\t\t\t\topen = false\n\t\t\tdefault:\n\t\t\t\toc = append(oc, n)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t}\n\tdf(n, &c1, &c2)\n\tif b {\n\t\treturn b, c1, c2, nil\n\t}\n\treturn b, Bits{}, Bits{}, oc\n}\n\n// BronKerbosch1 finds maximal cliques in an undirected graph.\n//\n// The graph must not contain parallel edges or loops.\n//\n// See https://en.wikipedia.org/wiki/Clique_(graph_theory) and\n// https://en.wikipedia.org/wiki/Bron%E2%80%93Kerbosch_algorithm for background.\n//\n// This method implements the BronKerbosch1 algorithm of WP; that is,\n// the original algorithm without improvements.\n//\n// The method calls the emit argument for each maximal clique in g, as long\n// as emit returns true.  If emit returns false, BronKerbosch1 returns\n// immediately.\n//\n// There are equivalent labeled and unlabeled versions of this method.\n//\n// See also more sophisticated variants BronKerbosch2 and BronKerbosch3.\nfunc (g Undirected) BronKerbosch1(emit func([]NI) bool) {\n\ta := g.AdjacencyList\n\tvar f func(R, P, X *Bits) bool\n\tf = func(R, P, X *Bits) bool {\n\t\tswitch {\n\t\tcase !P.Zero():\n\t\t\tvar r2, p2, x2 Bits\n\t\t\tpf := func(n NI) bool {\n\t\t\t\tr2.Set(*R)\n\t\t\t\tr2.SetBit(n, 1)\n\t\t\t\tp2.Clear()\n\t\t\t\tx2.Clear()\n\t\t\t\tfor _, to := range a[n] {\n\t\t\t\t\tif P.Bit(to) == 1 {\n\t\t\t\t\t\tp2.SetBit(to, 1)\n\t\t\t\t\t}\n\t\t\t\t\tif X.Bit(to) == 1 {\n\t\t\t\t\t\tx2.SetBit(to, 1)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif !f(&r2, &p2, &x2) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tP.SetBit(n, 0)\n\t\t\t\tX.SetBit(n, 1)\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif !P.Iterate(pf) {\n\t\t\t\treturn false\n\t\t\t}\n\t\tcase X.Zero():\n\t\t\treturn emit(R.Slice())\n\t\t}\n\t\treturn true\n\t}\n\tvar R, P, X Bits\n\tP.SetAll(len(a))\n\tf(&R, &P, &X)\n}\n\n// BKPivotMaxDegree is a strategy for BronKerbosch methods.\n//\n// To use it, take the method value (see golang.org/ref/spec#Method_values)\n// and pass it as the argument to BronKerbosch2 or 3.\n//\n// The strategy is to pick the node from P or X with the maximum degree\n// (number of edges) in g.  Note this is a shortcut from evaluating degrees\n// in P.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g Undirected) BKPivotMaxDegree(P, X *Bits) (p NI) {\n\t// choose pivot u as highest degree node from P or X\n\ta := g.AdjacencyList\n\tmaxDeg := -1\n\tP.Iterate(func(n NI) bool { // scan P\n\t\tif d := len(a[n]); d > maxDeg {\n\t\t\tp = n\n\t\t\tmaxDeg = d\n\t\t}\n\t\treturn true\n\t})\n\tX.Iterate(func(n NI) bool { // scan X\n\t\tif d := len(a[n]); d > maxDeg {\n\t\t\tp = n\n\t\t\tmaxDeg = d\n\t\t}\n\t\treturn true\n\t})\n\treturn\n}\n\n// BKPivotMinP is a strategy for BronKerbosch methods.\n//\n// To use it, take the method value (see golang.org/ref/spec#Method_values)\n// and pass it as the argument to BronKerbosch2 or 3.\n//\n// The strategy is to simply pick the first node in P.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g Undirected) BKPivotMinP(P, X *Bits) NI {\n\treturn P.From(0)\n}\n\n// BronKerbosch2 finds maximal cliques in an undirected graph.\n//\n// The graph must not contain parallel edges or loops.\n//\n// See https://en.wikipedia.org/wiki/Clique_(graph_theory) and\n// https://en.wikipedia.org/wiki/Bron%E2%80%93Kerbosch_algorithm for background.\n//\n// This method implements the BronKerbosch2 algorithm of WP; that is,\n// the original algorithm plus pivoting.\n//\n// The argument is a pivot function that must return a node of P or X.\n// P is guaranteed to contain at least one node.  X is not.\n// For example see BKPivotMaxDegree.\n//\n// The method calls the emit argument for each maximal clique in g, as long\n// as emit returns true.  If emit returns false, BronKerbosch1 returns\n// immediately.\n//\n// There are equivalent labeled and unlabeled versions of this method.\n//\n// See also simpler variant BronKerbosch1 and more sophisticated variant\n// BronKerbosch3.\nfunc (g Undirected) BronKerbosch2(pivot func(P, X *Bits) NI, emit func([]NI) bool) {\n\ta := g.AdjacencyList\n\tvar f func(R, P, X *Bits) bool\n\tf = func(R, P, X *Bits) bool {\n\t\tswitch {\n\t\tcase !P.Zero():\n\t\t\tvar r2, p2, x2, pnu Bits\n\t\t\t// compute P \\ N(u).  next 5 lines are only difference from BK1\n\t\t\tpnu.Set(*P)\n\t\t\tfor _, to := range a[pivot(P, X)] {\n\t\t\t\tpnu.SetBit(to, 0)\n\t\t\t}\n\t\t\t// remaining code like BK1\n\t\t\tpf := func(n NI) bool {\n\t\t\t\tr2.Set(*R)\n\t\t\t\tr2.SetBit(n, 1)\n\t\t\t\tp2.Clear()\n\t\t\t\tx2.Clear()\n\t\t\t\tfor _, to := range a[n] {\n\t\t\t\t\tif P.Bit(to) == 1 {\n\t\t\t\t\t\tp2.SetBit(to, 1)\n\t\t\t\t\t}\n\t\t\t\t\tif X.Bit(to) == 1 {\n\t\t\t\t\t\tx2.SetBit(to, 1)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif !f(&r2, &p2, &x2) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tP.SetBit(n, 0)\n\t\t\t\tX.SetBit(n, 1)\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif !pnu.Iterate(pf) {\n\t\t\t\treturn false\n\t\t\t}\n\t\tcase X.Zero():\n\t\t\treturn emit(R.Slice())\n\t\t}\n\t\treturn true\n\t}\n\tvar R, P, X Bits\n\tP.SetAll(len(a))\n\tf(&R, &P, &X)\n}\n\n// BronKerbosch3 finds maximal cliques in an undirected graph.\n//\n// The graph must not contain parallel edges or loops.\n//\n// See https://en.wikipedia.org/wiki/Clique_(graph_theory) and\n// https://en.wikipedia.org/wiki/Bron%E2%80%93Kerbosch_algorithm for background.\n//\n// This method implements the BronKerbosch3 algorithm of WP; that is,\n// the original algorithm with pivoting and degeneracy ordering.\n//\n// The argument is a pivot function that must return a node of P or X.\n// P is guaranteed to contain at least one node.  X is not.\n// For example see BKPivotMaxDegree.\n//\n// The method calls the emit argument for each maximal clique in g, as long\n// as emit returns true.  If emit returns false, BronKerbosch1 returns\n// immediately.\n//\n// There are equivalent labeled and unlabeled versions of this method.\n//\n// See also simpler variants BronKerbosch1 and BronKerbosch2.\nfunc (g Undirected) BronKerbosch3(pivot func(P, X *Bits) NI, emit func([]NI) bool) {\n\ta := g.AdjacencyList\n\tvar f func(R, P, X *Bits) bool\n\tf = func(R, P, X *Bits) bool {\n\t\tswitch {\n\t\tcase !P.Zero():\n\t\t\tvar r2, p2, x2, pnu Bits\n\t\t\t// compute P \\ N(u).  next lines are only difference from BK1\n\t\t\tpnu.Set(*P)\n\t\t\tfor _, to := range a[pivot(P, X)] {\n\t\t\t\tpnu.SetBit(to, 0)\n\t\t\t}\n\t\t\t// remaining code like BK2\n\t\t\tpf := func(n NI) bool {\n\t\t\t\tr2.Set(*R)\n\t\t\t\tr2.SetBit(n, 1)\n\t\t\t\tp2.Clear()\n\t\t\t\tx2.Clear()\n\t\t\t\tfor _, to := range a[n] {\n\t\t\t\t\tif P.Bit(to) == 1 {\n\t\t\t\t\t\tp2.SetBit(to, 1)\n\t\t\t\t\t}\n\t\t\t\t\tif X.Bit(to) == 1 {\n\t\t\t\t\t\tx2.SetBit(to, 1)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif !f(&r2, &p2, &x2) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tP.SetBit(n, 0)\n\t\t\t\tX.SetBit(n, 1)\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif !pnu.Iterate(pf) {\n\t\t\t\treturn false\n\t\t\t}\n\t\tcase X.Zero():\n\t\t\treturn emit(R.Slice())\n\t\t}\n\t\treturn true\n\t}\n\tvar R, P, X Bits\n\tP.SetAll(len(a))\n\t// code above same as BK2\n\t// code below new to BK3\n\t_, ord, _ := g.Degeneracy()\n\tvar p2, x2 Bits\n\tfor _, n := range ord {\n\t\tR.SetBit(n, 1)\n\t\tp2.Clear()\n\t\tx2.Clear()\n\t\tfor _, to := range a[n] {\n\t\t\tif P.Bit(to) == 1 {\n\t\t\t\tp2.SetBit(to, 1)\n\t\t\t}\n\t\t\tif X.Bit(to) == 1 {\n\t\t\t\tx2.SetBit(to, 1)\n\t\t\t}\n\t\t}\n\t\tif !f(&R, &p2, &x2) {\n\t\t\treturn\n\t\t}\n\t\tR.SetBit(n, 0)\n\t\tP.SetBit(n, 0)\n\t\tX.SetBit(n, 1)\n\t}\n}\n\n// ConnectedComponentBits returns a function that iterates over connected\n// components of g, returning a member bitmap for each.\n//\n// Each call of the returned function returns the order (number of nodes)\n// and bits of a connected component.  The returned function returns zeros\n// after returning all connected components.\n//\n// There are equivalent labeled and unlabeled versions of this method.\n//\n// See also ConnectedComponentReps, which has lighter weight return values.\nfunc (g Undirected) ConnectedComponentBits() func() (order int, bits Bits) {\n\ta := g.AdjacencyList\n\tvar vg Bits  // nodes visited in graph\n\tvar vc *Bits // nodes visited in current component\n\tvar nc int\n\tvar df func(NI)\n\tdf = func(n NI) {\n\t\tvg.SetBit(n, 1)\n\t\tvc.SetBit(n, 1)\n\t\tnc++\n\t\tfor _, nb := range a[n] {\n\t\t\tif vg.Bit(nb) == 0 {\n\t\t\t\tdf(nb)\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tvar n NI\n\treturn func() (o int, bits Bits) {\n\t\tfor ; n < NI(len(a)); n++ {\n\t\t\tif vg.Bit(n) == 0 {\n\t\t\t\tvc = &bits\n\t\t\t\tnc = 0\n\t\t\t\tdf(n)\n\t\t\t\treturn nc, bits\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n}\n\n// ConnectedComponentLists returns a function that iterates over connected\n// components of g, returning the member list of each.\n//\n// Each call of the returned function returns a node list of a connected\n// component.  The returned function returns nil after returning all connected\n// components.\n//\n// There are equivalent labeled and unlabeled versions of this method.\n//\n// See also ConnectedComponentReps, which has lighter weight return values.\nfunc (g Undirected) ConnectedComponentLists() func() []NI {\n\ta := g.AdjacencyList\n\tvar vg Bits // nodes visited in graph\n\tvar m []NI  // members of current component\n\tvar df func(NI)\n\tdf = func(n NI) {\n\t\tvg.SetBit(n, 1)\n\t\tm = append(m, n)\n\t\tfor _, nb := range a[n] {\n\t\t\tif vg.Bit(nb) == 0 {\n\t\t\t\tdf(nb)\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tvar n NI\n\treturn func() []NI {\n\t\tfor ; n < NI(len(a)); n++ {\n\t\t\tif vg.Bit(n) == 0 {\n\t\t\t\tm = nil\n\t\t\t\tdf(n)\n\t\t\t\treturn m\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n}\n\n// ConnectedComponentReps returns a representative node from each connected\n// component of g.\n//\n// Returned is a slice with a single representative node from each connected\n// component and also a parallel slice with the order, or number of nodes,\n// in the corresponding component.\n//\n// This is fairly minimal information describing connected components.\n// From a representative node, other nodes in the component can be reached\n// by depth first traversal for example.\n//\n// There are equivalent labeled and unlabeled versions of this method.\n//\n// See also ConnectedComponentBits and ConnectedComponentLists which can\n// collect component members in a single traversal, and IsConnected which\n// is an even simpler boolean test.\nfunc (g Undirected) ConnectedComponentReps() (reps []NI, orders []int) {\n\ta := g.AdjacencyList\n\tvar c Bits\n\tvar o int\n\tvar df func(NI)\n\tdf = func(n NI) {\n\t\tc.SetBit(n, 1)\n\t\to++\n\t\tfor _, nb := range a[n] {\n\t\t\tif c.Bit(nb) == 0 {\n\t\t\t\tdf(nb)\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tfor n := range a {\n\t\tif c.Bit(NI(n)) == 0 {\n\t\t\treps = append(reps, NI(n))\n\t\t\to = 0\n\t\t\tdf(NI(n))\n\t\t\torders = append(orders, o)\n\t\t}\n\t}\n\treturn\n}\n\n// Copy makes a deep copy of g.\n// Copy also computes the arc size ma, the number of arcs.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g Undirected) Copy() (c Undirected, ma int) {\n\tl, s := g.AdjacencyList.Copy()\n\treturn Undirected{l}, s\n}\n\n// Degeneracy computes k-degeneracy, vertex ordering and k-cores.\n//\n// See Wikipedia https://en.wikipedia.org/wiki/Degeneracy_(graph_theory)\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g Undirected) Degeneracy() (k int, ordering []NI, cores []int) {\n\ta := g.AdjacencyList\n\t// WP algorithm\n\tordering = make([]NI, len(a))\n\tvar L Bits\n\td := make([]int, len(a))\n\tvar D [][]NI\n\tfor v, nb := range a {\n\t\tdv := len(nb)\n\t\td[v] = dv\n\t\tfor len(D) <= dv {\n\t\t\tD = append(D, nil)\n\t\t}\n\t\tD[dv] = append(D[dv], NI(v))\n\t}\n\tfor ox := range a {\n\t\t// find a non-empty D\n\t\ti := 0\n\t\tfor len(D[i]) == 0 {\n\t\t\ti++\n\t\t}\n\t\t// k is max(i, k)\n\t\tif i > k {\n\t\t\tfor len(cores) <= i {\n\t\t\t\tcores = append(cores, 0)\n\t\t\t}\n\t\t\tcores[k] = ox\n\t\t\tk = i\n\t\t}\n\t\t// select from D[i]\n\t\tDi := D[i]\n\t\tlast := len(Di) - 1\n\t\tv := Di[last]\n\t\t// Add v to ordering, remove from Di\n\t\tordering[ox] = v\n\t\tL.SetBit(v, 1)\n\t\tD[i] = Di[:last]\n\t\t// move neighbors\n\t\tfor _, nb := range a[v] {\n\t\t\tif L.Bit(nb) == 1 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tdn := d[nb]  // old number of neighbors of nb\n\t\t\tDdn := D[dn] // nb is in this list\n\t\t\t// remove it from the list\n\t\t\tfor wx, w := range Ddn {\n\t\t\t\tif w == nb {\n\t\t\t\t\tlast := len(Ddn) - 1\n\t\t\t\t\tDdn[wx], Ddn[last] = Ddn[last], Ddn[wx]\n\t\t\t\t\tD[dn] = Ddn[:last]\n\t\t\t\t}\n\t\t\t}\n\t\t\tdn-- // new number of neighbors\n\t\t\td[nb] = dn\n\t\t\t// re--add it to it's new list\n\t\t\tD[dn] = append(D[dn], nb)\n\t\t}\n\t}\n\tcores[k] = len(ordering)\n\treturn\n}\n\n// Degree for undirected graphs, returns the degree of a node.\n//\n// The degree of a node in an undirected graph is the number of incident\n// edges, where loops count twice.\n//\n// If g is known to be loop-free, the result is simply equivalent to len(g[n]).\n// See handshaking lemma example at AdjacencyList.ArcSize.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g Undirected) Degree(n NI) int {\n\tto := g.AdjacencyList[n]\n\td := len(to) // just \"out\" degree,\n\tfor _, to := range to {\n\t\tif to == n {\n\t\t\td++ // except loops count twice\n\t\t}\n\t}\n\treturn d\n}\n\n// FromList constructs a FromList representing the tree reachable from\n// the given root.\n//\n// The connected component containing root should represent a simple graph,\n// connected as a tree.\n//\n// For nodes connected as a tree, the Path member of the returned FromList\n// will be populated with both From and Len values.  The MaxLen member will be\n// set but Leaves will be left a zero value.  Return value cycle will be -1.\n//\n// If the connected component containing root is not connected as a tree,\n// a cycle will be detected.  The returned FromList will be a zero value and\n// return value cycle will be a node involved in the cycle.\n//\n// Loops and parallel edges will be detected as cycles, however only in the\n// connected component containing root.  If g is not fully connected, nodes\n// not reachable from root will have PathEnd values of {From: -1, Len: 0}.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g Undirected) FromList(root NI) (f FromList, cycle NI) {\n\tp := make([]PathEnd, len(g.AdjacencyList))\n\tfor i := range p {\n\t\tp[i].From = -1\n\t}\n\tml := 0\n\tvar df func(NI, NI) bool\n\tdf = func(fr, n NI) bool {\n\t\tl := p[n].Len + 1\n\t\tfor _, to := range g.AdjacencyList[n] {\n\t\t\tif to == fr {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif p[to].Len > 0 {\n\t\t\t\tcycle = to\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tp[to] = PathEnd{From: n, Len: l}\n\t\t\tif l > ml {\n\t\t\t\tml = l\n\t\t\t}\n\t\t\tif !df(n, to) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\tp[root].Len = 1\n\tif !df(-1, root) {\n\t\treturn\n\t}\n\treturn FromList{Paths: p, MaxLen: ml}, -1\n}\n\n// IsConnected tests if an undirected graph is a single connected component.\n//\n// There are equivalent labeled and unlabeled versions of this method.\n//\n// See also ConnectedComponentReps for a method returning more information.\nfunc (g Undirected) IsConnected() bool {\n\ta := g.AdjacencyList\n\tif len(a) == 0 {\n\t\treturn true\n\t}\n\tvar b Bits\n\tb.SetAll(len(a))\n\tvar df func(NI)\n\tdf = func(n NI) {\n\t\tb.SetBit(n, 0)\n\t\tfor _, to := range a[n] {\n\t\t\tif b.Bit(to) == 1 {\n\t\t\t\tdf(to)\n\t\t\t}\n\t\t}\n\t}\n\tdf(0)\n\treturn b.Zero()\n}\n\n// IsTree identifies trees in undirected graphs.\n//\n// Return value isTree is true if the connected component reachable from root\n// is a tree.  Further, return value allTree is true if the entire graph g is\n// connected.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g Undirected) IsTree(root NI) (isTree, allTree bool) {\n\ta := g.AdjacencyList\n\tvar v Bits\n\tv.SetAll(len(a))\n\tvar df func(NI, NI) bool\n\tdf = func(fr, n NI) bool {\n\t\tif v.Bit(n) == 0 {\n\t\t\treturn false\n\t\t}\n\t\tv.SetBit(n, 0)\n\t\tfor _, to := range a[n] {\n\t\t\tif to != fr && !df(n, to) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\tv.SetBit(root, 0)\n\tfor _, to := range a[root] {\n\t\tif !df(root, to) {\n\t\t\treturn false, false\n\t\t}\n\t}\n\treturn true, v.Zero()\n}\n\n// Size returns the number of edges in g.\n//\n// See also ArcSize and HasLoop.\nfunc (g Undirected) Size() int {\n\tm2 := 0\n\tfor fr, to := range g.AdjacencyList {\n\t\tm2 += len(to)\n\t\tfor _, to := range to {\n\t\t\tif to == NI(fr) {\n\t\t\t\tm2++\n\t\t\t}\n\t\t}\n\t}\n\treturn m2 / 2\n}\n"
  },
  {
    "path": "vendor/github.com/soniakeys/graph/undir_cg.go",
    "content": "// Copyright 2014 Sonia Keys\n// License MIT: http://opensource.org/licenses/MIT\n\npackage graph\n\n// undir_RO.go is code generated from undir_cg.go by directives in graph.go.\n// Editing undir_cg.go is okay.  It is the code generation source.\n// DO NOT EDIT undir_RO.go.\n// The RO means read only and it is upper case RO to slow you down a bit\n// in case you start to edit the file.\n\n// Bipartite determines if a connected component of an undirected graph\n// is bipartite, a component where nodes can be partitioned into two sets\n// such that every edge in the component goes from one set to the other.\n//\n// Argument n can be any representative node of the component.\n//\n// If the component is bipartite, Bipartite returns true and a two-coloring\n// of the component.  Each color set is returned as a bitmap.  If the component\n// is not bipartite, Bipartite returns false and a representative odd cycle.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledUndirected) Bipartite(n NI) (b bool, c1, c2 Bits, oc []NI) {\n\tb = true\n\tvar open bool\n\tvar df func(n NI, c1, c2 *Bits)\n\tdf = func(n NI, c1, c2 *Bits) {\n\t\tc1.SetBit(n, 1)\n\t\tfor _, nb := range g.LabeledAdjacencyList[n] {\n\t\t\tif c1.Bit(nb.To) == 1 {\n\t\t\t\tb = false\n\t\t\t\toc = []NI{nb.To, n}\n\t\t\t\topen = true\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif c2.Bit(nb.To) == 1 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tdf(nb.To, c2, c1)\n\t\t\tif b {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tswitch {\n\t\t\tcase !open:\n\t\t\tcase n == oc[0]:\n\t\t\t\topen = false\n\t\t\tdefault:\n\t\t\t\toc = append(oc, n)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t}\n\tdf(n, &c1, &c2)\n\tif b {\n\t\treturn b, c1, c2, nil\n\t}\n\treturn b, Bits{}, Bits{}, oc\n}\n\n// BronKerbosch1 finds maximal cliques in an undirected graph.\n//\n// The graph must not contain parallel edges or loops.\n//\n// See https://en.wikipedia.org/wiki/Clique_(graph_theory) and\n// https://en.wikipedia.org/wiki/Bron%E2%80%93Kerbosch_algorithm for background.\n//\n// This method implements the BronKerbosch1 algorithm of WP; that is,\n// the original algorithm without improvements.\n//\n// The method calls the emit argument for each maximal clique in g, as long\n// as emit returns true.  If emit returns false, BronKerbosch1 returns\n// immediately.\n//\n// There are equivalent labeled and unlabeled versions of this method.\n//\n// See also more sophisticated variants BronKerbosch2 and BronKerbosch3.\nfunc (g LabeledUndirected) BronKerbosch1(emit func([]NI) bool) {\n\ta := g.LabeledAdjacencyList\n\tvar f func(R, P, X *Bits) bool\n\tf = func(R, P, X *Bits) bool {\n\t\tswitch {\n\t\tcase !P.Zero():\n\t\t\tvar r2, p2, x2 Bits\n\t\t\tpf := func(n NI) bool {\n\t\t\t\tr2.Set(*R)\n\t\t\t\tr2.SetBit(n, 1)\n\t\t\t\tp2.Clear()\n\t\t\t\tx2.Clear()\n\t\t\t\tfor _, to := range a[n] {\n\t\t\t\t\tif P.Bit(to.To) == 1 {\n\t\t\t\t\t\tp2.SetBit(to.To, 1)\n\t\t\t\t\t}\n\t\t\t\t\tif X.Bit(to.To) == 1 {\n\t\t\t\t\t\tx2.SetBit(to.To, 1)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif !f(&r2, &p2, &x2) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tP.SetBit(n, 0)\n\t\t\t\tX.SetBit(n, 1)\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif !P.Iterate(pf) {\n\t\t\t\treturn false\n\t\t\t}\n\t\tcase X.Zero():\n\t\t\treturn emit(R.Slice())\n\t\t}\n\t\treturn true\n\t}\n\tvar R, P, X Bits\n\tP.SetAll(len(a))\n\tf(&R, &P, &X)\n}\n\n// BKPivotMaxDegree is a strategy for BronKerbosch methods.\n//\n// To use it, take the method value (see golang.org/ref/spec#Method_values)\n// and pass it as the argument to BronKerbosch2 or 3.\n//\n// The strategy is to pick the node from P or X with the maximum degree\n// (number of edges) in g.  Note this is a shortcut from evaluating degrees\n// in P.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledUndirected) BKPivotMaxDegree(P, X *Bits) (p NI) {\n\t// choose pivot u as highest degree node from P or X\n\ta := g.LabeledAdjacencyList\n\tmaxDeg := -1\n\tP.Iterate(func(n NI) bool { // scan P\n\t\tif d := len(a[n]); d > maxDeg {\n\t\t\tp = n\n\t\t\tmaxDeg = d\n\t\t}\n\t\treturn true\n\t})\n\tX.Iterate(func(n NI) bool { // scan X\n\t\tif d := len(a[n]); d > maxDeg {\n\t\t\tp = n\n\t\t\tmaxDeg = d\n\t\t}\n\t\treturn true\n\t})\n\treturn\n}\n\n// BKPivotMinP is a strategy for BronKerbosch methods.\n//\n// To use it, take the method value (see golang.org/ref/spec#Method_values)\n// and pass it as the argument to BronKerbosch2 or 3.\n//\n// The strategy is to simply pick the first node in P.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledUndirected) BKPivotMinP(P, X *Bits) NI {\n\treturn P.From(0)\n}\n\n// BronKerbosch2 finds maximal cliques in an undirected graph.\n//\n// The graph must not contain parallel edges or loops.\n//\n// See https://en.wikipedia.org/wiki/Clique_(graph_theory) and\n// https://en.wikipedia.org/wiki/Bron%E2%80%93Kerbosch_algorithm for background.\n//\n// This method implements the BronKerbosch2 algorithm of WP; that is,\n// the original algorithm plus pivoting.\n//\n// The argument is a pivot function that must return a node of P or X.\n// P is guaranteed to contain at least one node.  X is not.\n// For example see BKPivotMaxDegree.\n//\n// The method calls the emit argument for each maximal clique in g, as long\n// as emit returns true.  If emit returns false, BronKerbosch1 returns\n// immediately.\n//\n// There are equivalent labeled and unlabeled versions of this method.\n//\n// See also simpler variant BronKerbosch1 and more sophisticated variant\n// BronKerbosch3.\nfunc (g LabeledUndirected) BronKerbosch2(pivot func(P, X *Bits) NI, emit func([]NI) bool) {\n\ta := g.LabeledAdjacencyList\n\tvar f func(R, P, X *Bits) bool\n\tf = func(R, P, X *Bits) bool {\n\t\tswitch {\n\t\tcase !P.Zero():\n\t\t\tvar r2, p2, x2, pnu Bits\n\t\t\t// compute P \\ N(u).  next 5 lines are only difference from BK1\n\t\t\tpnu.Set(*P)\n\t\t\tfor _, to := range a[pivot(P, X)] {\n\t\t\t\tpnu.SetBit(to.To, 0)\n\t\t\t}\n\t\t\t// remaining code like BK1\n\t\t\tpf := func(n NI) bool {\n\t\t\t\tr2.Set(*R)\n\t\t\t\tr2.SetBit(n, 1)\n\t\t\t\tp2.Clear()\n\t\t\t\tx2.Clear()\n\t\t\t\tfor _, to := range a[n] {\n\t\t\t\t\tif P.Bit(to.To) == 1 {\n\t\t\t\t\t\tp2.SetBit(to.To, 1)\n\t\t\t\t\t}\n\t\t\t\t\tif X.Bit(to.To) == 1 {\n\t\t\t\t\t\tx2.SetBit(to.To, 1)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif !f(&r2, &p2, &x2) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tP.SetBit(n, 0)\n\t\t\t\tX.SetBit(n, 1)\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif !pnu.Iterate(pf) {\n\t\t\t\treturn false\n\t\t\t}\n\t\tcase X.Zero():\n\t\t\treturn emit(R.Slice())\n\t\t}\n\t\treturn true\n\t}\n\tvar R, P, X Bits\n\tP.SetAll(len(a))\n\tf(&R, &P, &X)\n}\n\n// BronKerbosch3 finds maximal cliques in an undirected graph.\n//\n// The graph must not contain parallel edges or loops.\n//\n// See https://en.wikipedia.org/wiki/Clique_(graph_theory) and\n// https://en.wikipedia.org/wiki/Bron%E2%80%93Kerbosch_algorithm for background.\n//\n// This method implements the BronKerbosch3 algorithm of WP; that is,\n// the original algorithm with pivoting and degeneracy ordering.\n//\n// The argument is a pivot function that must return a node of P or X.\n// P is guaranteed to contain at least one node.  X is not.\n// For example see BKPivotMaxDegree.\n//\n// The method calls the emit argument for each maximal clique in g, as long\n// as emit returns true.  If emit returns false, BronKerbosch1 returns\n// immediately.\n//\n// There are equivalent labeled and unlabeled versions of this method.\n//\n// See also simpler variants BronKerbosch1 and BronKerbosch2.\nfunc (g LabeledUndirected) BronKerbosch3(pivot func(P, X *Bits) NI, emit func([]NI) bool) {\n\ta := g.LabeledAdjacencyList\n\tvar f func(R, P, X *Bits) bool\n\tf = func(R, P, X *Bits) bool {\n\t\tswitch {\n\t\tcase !P.Zero():\n\t\t\tvar r2, p2, x2, pnu Bits\n\t\t\t// compute P \\ N(u).  next lines are only difference from BK1\n\t\t\tpnu.Set(*P)\n\t\t\tfor _, to := range a[pivot(P, X)] {\n\t\t\t\tpnu.SetBit(to.To, 0)\n\t\t\t}\n\t\t\t// remaining code like BK2\n\t\t\tpf := func(n NI) bool {\n\t\t\t\tr2.Set(*R)\n\t\t\t\tr2.SetBit(n, 1)\n\t\t\t\tp2.Clear()\n\t\t\t\tx2.Clear()\n\t\t\t\tfor _, to := range a[n] {\n\t\t\t\t\tif P.Bit(to.To) == 1 {\n\t\t\t\t\t\tp2.SetBit(to.To, 1)\n\t\t\t\t\t}\n\t\t\t\t\tif X.Bit(to.To) == 1 {\n\t\t\t\t\t\tx2.SetBit(to.To, 1)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif !f(&r2, &p2, &x2) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tP.SetBit(n, 0)\n\t\t\t\tX.SetBit(n, 1)\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif !pnu.Iterate(pf) {\n\t\t\t\treturn false\n\t\t\t}\n\t\tcase X.Zero():\n\t\t\treturn emit(R.Slice())\n\t\t}\n\t\treturn true\n\t}\n\tvar R, P, X Bits\n\tP.SetAll(len(a))\n\t// code above same as BK2\n\t// code below new to BK3\n\t_, ord, _ := g.Degeneracy()\n\tvar p2, x2 Bits\n\tfor _, n := range ord {\n\t\tR.SetBit(n, 1)\n\t\tp2.Clear()\n\t\tx2.Clear()\n\t\tfor _, to := range a[n] {\n\t\t\tif P.Bit(to.To) == 1 {\n\t\t\t\tp2.SetBit(to.To, 1)\n\t\t\t}\n\t\t\tif X.Bit(to.To) == 1 {\n\t\t\t\tx2.SetBit(to.To, 1)\n\t\t\t}\n\t\t}\n\t\tif !f(&R, &p2, &x2) {\n\t\t\treturn\n\t\t}\n\t\tR.SetBit(n, 0)\n\t\tP.SetBit(n, 0)\n\t\tX.SetBit(n, 1)\n\t}\n}\n\n// ConnectedComponentBits returns a function that iterates over connected\n// components of g, returning a member bitmap for each.\n//\n// Each call of the returned function returns the order (number of nodes)\n// and bits of a connected component.  The returned function returns zeros\n// after returning all connected components.\n//\n// There are equivalent labeled and unlabeled versions of this method.\n//\n// See also ConnectedComponentReps, which has lighter weight return values.\nfunc (g LabeledUndirected) ConnectedComponentBits() func() (order int, bits Bits) {\n\ta := g.LabeledAdjacencyList\n\tvar vg Bits  // nodes visited in graph\n\tvar vc *Bits // nodes visited in current component\n\tvar nc int\n\tvar df func(NI)\n\tdf = func(n NI) {\n\t\tvg.SetBit(n, 1)\n\t\tvc.SetBit(n, 1)\n\t\tnc++\n\t\tfor _, nb := range a[n] {\n\t\t\tif vg.Bit(nb.To) == 0 {\n\t\t\t\tdf(nb.To)\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tvar n NI\n\treturn func() (o int, bits Bits) {\n\t\tfor ; n < NI(len(a)); n++ {\n\t\t\tif vg.Bit(n) == 0 {\n\t\t\t\tvc = &bits\n\t\t\t\tnc = 0\n\t\t\t\tdf(n)\n\t\t\t\treturn nc, bits\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n}\n\n// ConnectedComponentLists returns a function that iterates over connected\n// components of g, returning the member list of each.\n//\n// Each call of the returned function returns a node list of a connected\n// component.  The returned function returns nil after returning all connected\n// components.\n//\n// There are equivalent labeled and unlabeled versions of this method.\n//\n// See also ConnectedComponentReps, which has lighter weight return values.\nfunc (g LabeledUndirected) ConnectedComponentLists() func() []NI {\n\ta := g.LabeledAdjacencyList\n\tvar vg Bits // nodes visited in graph\n\tvar m []NI  // members of current component\n\tvar df func(NI)\n\tdf = func(n NI) {\n\t\tvg.SetBit(n, 1)\n\t\tm = append(m, n)\n\t\tfor _, nb := range a[n] {\n\t\t\tif vg.Bit(nb.To) == 0 {\n\t\t\t\tdf(nb.To)\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tvar n NI\n\treturn func() []NI {\n\t\tfor ; n < NI(len(a)); n++ {\n\t\t\tif vg.Bit(n) == 0 {\n\t\t\t\tm = nil\n\t\t\t\tdf(n)\n\t\t\t\treturn m\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n}\n\n// ConnectedComponentReps returns a representative node from each connected\n// component of g.\n//\n// Returned is a slice with a single representative node from each connected\n// component and also a parallel slice with the order, or number of nodes,\n// in the corresponding component.\n//\n// This is fairly minimal information describing connected components.\n// From a representative node, other nodes in the component can be reached\n// by depth first traversal for example.\n//\n// There are equivalent labeled and unlabeled versions of this method.\n//\n// See also ConnectedComponentBits and ConnectedComponentLists which can\n// collect component members in a single traversal, and IsConnected which\n// is an even simpler boolean test.\nfunc (g LabeledUndirected) ConnectedComponentReps() (reps []NI, orders []int) {\n\ta := g.LabeledAdjacencyList\n\tvar c Bits\n\tvar o int\n\tvar df func(NI)\n\tdf = func(n NI) {\n\t\tc.SetBit(n, 1)\n\t\to++\n\t\tfor _, nb := range a[n] {\n\t\t\tif c.Bit(nb.To) == 0 {\n\t\t\t\tdf(nb.To)\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tfor n := range a {\n\t\tif c.Bit(NI(n)) == 0 {\n\t\t\treps = append(reps, NI(n))\n\t\t\to = 0\n\t\t\tdf(NI(n))\n\t\t\torders = append(orders, o)\n\t\t}\n\t}\n\treturn\n}\n\n// Copy makes a deep copy of g.\n// Copy also computes the arc size ma, the number of arcs.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledUndirected) Copy() (c LabeledUndirected, ma int) {\n\tl, s := g.LabeledAdjacencyList.Copy()\n\treturn LabeledUndirected{l}, s\n}\n\n// Degeneracy computes k-degeneracy, vertex ordering and k-cores.\n//\n// See Wikipedia https://en.wikipedia.org/wiki/Degeneracy_(graph_theory)\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledUndirected) Degeneracy() (k int, ordering []NI, cores []int) {\n\ta := g.LabeledAdjacencyList\n\t// WP algorithm\n\tordering = make([]NI, len(a))\n\tvar L Bits\n\td := make([]int, len(a))\n\tvar D [][]NI\n\tfor v, nb := range a {\n\t\tdv := len(nb)\n\t\td[v] = dv\n\t\tfor len(D) <= dv {\n\t\t\tD = append(D, nil)\n\t\t}\n\t\tD[dv] = append(D[dv], NI(v))\n\t}\n\tfor ox := range a {\n\t\t// find a non-empty D\n\t\ti := 0\n\t\tfor len(D[i]) == 0 {\n\t\t\ti++\n\t\t}\n\t\t// k is max(i, k)\n\t\tif i > k {\n\t\t\tfor len(cores) <= i {\n\t\t\t\tcores = append(cores, 0)\n\t\t\t}\n\t\t\tcores[k] = ox\n\t\t\tk = i\n\t\t}\n\t\t// select from D[i]\n\t\tDi := D[i]\n\t\tlast := len(Di) - 1\n\t\tv := Di[last]\n\t\t// Add v to ordering, remove from Di\n\t\tordering[ox] = v\n\t\tL.SetBit(v, 1)\n\t\tD[i] = Di[:last]\n\t\t// move neighbors\n\t\tfor _, nb := range a[v] {\n\t\t\tif L.Bit(nb.To) == 1 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tdn := d[nb.To] // old number of neighbors of nb\n\t\t\tDdn := D[dn]   // nb is in this list\n\t\t\t// remove it from the list\n\t\t\tfor wx, w := range Ddn {\n\t\t\t\tif w == nb.To {\n\t\t\t\t\tlast := len(Ddn) - 1\n\t\t\t\t\tDdn[wx], Ddn[last] = Ddn[last], Ddn[wx]\n\t\t\t\t\tD[dn] = Ddn[:last]\n\t\t\t\t}\n\t\t\t}\n\t\t\tdn-- // new number of neighbors\n\t\t\td[nb.To] = dn\n\t\t\t// re--add it to it's new list\n\t\t\tD[dn] = append(D[dn], nb.To)\n\t\t}\n\t}\n\tcores[k] = len(ordering)\n\treturn\n}\n\n// Degree for undirected graphs, returns the degree of a node.\n//\n// The degree of a node in an undirected graph is the number of incident\n// edges, where loops count twice.\n//\n// If g is known to be loop-free, the result is simply equivalent to len(g[n]).\n// See handshaking lemma example at AdjacencyList.ArcSize.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledUndirected) Degree(n NI) int {\n\tto := g.LabeledAdjacencyList[n]\n\td := len(to) // just \"out\" degree,\n\tfor _, to := range to {\n\t\tif to.To == n {\n\t\t\td++ // except loops count twice\n\t\t}\n\t}\n\treturn d\n}\n\n// FromList constructs a FromList representing the tree reachable from\n// the given root.\n//\n// The connected component containing root should represent a simple graph,\n// connected as a tree.\n//\n// For nodes connected as a tree, the Path member of the returned FromList\n// will be populated with both From and Len values.  The MaxLen member will be\n// set but Leaves will be left a zero value.  Return value cycle will be -1.\n//\n// If the connected component containing root is not connected as a tree,\n// a cycle will be detected.  The returned FromList will be a zero value and\n// return value cycle will be a node involved in the cycle.\n//\n// Loops and parallel edges will be detected as cycles, however only in the\n// connected component containing root.  If g is not fully connected, nodes\n// not reachable from root will have PathEnd values of {From: -1, Len: 0}.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledUndirected) FromList(root NI) (f FromList, cycle NI) {\n\tp := make([]PathEnd, len(g.LabeledAdjacencyList))\n\tfor i := range p {\n\t\tp[i].From = -1\n\t}\n\tml := 0\n\tvar df func(NI, NI) bool\n\tdf = func(fr, n NI) bool {\n\t\tl := p[n].Len + 1\n\t\tfor _, to := range g.LabeledAdjacencyList[n] {\n\t\t\tif to.To == fr {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif p[to.To].Len > 0 {\n\t\t\t\tcycle = to.To\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tp[to.To] = PathEnd{From: n, Len: l}\n\t\t\tif l > ml {\n\t\t\t\tml = l\n\t\t\t}\n\t\t\tif !df(n, to.To) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\tp[root].Len = 1\n\tif !df(-1, root) {\n\t\treturn\n\t}\n\treturn FromList{Paths: p, MaxLen: ml}, -1\n}\n\n// IsConnected tests if an undirected graph is a single connected component.\n//\n// There are equivalent labeled and unlabeled versions of this method.\n//\n// See also ConnectedComponentReps for a method returning more information.\nfunc (g LabeledUndirected) IsConnected() bool {\n\ta := g.LabeledAdjacencyList\n\tif len(a) == 0 {\n\t\treturn true\n\t}\n\tvar b Bits\n\tb.SetAll(len(a))\n\tvar df func(NI)\n\tdf = func(n NI) {\n\t\tb.SetBit(n, 0)\n\t\tfor _, to := range a[n] {\n\t\t\tif b.Bit(to.To) == 1 {\n\t\t\t\tdf(to.To)\n\t\t\t}\n\t\t}\n\t}\n\tdf(0)\n\treturn b.Zero()\n}\n\n// IsTree identifies trees in undirected graphs.\n//\n// Return value isTree is true if the connected component reachable from root\n// is a tree.  Further, return value allTree is true if the entire graph g is\n// connected.\n//\n// There are equivalent labeled and unlabeled versions of this method.\nfunc (g LabeledUndirected) IsTree(root NI) (isTree, allTree bool) {\n\ta := g.LabeledAdjacencyList\n\tvar v Bits\n\tv.SetAll(len(a))\n\tvar df func(NI, NI) bool\n\tdf = func(fr, n NI) bool {\n\t\tif v.Bit(n) == 0 {\n\t\t\treturn false\n\t\t}\n\t\tv.SetBit(n, 0)\n\t\tfor _, to := range a[n] {\n\t\t\tif to.To != fr && !df(n, to.To) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n\tv.SetBit(root, 0)\n\tfor _, to := range a[root] {\n\t\tif !df(root, to.To) {\n\t\t\treturn false, false\n\t\t}\n\t}\n\treturn true, v.Zero()\n}\n\n// Size returns the number of edges in g.\n//\n// See also ArcSize and HasLoop.\nfunc (g LabeledUndirected) Size() int {\n\tm2 := 0\n\tfor fr, to := range g.LabeledAdjacencyList {\n\t\tm2 += len(to)\n\t\tfor _, to := range to {\n\t\t\tif to.To == NI(fr) {\n\t\t\t\tm2++\n\t\t\t}\n\t\t}\n\t}\n\treturn m2 / 2\n}\n"
  },
  {
    "path": "vendor/golang.org/x/net/LICENSE",
    "content": "Copyright (c) 2009 The Go Authors. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n   * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n   * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n   * Neither the name of Google Inc. nor the names of its\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  },
  {
    "path": "vendor/golang.org/x/net/PATENTS",
    "content": "Additional IP Rights Grant (Patents)\n\n\"This implementation\" means the copyrightable works distributed by\nGoogle as part of the Go project.\n\nGoogle hereby grants to You a perpetual, worldwide, non-exclusive,\nno-charge, royalty-free, irrevocable (except as stated in this section)\npatent license to make, have made, use, offer to sell, sell, import,\ntransfer and otherwise run, modify and propagate the contents of this\nimplementation of Go, where such license applies only to those patent\nclaims, both currently owned or controlled by Google and acquired in\nthe future, licensable by Google that are necessarily infringed by this\nimplementation of Go.  This grant does not include claims that would be\ninfringed only as a consequence of further modification of this\nimplementation.  If you or your agent or exclusive licensee institute or\norder or agree to the institution of patent litigation against any\nentity (including a cross-claim or counterclaim in a lawsuit) alleging\nthat this implementation of Go or any code incorporated within this\nimplementation of Go constitutes direct or contributory patent\ninfringement, or inducement of patent infringement, then any patent\nrights granted to you under this License for this implementation of Go\nshall terminate as of the date such litigation is filed.\n"
  },
  {
    "path": "vendor/golang.org/x/net/context/context.go",
    "content": "// Copyright 2014 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Package context defines the Context type, which carries deadlines,\n// cancelation signals, and other request-scoped values across API boundaries\n// and between processes.\n//\n// Incoming requests to a server should create a Context, and outgoing calls to\n// servers should accept a Context.  The chain of function calls between must\n// propagate the Context, optionally replacing it with a modified copy created\n// using WithDeadline, WithTimeout, WithCancel, or WithValue.\n//\n// Programs that use Contexts should follow these rules to keep interfaces\n// consistent across packages and enable static analysis tools to check context\n// propagation:\n//\n// Do not store Contexts inside a struct type; instead, pass a Context\n// explicitly to each function that needs it.  The Context should be the first\n// parameter, typically named ctx:\n//\n// \tfunc DoSomething(ctx context.Context, arg Arg) error {\n// \t\t// ... use ctx ...\n// \t}\n//\n// Do not pass a nil Context, even if a function permits it.  Pass context.TODO\n// if you are unsure about which Context to use.\n//\n// Use context Values only for request-scoped data that transits processes and\n// APIs, not for passing optional parameters to functions.\n//\n// The same Context may be passed to functions running in different goroutines;\n// Contexts are safe for simultaneous use by multiple goroutines.\n//\n// See http://blog.golang.org/context for example code for a server that uses\n// Contexts.\npackage context\n\nimport \"time\"\n\n// A Context carries a deadline, a cancelation signal, and other values across\n// API boundaries.\n//\n// Context's methods may be called by multiple goroutines simultaneously.\ntype Context interface {\n\t// Deadline returns the time when work done on behalf of this context\n\t// should be canceled.  Deadline returns ok==false when no deadline is\n\t// set.  Successive calls to Deadline return the same results.\n\tDeadline() (deadline time.Time, ok bool)\n\n\t// Done returns a channel that's closed when work done on behalf of this\n\t// context should be canceled.  Done may return nil if this context can\n\t// never be canceled.  Successive calls to Done return the same value.\n\t//\n\t// WithCancel arranges for Done to be closed when cancel is called;\n\t// WithDeadline arranges for Done to be closed when the deadline\n\t// expires; WithTimeout arranges for Done to be closed when the timeout\n\t// elapses.\n\t//\n\t// Done is provided for use in select statements:\n\t//\n\t//  // Stream generates values with DoSomething and sends them to out\n\t//  // until DoSomething returns an error or ctx.Done is closed.\n\t//  func Stream(ctx context.Context, out <-chan Value) error {\n\t//  \tfor {\n\t//  \t\tv, err := DoSomething(ctx)\n\t//  \t\tif err != nil {\n\t//  \t\t\treturn err\n\t//  \t\t}\n\t//  \t\tselect {\n\t//  \t\tcase <-ctx.Done():\n\t//  \t\t\treturn ctx.Err()\n\t//  \t\tcase out <- v:\n\t//  \t\t}\n\t//  \t}\n\t//  }\n\t//\n\t// See http://blog.golang.org/pipelines for more examples of how to use\n\t// a Done channel for cancelation.\n\tDone() <-chan struct{}\n\n\t// Err returns a non-nil error value after Done is closed.  Err returns\n\t// Canceled if the context was canceled or DeadlineExceeded if the\n\t// context's deadline passed.  No other values for Err are defined.\n\t// After Done is closed, successive calls to Err return the same value.\n\tErr() error\n\n\t// Value returns the value associated with this context for key, or nil\n\t// if no value is associated with key.  Successive calls to Value with\n\t// the same key returns the same result.\n\t//\n\t// Use context values only for request-scoped data that transits\n\t// processes and API boundaries, not for passing optional parameters to\n\t// functions.\n\t//\n\t// A key identifies a specific value in a Context.  Functions that wish\n\t// to store values in Context typically allocate a key in a global\n\t// variable then use that key as the argument to context.WithValue and\n\t// Context.Value.  A key can be any type that supports equality;\n\t// packages should define keys as an unexported type to avoid\n\t// collisions.\n\t//\n\t// Packages that define a Context key should provide type-safe accessors\n\t// for the values stores using that key:\n\t//\n\t// \t// Package user defines a User type that's stored in Contexts.\n\t// \tpackage user\n\t//\n\t// \timport \"golang.org/x/net/context\"\n\t//\n\t// \t// User is the type of value stored in the Contexts.\n\t// \ttype User struct {...}\n\t//\n\t// \t// key is an unexported type for keys defined in this package.\n\t// \t// This prevents collisions with keys defined in other packages.\n\t// \ttype key int\n\t//\n\t// \t// userKey is the key for user.User values in Contexts.  It is\n\t// \t// unexported; clients use user.NewContext and user.FromContext\n\t// \t// instead of using this key directly.\n\t// \tvar userKey key = 0\n\t//\n\t// \t// NewContext returns a new Context that carries value u.\n\t// \tfunc NewContext(ctx context.Context, u *User) context.Context {\n\t// \t\treturn context.WithValue(ctx, userKey, u)\n\t// \t}\n\t//\n\t// \t// FromContext returns the User value stored in ctx, if any.\n\t// \tfunc FromContext(ctx context.Context) (*User, bool) {\n\t// \t\tu, ok := ctx.Value(userKey).(*User)\n\t// \t\treturn u, ok\n\t// \t}\n\tValue(key interface{}) interface{}\n}\n\n// Background returns a non-nil, empty Context. It is never canceled, has no\n// values, and has no deadline.  It is typically used by the main function,\n// initialization, and tests, and as the top-level Context for incoming\n// requests.\nfunc Background() Context {\n\treturn background\n}\n\n// TODO returns a non-nil, empty Context.  Code should use context.TODO when\n// it's unclear which Context to use or it is not yet available (because the\n// surrounding function has not yet been extended to accept a Context\n// parameter).  TODO is recognized by static analysis tools that determine\n// whether Contexts are propagated correctly in a program.\nfunc TODO() Context {\n\treturn todo\n}\n\n// A CancelFunc tells an operation to abandon its work.\n// A CancelFunc does not wait for the work to stop.\n// After the first call, subsequent calls to a CancelFunc do nothing.\ntype CancelFunc func()\n"
  },
  {
    "path": "vendor/golang.org/x/net/context/ctxhttp/cancelreq.go",
    "content": "// Copyright 2015 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// +build go1.5\n\npackage ctxhttp\n\nimport \"net/http\"\n\nfunc canceler(client *http.Client, req *http.Request) func() {\n\t// TODO(djd): Respect any existing value of req.Cancel.\n\tch := make(chan struct{})\n\treq.Cancel = ch\n\n\treturn func() {\n\t\tclose(ch)\n\t}\n}\n"
  },
  {
    "path": "vendor/golang.org/x/net/context/ctxhttp/cancelreq_go14.go",
    "content": "// Copyright 2015 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// +build !go1.5\n\npackage ctxhttp\n\nimport \"net/http\"\n\ntype requestCanceler interface {\n\tCancelRequest(*http.Request)\n}\n\nfunc canceler(client *http.Client, req *http.Request) func() {\n\trc, ok := client.Transport.(requestCanceler)\n\tif !ok {\n\t\treturn func() {}\n\t}\n\treturn func() {\n\t\trc.CancelRequest(req)\n\t}\n}\n"
  },
  {
    "path": "vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go",
    "content": "// Copyright 2015 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Package ctxhttp provides helper functions for performing context-aware HTTP requests.\npackage ctxhttp\n\nimport (\n\t\"io\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"strings\"\n\n\t\"golang.org/x/net/context\"\n)\n\nfunc nop() {}\n\nvar (\n\ttestHookContextDoneBeforeHeaders = nop\n\ttestHookDoReturned               = nop\n\ttestHookDidBodyClose             = nop\n)\n\n// Do sends an HTTP request with the provided http.Client and returns an HTTP response.\n// If the client is nil, http.DefaultClient is used.\n// If the context is canceled or times out, ctx.Err() will be returned.\nfunc Do(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error) {\n\tif client == nil {\n\t\tclient = http.DefaultClient\n\t}\n\n\t// Request cancelation changed in Go 1.5, see cancelreq.go and cancelreq_go14.go.\n\tcancel := canceler(client, req)\n\n\ttype responseAndError struct {\n\t\tresp *http.Response\n\t\terr  error\n\t}\n\tresult := make(chan responseAndError, 1)\n\n\t// Make local copies of test hooks closed over by goroutines below.\n\t// Prevents data races in tests.\n\ttestHookDoReturned := testHookDoReturned\n\ttestHookDidBodyClose := testHookDidBodyClose\n\n\tgo func() {\n\t\tresp, err := client.Do(req)\n\t\ttestHookDoReturned()\n\t\tresult <- responseAndError{resp, err}\n\t}()\n\n\tvar resp *http.Response\n\n\tselect {\n\tcase <-ctx.Done():\n\t\ttestHookContextDoneBeforeHeaders()\n\t\tcancel()\n\t\t// Clean up after the goroutine calling client.Do:\n\t\tgo func() {\n\t\t\tif r := <-result; r.resp != nil {\n\t\t\t\ttestHookDidBodyClose()\n\t\t\t\tr.resp.Body.Close()\n\t\t\t}\n\t\t}()\n\t\treturn nil, ctx.Err()\n\tcase r := <-result:\n\t\tvar err error\n\t\tresp, err = r.resp, r.err\n\t\tif err != nil {\n\t\t\treturn resp, err\n\t\t}\n\t}\n\n\tc := make(chan struct{})\n\tgo func() {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\tcancel()\n\t\tcase <-c:\n\t\t\t// The response's Body is closed.\n\t\t}\n\t}()\n\tresp.Body = &notifyingReader{resp.Body, c}\n\n\treturn resp, nil\n}\n\n// Get issues a GET request via the Do function.\nfunc Get(ctx context.Context, client *http.Client, url string) (*http.Response, error) {\n\treq, err := http.NewRequest(\"GET\", url, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn Do(ctx, client, req)\n}\n\n// Head issues a HEAD request via the Do function.\nfunc Head(ctx context.Context, client *http.Client, url string) (*http.Response, error) {\n\treq, err := http.NewRequest(\"HEAD\", url, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn Do(ctx, client, req)\n}\n\n// Post issues a POST request via the Do function.\nfunc Post(ctx context.Context, client *http.Client, url string, bodyType string, body io.Reader) (*http.Response, error) {\n\treq, err := http.NewRequest(\"POST\", url, body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Header.Set(\"Content-Type\", bodyType)\n\treturn Do(ctx, client, req)\n}\n\n// PostForm issues a POST request via the Do function.\nfunc PostForm(ctx context.Context, client *http.Client, url string, data url.Values) (*http.Response, error) {\n\treturn Post(ctx, client, url, \"application/x-www-form-urlencoded\", strings.NewReader(data.Encode()))\n}\n\n// notifyingReader is an io.ReadCloser that closes the notify channel after\n// Close is called or a Read fails on the underlying ReadCloser.\ntype notifyingReader struct {\n\tio.ReadCloser\n\tnotify chan<- struct{}\n}\n\nfunc (r *notifyingReader) Read(p []byte) (int, error) {\n\tn, err := r.ReadCloser.Read(p)\n\tif err != nil && r.notify != nil {\n\t\tclose(r.notify)\n\t\tr.notify = nil\n\t}\n\treturn n, err\n}\n\nfunc (r *notifyingReader) Close() error {\n\terr := r.ReadCloser.Close()\n\tif r.notify != nil {\n\t\tclose(r.notify)\n\t\tr.notify = nil\n\t}\n\treturn err\n}\n"
  },
  {
    "path": "vendor/golang.org/x/net/context/go17.go",
    "content": "// Copyright 2016 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// +build go1.7\n\npackage context\n\nimport (\n\t\"context\" // standard library's context, as of Go 1.7\n\t\"time\"\n)\n\nvar (\n\ttodo       = context.TODO()\n\tbackground = context.Background()\n)\n\n// Canceled is the error returned by Context.Err when the context is canceled.\nvar Canceled = context.Canceled\n\n// DeadlineExceeded is the error returned by Context.Err when the context's\n// deadline passes.\nvar DeadlineExceeded = context.DeadlineExceeded\n\n// WithCancel returns a copy of parent with a new Done channel. The returned\n// context's Done channel is closed when the returned cancel function is called\n// or when the parent context's Done channel is closed, whichever happens first.\n//\n// Canceling this context releases resources associated with it, so code should\n// call cancel as soon as the operations running in this Context complete.\nfunc WithCancel(parent Context) (ctx Context, cancel CancelFunc) {\n\tctx, f := context.WithCancel(parent)\n\treturn ctx, CancelFunc(f)\n}\n\n// WithDeadline returns a copy of the parent context with the deadline adjusted\n// to be no later than d.  If the parent's deadline is already earlier than d,\n// WithDeadline(parent, d) is semantically equivalent to parent.  The returned\n// context's Done channel is closed when the deadline expires, when the returned\n// cancel function is called, or when the parent context's Done channel is\n// closed, whichever happens first.\n//\n// Canceling this context releases resources associated with it, so code should\n// call cancel as soon as the operations running in this Context complete.\nfunc WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) {\n\tctx, f := context.WithDeadline(parent, deadline)\n\treturn ctx, CancelFunc(f)\n}\n\n// WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)).\n//\n// Canceling this context releases resources associated with it, so code should\n// call cancel as soon as the operations running in this Context complete:\n//\n// \tfunc slowOperationWithTimeout(ctx context.Context) (Result, error) {\n// \t\tctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)\n// \t\tdefer cancel()  // releases resources if slowOperation completes before timeout elapses\n// \t\treturn slowOperation(ctx)\n// \t}\nfunc WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) {\n\treturn WithDeadline(parent, time.Now().Add(timeout))\n}\n\n// WithValue returns a copy of parent in which the value associated with key is\n// val.\n//\n// Use context Values only for request-scoped data that transits processes and\n// APIs, not for passing optional parameters to functions.\nfunc WithValue(parent Context, key interface{}, val interface{}) Context {\n\treturn context.WithValue(parent, key, val)\n}\n"
  },
  {
    "path": "vendor/golang.org/x/net/context/pre_go17.go",
    "content": "// Copyright 2014 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// +build !go1.7\n\npackage context\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"sync\"\n\t\"time\"\n)\n\n// An emptyCtx is never canceled, has no values, and has no deadline.  It is not\n// struct{}, since vars of this type must have distinct addresses.\ntype emptyCtx int\n\nfunc (*emptyCtx) Deadline() (deadline time.Time, ok bool) {\n\treturn\n}\n\nfunc (*emptyCtx) Done() <-chan struct{} {\n\treturn nil\n}\n\nfunc (*emptyCtx) Err() error {\n\treturn nil\n}\n\nfunc (*emptyCtx) Value(key interface{}) interface{} {\n\treturn nil\n}\n\nfunc (e *emptyCtx) String() string {\n\tswitch e {\n\tcase background:\n\t\treturn \"context.Background\"\n\tcase todo:\n\t\treturn \"context.TODO\"\n\t}\n\treturn \"unknown empty Context\"\n}\n\nvar (\n\tbackground = new(emptyCtx)\n\ttodo       = new(emptyCtx)\n)\n\n// Canceled is the error returned by Context.Err when the context is canceled.\nvar Canceled = errors.New(\"context canceled\")\n\n// DeadlineExceeded is the error returned by Context.Err when the context's\n// deadline passes.\nvar DeadlineExceeded = errors.New(\"context deadline exceeded\")\n\n// WithCancel returns a copy of parent with a new Done channel. The returned\n// context's Done channel is closed when the returned cancel function is called\n// or when the parent context's Done channel is closed, whichever happens first.\n//\n// Canceling this context releases resources associated with it, so code should\n// call cancel as soon as the operations running in this Context complete.\nfunc WithCancel(parent Context) (ctx Context, cancel CancelFunc) {\n\tc := newCancelCtx(parent)\n\tpropagateCancel(parent, c)\n\treturn c, func() { c.cancel(true, Canceled) }\n}\n\n// newCancelCtx returns an initialized cancelCtx.\nfunc newCancelCtx(parent Context) *cancelCtx {\n\treturn &cancelCtx{\n\t\tContext: parent,\n\t\tdone:    make(chan struct{}),\n\t}\n}\n\n// propagateCancel arranges for child to be canceled when parent is.\nfunc propagateCancel(parent Context, child canceler) {\n\tif parent.Done() == nil {\n\t\treturn // parent is never canceled\n\t}\n\tif p, ok := parentCancelCtx(parent); ok {\n\t\tp.mu.Lock()\n\t\tif p.err != nil {\n\t\t\t// parent has already been canceled\n\t\t\tchild.cancel(false, p.err)\n\t\t} else {\n\t\t\tif p.children == nil {\n\t\t\t\tp.children = make(map[canceler]bool)\n\t\t\t}\n\t\t\tp.children[child] = true\n\t\t}\n\t\tp.mu.Unlock()\n\t} else {\n\t\tgo func() {\n\t\t\tselect {\n\t\t\tcase <-parent.Done():\n\t\t\t\tchild.cancel(false, parent.Err())\n\t\t\tcase <-child.Done():\n\t\t\t}\n\t\t}()\n\t}\n}\n\n// parentCancelCtx follows a chain of parent references until it finds a\n// *cancelCtx.  This function understands how each of the concrete types in this\n// package represents its parent.\nfunc parentCancelCtx(parent Context) (*cancelCtx, bool) {\n\tfor {\n\t\tswitch c := parent.(type) {\n\t\tcase *cancelCtx:\n\t\t\treturn c, true\n\t\tcase *timerCtx:\n\t\t\treturn c.cancelCtx, true\n\t\tcase *valueCtx:\n\t\t\tparent = c.Context\n\t\tdefault:\n\t\t\treturn nil, false\n\t\t}\n\t}\n}\n\n// removeChild removes a context from its parent.\nfunc removeChild(parent Context, child canceler) {\n\tp, ok := parentCancelCtx(parent)\n\tif !ok {\n\t\treturn\n\t}\n\tp.mu.Lock()\n\tif p.children != nil {\n\t\tdelete(p.children, child)\n\t}\n\tp.mu.Unlock()\n}\n\n// A canceler is a context type that can be canceled directly.  The\n// implementations are *cancelCtx and *timerCtx.\ntype canceler interface {\n\tcancel(removeFromParent bool, err error)\n\tDone() <-chan struct{}\n}\n\n// A cancelCtx can be canceled.  When canceled, it also cancels any children\n// that implement canceler.\ntype cancelCtx struct {\n\tContext\n\n\tdone chan struct{} // closed by the first cancel call.\n\n\tmu       sync.Mutex\n\tchildren map[canceler]bool // set to nil by the first cancel call\n\terr      error             // set to non-nil by the first cancel call\n}\n\nfunc (c *cancelCtx) Done() <-chan struct{} {\n\treturn c.done\n}\n\nfunc (c *cancelCtx) Err() error {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\treturn c.err\n}\n\nfunc (c *cancelCtx) String() string {\n\treturn fmt.Sprintf(\"%v.WithCancel\", c.Context)\n}\n\n// cancel closes c.done, cancels each of c's children, and, if\n// removeFromParent is true, removes c from its parent's children.\nfunc (c *cancelCtx) cancel(removeFromParent bool, err error) {\n\tif err == nil {\n\t\tpanic(\"context: internal error: missing cancel error\")\n\t}\n\tc.mu.Lock()\n\tif c.err != nil {\n\t\tc.mu.Unlock()\n\t\treturn // already canceled\n\t}\n\tc.err = err\n\tclose(c.done)\n\tfor child := range c.children {\n\t\t// NOTE: acquiring the child's lock while holding parent's lock.\n\t\tchild.cancel(false, err)\n\t}\n\tc.children = nil\n\tc.mu.Unlock()\n\n\tif removeFromParent {\n\t\tremoveChild(c.Context, c)\n\t}\n}\n\n// WithDeadline returns a copy of the parent context with the deadline adjusted\n// to be no later than d.  If the parent's deadline is already earlier than d,\n// WithDeadline(parent, d) is semantically equivalent to parent.  The returned\n// context's Done channel is closed when the deadline expires, when the returned\n// cancel function is called, or when the parent context's Done channel is\n// closed, whichever happens first.\n//\n// Canceling this context releases resources associated with it, so code should\n// call cancel as soon as the operations running in this Context complete.\nfunc WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) {\n\tif cur, ok := parent.Deadline(); ok && cur.Before(deadline) {\n\t\t// The current deadline is already sooner than the new one.\n\t\treturn WithCancel(parent)\n\t}\n\tc := &timerCtx{\n\t\tcancelCtx: newCancelCtx(parent),\n\t\tdeadline:  deadline,\n\t}\n\tpropagateCancel(parent, c)\n\td := deadline.Sub(time.Now())\n\tif d <= 0 {\n\t\tc.cancel(true, DeadlineExceeded) // deadline has already passed\n\t\treturn c, func() { c.cancel(true, Canceled) }\n\t}\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\tif c.err == nil {\n\t\tc.timer = time.AfterFunc(d, func() {\n\t\t\tc.cancel(true, DeadlineExceeded)\n\t\t})\n\t}\n\treturn c, func() { c.cancel(true, Canceled) }\n}\n\n// A timerCtx carries a timer and a deadline.  It embeds a cancelCtx to\n// implement Done and Err.  It implements cancel by stopping its timer then\n// delegating to cancelCtx.cancel.\ntype timerCtx struct {\n\t*cancelCtx\n\ttimer *time.Timer // Under cancelCtx.mu.\n\n\tdeadline time.Time\n}\n\nfunc (c *timerCtx) Deadline() (deadline time.Time, ok bool) {\n\treturn c.deadline, true\n}\n\nfunc (c *timerCtx) String() string {\n\treturn fmt.Sprintf(\"%v.WithDeadline(%s [%s])\", c.cancelCtx.Context, c.deadline, c.deadline.Sub(time.Now()))\n}\n\nfunc (c *timerCtx) cancel(removeFromParent bool, err error) {\n\tc.cancelCtx.cancel(false, err)\n\tif removeFromParent {\n\t\t// Remove this timerCtx from its parent cancelCtx's children.\n\t\tremoveChild(c.cancelCtx.Context, c)\n\t}\n\tc.mu.Lock()\n\tif c.timer != nil {\n\t\tc.timer.Stop()\n\t\tc.timer = nil\n\t}\n\tc.mu.Unlock()\n}\n\n// WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)).\n//\n// Canceling this context releases resources associated with it, so code should\n// call cancel as soon as the operations running in this Context complete:\n//\n// \tfunc slowOperationWithTimeout(ctx context.Context) (Result, error) {\n// \t\tctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)\n// \t\tdefer cancel()  // releases resources if slowOperation completes before timeout elapses\n// \t\treturn slowOperation(ctx)\n// \t}\nfunc WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) {\n\treturn WithDeadline(parent, time.Now().Add(timeout))\n}\n\n// WithValue returns a copy of parent in which the value associated with key is\n// val.\n//\n// Use context Values only for request-scoped data that transits processes and\n// APIs, not for passing optional parameters to functions.\nfunc WithValue(parent Context, key interface{}, val interface{}) Context {\n\treturn &valueCtx{parent, key, val}\n}\n\n// A valueCtx carries a key-value pair.  It implements Value for that key and\n// delegates all other calls to the embedded Context.\ntype valueCtx struct {\n\tContext\n\tkey, val interface{}\n}\n\nfunc (c *valueCtx) String() string {\n\treturn fmt.Sprintf(\"%v.WithValue(%#v, %#v)\", c.Context, c.key, c.val)\n}\n\nfunc (c *valueCtx) Value(key interface{}) interface{} {\n\tif c.key == key {\n\t\treturn c.val\n\t}\n\treturn c.Context.Value(key)\n}\n"
  },
  {
    "path": "vendor/golang.org/x/oauth2/.travis.yml",
    "content": "language: go\n\ngo:\n  - 1.3\n  - 1.4\n\ninstall:\n  - export GOPATH=\"$HOME/gopath\"\n  - mkdir -p \"$GOPATH/src/golang.org/x\"\n  - mv \"$TRAVIS_BUILD_DIR\" \"$GOPATH/src/golang.org/x/oauth2\"\n  - go get -v -t -d golang.org/x/oauth2/...\n\nscript:\n  - go test -v golang.org/x/oauth2/...\n"
  },
  {
    "path": "vendor/golang.org/x/oauth2/AUTHORS",
    "content": "# This source code refers to The Go Authors for copyright purposes.\n# The master list of authors is in the main Go distribution,\n# visible at http://tip.golang.org/AUTHORS.\n"
  },
  {
    "path": "vendor/golang.org/x/oauth2/CONTRIBUTING.md",
    "content": "# Contributing to Go\n\nGo is an open source project.\n\nIt is the work of hundreds of contributors. We appreciate your help!\n\n\n## Filing issues\n\nWhen [filing an issue](https://github.com/golang/oauth2/issues), make sure to answer these five questions:\n\n1. What version of Go are you using (`go version`)?\n2. What operating system and processor architecture are you using?\n3. What did you do?\n4. What did you expect to see?\n5. What did you see instead?\n\nGeneral questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker.\nThe gophers there will answer or ask you to file an issue if you've tripped over a bug.\n\n## Contributing code\n\nPlease read the [Contribution Guidelines](https://golang.org/doc/contribute.html)\nbefore sending patches.\n\n**We do not accept GitHub pull requests**\n(we use [Gerrit](https://code.google.com/p/gerrit/) instead for code review).\n\nUnless otherwise noted, the Go source files are distributed under\nthe BSD-style license found in the LICENSE file.\n\n"
  },
  {
    "path": "vendor/golang.org/x/oauth2/CONTRIBUTORS",
    "content": "# This source code was written by the Go contributors.\n# The master list of contributors is in the main Go distribution,\n# visible at http://tip.golang.org/CONTRIBUTORS.\n"
  },
  {
    "path": "vendor/golang.org/x/oauth2/LICENSE",
    "content": "Copyright (c) 2009 The oauth2 Authors. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n   * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n   * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n   * Neither the name of Google Inc. nor the names of its\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  },
  {
    "path": "vendor/golang.org/x/oauth2/README.md",
    "content": "# OAuth2 for Go\n\n[![Build Status](https://travis-ci.org/golang/oauth2.svg?branch=master)](https://travis-ci.org/golang/oauth2)\n\noauth2 package contains a client implementation for OAuth 2.0 spec.\n\n## Installation\n\n~~~~\ngo get golang.org/x/oauth2\n~~~~\n\nSee godoc for further documentation and examples.\n\n* [godoc.org/golang.org/x/oauth2](http://godoc.org/golang.org/x/oauth2)\n* [godoc.org/golang.org/x/oauth2/google](http://godoc.org/golang.org/x/oauth2/google)\n\n\n## App Engine\n\nIn change 96e89be (March 2015) we removed the `oauth2.Context2` type in favor\nof the [`context.Context`](https://golang.org/x/net/context#Context) type from\nthe `golang.org/x/net/context` package\n\nThis means its no longer possible to use the \"Classic App Engine\"\n`appengine.Context` type with the `oauth2` package. (You're using\nClassic App Engine if you import the package `\"appengine\"`.)\n\nTo work around this, you may use the new `\"google.golang.org/appengine\"`\npackage. This package has almost the same API as the `\"appengine\"` package,\nbut it can be fetched with `go get` and used on \"Managed VMs\" and well as\nClassic App Engine.\n\nSee the [new `appengine` package's readme](https://github.com/golang/appengine#updating-a-go-app-engine-app)\nfor information on updating your app.\n\nIf you don't want to update your entire app to use the new App Engine packages,\nyou may use both sets of packages in parallel, using only the new packages\nwith the `oauth2` package.\n\n\timport (\n\t\t\"golang.org/x/net/context\"\n\t\t\"golang.org/x/oauth2\"\n\t\t\"golang.org/x/oauth2/google\"\n\t\tnewappengine \"google.golang.org/appengine\"\n\t\tnewurlfetch \"google.golang.org/appengine/urlfetch\"\n\n\t\t\"appengine\"\n\t)\n\n\tfunc handler(w http.ResponseWriter, r *http.Request) {\n\t\tvar c appengine.Context = appengine.NewContext(r)\n\t\tc.Infof(\"Logging a message with the old package\")\n\n\t\tvar ctx context.Context = newappengine.NewContext(r)\n\t\tclient := &http.Client{\n\t\t\tTransport: &oauth2.Transport{\n\t\t\t\tSource: google.AppEngineTokenSource(ctx, \"scope\"),\n\t\t\t\tBase:   &newurlfetch.Transport{Context: ctx},\n\t\t\t},\n\t\t}\n\t\tclient.Get(\"...\")\n\t}\n\n"
  },
  {
    "path": "vendor/golang.org/x/oauth2/client_appengine.go",
    "content": "// Copyright 2014 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// +build appengine\n\n// App Engine hooks.\n\npackage oauth2\n\nimport (\n\t\"net/http\"\n\n\t\"golang.org/x/net/context\"\n\t\"golang.org/x/oauth2/internal\"\n\t\"google.golang.org/appengine/urlfetch\"\n)\n\nfunc init() {\n\tinternal.RegisterContextClientFunc(contextClientAppEngine)\n}\n\nfunc contextClientAppEngine(ctx context.Context) (*http.Client, error) {\n\treturn urlfetch.Client(ctx), nil\n}\n"
  },
  {
    "path": "vendor/golang.org/x/oauth2/internal/oauth2.go",
    "content": "// Copyright 2014 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Package internal contains support packages for oauth2 package.\npackage internal\n\nimport (\n\t\"bufio\"\n\t\"crypto/rsa\"\n\t\"crypto/x509\"\n\t\"encoding/pem\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"strings\"\n)\n\n// ParseKey converts the binary contents of a private key file\n// to an *rsa.PrivateKey. It detects whether the private key is in a\n// PEM container or not. If so, it extracts the the private key\n// from PEM container before conversion. It only supports PEM\n// containers with no passphrase.\nfunc ParseKey(key []byte) (*rsa.PrivateKey, error) {\n\tblock, _ := pem.Decode(key)\n\tif block != nil {\n\t\tkey = block.Bytes\n\t}\n\tparsedKey, err := x509.ParsePKCS8PrivateKey(key)\n\tif err != nil {\n\t\tparsedKey, err = x509.ParsePKCS1PrivateKey(key)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"private key should be a PEM or plain PKSC1 or PKCS8; parse error: %v\", err)\n\t\t}\n\t}\n\tparsed, ok := parsedKey.(*rsa.PrivateKey)\n\tif !ok {\n\t\treturn nil, errors.New(\"private key is invalid\")\n\t}\n\treturn parsed, nil\n}\n\nfunc ParseINI(ini io.Reader) (map[string]map[string]string, error) {\n\tresult := map[string]map[string]string{\n\t\t\"\": map[string]string{}, // root section\n\t}\n\tscanner := bufio.NewScanner(ini)\n\tcurrentSection := \"\"\n\tfor scanner.Scan() {\n\t\tline := strings.TrimSpace(scanner.Text())\n\t\tif strings.HasPrefix(line, \";\") {\n\t\t\t// comment.\n\t\t\tcontinue\n\t\t}\n\t\tif strings.HasPrefix(line, \"[\") && strings.HasSuffix(line, \"]\") {\n\t\t\tcurrentSection = strings.TrimSpace(line[1 : len(line)-1])\n\t\t\tresult[currentSection] = map[string]string{}\n\t\t\tcontinue\n\t\t}\n\t\tparts := strings.SplitN(line, \"=\", 2)\n\t\tif len(parts) == 2 && parts[0] != \"\" {\n\t\t\tresult[currentSection][strings.TrimSpace(parts[0])] = strings.TrimSpace(parts[1])\n\t\t}\n\t}\n\tif err := scanner.Err(); err != nil {\n\t\treturn nil, fmt.Errorf(\"error scanning ini: %v\", err)\n\t}\n\treturn result, nil\n}\n\nfunc CondVal(v string) []string {\n\tif v == \"\" {\n\t\treturn nil\n\t}\n\treturn []string{v}\n}\n"
  },
  {
    "path": "vendor/golang.org/x/oauth2/internal/token.go",
    "content": "// Copyright 2014 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Package internal contains support packages for oauth2 package.\npackage internal\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"mime\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n\n\t\"golang.org/x/net/context\"\n)\n\n// Token represents the crendentials used to authorize\n// the requests to access protected resources on the OAuth 2.0\n// provider's backend.\n//\n// This type is a mirror of oauth2.Token and exists to break\n// an otherwise-circular dependency. Other internal packages\n// should convert this Token into an oauth2.Token before use.\ntype Token struct {\n\t// AccessToken is the token that authorizes and authenticates\n\t// the requests.\n\tAccessToken string\n\n\t// TokenType is the type of token.\n\t// The Type method returns either this or \"Bearer\", the default.\n\tTokenType string\n\n\t// RefreshToken is a token that's used by the application\n\t// (as opposed to the user) to refresh the access token\n\t// if it expires.\n\tRefreshToken string\n\n\t// Expiry is the optional expiration time of the access token.\n\t//\n\t// If zero, TokenSource implementations will reuse the same\n\t// token forever and RefreshToken or equivalent\n\t// mechanisms for that TokenSource will not be used.\n\tExpiry time.Time\n\n\t// Raw optionally contains extra metadata from the server\n\t// when updating a token.\n\tRaw interface{}\n}\n\n// tokenJSON is the struct representing the HTTP response from OAuth2\n// providers returning a token in JSON form.\ntype tokenJSON struct {\n\tAccessToken  string         `json:\"access_token\"`\n\tTokenType    string         `json:\"token_type\"`\n\tRefreshToken string         `json:\"refresh_token\"`\n\tExpiresIn    expirationTime `json:\"expires_in\"` // at least PayPal returns string, while most return number\n\tExpires      expirationTime `json:\"expires\"`    // broken Facebook spelling of expires_in\n}\n\nfunc (e *tokenJSON) expiry() (t time.Time) {\n\tif v := e.ExpiresIn; v != 0 {\n\t\treturn time.Now().Add(time.Duration(v) * time.Second)\n\t}\n\tif v := e.Expires; v != 0 {\n\t\treturn time.Now().Add(time.Duration(v) * time.Second)\n\t}\n\treturn\n}\n\ntype expirationTime int32\n\nfunc (e *expirationTime) UnmarshalJSON(b []byte) error {\n\tvar n json.Number\n\terr := json.Unmarshal(b, &n)\n\tif err != nil {\n\t\treturn err\n\t}\n\ti, err := n.Int64()\n\tif err != nil {\n\t\treturn err\n\t}\n\t*e = expirationTime(i)\n\treturn nil\n}\n\nvar brokenAuthHeaderProviders = []string{\n\t\"https://accounts.google.com/\",\n\t\"https://api.dropbox.com/\",\n\t\"https://api.dropboxapi.com/\",\n\t\"https://api.instagram.com/\",\n\t\"https://api.netatmo.net/\",\n\t\"https://api.odnoklassniki.ru/\",\n\t\"https://api.pushbullet.com/\",\n\t\"https://api.soundcloud.com/\",\n\t\"https://api.twitch.tv/\",\n\t\"https://app.box.com/\",\n\t\"https://connect.stripe.com/\",\n\t\"https://login.microsoftonline.com/\",\n\t\"https://login.salesforce.com/\",\n\t\"https://oauth.sandbox.trainingpeaks.com/\",\n\t\"https://oauth.trainingpeaks.com/\",\n\t\"https://oauth.vk.com/\",\n\t\"https://openapi.baidu.com/\",\n\t\"https://slack.com/\",\n\t\"https://test-sandbox.auth.corp.google.com\",\n\t\"https://test.salesforce.com/\",\n\t\"https://user.gini.net/\",\n\t\"https://www.douban.com/\",\n\t\"https://www.googleapis.com/\",\n\t\"https://www.linkedin.com/\",\n\t\"https://www.strava.com/oauth/\",\n\t\"https://www.wunderlist.com/oauth/\",\n\t\"https://api.patreon.com/\",\n}\n\nfunc RegisterBrokenAuthHeaderProvider(tokenURL string) {\n\tbrokenAuthHeaderProviders = append(brokenAuthHeaderProviders, tokenURL)\n}\n\n// providerAuthHeaderWorks reports whether the OAuth2 server identified by the tokenURL\n// implements the OAuth2 spec correctly\n// See https://code.google.com/p/goauth2/issues/detail?id=31 for background.\n// In summary:\n// - Reddit only accepts client secret in the Authorization header\n// - Dropbox accepts either it in URL param or Auth header, but not both.\n// - Google only accepts URL param (not spec compliant?), not Auth header\n// - Stripe only accepts client secret in Auth header with Bearer method, not Basic\nfunc providerAuthHeaderWorks(tokenURL string) bool {\n\tfor _, s := range brokenAuthHeaderProviders {\n\t\tif strings.HasPrefix(tokenURL, s) {\n\t\t\t// Some sites fail to implement the OAuth2 spec fully.\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// Assume the provider implements the spec properly\n\t// otherwise. We can add more exceptions as they're\n\t// discovered. We will _not_ be adding configurable hooks\n\t// to this package to let users select server bugs.\n\treturn true\n}\n\nfunc RetrieveToken(ctx context.Context, ClientID, ClientSecret, TokenURL string, v url.Values) (*Token, error) {\n\thc, err := ContextClient(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tv.Set(\"client_id\", ClientID)\n\tbustedAuth := !providerAuthHeaderWorks(TokenURL)\n\tif bustedAuth && ClientSecret != \"\" {\n\t\tv.Set(\"client_secret\", ClientSecret)\n\t}\n\treq, err := http.NewRequest(\"POST\", TokenURL, strings.NewReader(v.Encode()))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\tif !bustedAuth {\n\t\treq.SetBasicAuth(ClientID, ClientSecret)\n\t}\n\tr, err := hc.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer r.Body.Close()\n\tbody, err := ioutil.ReadAll(io.LimitReader(r.Body, 1<<20))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"oauth2: cannot fetch token: %v\", err)\n\t}\n\tif code := r.StatusCode; code < 200 || code > 299 {\n\t\treturn nil, fmt.Errorf(\"oauth2: cannot fetch token: %v\\nResponse: %s\", r.Status, body)\n\t}\n\n\tvar token *Token\n\tcontent, _, _ := mime.ParseMediaType(r.Header.Get(\"Content-Type\"))\n\tswitch content {\n\tcase \"application/x-www-form-urlencoded\", \"text/plain\":\n\t\tvals, err := url.ParseQuery(string(body))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttoken = &Token{\n\t\t\tAccessToken:  vals.Get(\"access_token\"),\n\t\t\tTokenType:    vals.Get(\"token_type\"),\n\t\t\tRefreshToken: vals.Get(\"refresh_token\"),\n\t\t\tRaw:          vals,\n\t\t}\n\t\te := vals.Get(\"expires_in\")\n\t\tif e == \"\" {\n\t\t\t// TODO(jbd): Facebook's OAuth2 implementation is broken and\n\t\t\t// returns expires_in field in expires. Remove the fallback to expires,\n\t\t\t// when Facebook fixes their implementation.\n\t\t\te = vals.Get(\"expires\")\n\t\t}\n\t\texpires, _ := strconv.Atoi(e)\n\t\tif expires != 0 {\n\t\t\ttoken.Expiry = time.Now().Add(time.Duration(expires) * time.Second)\n\t\t}\n\tdefault:\n\t\tvar tj tokenJSON\n\t\tif err = json.Unmarshal(body, &tj); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttoken = &Token{\n\t\t\tAccessToken:  tj.AccessToken,\n\t\t\tTokenType:    tj.TokenType,\n\t\t\tRefreshToken: tj.RefreshToken,\n\t\t\tExpiry:       tj.expiry(),\n\t\t\tRaw:          make(map[string]interface{}),\n\t\t}\n\t\tjson.Unmarshal(body, &token.Raw) // no error checks for optional fields\n\t}\n\t// Don't overwrite `RefreshToken` with an empty value\n\t// if this was a token refreshing request.\n\tif token.RefreshToken == \"\" {\n\t\ttoken.RefreshToken = v.Get(\"refresh_token\")\n\t}\n\treturn token, nil\n}\n"
  },
  {
    "path": "vendor/golang.org/x/oauth2/internal/transport.go",
    "content": "// Copyright 2014 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Package internal contains support packages for oauth2 package.\npackage internal\n\nimport (\n\t\"net/http\"\n\n\t\"golang.org/x/net/context\"\n)\n\n// HTTPClient is the context key to use with golang.org/x/net/context's\n// WithValue function to associate an *http.Client value with a context.\nvar HTTPClient ContextKey\n\n// ContextKey is just an empty struct. It exists so HTTPClient can be\n// an immutable public variable with a unique type. It's immutable\n// because nobody else can create a ContextKey, being unexported.\ntype ContextKey struct{}\n\n// ContextClientFunc is a func which tries to return an *http.Client\n// given a Context value. If it returns an error, the search stops\n// with that error.  If it returns (nil, nil), the search continues\n// down the list of registered funcs.\ntype ContextClientFunc func(context.Context) (*http.Client, error)\n\nvar contextClientFuncs []ContextClientFunc\n\nfunc RegisterContextClientFunc(fn ContextClientFunc) {\n\tcontextClientFuncs = append(contextClientFuncs, fn)\n}\n\nfunc ContextClient(ctx context.Context) (*http.Client, error) {\n\tif ctx != nil {\n\t\tif hc, ok := ctx.Value(HTTPClient).(*http.Client); ok {\n\t\t\treturn hc, nil\n\t\t}\n\t}\n\tfor _, fn := range contextClientFuncs {\n\t\tc, err := fn(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif c != nil {\n\t\t\treturn c, nil\n\t\t}\n\t}\n\treturn http.DefaultClient, nil\n}\n\nfunc ContextTransport(ctx context.Context) http.RoundTripper {\n\thc, err := ContextClient(ctx)\n\t// This is a rare error case (somebody using nil on App Engine).\n\tif err != nil {\n\t\treturn ErrorTransport{err}\n\t}\n\treturn hc.Transport\n}\n\n// ErrorTransport returns the specified error on RoundTrip.\n// This RoundTripper should be used in rare error cases where\n// error handling can be postponed to response handling time.\ntype ErrorTransport struct{ Err error }\n\nfunc (t ErrorTransport) RoundTrip(*http.Request) (*http.Response, error) {\n\treturn nil, t.Err\n}\n"
  },
  {
    "path": "vendor/golang.org/x/oauth2/oauth2.go",
    "content": "// Copyright 2014 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Package oauth2 provides support for making\n// OAuth2 authorized and authenticated HTTP requests.\n// It can additionally grant authorization with Bearer JWT.\npackage oauth2\n\nimport (\n\t\"bytes\"\n\t\"errors\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"strings\"\n\t\"sync\"\n\n\t\"golang.org/x/net/context\"\n\t\"golang.org/x/oauth2/internal\"\n)\n\n// NoContext is the default context you should supply if not using\n// your own context.Context (see https://golang.org/x/net/context).\nvar NoContext = context.TODO()\n\n// RegisterBrokenAuthHeaderProvider registers an OAuth2 server\n// identified by the tokenURL prefix as an OAuth2 implementation\n// which doesn't support the HTTP Basic authentication\n// scheme to authenticate with the authorization server.\n// Once a server is registered, credentials (client_id and client_secret)\n// will be passed as query parameters rather than being present\n// in the Authorization header.\n// See https://code.google.com/p/goauth2/issues/detail?id=31 for background.\nfunc RegisterBrokenAuthHeaderProvider(tokenURL string) {\n\tinternal.RegisterBrokenAuthHeaderProvider(tokenURL)\n}\n\n// Config describes a typical 3-legged OAuth2 flow, with both the\n// client application information and the server's endpoint URLs.\ntype Config struct {\n\t// ClientID is the application's ID.\n\tClientID string\n\n\t// ClientSecret is the application's secret.\n\tClientSecret string\n\n\t// Endpoint contains the resource server's token endpoint\n\t// URLs. These are constants specific to each server and are\n\t// often available via site-specific packages, such as\n\t// google.Endpoint or github.Endpoint.\n\tEndpoint Endpoint\n\n\t// RedirectURL is the URL to redirect users going through\n\t// the OAuth flow, after the resource owner's URLs.\n\tRedirectURL string\n\n\t// Scope specifies optional requested permissions.\n\tScopes []string\n}\n\n// A TokenSource is anything that can return a token.\ntype TokenSource interface {\n\t// Token returns a token or an error.\n\t// Token must be safe for concurrent use by multiple goroutines.\n\t// The returned Token must not be modified.\n\tToken() (*Token, error)\n}\n\n// Endpoint contains the OAuth 2.0 provider's authorization and token\n// endpoint URLs.\ntype Endpoint struct {\n\tAuthURL  string\n\tTokenURL string\n}\n\nvar (\n\t// AccessTypeOnline and AccessTypeOffline are options passed\n\t// to the Options.AuthCodeURL method. They modify the\n\t// \"access_type\" field that gets sent in the URL returned by\n\t// AuthCodeURL.\n\t//\n\t// Online is the default if neither is specified. If your\n\t// application needs to refresh access tokens when the user\n\t// is not present at the browser, then use offline. This will\n\t// result in your application obtaining a refresh token the\n\t// first time your application exchanges an authorization\n\t// code for a user.\n\tAccessTypeOnline  AuthCodeOption = SetAuthURLParam(\"access_type\", \"online\")\n\tAccessTypeOffline AuthCodeOption = SetAuthURLParam(\"access_type\", \"offline\")\n\n\t// ApprovalForce forces the users to view the consent dialog\n\t// and confirm the permissions request at the URL returned\n\t// from AuthCodeURL, even if they've already done so.\n\tApprovalForce AuthCodeOption = SetAuthURLParam(\"approval_prompt\", \"force\")\n)\n\n// An AuthCodeOption is passed to Config.AuthCodeURL.\ntype AuthCodeOption interface {\n\tsetValue(url.Values)\n}\n\ntype setParam struct{ k, v string }\n\nfunc (p setParam) setValue(m url.Values) { m.Set(p.k, p.v) }\n\n// SetAuthURLParam builds an AuthCodeOption which passes key/value parameters\n// to a provider's authorization endpoint.\nfunc SetAuthURLParam(key, value string) AuthCodeOption {\n\treturn setParam{key, value}\n}\n\n// AuthCodeURL returns a URL to OAuth 2.0 provider's consent page\n// that asks for permissions for the required scopes explicitly.\n//\n// State is a token to protect the user from CSRF attacks. You must\n// always provide a non-zero string and validate that it matches the\n// the state query parameter on your redirect callback.\n// See http://tools.ietf.org/html/rfc6749#section-10.12 for more info.\n//\n// Opts may include AccessTypeOnline or AccessTypeOffline, as well\n// as ApprovalForce.\nfunc (c *Config) AuthCodeURL(state string, opts ...AuthCodeOption) string {\n\tvar buf bytes.Buffer\n\tbuf.WriteString(c.Endpoint.AuthURL)\n\tv := url.Values{\n\t\t\"response_type\": {\"code\"},\n\t\t\"client_id\":     {c.ClientID},\n\t\t\"redirect_uri\":  internal.CondVal(c.RedirectURL),\n\t\t\"scope\":         internal.CondVal(strings.Join(c.Scopes, \" \")),\n\t\t\"state\":         internal.CondVal(state),\n\t}\n\tfor _, opt := range opts {\n\t\topt.setValue(v)\n\t}\n\tif strings.Contains(c.Endpoint.AuthURL, \"?\") {\n\t\tbuf.WriteByte('&')\n\t} else {\n\t\tbuf.WriteByte('?')\n\t}\n\tbuf.WriteString(v.Encode())\n\treturn buf.String()\n}\n\n// PasswordCredentialsToken converts a resource owner username and password\n// pair into a token.\n//\n// Per the RFC, this grant type should only be used \"when there is a high\n// degree of trust between the resource owner and the client (e.g., the client\n// is part of the device operating system or a highly privileged application),\n// and when other authorization grant types are not available.\"\n// See https://tools.ietf.org/html/rfc6749#section-4.3 for more info.\n//\n// The HTTP client to use is derived from the context.\n// If nil, http.DefaultClient is used.\nfunc (c *Config) PasswordCredentialsToken(ctx context.Context, username, password string) (*Token, error) {\n\treturn retrieveToken(ctx, c, url.Values{\n\t\t\"grant_type\": {\"password\"},\n\t\t\"username\":   {username},\n\t\t\"password\":   {password},\n\t\t\"scope\":      internal.CondVal(strings.Join(c.Scopes, \" \")),\n\t})\n}\n\n// Exchange converts an authorization code into a token.\n//\n// It is used after a resource provider redirects the user back\n// to the Redirect URI (the URL obtained from AuthCodeURL).\n//\n// The HTTP client to use is derived from the context.\n// If a client is not provided via the context, http.DefaultClient is used.\n//\n// The code will be in the *http.Request.FormValue(\"code\"). Before\n// calling Exchange, be sure to validate FormValue(\"state\").\nfunc (c *Config) Exchange(ctx context.Context, code string) (*Token, error) {\n\treturn retrieveToken(ctx, c, url.Values{\n\t\t\"grant_type\":   {\"authorization_code\"},\n\t\t\"code\":         {code},\n\t\t\"redirect_uri\": internal.CondVal(c.RedirectURL),\n\t\t\"scope\":        internal.CondVal(strings.Join(c.Scopes, \" \")),\n\t})\n}\n\n// Client returns an HTTP client using the provided token.\n// The token will auto-refresh as necessary. The underlying\n// HTTP transport will be obtained using the provided context.\n// The returned client and its Transport should not be modified.\nfunc (c *Config) Client(ctx context.Context, t *Token) *http.Client {\n\treturn NewClient(ctx, c.TokenSource(ctx, t))\n}\n\n// TokenSource returns a TokenSource that returns t until t expires,\n// automatically refreshing it as necessary using the provided context.\n//\n// Most users will use Config.Client instead.\nfunc (c *Config) TokenSource(ctx context.Context, t *Token) TokenSource {\n\ttkr := &tokenRefresher{\n\t\tctx:  ctx,\n\t\tconf: c,\n\t}\n\tif t != nil {\n\t\ttkr.refreshToken = t.RefreshToken\n\t}\n\treturn &reuseTokenSource{\n\t\tt:   t,\n\t\tnew: tkr,\n\t}\n}\n\n// tokenRefresher is a TokenSource that makes \"grant_type\"==\"refresh_token\"\n// HTTP requests to renew a token using a RefreshToken.\ntype tokenRefresher struct {\n\tctx          context.Context // used to get HTTP requests\n\tconf         *Config\n\trefreshToken string\n}\n\n// WARNING: Token is not safe for concurrent access, as it\n// updates the tokenRefresher's refreshToken field.\n// Within this package, it is used by reuseTokenSource which\n// synchronizes calls to this method with its own mutex.\nfunc (tf *tokenRefresher) Token() (*Token, error) {\n\tif tf.refreshToken == \"\" {\n\t\treturn nil, errors.New(\"oauth2: token expired and refresh token is not set\")\n\t}\n\n\ttk, err := retrieveToken(tf.ctx, tf.conf, url.Values{\n\t\t\"grant_type\":    {\"refresh_token\"},\n\t\t\"refresh_token\": {tf.refreshToken},\n\t})\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif tf.refreshToken != tk.RefreshToken {\n\t\ttf.refreshToken = tk.RefreshToken\n\t}\n\treturn tk, err\n}\n\n// reuseTokenSource is a TokenSource that holds a single token in memory\n// and validates its expiry before each call to retrieve it with\n// Token. If it's expired, it will be auto-refreshed using the\n// new TokenSource.\ntype reuseTokenSource struct {\n\tnew TokenSource // called when t is expired.\n\n\tmu sync.Mutex // guards t\n\tt  *Token\n}\n\n// Token returns the current token if it's still valid, else will\n// refresh the current token (using r.Context for HTTP client\n// information) and return the new one.\nfunc (s *reuseTokenSource) Token() (*Token, error) {\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\tif s.t.Valid() {\n\t\treturn s.t, nil\n\t}\n\tt, err := s.new.Token()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ts.t = t\n\treturn t, nil\n}\n\n// StaticTokenSource returns a TokenSource that always returns the same token.\n// Because the provided token t is never refreshed, StaticTokenSource is only\n// useful for tokens that never expire.\nfunc StaticTokenSource(t *Token) TokenSource {\n\treturn staticTokenSource{t}\n}\n\n// staticTokenSource is a TokenSource that always returns the same Token.\ntype staticTokenSource struct {\n\tt *Token\n}\n\nfunc (s staticTokenSource) Token() (*Token, error) {\n\treturn s.t, nil\n}\n\n// HTTPClient is the context key to use with golang.org/x/net/context's\n// WithValue function to associate an *http.Client value with a context.\nvar HTTPClient internal.ContextKey\n\n// NewClient creates an *http.Client from a Context and TokenSource.\n// The returned client is not valid beyond the lifetime of the context.\n//\n// As a special case, if src is nil, a non-OAuth2 client is returned\n// using the provided context. This exists to support related OAuth2\n// packages.\nfunc NewClient(ctx context.Context, src TokenSource) *http.Client {\n\tif src == nil {\n\t\tc, err := internal.ContextClient(ctx)\n\t\tif err != nil {\n\t\t\treturn &http.Client{Transport: internal.ErrorTransport{err}}\n\t\t}\n\t\treturn c\n\t}\n\treturn &http.Client{\n\t\tTransport: &Transport{\n\t\t\tBase:   internal.ContextTransport(ctx),\n\t\t\tSource: ReuseTokenSource(nil, src),\n\t\t},\n\t}\n}\n\n// ReuseTokenSource returns a TokenSource which repeatedly returns the\n// same token as long as it's valid, starting with t.\n// When its cached token is invalid, a new token is obtained from src.\n//\n// ReuseTokenSource is typically used to reuse tokens from a cache\n// (such as a file on disk) between runs of a program, rather than\n// obtaining new tokens unnecessarily.\n//\n// The initial token t may be nil, in which case the TokenSource is\n// wrapped in a caching version if it isn't one already. This also\n// means it's always safe to wrap ReuseTokenSource around any other\n// TokenSource without adverse effects.\nfunc ReuseTokenSource(t *Token, src TokenSource) TokenSource {\n\t// Don't wrap a reuseTokenSource in itself. That would work,\n\t// but cause an unnecessary number of mutex operations.\n\t// Just build the equivalent one.\n\tif rt, ok := src.(*reuseTokenSource); ok {\n\t\tif t == nil {\n\t\t\t// Just use it directly.\n\t\t\treturn rt\n\t\t}\n\t\tsrc = rt.new\n\t}\n\treturn &reuseTokenSource{\n\t\tt:   t,\n\t\tnew: src,\n\t}\n}\n"
  },
  {
    "path": "vendor/golang.org/x/oauth2/token.go",
    "content": "// Copyright 2014 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage oauth2\n\nimport (\n\t\"net/http\"\n\t\"net/url\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n\n\t\"golang.org/x/net/context\"\n\t\"golang.org/x/oauth2/internal\"\n)\n\n// expiryDelta determines how earlier a token should be considered\n// expired than its actual expiration time. It is used to avoid late\n// expirations due to client-server time mismatches.\nconst expiryDelta = 10 * time.Second\n\n// Token represents the crendentials used to authorize\n// the requests to access protected resources on the OAuth 2.0\n// provider's backend.\n//\n// Most users of this package should not access fields of Token\n// directly. They're exported mostly for use by related packages\n// implementing derivative OAuth2 flows.\ntype Token struct {\n\t// AccessToken is the token that authorizes and authenticates\n\t// the requests.\n\tAccessToken string `json:\"access_token\"`\n\n\t// TokenType is the type of token.\n\t// The Type method returns either this or \"Bearer\", the default.\n\tTokenType string `json:\"token_type,omitempty\"`\n\n\t// RefreshToken is a token that's used by the application\n\t// (as opposed to the user) to refresh the access token\n\t// if it expires.\n\tRefreshToken string `json:\"refresh_token,omitempty\"`\n\n\t// Expiry is the optional expiration time of the access token.\n\t//\n\t// If zero, TokenSource implementations will reuse the same\n\t// token forever and RefreshToken or equivalent\n\t// mechanisms for that TokenSource will not be used.\n\tExpiry time.Time `json:\"expiry,omitempty\"`\n\n\t// raw optionally contains extra metadata from the server\n\t// when updating a token.\n\traw interface{}\n}\n\n// Type returns t.TokenType if non-empty, else \"Bearer\".\nfunc (t *Token) Type() string {\n\tif strings.EqualFold(t.TokenType, \"bearer\") {\n\t\treturn \"Bearer\"\n\t}\n\tif strings.EqualFold(t.TokenType, \"mac\") {\n\t\treturn \"MAC\"\n\t}\n\tif strings.EqualFold(t.TokenType, \"basic\") {\n\t\treturn \"Basic\"\n\t}\n\tif t.TokenType != \"\" {\n\t\treturn t.TokenType\n\t}\n\treturn \"Bearer\"\n}\n\n// SetAuthHeader sets the Authorization header to r using the access\n// token in t.\n//\n// This method is unnecessary when using Transport or an HTTP Client\n// returned by this package.\nfunc (t *Token) SetAuthHeader(r *http.Request) {\n\tr.Header.Set(\"Authorization\", t.Type()+\" \"+t.AccessToken)\n}\n\n// WithExtra returns a new Token that's a clone of t, but using the\n// provided raw extra map. This is only intended for use by packages\n// implementing derivative OAuth2 flows.\nfunc (t *Token) WithExtra(extra interface{}) *Token {\n\tt2 := new(Token)\n\t*t2 = *t\n\tt2.raw = extra\n\treturn t2\n}\n\n// Extra returns an extra field.\n// Extra fields are key-value pairs returned by the server as a\n// part of the token retrieval response.\nfunc (t *Token) Extra(key string) interface{} {\n\tif raw, ok := t.raw.(map[string]interface{}); ok {\n\t\treturn raw[key]\n\t}\n\n\tvals, ok := t.raw.(url.Values)\n\tif !ok {\n\t\treturn nil\n\t}\n\n\tv := vals.Get(key)\n\tswitch s := strings.TrimSpace(v); strings.Count(s, \".\") {\n\tcase 0: // Contains no \".\"; try to parse as int\n\t\tif i, err := strconv.ParseInt(s, 10, 64); err == nil {\n\t\t\treturn i\n\t\t}\n\tcase 1: // Contains a single \".\"; try to parse as float\n\t\tif f, err := strconv.ParseFloat(s, 64); err == nil {\n\t\t\treturn f\n\t\t}\n\t}\n\n\treturn v\n}\n\n// expired reports whether the token is expired.\n// t must be non-nil.\nfunc (t *Token) expired() bool {\n\tif t.Expiry.IsZero() {\n\t\treturn false\n\t}\n\treturn t.Expiry.Add(-expiryDelta).Before(time.Now())\n}\n\n// Valid reports whether t is non-nil, has an AccessToken, and is not expired.\nfunc (t *Token) Valid() bool {\n\treturn t != nil && t.AccessToken != \"\" && !t.expired()\n}\n\n// tokenFromInternal maps an *internal.Token struct into\n// a *Token struct.\nfunc tokenFromInternal(t *internal.Token) *Token {\n\tif t == nil {\n\t\treturn nil\n\t}\n\treturn &Token{\n\t\tAccessToken:  t.AccessToken,\n\t\tTokenType:    t.TokenType,\n\t\tRefreshToken: t.RefreshToken,\n\t\tExpiry:       t.Expiry,\n\t\traw:          t.Raw,\n\t}\n}\n\n// retrieveToken takes a *Config and uses that to retrieve an *internal.Token.\n// This token is then mapped from *internal.Token into an *oauth2.Token which is returned along\n// with an error..\nfunc retrieveToken(ctx context.Context, c *Config, v url.Values) (*Token, error) {\n\ttk, err := internal.RetrieveToken(ctx, c.ClientID, c.ClientSecret, c.Endpoint.TokenURL, v)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn tokenFromInternal(tk), nil\n}\n"
  },
  {
    "path": "vendor/golang.org/x/oauth2/transport.go",
    "content": "// Copyright 2014 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage oauth2\n\nimport (\n\t\"errors\"\n\t\"io\"\n\t\"net/http\"\n\t\"sync\"\n)\n\n// Transport is an http.RoundTripper that makes OAuth 2.0 HTTP requests,\n// wrapping a base RoundTripper and adding an Authorization header\n// with a token from the supplied Sources.\n//\n// Transport is a low-level mechanism. Most code will use the\n// higher-level Config.Client method instead.\ntype Transport struct {\n\t// Source supplies the token to add to outgoing requests'\n\t// Authorization headers.\n\tSource TokenSource\n\n\t// Base is the base RoundTripper used to make HTTP requests.\n\t// If nil, http.DefaultTransport is used.\n\tBase http.RoundTripper\n\n\tmu     sync.Mutex                      // guards modReq\n\tmodReq map[*http.Request]*http.Request // original -> modified\n}\n\n// RoundTrip authorizes and authenticates the request with an\n// access token. If no token exists or token is expired,\n// tries to refresh/fetch a new token.\nfunc (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {\n\tif t.Source == nil {\n\t\treturn nil, errors.New(\"oauth2: Transport's Source is nil\")\n\t}\n\ttoken, err := t.Source.Token()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq2 := cloneRequest(req) // per RoundTripper contract\n\ttoken.SetAuthHeader(req2)\n\tt.setModReq(req, req2)\n\tres, err := t.base().RoundTrip(req2)\n\tif err != nil {\n\t\tt.setModReq(req, nil)\n\t\treturn nil, err\n\t}\n\tres.Body = &onEOFReader{\n\t\trc: res.Body,\n\t\tfn: func() { t.setModReq(req, nil) },\n\t}\n\treturn res, nil\n}\n\n// CancelRequest cancels an in-flight request by closing its connection.\nfunc (t *Transport) CancelRequest(req *http.Request) {\n\ttype canceler interface {\n\t\tCancelRequest(*http.Request)\n\t}\n\tif cr, ok := t.base().(canceler); ok {\n\t\tt.mu.Lock()\n\t\tmodReq := t.modReq[req]\n\t\tdelete(t.modReq, req)\n\t\tt.mu.Unlock()\n\t\tcr.CancelRequest(modReq)\n\t}\n}\n\nfunc (t *Transport) base() http.RoundTripper {\n\tif t.Base != nil {\n\t\treturn t.Base\n\t}\n\treturn http.DefaultTransport\n}\n\nfunc (t *Transport) setModReq(orig, mod *http.Request) {\n\tt.mu.Lock()\n\tdefer t.mu.Unlock()\n\tif t.modReq == nil {\n\t\tt.modReq = make(map[*http.Request]*http.Request)\n\t}\n\tif mod == nil {\n\t\tdelete(t.modReq, orig)\n\t} else {\n\t\tt.modReq[orig] = mod\n\t}\n}\n\n// cloneRequest returns a clone of the provided *http.Request.\n// The clone is a shallow copy of the struct and its Header map.\nfunc cloneRequest(r *http.Request) *http.Request {\n\t// shallow copy of the struct\n\tr2 := new(http.Request)\n\t*r2 = *r\n\t// deep copy of the Header\n\tr2.Header = make(http.Header, len(r.Header))\n\tfor k, s := range r.Header {\n\t\tr2.Header[k] = append([]string(nil), s...)\n\t}\n\treturn r2\n}\n\ntype onEOFReader struct {\n\trc io.ReadCloser\n\tfn func()\n}\n\nfunc (r *onEOFReader) Read(p []byte) (n int, err error) {\n\tn, err = r.rc.Read(p)\n\tif err == io.EOF {\n\t\tr.runFunc()\n\t}\n\treturn\n}\n\nfunc (r *onEOFReader) Close() error {\n\terr := r.rc.Close()\n\tr.runFunc()\n\treturn err\n}\n\nfunc (r *onEOFReader) runFunc() {\n\tif fn := r.fn; fn != nil {\n\t\tfn()\n\t\tr.fn = nil\n\t}\n}\n"
  },
  {
    "path": "vendor/google.golang.org/api/LICENSE",
    "content": "Copyright (c) 2011 Google Inc. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n   * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n   * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n   * Neither the name of Google Inc. nor the names of its\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  },
  {
    "path": "vendor/google.golang.org/api/drive/v3/drive-api.json",
    "content": "{\n \"kind\": \"discovery#restDescription\",\n \"etag\": \"\\\"bRFOOrZKfO9LweMbPqu0kcu6De8/O9_NbpoVnW5GMGl7qWBIajcyrt8\\\"\",\n \"discoveryVersion\": \"v1\",\n \"id\": \"drive:v3\",\n \"name\": \"drive\",\n \"version\": \"v3\",\n \"revision\": \"20160303\",\n \"title\": \"Drive API\",\n \"description\": \"The API to interact with Drive.\",\n \"ownerDomain\": \"google.com\",\n \"ownerName\": \"Google\",\n \"icons\": {\n  \"x16\": \"https://ssl.gstatic.com/docs/doclist/images/drive_icon_16.png\",\n  \"x32\": \"https://ssl.gstatic.com/docs/doclist/images/drive_icon_32.png\"\n },\n \"documentationLink\": \"https://developers.google.com/drive/\",\n \"protocol\": \"rest\",\n \"baseUrl\": \"https://www.googleapis.com/drive/v3/\",\n \"basePath\": \"/drive/v3/\",\n \"rootUrl\": \"https://www.googleapis.com/\",\n \"servicePath\": \"drive/v3/\",\n \"batchPath\": \"batch\",\n \"parameters\": {\n  \"alt\": {\n   \"type\": \"string\",\n   \"description\": \"Data format for the response.\",\n   \"default\": \"json\",\n   \"enum\": [\n    \"json\"\n   ],\n   \"enumDescriptions\": [\n    \"Responses with Content-Type of application/json\"\n   ],\n   \"location\": \"query\"\n  },\n  \"fields\": {\n   \"type\": \"string\",\n   \"description\": \"Selector specifying which fields to include in a partial response.\",\n   \"location\": \"query\"\n  },\n  \"key\": {\n   \"type\": \"string\",\n   \"description\": \"API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.\",\n   \"location\": \"query\"\n  },\n  \"oauth_token\": {\n   \"type\": \"string\",\n   \"description\": \"OAuth 2.0 token for the current user.\",\n   \"location\": \"query\"\n  },\n  \"prettyPrint\": {\n   \"type\": \"boolean\",\n   \"description\": \"Returns response with indentations and line breaks.\",\n   \"default\": \"true\",\n   \"location\": \"query\"\n  },\n  \"quotaUser\": {\n   \"type\": \"string\",\n   \"description\": \"Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.\",\n   \"location\": \"query\"\n  },\n  \"userIp\": {\n   \"type\": \"string\",\n   \"description\": \"IP address of the site where the request originates. Use this if you want to enforce per-user limits.\",\n   \"location\": \"query\"\n  }\n },\n \"auth\": {\n  \"oauth2\": {\n   \"scopes\": {\n    \"https://www.googleapis.com/auth/drive\": {\n     \"description\": \"View and manage the files in your Google Drive\"\n    },\n    \"https://www.googleapis.com/auth/drive.appdata\": {\n     \"description\": \"View and manage its own configuration data in your Google Drive\"\n    },\n    \"https://www.googleapis.com/auth/drive.file\": {\n     \"description\": \"View and manage Google Drive files and folders that you have opened or created with this app\"\n    },\n    \"https://www.googleapis.com/auth/drive.metadata\": {\n     \"description\": \"View and manage metadata of files in your Google Drive\"\n    },\n    \"https://www.googleapis.com/auth/drive.metadata.readonly\": {\n     \"description\": \"View metadata for files in your Google Drive\"\n    },\n    \"https://www.googleapis.com/auth/drive.photos.readonly\": {\n     \"description\": \"View the photos, videos and albums in your Google Photos\"\n    },\n    \"https://www.googleapis.com/auth/drive.readonly\": {\n     \"description\": \"View the files in your Google Drive\"\n    },\n    \"https://www.googleapis.com/auth/drive.scripts\": {\n     \"description\": \"Modify your Google Apps Script scripts' behavior\"\n    }\n   }\n  }\n },\n \"schemas\": {\n  \"About\": {\n   \"id\": \"About\",\n   \"type\": \"object\",\n   \"description\": \"Information about the user, the user's Drive, and system capabilities.\",\n   \"properties\": {\n    \"appInstalled\": {\n     \"type\": \"boolean\",\n     \"description\": \"Whether the user has installed the requesting app.\"\n    },\n    \"exportFormats\": {\n     \"type\": \"object\",\n     \"description\": \"A map of source MIME type to possible targets for all supported exports.\",\n     \"additionalProperties\": {\n      \"type\": \"array\",\n      \"items\": {\n       \"type\": \"string\"\n      }\n     }\n    },\n    \"folderColorPalette\": {\n     \"type\": \"array\",\n     \"description\": \"The currently supported folder colors as RGB hex strings.\",\n     \"items\": {\n      \"type\": \"string\"\n     }\n    },\n    \"importFormats\": {\n     \"type\": \"object\",\n     \"description\": \"A map of source MIME type to possible targets for all supported imports.\",\n     \"additionalProperties\": {\n      \"type\": \"array\",\n      \"items\": {\n       \"type\": \"string\"\n      }\n     }\n    },\n    \"kind\": {\n     \"type\": \"string\",\n     \"description\": \"This is always drive#about.\",\n     \"default\": \"drive#about\"\n    },\n    \"maxImportSizes\": {\n     \"type\": \"object\",\n     \"description\": \"A map of maximum import sizes by MIME type, in bytes.\",\n     \"additionalProperties\": {\n      \"type\": \"string\",\n      \"format\": \"int64\"\n     }\n    },\n    \"maxUploadSize\": {\n     \"type\": \"string\",\n     \"description\": \"The maximum upload size in bytes.\",\n     \"format\": \"int64\"\n    },\n    \"storageQuota\": {\n     \"type\": \"object\",\n     \"description\": \"The user's storage quota limits and usage. All fields are measured in bytes.\",\n     \"properties\": {\n      \"limit\": {\n       \"type\": \"string\",\n       \"description\": \"The usage limit, if applicable. This will not be present if the user has unlimited storage.\",\n       \"format\": \"int64\"\n      },\n      \"usage\": {\n       \"type\": \"string\",\n       \"description\": \"The total usage across all services.\",\n       \"format\": \"int64\"\n      },\n      \"usageInDrive\": {\n       \"type\": \"string\",\n       \"description\": \"The usage by all files in Google Drive.\",\n       \"format\": \"int64\"\n      },\n      \"usageInDriveTrash\": {\n       \"type\": \"string\",\n       \"description\": \"The usage by trashed files in Google Drive.\",\n       \"format\": \"int64\"\n      }\n     }\n    },\n    \"user\": {\n     \"$ref\": \"User\",\n     \"description\": \"The authenticated user.\"\n    }\n   }\n  },\n  \"Change\": {\n   \"id\": \"Change\",\n   \"type\": \"object\",\n   \"description\": \"A change to a file.\",\n   \"properties\": {\n    \"file\": {\n     \"$ref\": \"File\",\n     \"description\": \"The updated state of the file. Present if the file has not been removed.\"\n    },\n    \"fileId\": {\n     \"type\": \"string\",\n     \"description\": \"The ID of the file which has changed.\"\n    },\n    \"kind\": {\n     \"type\": \"string\",\n     \"description\": \"This is always drive#change.\",\n     \"default\": \"drive#change\"\n    },\n    \"removed\": {\n     \"type\": \"boolean\",\n     \"description\": \"Whether the file has been removed from the view of the changes list, for example by deletion or lost access.\"\n    },\n    \"time\": {\n     \"type\": \"string\",\n     \"description\": \"The time of this change (RFC 3339 date-time).\",\n     \"format\": \"date-time\"\n    }\n   }\n  },\n  \"ChangeList\": {\n   \"id\": \"ChangeList\",\n   \"type\": \"object\",\n   \"description\": \"A list of changes for a user.\",\n   \"properties\": {\n    \"changes\": {\n     \"type\": \"array\",\n     \"description\": \"The page of changes.\",\n     \"items\": {\n      \"$ref\": \"Change\"\n     }\n    },\n    \"kind\": {\n     \"type\": \"string\",\n     \"description\": \"This is always drive#changeList.\",\n     \"default\": \"drive#changeList\"\n    },\n    \"newStartPageToken\": {\n     \"type\": \"string\",\n     \"description\": \"The starting page token for future changes. This will be present only if the end of the current changes list has been reached.\"\n    },\n    \"nextPageToken\": {\n     \"type\": \"string\",\n     \"description\": \"The page token for the next page of changes. This will be absent if the end of the current changes list has been reached.\"\n    }\n   }\n  },\n  \"Channel\": {\n   \"id\": \"Channel\",\n   \"type\": \"object\",\n   \"description\": \"An notification channel used to watch for resource changes.\",\n   \"properties\": {\n    \"address\": {\n     \"type\": \"string\",\n     \"description\": \"The address where notifications are delivered for this channel.\"\n    },\n    \"expiration\": {\n     \"type\": \"string\",\n     \"description\": \"Date and time of notification channel expiration, expressed as a Unix timestamp, in milliseconds. Optional.\",\n     \"format\": \"int64\"\n    },\n    \"id\": {\n     \"type\": \"string\",\n     \"description\": \"A UUID or similar unique string that identifies this channel.\"\n    },\n    \"kind\": {\n     \"type\": \"string\",\n     \"description\": \"Identifies this as a notification channel used to watch for changes to a resource. Value: the fixed string \\\"api#channel\\\".\",\n     \"default\": \"api#channel\"\n    },\n    \"params\": {\n     \"type\": \"object\",\n     \"description\": \"Additional parameters controlling delivery channel behavior. Optional.\",\n     \"additionalProperties\": {\n      \"type\": \"string\",\n      \"description\": \"Declares a new parameter by name.\"\n     }\n    },\n    \"payload\": {\n     \"type\": \"boolean\",\n     \"description\": \"A Boolean value to indicate whether payload is wanted. Optional.\"\n    },\n    \"resourceId\": {\n     \"type\": \"string\",\n     \"description\": \"An opaque ID that identifies the resource being watched on this channel. Stable across different API versions.\"\n    },\n    \"resourceUri\": {\n     \"type\": \"string\",\n     \"description\": \"A version-specific identifier for the watched resource.\"\n    },\n    \"token\": {\n     \"type\": \"string\",\n     \"description\": \"An arbitrary string delivered to the target address with each notification delivered over this channel. Optional.\"\n    },\n    \"type\": {\n     \"type\": \"string\",\n     \"description\": \"The type of delivery mechanism used for this channel.\"\n    }\n   }\n  },\n  \"Comment\": {\n   \"id\": \"Comment\",\n   \"type\": \"object\",\n   \"description\": \"A comment on a file.\",\n   \"properties\": {\n    \"anchor\": {\n     \"type\": \"string\",\n     \"description\": \"A region of the document represented as a JSON string. See anchor documentation for details on how to define and interpret anchor properties.\"\n    },\n    \"author\": {\n     \"$ref\": \"User\",\n     \"description\": \"The user who created the comment.\"\n    },\n    \"content\": {\n     \"type\": \"string\",\n     \"description\": \"The plain text content of the comment. This field is used for setting the content, while htmlContent should be displayed.\",\n     \"annotations\": {\n      \"required\": [\n       \"drive.comments.create\",\n       \"drive.comments.update\"\n      ]\n     }\n    },\n    \"createdTime\": {\n     \"type\": \"string\",\n     \"description\": \"The time at which the comment was created (RFC 3339 date-time).\",\n     \"format\": \"date-time\"\n    },\n    \"deleted\": {\n     \"type\": \"boolean\",\n     \"description\": \"Whether the comment has been deleted. A deleted comment has no content.\"\n    },\n    \"htmlContent\": {\n     \"type\": \"string\",\n     \"description\": \"The content of the comment with HTML formatting.\"\n    },\n    \"id\": {\n     \"type\": \"string\",\n     \"description\": \"The ID of the comment.\"\n    },\n    \"kind\": {\n     \"type\": \"string\",\n     \"description\": \"This is always drive#comment.\",\n     \"default\": \"drive#comment\"\n    },\n    \"modifiedTime\": {\n     \"type\": \"string\",\n     \"description\": \"The last time the comment or any of its replies was modified (RFC 3339 date-time).\",\n     \"format\": \"date-time\"\n    },\n    \"quotedFileContent\": {\n     \"type\": \"object\",\n     \"description\": \"The file content to which the comment refers, typically within the anchor region. For a text file, for example, this would be the text at the location of the comment.\",\n     \"properties\": {\n      \"mimeType\": {\n       \"type\": \"string\",\n       \"description\": \"The MIME type of the quoted content.\"\n      },\n      \"value\": {\n       \"type\": \"string\",\n       \"description\": \"The quoted content itself. This is interpreted as plain text if set through the API.\"\n      }\n     }\n    },\n    \"replies\": {\n     \"type\": \"array\",\n     \"description\": \"The full list of replies to the comment in chronological order.\",\n     \"items\": {\n      \"$ref\": \"Reply\"\n     }\n    },\n    \"resolved\": {\n     \"type\": \"boolean\",\n     \"description\": \"Whether the comment has been resolved by one of its replies.\"\n    }\n   }\n  },\n  \"CommentList\": {\n   \"id\": \"CommentList\",\n   \"type\": \"object\",\n   \"description\": \"A list of comments on a file.\",\n   \"properties\": {\n    \"comments\": {\n     \"type\": \"array\",\n     \"description\": \"The page of comments.\",\n     \"items\": {\n      \"$ref\": \"Comment\"\n     }\n    },\n    \"kind\": {\n     \"type\": \"string\",\n     \"description\": \"This is always drive#commentList.\",\n     \"default\": \"drive#commentList\"\n    },\n    \"nextPageToken\": {\n     \"type\": \"string\",\n     \"description\": \"The page token for the next page of comments. This will be absent if the end of the comments list has been reached.\"\n    }\n   }\n  },\n  \"File\": {\n   \"id\": \"File\",\n   \"type\": \"object\",\n   \"description\": \"The metadata for a file.\",\n   \"properties\": {\n    \"appProperties\": {\n     \"type\": \"object\",\n     \"description\": \"A collection of arbitrary key-value pairs which are private to the requesting app.\\nEntries with null values are cleared in update and copy requests.\",\n     \"additionalProperties\": {\n      \"type\": \"string\"\n     }\n    },\n    \"capabilities\": {\n     \"type\": \"object\",\n     \"description\": \"Capabilities the current user has on the file.\",\n     \"properties\": {\n      \"canComment\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether the user can comment on the file.\"\n      },\n      \"canCopy\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether the user can copy the file.\"\n      },\n      \"canEdit\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether the user can edit the file's content.\"\n      },\n      \"canReadRevisions\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether the current user has read access to the Revisions resource of the file.\"\n      },\n      \"canShare\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether the user can modify the file's permissions and sharing settings.\"\n      }\n     }\n    },\n    \"contentHints\": {\n     \"type\": \"object\",\n     \"description\": \"Additional information about the content of the file. These fields are never populated in responses.\",\n     \"properties\": {\n      \"indexableText\": {\n       \"type\": \"string\",\n       \"description\": \"Text to be indexed for the file to improve fullText queries. This is limited to 128KB in length and may contain HTML elements.\"\n      },\n      \"thumbnail\": {\n       \"type\": \"object\",\n       \"description\": \"A thumbnail for the file. This will only be used if Drive cannot generate a standard thumbnail.\",\n       \"properties\": {\n        \"image\": {\n         \"type\": \"string\",\n         \"description\": \"The thumbnail data encoded with URL-safe Base64 (RFC 4648 section 5).\",\n         \"format\": \"byte\"\n        },\n        \"mimeType\": {\n         \"type\": \"string\",\n         \"description\": \"The MIME type of the thumbnail.\"\n        }\n       }\n      }\n     }\n    },\n    \"createdTime\": {\n     \"type\": \"string\",\n     \"description\": \"The time at which the file was created (RFC 3339 date-time).\",\n     \"format\": \"date-time\"\n    },\n    \"description\": {\n     \"type\": \"string\",\n     \"description\": \"A short description of the file.\"\n    },\n    \"explicitlyTrashed\": {\n     \"type\": \"boolean\",\n     \"description\": \"Whether the file has been explicitly trashed, as opposed to recursively trashed from a parent folder.\"\n    },\n    \"fileExtension\": {\n     \"type\": \"string\",\n     \"description\": \"The final component of fullFileExtension. This is only available for files with binary content in Drive.\"\n    },\n    \"folderColorRgb\": {\n     \"type\": \"string\",\n     \"description\": \"The color for a folder as an RGB hex string. The supported colors are published in the folderColorPalette field of the About resource.\\nIf an unsupported color is specified, the closest color in the palette will be used instead.\"\n    },\n    \"fullFileExtension\": {\n     \"type\": \"string\",\n     \"description\": \"The full file extension extracted from the name field. May contain multiple concatenated extensions, such as \\\"tar.gz\\\". This is only available for files with binary content in Drive.\\nThis is automatically updated when the name field changes, however it is not cleared if the new name does not contain a valid extension.\"\n    },\n    \"headRevisionId\": {\n     \"type\": \"string\",\n     \"description\": \"The ID of the file's head revision. This is currently only available for files with binary content in Drive.\"\n    },\n    \"iconLink\": {\n     \"type\": \"string\",\n     \"description\": \"A static, unauthenticated link to the file's icon.\"\n    },\n    \"id\": {\n     \"type\": \"string\",\n     \"description\": \"The ID of the file.\"\n    },\n    \"imageMediaMetadata\": {\n     \"type\": \"object\",\n     \"description\": \"Additional metadata about image media, if available.\",\n     \"properties\": {\n      \"aperture\": {\n       \"type\": \"number\",\n       \"description\": \"The aperture used to create the photo (f-number).\",\n       \"format\": \"float\"\n      },\n      \"cameraMake\": {\n       \"type\": \"string\",\n       \"description\": \"The make of the camera used to create the photo.\"\n      },\n      \"cameraModel\": {\n       \"type\": \"string\",\n       \"description\": \"The model of the camera used to create the photo.\"\n      },\n      \"colorSpace\": {\n       \"type\": \"string\",\n       \"description\": \"The color space of the photo.\"\n      },\n      \"exposureBias\": {\n       \"type\": \"number\",\n       \"description\": \"The exposure bias of the photo (APEX value).\",\n       \"format\": \"float\"\n      },\n      \"exposureMode\": {\n       \"type\": \"string\",\n       \"description\": \"The exposure mode used to create the photo.\"\n      },\n      \"exposureTime\": {\n       \"type\": \"number\",\n       \"description\": \"The length of the exposure, in seconds.\",\n       \"format\": \"float\"\n      },\n      \"flashUsed\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether a flash was used to create the photo.\"\n      },\n      \"focalLength\": {\n       \"type\": \"number\",\n       \"description\": \"The focal length used to create the photo, in millimeters.\",\n       \"format\": \"float\"\n      },\n      \"height\": {\n       \"type\": \"integer\",\n       \"description\": \"The height of the image in pixels.\",\n       \"format\": \"int32\"\n      },\n      \"isoSpeed\": {\n       \"type\": \"integer\",\n       \"description\": \"The ISO speed used to create the photo.\",\n       \"format\": \"int32\"\n      },\n      \"lens\": {\n       \"type\": \"string\",\n       \"description\": \"The lens used to create the photo.\"\n      },\n      \"location\": {\n       \"type\": \"object\",\n       \"description\": \"Geographic location information stored in the image.\",\n       \"properties\": {\n        \"altitude\": {\n         \"type\": \"number\",\n         \"description\": \"The altitude stored in the image.\",\n         \"format\": \"double\"\n        },\n        \"latitude\": {\n         \"type\": \"number\",\n         \"description\": \"The latitude stored in the image.\",\n         \"format\": \"double\"\n        },\n        \"longitude\": {\n         \"type\": \"number\",\n         \"description\": \"The longitude stored in the image.\",\n         \"format\": \"double\"\n        }\n       }\n      },\n      \"maxApertureValue\": {\n       \"type\": \"number\",\n       \"description\": \"The smallest f-number of the lens at the focal length used to create the photo (APEX value).\",\n       \"format\": \"float\"\n      },\n      \"meteringMode\": {\n       \"type\": \"string\",\n       \"description\": \"The metering mode used to create the photo.\"\n      },\n      \"rotation\": {\n       \"type\": \"integer\",\n       \"description\": \"The rotation in clockwise degrees from the image's original orientation.\",\n       \"format\": \"int32\"\n      },\n      \"sensor\": {\n       \"type\": \"string\",\n       \"description\": \"The type of sensor used to create the photo.\"\n      },\n      \"subjectDistance\": {\n       \"type\": \"integer\",\n       \"description\": \"The distance to the subject of the photo, in meters.\",\n       \"format\": \"int32\"\n      },\n      \"time\": {\n       \"type\": \"string\",\n       \"description\": \"The date and time the photo was taken (EXIF DateTime).\"\n      },\n      \"whiteBalance\": {\n       \"type\": \"string\",\n       \"description\": \"The white balance mode used to create the photo.\"\n      },\n      \"width\": {\n       \"type\": \"integer\",\n       \"description\": \"The width of the image in pixels.\",\n       \"format\": \"int32\"\n      }\n     }\n    },\n    \"kind\": {\n     \"type\": \"string\",\n     \"description\": \"This is always drive#file.\",\n     \"default\": \"drive#file\"\n    },\n    \"lastModifyingUser\": {\n     \"$ref\": \"User\",\n     \"description\": \"The last user to modify the file.\"\n    },\n    \"md5Checksum\": {\n     \"type\": \"string\",\n     \"description\": \"The MD5 checksum for the content of the file. This is only applicable to files with binary content in Drive.\"\n    },\n    \"mimeType\": {\n     \"type\": \"string\",\n     \"description\": \"The MIME type of the file.\\nDrive will attempt to automatically detect an appropriate value from uploaded content if no value is provided. The value cannot be changed unless a new revision is uploaded.\\nIf a file is created with a Google Doc MIME type, the uploaded content will be imported if possible. The supported import formats are published in the About resource.\"\n    },\n    \"modifiedByMeTime\": {\n     \"type\": \"string\",\n     \"description\": \"The last time the file was modified by the user (RFC 3339 date-time).\",\n     \"format\": \"date-time\"\n    },\n    \"modifiedTime\": {\n     \"type\": \"string\",\n     \"description\": \"The last time the file was modified by anyone (RFC 3339 date-time).\\nNote that setting modifiedTime will also update modifiedByMeTime for the user.\",\n     \"format\": \"date-time\"\n    },\n    \"name\": {\n     \"type\": \"string\",\n     \"description\": \"The name of the file. This is not necessarily unique within a folder.\"\n    },\n    \"originalFilename\": {\n     \"type\": \"string\",\n     \"description\": \"The original filename of the uploaded content if available, or else the original value of the name field. This is only available for files with binary content in Drive.\"\n    },\n    \"ownedByMe\": {\n     \"type\": \"boolean\",\n     \"description\": \"Whether the user owns the file.\"\n    },\n    \"owners\": {\n     \"type\": \"array\",\n     \"description\": \"The owners of the file. Currently, only certain legacy files may have more than one owner.\",\n     \"items\": {\n      \"$ref\": \"User\"\n     }\n    },\n    \"parents\": {\n     \"type\": \"array\",\n     \"description\": \"The IDs of the parent folders which contain the file.\\nIf not specified as part of a create request, the file will be placed directly in the My Drive folder. Update requests must use the addParents and removeParents parameters to modify the values.\",\n     \"items\": {\n      \"type\": \"string\"\n     }\n    },\n    \"permissions\": {\n     \"type\": \"array\",\n     \"description\": \"The full list of permissions for the file. This is only available if the requesting user can share the file.\",\n     \"items\": {\n      \"$ref\": \"Permission\"\n     }\n    },\n    \"properties\": {\n     \"type\": \"object\",\n     \"description\": \"A collection of arbitrary key-value pairs which are visible to all apps.\\nEntries with null values are cleared in update and copy requests.\",\n     \"additionalProperties\": {\n      \"type\": \"string\"\n     }\n    },\n    \"quotaBytesUsed\": {\n     \"type\": \"string\",\n     \"description\": \"The number of storage quota bytes used by the file. This includes the head revision as well as previous revisions with keepForever enabled.\",\n     \"format\": \"int64\"\n    },\n    \"shared\": {\n     \"type\": \"boolean\",\n     \"description\": \"Whether the file has been shared.\"\n    },\n    \"sharedWithMeTime\": {\n     \"type\": \"string\",\n     \"description\": \"The time at which the file was shared with the user, if applicable (RFC 3339 date-time).\",\n     \"format\": \"date-time\"\n    },\n    \"sharingUser\": {\n     \"$ref\": \"User\",\n     \"description\": \"The user who shared the file with the requesting user, if applicable.\"\n    },\n    \"size\": {\n     \"type\": \"string\",\n     \"description\": \"The size of the file's content in bytes. This is only applicable to files with binary content in Drive.\",\n     \"format\": \"int64\"\n    },\n    \"spaces\": {\n     \"type\": \"array\",\n     \"description\": \"The list of spaces which contain the file. The currently supported values are 'drive', 'appDataFolder' and 'photos'.\",\n     \"items\": {\n      \"type\": \"string\"\n     }\n    },\n    \"starred\": {\n     \"type\": \"boolean\",\n     \"description\": \"Whether the user has starred the file.\"\n    },\n    \"thumbnailLink\": {\n     \"type\": \"string\",\n     \"description\": \"A short-lived link to the file's thumbnail, if available. Typically lasts on the order of hours.\"\n    },\n    \"trashed\": {\n     \"type\": \"boolean\",\n     \"description\": \"Whether the file has been trashed, either explicitly or from a trashed parent folder. Only the owner may trash a file, and other users cannot see files in the owner's trash.\"\n    },\n    \"version\": {\n     \"type\": \"string\",\n     \"description\": \"A monotonically increasing version number for the file. This reflects every change made to the file on the server, even those not visible to the user.\",\n     \"format\": \"int64\"\n    },\n    \"videoMediaMetadata\": {\n     \"type\": \"object\",\n     \"description\": \"Additional metadata about video media. This may not be available immediately upon upload.\",\n     \"properties\": {\n      \"durationMillis\": {\n       \"type\": \"string\",\n       \"description\": \"The duration of the video in milliseconds.\",\n       \"format\": \"int64\"\n      },\n      \"height\": {\n       \"type\": \"integer\",\n       \"description\": \"The height of the video in pixels.\",\n       \"format\": \"int32\"\n      },\n      \"width\": {\n       \"type\": \"integer\",\n       \"description\": \"The width of the video in pixels.\",\n       \"format\": \"int32\"\n      }\n     }\n    },\n    \"viewedByMe\": {\n     \"type\": \"boolean\",\n     \"description\": \"Whether the file has been viewed by this user.\"\n    },\n    \"viewedByMeTime\": {\n     \"type\": \"string\",\n     \"description\": \"The last time the file was viewed by the user (RFC 3339 date-time).\",\n     \"format\": \"date-time\"\n    },\n    \"viewersCanCopyContent\": {\n     \"type\": \"boolean\",\n     \"description\": \"Whether users with only reader or commenter permission can copy the file's content. This affects copy, download, and print operations.\"\n    },\n    \"webContentLink\": {\n     \"type\": \"string\",\n     \"description\": \"A link for downloading the content of the file in a browser. This is only available for files with binary content in Drive.\"\n    },\n    \"webViewLink\": {\n     \"type\": \"string\",\n     \"description\": \"A link for opening the file in a relevant Google editor or viewer in a browser.\"\n    },\n    \"writersCanShare\": {\n     \"type\": \"boolean\",\n     \"description\": \"Whether users with only writer permission can modify the file's permissions.\"\n    }\n   }\n  },\n  \"FileList\": {\n   \"id\": \"FileList\",\n   \"type\": \"object\",\n   \"description\": \"A list of files.\",\n   \"properties\": {\n    \"files\": {\n     \"type\": \"array\",\n     \"description\": \"The page of files.\",\n     \"items\": {\n      \"$ref\": \"File\"\n     }\n    },\n    \"kind\": {\n     \"type\": \"string\",\n     \"description\": \"This is always drive#fileList.\",\n     \"default\": \"drive#fileList\"\n    },\n    \"nextPageToken\": {\n     \"type\": \"string\",\n     \"description\": \"The page token for the next page of files. This will be absent if the end of the files list has been reached.\"\n    }\n   }\n  },\n  \"GeneratedIds\": {\n   \"id\": \"GeneratedIds\",\n   \"type\": \"object\",\n   \"description\": \"A list of generated file IDs which can be provided in create requests.\",\n   \"properties\": {\n    \"ids\": {\n     \"type\": \"array\",\n     \"description\": \"The IDs generated for the requesting user in the specified space.\",\n     \"items\": {\n      \"type\": \"string\"\n     }\n    },\n    \"kind\": {\n     \"type\": \"string\",\n     \"description\": \"This is always drive#generatedIds\",\n     \"default\": \"drive#generatedIds\"\n    },\n    \"space\": {\n     \"type\": \"string\",\n     \"description\": \"The type of file that can be created with these IDs.\"\n    }\n   }\n  },\n  \"Permission\": {\n   \"id\": \"Permission\",\n   \"type\": \"object\",\n   \"description\": \"A permission for a file. A permission grants a user, group, domain or the world access to a file or a folder hierarchy.\",\n   \"properties\": {\n    \"allowFileDiscovery\": {\n     \"type\": \"boolean\",\n     \"description\": \"Whether the permission allows the file to be discovered through search. This is only applicable for permissions of type domain or anyone.\"\n    },\n    \"displayName\": {\n     \"type\": \"string\",\n     \"description\": \"A displayable name for users, groups or domains.\"\n    },\n    \"domain\": {\n     \"type\": \"string\",\n     \"description\": \"The domain to which this permission refers.\"\n    },\n    \"emailAddress\": {\n     \"type\": \"string\",\n     \"description\": \"The email address of the user or group to which this permission refers.\"\n    },\n    \"id\": {\n     \"type\": \"string\",\n     \"description\": \"The ID of this permission. This is a unique identifier for the grantee, and is published in User resources as permissionId.\"\n    },\n    \"kind\": {\n     \"type\": \"string\",\n     \"description\": \"This is always drive#permission.\",\n     \"default\": \"drive#permission\"\n    },\n    \"photoLink\": {\n     \"type\": \"string\",\n     \"description\": \"A link to the user's profile photo, if available.\"\n    },\n    \"role\": {\n     \"type\": \"string\",\n     \"description\": \"The role granted by this permission. Valid values are:  \\n- owner \\n- writer \\n- commenter \\n- reader\",\n     \"annotations\": {\n      \"required\": [\n       \"drive.permissions.create\"\n      ]\n     }\n    },\n    \"type\": {\n     \"type\": \"string\",\n     \"description\": \"The type of the grantee. Valid values are:  \\n- user \\n- group \\n- domain \\n- anyone\",\n     \"annotations\": {\n      \"required\": [\n       \"drive.permissions.create\"\n      ]\n     }\n    }\n   }\n  },\n  \"PermissionList\": {\n   \"id\": \"PermissionList\",\n   \"type\": \"object\",\n   \"description\": \"A list of permissions for a file.\",\n   \"properties\": {\n    \"kind\": {\n     \"type\": \"string\",\n     \"description\": \"This is always drive#permissionList.\",\n     \"default\": \"drive#permissionList\"\n    },\n    \"permissions\": {\n     \"type\": \"array\",\n     \"description\": \"The full list of permissions.\",\n     \"items\": {\n      \"$ref\": \"Permission\"\n     }\n    }\n   }\n  },\n  \"Reply\": {\n   \"id\": \"Reply\",\n   \"type\": \"object\",\n   \"description\": \"A reply to a comment on a file.\",\n   \"properties\": {\n    \"action\": {\n     \"type\": \"string\",\n     \"description\": \"The action the reply performed to the parent comment. Valid values are:  \\n- resolve \\n- reopen\"\n    },\n    \"author\": {\n     \"$ref\": \"User\",\n     \"description\": \"The user who created the reply.\"\n    },\n    \"content\": {\n     \"type\": \"string\",\n     \"description\": \"The plain text content of the reply. This field is used for setting the content, while htmlContent should be displayed. This is required on creates if no action is specified.\",\n     \"annotations\": {\n      \"required\": [\n       \"drive.replies.update\"\n      ]\n     }\n    },\n    \"createdTime\": {\n     \"type\": \"string\",\n     \"description\": \"The time at which the reply was created (RFC 3339 date-time).\",\n     \"format\": \"date-time\"\n    },\n    \"deleted\": {\n     \"type\": \"boolean\",\n     \"description\": \"Whether the reply has been deleted. A deleted reply has no content.\"\n    },\n    \"htmlContent\": {\n     \"type\": \"string\",\n     \"description\": \"The content of the reply with HTML formatting.\"\n    },\n    \"id\": {\n     \"type\": \"string\",\n     \"description\": \"The ID of the reply.\"\n    },\n    \"kind\": {\n     \"type\": \"string\",\n     \"description\": \"This is always drive#reply.\",\n     \"default\": \"drive#reply\"\n    },\n    \"modifiedTime\": {\n     \"type\": \"string\",\n     \"description\": \"The last time the reply was modified (RFC 3339 date-time).\",\n     \"format\": \"date-time\"\n    }\n   }\n  },\n  \"ReplyList\": {\n   \"id\": \"ReplyList\",\n   \"type\": \"object\",\n   \"description\": \"A list of replies to a comment on a file.\",\n   \"properties\": {\n    \"kind\": {\n     \"type\": \"string\",\n     \"description\": \"This is always drive#replyList.\",\n     \"default\": \"drive#replyList\"\n    },\n    \"nextPageToken\": {\n     \"type\": \"string\",\n     \"description\": \"The page token for the next page of replies. This will be absent if the end of the replies list has been reached.\"\n    },\n    \"replies\": {\n     \"type\": \"array\",\n     \"description\": \"The page of replies.\",\n     \"items\": {\n      \"$ref\": \"Reply\"\n     }\n    }\n   }\n  },\n  \"Revision\": {\n   \"id\": \"Revision\",\n   \"type\": \"object\",\n   \"description\": \"The metadata for a revision to a file.\",\n   \"properties\": {\n    \"id\": {\n     \"type\": \"string\",\n     \"description\": \"The ID of the revision.\"\n    },\n    \"keepForever\": {\n     \"type\": \"boolean\",\n     \"description\": \"Whether to keep this revision forever, even if it is no longer the head revision. If not set, the revision will be automatically purged 30 days after newer content is uploaded. This can be set on a maximum of 200 revisions for a file.\\nThis field is only applicable to files with binary content in Drive.\"\n    },\n    \"kind\": {\n     \"type\": \"string\",\n     \"description\": \"This is always drive#revision.\",\n     \"default\": \"drive#revision\"\n    },\n    \"lastModifyingUser\": {\n     \"$ref\": \"User\",\n     \"description\": \"The last user to modify this revision.\"\n    },\n    \"md5Checksum\": {\n     \"type\": \"string\",\n     \"description\": \"The MD5 checksum of the revision's content. This is only applicable to files with binary content in Drive.\"\n    },\n    \"mimeType\": {\n     \"type\": \"string\",\n     \"description\": \"The MIME type of the revision.\"\n    },\n    \"modifiedTime\": {\n     \"type\": \"string\",\n     \"description\": \"The last time the revision was modified (RFC 3339 date-time).\",\n     \"format\": \"date-time\"\n    },\n    \"originalFilename\": {\n     \"type\": \"string\",\n     \"description\": \"The original filename used to create this revision. This is only applicable to files with binary content in Drive.\"\n    },\n    \"publishAuto\": {\n     \"type\": \"boolean\",\n     \"description\": \"Whether subsequent revisions will be automatically republished. This is only applicable to Google Docs.\"\n    },\n    \"published\": {\n     \"type\": \"boolean\",\n     \"description\": \"Whether this revision is published. This is only applicable to Google Docs.\"\n    },\n    \"publishedOutsideDomain\": {\n     \"type\": \"boolean\",\n     \"description\": \"Whether this revision is published outside the domain. This is only applicable to Google Docs.\"\n    },\n    \"size\": {\n     \"type\": \"string\",\n     \"description\": \"The size of the revision's content in bytes. This is only applicable to files with binary content in Drive.\",\n     \"format\": \"int64\"\n    }\n   }\n  },\n  \"RevisionList\": {\n   \"id\": \"RevisionList\",\n   \"type\": \"object\",\n   \"description\": \"A list of revisions of a file.\",\n   \"properties\": {\n    \"kind\": {\n     \"type\": \"string\",\n     \"description\": \"This is always drive#revisionList.\",\n     \"default\": \"drive#revisionList\"\n    },\n    \"revisions\": {\n     \"type\": \"array\",\n     \"description\": \"The full list of revisions.\",\n     \"items\": {\n      \"$ref\": \"Revision\"\n     }\n    }\n   }\n  },\n  \"StartPageToken\": {\n   \"id\": \"StartPageToken\",\n   \"type\": \"object\",\n   \"properties\": {\n    \"kind\": {\n     \"type\": \"string\",\n     \"description\": \"This is always drive#startPageToken.\",\n     \"default\": \"drive#startPageToken\"\n    },\n    \"startPageToken\": {\n     \"type\": \"string\",\n     \"description\": \"The starting page token for listing changes.\"\n    }\n   }\n  },\n  \"User\": {\n   \"id\": \"User\",\n   \"type\": \"object\",\n   \"description\": \"Information about a Drive user.\",\n   \"properties\": {\n    \"displayName\": {\n     \"type\": \"string\",\n     \"description\": \"A plain text displayable name for this user.\"\n    },\n    \"emailAddress\": {\n     \"type\": \"string\",\n     \"description\": \"The email address of the user. This may not be present in certain contexts if the user has not made their email address visible to the requester.\"\n    },\n    \"kind\": {\n     \"type\": \"string\",\n     \"description\": \"This is always drive#user.\",\n     \"default\": \"drive#user\"\n    },\n    \"me\": {\n     \"type\": \"boolean\",\n     \"description\": \"Whether this user is the requesting user.\"\n    },\n    \"permissionId\": {\n     \"type\": \"string\",\n     \"description\": \"The user's ID as visible in Permission resources.\"\n    },\n    \"photoLink\": {\n     \"type\": \"string\",\n     \"description\": \"A link to the user's profile photo, if available.\"\n    }\n   }\n  }\n },\n \"resources\": {\n  \"about\": {\n   \"methods\": {\n    \"get\": {\n     \"id\": \"drive.about.get\",\n     \"path\": \"about\",\n     \"httpMethod\": \"GET\",\n     \"description\": \"Gets information about the user, the user's Drive, and system capabilities.\",\n     \"response\": {\n      \"$ref\": \"About\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.appdata\",\n      \"https://www.googleapis.com/auth/drive.file\",\n      \"https://www.googleapis.com/auth/drive.metadata\",\n      \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n      \"https://www.googleapis.com/auth/drive.photos.readonly\",\n      \"https://www.googleapis.com/auth/drive.readonly\"\n     ]\n    }\n   }\n  },\n  \"changes\": {\n   \"methods\": {\n    \"getStartPageToken\": {\n     \"id\": \"drive.changes.getStartPageToken\",\n     \"path\": \"changes/startPageToken\",\n     \"httpMethod\": \"GET\",\n     \"description\": \"Gets the starting pageToken for listing future changes.\",\n     \"response\": {\n      \"$ref\": \"StartPageToken\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.appdata\",\n      \"https://www.googleapis.com/auth/drive.file\",\n      \"https://www.googleapis.com/auth/drive.metadata\",\n      \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n      \"https://www.googleapis.com/auth/drive.photos.readonly\",\n      \"https://www.googleapis.com/auth/drive.readonly\"\n     ]\n    },\n    \"list\": {\n     \"id\": \"drive.changes.list\",\n     \"path\": \"changes\",\n     \"httpMethod\": \"GET\",\n     \"description\": \"Lists changes for a user.\",\n     \"parameters\": {\n      \"includeRemoved\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether to include changes indicating that items have left the view of the changes list, for example by deletion or lost access.\",\n       \"default\": \"true\",\n       \"location\": \"query\"\n      },\n      \"pageSize\": {\n       \"type\": \"integer\",\n       \"description\": \"The maximum number of changes to return per page.\",\n       \"default\": \"100\",\n       \"format\": \"int32\",\n       \"minimum\": \"1\",\n       \"maximum\": \"1000\",\n       \"location\": \"query\"\n      },\n      \"pageToken\": {\n       \"type\": \"string\",\n       \"description\": \"The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response or to the response from the getStartPageToken method.\",\n       \"required\": true,\n       \"location\": \"query\"\n      },\n      \"restrictToMyDrive\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether to restrict the results to changes inside the My Drive hierarchy. This omits changes to files such as those in the Application Data folder or shared files which have not been added to My Drive.\",\n       \"default\": \"false\",\n       \"location\": \"query\"\n      },\n      \"spaces\": {\n       \"type\": \"string\",\n       \"description\": \"A comma-separated list of spaces to query within the user corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.\",\n       \"default\": \"drive\",\n       \"location\": \"query\"\n      }\n     },\n     \"parameterOrder\": [\n      \"pageToken\"\n     ],\n     \"response\": {\n      \"$ref\": \"ChangeList\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.appdata\",\n      \"https://www.googleapis.com/auth/drive.file\",\n      \"https://www.googleapis.com/auth/drive.metadata\",\n      \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n      \"https://www.googleapis.com/auth/drive.photos.readonly\",\n      \"https://www.googleapis.com/auth/drive.readonly\"\n     ],\n     \"supportsSubscription\": true\n    },\n    \"watch\": {\n     \"id\": \"drive.changes.watch\",\n     \"path\": \"changes/watch\",\n     \"httpMethod\": \"POST\",\n     \"description\": \"Subscribes to changes for a user.\",\n     \"parameters\": {\n      \"includeRemoved\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether to include changes indicating that items have left the view of the changes list, for example by deletion or lost access.\",\n       \"default\": \"true\",\n       \"location\": \"query\"\n      },\n      \"pageSize\": {\n       \"type\": \"integer\",\n       \"description\": \"The maximum number of changes to return per page.\",\n       \"default\": \"100\",\n       \"format\": \"int32\",\n       \"minimum\": \"1\",\n       \"maximum\": \"1000\",\n       \"location\": \"query\"\n      },\n      \"pageToken\": {\n       \"type\": \"string\",\n       \"description\": \"The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response or to the response from the getStartPageToken method.\",\n       \"required\": true,\n       \"location\": \"query\"\n      },\n      \"restrictToMyDrive\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether to restrict the results to changes inside the My Drive hierarchy. This omits changes to files such as those in the Application Data folder or shared files which have not been added to My Drive.\",\n       \"default\": \"false\",\n       \"location\": \"query\"\n      },\n      \"spaces\": {\n       \"type\": \"string\",\n       \"description\": \"A comma-separated list of spaces to query within the user corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.\",\n       \"default\": \"drive\",\n       \"location\": \"query\"\n      }\n     },\n     \"parameterOrder\": [\n      \"pageToken\"\n     ],\n     \"request\": {\n      \"$ref\": \"Channel\",\n      \"parameterName\": \"resource\"\n     },\n     \"response\": {\n      \"$ref\": \"Channel\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.appdata\",\n      \"https://www.googleapis.com/auth/drive.file\",\n      \"https://www.googleapis.com/auth/drive.metadata\",\n      \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n      \"https://www.googleapis.com/auth/drive.photos.readonly\",\n      \"https://www.googleapis.com/auth/drive.readonly\"\n     ],\n     \"supportsSubscription\": true\n    }\n   }\n  },\n  \"channels\": {\n   \"methods\": {\n    \"stop\": {\n     \"id\": \"drive.channels.stop\",\n     \"path\": \"channels/stop\",\n     \"httpMethod\": \"POST\",\n     \"description\": \"Stop watching resources through this channel\",\n     \"request\": {\n      \"$ref\": \"Channel\",\n      \"parameterName\": \"resource\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.appdata\",\n      \"https://www.googleapis.com/auth/drive.file\",\n      \"https://www.googleapis.com/auth/drive.metadata\",\n      \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n      \"https://www.googleapis.com/auth/drive.photos.readonly\",\n      \"https://www.googleapis.com/auth/drive.readonly\"\n     ]\n    }\n   }\n  },\n  \"comments\": {\n   \"methods\": {\n    \"create\": {\n     \"id\": \"drive.comments.create\",\n     \"path\": \"files/{fileId}/comments\",\n     \"httpMethod\": \"POST\",\n     \"description\": \"Creates a new comment on a file.\",\n     \"parameters\": {\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\"\n     ],\n     \"request\": {\n      \"$ref\": \"Comment\"\n     },\n     \"response\": {\n      \"$ref\": \"Comment\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.file\"\n     ]\n    },\n    \"delete\": {\n     \"id\": \"drive.comments.delete\",\n     \"path\": \"files/{fileId}/comments/{commentId}\",\n     \"httpMethod\": \"DELETE\",\n     \"description\": \"Deletes a comment.\",\n     \"parameters\": {\n      \"commentId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the comment.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\",\n      \"commentId\"\n     ],\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.file\"\n     ]\n    },\n    \"get\": {\n     \"id\": \"drive.comments.get\",\n     \"path\": \"files/{fileId}/comments/{commentId}\",\n     \"httpMethod\": \"GET\",\n     \"description\": \"Gets a comment by ID.\",\n     \"parameters\": {\n      \"commentId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the comment.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"includeDeleted\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether to return deleted comments. Deleted comments will not include their original content.\",\n       \"default\": \"false\",\n       \"location\": \"query\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\",\n      \"commentId\"\n     ],\n     \"response\": {\n      \"$ref\": \"Comment\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.file\",\n      \"https://www.googleapis.com/auth/drive.readonly\"\n     ]\n    },\n    \"list\": {\n     \"id\": \"drive.comments.list\",\n     \"path\": \"files/{fileId}/comments\",\n     \"httpMethod\": \"GET\",\n     \"description\": \"Lists a file's comments.\",\n     \"parameters\": {\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"includeDeleted\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether to include deleted comments. Deleted comments will not include their original content.\",\n       \"default\": \"false\",\n       \"location\": \"query\"\n      },\n      \"pageSize\": {\n       \"type\": \"integer\",\n       \"description\": \"The maximum number of comments to return per page.\",\n       \"default\": \"20\",\n       \"format\": \"int32\",\n       \"minimum\": \"1\",\n       \"maximum\": \"100\",\n       \"location\": \"query\"\n      },\n      \"pageToken\": {\n       \"type\": \"string\",\n       \"description\": \"The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.\",\n       \"location\": \"query\"\n      },\n      \"startModifiedTime\": {\n       \"type\": \"string\",\n       \"description\": \"The minimum value of 'modifiedTime' for the result comments (RFC 3339 date-time).\",\n       \"location\": \"query\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\"\n     ],\n     \"response\": {\n      \"$ref\": \"CommentList\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.file\",\n      \"https://www.googleapis.com/auth/drive.readonly\"\n     ]\n    },\n    \"update\": {\n     \"id\": \"drive.comments.update\",\n     \"path\": \"files/{fileId}/comments/{commentId}\",\n     \"httpMethod\": \"PATCH\",\n     \"description\": \"Updates a comment with patch semantics.\",\n     \"parameters\": {\n      \"commentId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the comment.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\",\n      \"commentId\"\n     ],\n     \"request\": {\n      \"$ref\": \"Comment\"\n     },\n     \"response\": {\n      \"$ref\": \"Comment\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.file\"\n     ]\n    }\n   }\n  },\n  \"files\": {\n   \"methods\": {\n    \"copy\": {\n     \"id\": \"drive.files.copy\",\n     \"path\": \"files/{fileId}/copy\",\n     \"httpMethod\": \"POST\",\n     \"description\": \"Creates a copy of a file and applies any requested updates with patch semantics.\",\n     \"parameters\": {\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"ignoreDefaultVisibility\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether to ignore the domain's default visibility settings for the created file. Domain administrators can choose to make all uploaded files visible to the domain by default; this parameter bypasses that behavior for the request. Permissions are still inherited from parent folders.\",\n       \"default\": \"false\",\n       \"location\": \"query\"\n      },\n      \"keepRevisionForever\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether to set the 'keepForever' field in the new head revision. This is only applicable to files with binary content in Drive.\",\n       \"default\": \"false\",\n       \"location\": \"query\"\n      },\n      \"ocrLanguage\": {\n       \"type\": \"string\",\n       \"description\": \"A language hint for OCR processing during image import (ISO 639-1 code).\",\n       \"location\": \"query\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\"\n     ],\n     \"request\": {\n      \"$ref\": \"File\"\n     },\n     \"response\": {\n      \"$ref\": \"File\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.appdata\",\n      \"https://www.googleapis.com/auth/drive.file\",\n      \"https://www.googleapis.com/auth/drive.photos.readonly\"\n     ]\n    },\n    \"create\": {\n     \"id\": \"drive.files.create\",\n     \"path\": \"files\",\n     \"httpMethod\": \"POST\",\n     \"description\": \"Creates a new file.\",\n     \"parameters\": {\n      \"ignoreDefaultVisibility\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether to ignore the domain's default visibility settings for the created file. Domain administrators can choose to make all uploaded files visible to the domain by default; this parameter bypasses that behavior for the request. Permissions are still inherited from parent folders.\",\n       \"default\": \"false\",\n       \"location\": \"query\"\n      },\n      \"keepRevisionForever\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether to set the 'keepForever' field in the new head revision. This is only applicable to files with binary content in Drive.\",\n       \"default\": \"false\",\n       \"location\": \"query\"\n      },\n      \"ocrLanguage\": {\n       \"type\": \"string\",\n       \"description\": \"A language hint for OCR processing during image import (ISO 639-1 code).\",\n       \"location\": \"query\"\n      },\n      \"useContentAsIndexableText\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether to use the uploaded content as indexable text.\",\n       \"default\": \"false\",\n       \"location\": \"query\"\n      }\n     },\n     \"request\": {\n      \"$ref\": \"File\"\n     },\n     \"response\": {\n      \"$ref\": \"File\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.appdata\",\n      \"https://www.googleapis.com/auth/drive.file\"\n     ],\n     \"supportsMediaUpload\": true,\n     \"mediaUpload\": {\n      \"accept\": [\n       \"*/*\"\n      ],\n      \"maxSize\": \"5120GB\",\n      \"protocols\": {\n       \"simple\": {\n        \"multipart\": true,\n        \"path\": \"/upload/drive/v3/files\"\n       },\n       \"resumable\": {\n        \"multipart\": true,\n        \"path\": \"/resumable/upload/drive/v3/files\"\n       }\n      }\n     },\n     \"supportsSubscription\": true\n    },\n    \"delete\": {\n     \"id\": \"drive.files.delete\",\n     \"path\": \"files/{fileId}\",\n     \"httpMethod\": \"DELETE\",\n     \"description\": \"Permanently deletes a file owned by the user without moving it to the trash. If the target is a folder, all descendants owned by the user are also deleted.\",\n     \"parameters\": {\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\"\n     ],\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.appdata\",\n      \"https://www.googleapis.com/auth/drive.file\"\n     ]\n    },\n    \"emptyTrash\": {\n     \"id\": \"drive.files.emptyTrash\",\n     \"path\": \"files/trash\",\n     \"httpMethod\": \"DELETE\",\n     \"description\": \"Permanently deletes all of the user's trashed files.\",\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\"\n     ]\n    },\n    \"export\": {\n     \"id\": \"drive.files.export\",\n     \"path\": \"files/{fileId}/export\",\n     \"httpMethod\": \"GET\",\n     \"description\": \"Exports a Google Doc to the requested MIME type and returns the exported content.\",\n     \"parameters\": {\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"mimeType\": {\n       \"type\": \"string\",\n       \"description\": \"The MIME type of the format requested for this export.\",\n       \"required\": true,\n       \"location\": \"query\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\",\n      \"mimeType\"\n     ],\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.file\",\n      \"https://www.googleapis.com/auth/drive.readonly\"\n     ],\n     \"supportsMediaDownload\": true\n    },\n    \"generateIds\": {\n     \"id\": \"drive.files.generateIds\",\n     \"path\": \"files/generateIds\",\n     \"httpMethod\": \"GET\",\n     \"description\": \"Generates a set of file IDs which can be provided in create requests.\",\n     \"parameters\": {\n      \"count\": {\n       \"type\": \"integer\",\n       \"description\": \"The number of IDs to return.\",\n       \"default\": \"10\",\n       \"format\": \"int32\",\n       \"minimum\": \"1\",\n       \"maximum\": \"1000\",\n       \"location\": \"query\"\n      },\n      \"space\": {\n       \"type\": \"string\",\n       \"description\": \"The space in which the IDs can be used to create new files. Supported values are 'drive' and 'appDataFolder'.\",\n       \"default\": \"drive\",\n       \"location\": \"query\"\n      }\n     },\n     \"response\": {\n      \"$ref\": \"GeneratedIds\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.appdata\",\n      \"https://www.googleapis.com/auth/drive.file\"\n     ]\n    },\n    \"get\": {\n     \"id\": \"drive.files.get\",\n     \"path\": \"files/{fileId}\",\n     \"httpMethod\": \"GET\",\n     \"description\": \"Gets a file's metadata or content by ID.\",\n     \"parameters\": {\n      \"acknowledgeAbuse\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether the user is acknowledging the risk of downloading known malware or other abusive files. This is only applicable when alt=media.\",\n       \"default\": \"false\",\n       \"location\": \"query\"\n      },\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\"\n     ],\n     \"response\": {\n      \"$ref\": \"File\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.appdata\",\n      \"https://www.googleapis.com/auth/drive.file\",\n      \"https://www.googleapis.com/auth/drive.metadata\",\n      \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n      \"https://www.googleapis.com/auth/drive.photos.readonly\",\n      \"https://www.googleapis.com/auth/drive.readonly\"\n     ],\n     \"supportsMediaDownload\": true,\n     \"useMediaDownloadService\": true,\n     \"supportsSubscription\": true\n    },\n    \"list\": {\n     \"id\": \"drive.files.list\",\n     \"path\": \"files\",\n     \"httpMethod\": \"GET\",\n     \"description\": \"Lists or searches files.\",\n     \"parameters\": {\n      \"corpus\": {\n       \"type\": \"string\",\n       \"description\": \"The source of files to list.\",\n       \"default\": \"user\",\n       \"enum\": [\n        \"domain\",\n        \"user\"\n       ],\n       \"enumDescriptions\": [\n        \"Files shared to the user's domain.\",\n        \"Files owned by or shared to the user.\"\n       ],\n       \"location\": \"query\"\n      },\n      \"orderBy\": {\n       \"type\": \"string\",\n       \"description\": \"A comma-separated list of sort keys. Valid keys are 'createdTime', 'folder', 'modifiedByMeTime', 'modifiedTime', 'name', 'quotaBytesUsed', 'recency', 'sharedWithMeTime', 'starred', and 'viewedByMeTime'. Each key sorts ascending by default, but may be reversed with the 'desc' modifier. Example usage: ?orderBy=folder,modifiedTime desc,name. Please note that there is a current limitation for users with approximately one million files in which the requested sort order is ignored.\",\n       \"location\": \"query\"\n      },\n      \"pageSize\": {\n       \"type\": \"integer\",\n       \"description\": \"The maximum number of files to return per page.\",\n       \"default\": \"100\",\n       \"format\": \"int32\",\n       \"minimum\": \"1\",\n       \"maximum\": \"1000\",\n       \"location\": \"query\"\n      },\n      \"pageToken\": {\n       \"type\": \"string\",\n       \"description\": \"The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.\",\n       \"location\": \"query\"\n      },\n      \"q\": {\n       \"type\": \"string\",\n       \"description\": \"A query for filtering the file results. See the \\\"Search for Files\\\" guide for supported syntax.\",\n       \"location\": \"query\"\n      },\n      \"spaces\": {\n       \"type\": \"string\",\n       \"description\": \"A comma-separated list of spaces to query within the corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.\",\n       \"default\": \"drive\",\n       \"location\": \"query\"\n      }\n     },\n     \"response\": {\n      \"$ref\": \"FileList\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.appdata\",\n      \"https://www.googleapis.com/auth/drive.file\",\n      \"https://www.googleapis.com/auth/drive.metadata\",\n      \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n      \"https://www.googleapis.com/auth/drive.photos.readonly\",\n      \"https://www.googleapis.com/auth/drive.readonly\"\n     ]\n    },\n    \"update\": {\n     \"id\": \"drive.files.update\",\n     \"path\": \"files/{fileId}\",\n     \"httpMethod\": \"PATCH\",\n     \"description\": \"Updates a file's metadata and/or content with patch semantics.\",\n     \"parameters\": {\n      \"addParents\": {\n       \"type\": \"string\",\n       \"description\": \"A comma-separated list of parent IDs to add.\",\n       \"location\": \"query\"\n      },\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"keepRevisionForever\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether to set the 'keepForever' field in the new head revision. This is only applicable to files with binary content in Drive.\",\n       \"default\": \"false\",\n       \"location\": \"query\"\n      },\n      \"ocrLanguage\": {\n       \"type\": \"string\",\n       \"description\": \"A language hint for OCR processing during image import (ISO 639-1 code).\",\n       \"location\": \"query\"\n      },\n      \"removeParents\": {\n       \"type\": \"string\",\n       \"description\": \"A comma-separated list of parent IDs to remove.\",\n       \"location\": \"query\"\n      },\n      \"useContentAsIndexableText\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether to use the uploaded content as indexable text.\",\n       \"default\": \"false\",\n       \"location\": \"query\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\"\n     ],\n     \"request\": {\n      \"$ref\": \"File\"\n     },\n     \"response\": {\n      \"$ref\": \"File\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.appdata\",\n      \"https://www.googleapis.com/auth/drive.file\",\n      \"https://www.googleapis.com/auth/drive.metadata\",\n      \"https://www.googleapis.com/auth/drive.scripts\"\n     ],\n     \"supportsMediaUpload\": true,\n     \"mediaUpload\": {\n      \"accept\": [\n       \"*/*\"\n      ],\n      \"maxSize\": \"5120GB\",\n      \"protocols\": {\n       \"simple\": {\n        \"multipart\": true,\n        \"path\": \"/upload/drive/v3/files/{fileId}\"\n       },\n       \"resumable\": {\n        \"multipart\": true,\n        \"path\": \"/resumable/upload/drive/v3/files/{fileId}\"\n       }\n      }\n     }\n    },\n    \"watch\": {\n     \"id\": \"drive.files.watch\",\n     \"path\": \"files/{fileId}/watch\",\n     \"httpMethod\": \"POST\",\n     \"description\": \"Subscribes to changes to a file\",\n     \"parameters\": {\n      \"acknowledgeAbuse\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether the user is acknowledging the risk of downloading known malware or other abusive files. This is only applicable when alt=media.\",\n       \"default\": \"false\",\n       \"location\": \"query\"\n      },\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\"\n     ],\n     \"request\": {\n      \"$ref\": \"Channel\",\n      \"parameterName\": \"resource\"\n     },\n     \"response\": {\n      \"$ref\": \"Channel\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.appdata\",\n      \"https://www.googleapis.com/auth/drive.file\",\n      \"https://www.googleapis.com/auth/drive.metadata\",\n      \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n      \"https://www.googleapis.com/auth/drive.photos.readonly\",\n      \"https://www.googleapis.com/auth/drive.readonly\"\n     ],\n     \"supportsMediaDownload\": true,\n     \"useMediaDownloadService\": true,\n     \"supportsSubscription\": true\n    }\n   }\n  },\n  \"permissions\": {\n   \"methods\": {\n    \"create\": {\n     \"id\": \"drive.permissions.create\",\n     \"path\": \"files/{fileId}/permissions\",\n     \"httpMethod\": \"POST\",\n     \"description\": \"Creates a permission for a file.\",\n     \"parameters\": {\n      \"emailMessage\": {\n       \"type\": \"string\",\n       \"description\": \"A custom message to include in the notification email.\",\n       \"location\": \"query\"\n      },\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"sendNotificationEmail\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether to send a notification email when sharing to users or groups. This defaults to true for users and groups, and is not allowed for other requests. It must not be disabled for ownership transfers.\",\n       \"location\": \"query\"\n      },\n      \"transferOwnership\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether to transfer ownership to the specified user and downgrade the current owner to a writer. This parameter is required as an acknowledgement of the side effect.\",\n       \"default\": \"false\",\n       \"location\": \"query\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\"\n     ],\n     \"request\": {\n      \"$ref\": \"Permission\"\n     },\n     \"response\": {\n      \"$ref\": \"Permission\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.file\"\n     ]\n    },\n    \"delete\": {\n     \"id\": \"drive.permissions.delete\",\n     \"path\": \"files/{fileId}/permissions/{permissionId}\",\n     \"httpMethod\": \"DELETE\",\n     \"description\": \"Deletes a permission.\",\n     \"parameters\": {\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"permissionId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the permission.\",\n       \"required\": true,\n       \"location\": \"path\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\",\n      \"permissionId\"\n     ],\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.file\"\n     ]\n    },\n    \"get\": {\n     \"id\": \"drive.permissions.get\",\n     \"path\": \"files/{fileId}/permissions/{permissionId}\",\n     \"httpMethod\": \"GET\",\n     \"description\": \"Gets a permission by ID.\",\n     \"parameters\": {\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"permissionId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the permission.\",\n       \"required\": true,\n       \"location\": \"path\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\",\n      \"permissionId\"\n     ],\n     \"response\": {\n      \"$ref\": \"Permission\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.file\",\n      \"https://www.googleapis.com/auth/drive.metadata\",\n      \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n      \"https://www.googleapis.com/auth/drive.photos.readonly\",\n      \"https://www.googleapis.com/auth/drive.readonly\"\n     ]\n    },\n    \"list\": {\n     \"id\": \"drive.permissions.list\",\n     \"path\": \"files/{fileId}/permissions\",\n     \"httpMethod\": \"GET\",\n     \"description\": \"Lists a file's permissions.\",\n     \"parameters\": {\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\"\n     ],\n     \"response\": {\n      \"$ref\": \"PermissionList\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.file\",\n      \"https://www.googleapis.com/auth/drive.metadata\",\n      \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n      \"https://www.googleapis.com/auth/drive.photos.readonly\",\n      \"https://www.googleapis.com/auth/drive.readonly\"\n     ]\n    },\n    \"update\": {\n     \"id\": \"drive.permissions.update\",\n     \"path\": \"files/{fileId}/permissions/{permissionId}\",\n     \"httpMethod\": \"PATCH\",\n     \"description\": \"Updates a permission with patch semantics.\",\n     \"parameters\": {\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"permissionId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the permission.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"transferOwnership\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether to transfer ownership to the specified user and downgrade the current owner to a writer. This parameter is required as an acknowledgement of the side effect.\",\n       \"default\": \"false\",\n       \"location\": \"query\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\",\n      \"permissionId\"\n     ],\n     \"request\": {\n      \"$ref\": \"Permission\"\n     },\n     \"response\": {\n      \"$ref\": \"Permission\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.file\"\n     ]\n    }\n   }\n  },\n  \"replies\": {\n   \"methods\": {\n    \"create\": {\n     \"id\": \"drive.replies.create\",\n     \"path\": \"files/{fileId}/comments/{commentId}/replies\",\n     \"httpMethod\": \"POST\",\n     \"description\": \"Creates a new reply to a comment.\",\n     \"parameters\": {\n      \"commentId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the comment.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\",\n      \"commentId\"\n     ],\n     \"request\": {\n      \"$ref\": \"Reply\"\n     },\n     \"response\": {\n      \"$ref\": \"Reply\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.file\"\n     ]\n    },\n    \"delete\": {\n     \"id\": \"drive.replies.delete\",\n     \"path\": \"files/{fileId}/comments/{commentId}/replies/{replyId}\",\n     \"httpMethod\": \"DELETE\",\n     \"description\": \"Deletes a reply.\",\n     \"parameters\": {\n      \"commentId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the comment.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"replyId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the reply.\",\n       \"required\": true,\n       \"location\": \"path\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\",\n      \"commentId\",\n      \"replyId\"\n     ],\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.file\"\n     ]\n    },\n    \"get\": {\n     \"id\": \"drive.replies.get\",\n     \"path\": \"files/{fileId}/comments/{commentId}/replies/{replyId}\",\n     \"httpMethod\": \"GET\",\n     \"description\": \"Gets a reply by ID.\",\n     \"parameters\": {\n      \"commentId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the comment.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"includeDeleted\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether to return deleted replies. Deleted replies will not include their original content.\",\n       \"default\": \"false\",\n       \"location\": \"query\"\n      },\n      \"replyId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the reply.\",\n       \"required\": true,\n       \"location\": \"path\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\",\n      \"commentId\",\n      \"replyId\"\n     ],\n     \"response\": {\n      \"$ref\": \"Reply\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.file\",\n      \"https://www.googleapis.com/auth/drive.readonly\"\n     ]\n    },\n    \"list\": {\n     \"id\": \"drive.replies.list\",\n     \"path\": \"files/{fileId}/comments/{commentId}/replies\",\n     \"httpMethod\": \"GET\",\n     \"description\": \"Lists a comment's replies.\",\n     \"parameters\": {\n      \"commentId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the comment.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"includeDeleted\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether to include deleted replies. Deleted replies will not include their original content.\",\n       \"default\": \"false\",\n       \"location\": \"query\"\n      },\n      \"pageSize\": {\n       \"type\": \"integer\",\n       \"description\": \"The maximum number of replies to return per page.\",\n       \"default\": \"20\",\n       \"format\": \"int32\",\n       \"minimum\": \"1\",\n       \"maximum\": \"100\",\n       \"location\": \"query\"\n      },\n      \"pageToken\": {\n       \"type\": \"string\",\n       \"description\": \"The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.\",\n       \"location\": \"query\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\",\n      \"commentId\"\n     ],\n     \"response\": {\n      \"$ref\": \"ReplyList\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.file\",\n      \"https://www.googleapis.com/auth/drive.readonly\"\n     ]\n    },\n    \"update\": {\n     \"id\": \"drive.replies.update\",\n     \"path\": \"files/{fileId}/comments/{commentId}/replies/{replyId}\",\n     \"httpMethod\": \"PATCH\",\n     \"description\": \"Updates a reply with patch semantics.\",\n     \"parameters\": {\n      \"commentId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the comment.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"replyId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the reply.\",\n       \"required\": true,\n       \"location\": \"path\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\",\n      \"commentId\",\n      \"replyId\"\n     ],\n     \"request\": {\n      \"$ref\": \"Reply\"\n     },\n     \"response\": {\n      \"$ref\": \"Reply\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.file\"\n     ]\n    }\n   }\n  },\n  \"revisions\": {\n   \"methods\": {\n    \"delete\": {\n     \"id\": \"drive.revisions.delete\",\n     \"path\": \"files/{fileId}/revisions/{revisionId}\",\n     \"httpMethod\": \"DELETE\",\n     \"description\": \"Permanently deletes a revision. This method is only applicable to files with binary content in Drive.\",\n     \"parameters\": {\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"revisionId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the revision.\",\n       \"required\": true,\n       \"location\": \"path\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\",\n      \"revisionId\"\n     ],\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.appdata\",\n      \"https://www.googleapis.com/auth/drive.file\"\n     ]\n    },\n    \"get\": {\n     \"id\": \"drive.revisions.get\",\n     \"path\": \"files/{fileId}/revisions/{revisionId}\",\n     \"httpMethod\": \"GET\",\n     \"description\": \"Gets a revision's metadata or content by ID.\",\n     \"parameters\": {\n      \"acknowledgeAbuse\": {\n       \"type\": \"boolean\",\n       \"description\": \"Whether the user is acknowledging the risk of downloading known malware or other abusive files. This is only applicable when alt=media.\",\n       \"default\": \"false\",\n       \"location\": \"query\"\n      },\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"revisionId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the revision.\",\n       \"required\": true,\n       \"location\": \"path\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\",\n      \"revisionId\"\n     ],\n     \"response\": {\n      \"$ref\": \"Revision\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.appdata\",\n      \"https://www.googleapis.com/auth/drive.file\",\n      \"https://www.googleapis.com/auth/drive.metadata\",\n      \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n      \"https://www.googleapis.com/auth/drive.photos.readonly\",\n      \"https://www.googleapis.com/auth/drive.readonly\"\n     ],\n     \"supportsMediaDownload\": true,\n     \"useMediaDownloadService\": true\n    },\n    \"list\": {\n     \"id\": \"drive.revisions.list\",\n     \"path\": \"files/{fileId}/revisions\",\n     \"httpMethod\": \"GET\",\n     \"description\": \"Lists a file's revisions.\",\n     \"parameters\": {\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\"\n     ],\n     \"response\": {\n      \"$ref\": \"RevisionList\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.appdata\",\n      \"https://www.googleapis.com/auth/drive.file\",\n      \"https://www.googleapis.com/auth/drive.metadata\",\n      \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n      \"https://www.googleapis.com/auth/drive.photos.readonly\",\n      \"https://www.googleapis.com/auth/drive.readonly\"\n     ]\n    },\n    \"update\": {\n     \"id\": \"drive.revisions.update\",\n     \"path\": \"files/{fileId}/revisions/{revisionId}\",\n     \"httpMethod\": \"PATCH\",\n     \"description\": \"Updates a revision with patch semantics.\",\n     \"parameters\": {\n      \"fileId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the file.\",\n       \"required\": true,\n       \"location\": \"path\"\n      },\n      \"revisionId\": {\n       \"type\": \"string\",\n       \"description\": \"The ID of the revision.\",\n       \"required\": true,\n       \"location\": \"path\"\n      }\n     },\n     \"parameterOrder\": [\n      \"fileId\",\n      \"revisionId\"\n     ],\n     \"request\": {\n      \"$ref\": \"Revision\"\n     },\n     \"response\": {\n      \"$ref\": \"Revision\"\n     },\n     \"scopes\": [\n      \"https://www.googleapis.com/auth/drive\",\n      \"https://www.googleapis.com/auth/drive.appdata\",\n      \"https://www.googleapis.com/auth/drive.file\"\n     ]\n    }\n   }\n  }\n }\n}\n"
  },
  {
    "path": "vendor/google.golang.org/api/drive/v3/drive-gen.go",
    "content": "// Package drive provides access to the Drive API.\n//\n// See https://developers.google.com/drive/\n//\n// Usage example:\n//\n//   import \"google.golang.org/api/drive/v3\"\n//   ...\n//   driveService, err := drive.New(oauthHttpClient)\npackage drive\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\tcontext \"golang.org/x/net/context\"\n\tctxhttp \"golang.org/x/net/context/ctxhttp\"\n\tgensupport \"google.golang.org/api/gensupport\"\n\tgoogleapi \"google.golang.org/api/googleapi\"\n\t\"io\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"strconv\"\n\t\"strings\"\n)\n\n// Always reference these packages, just in case the auto-generated code\n// below doesn't.\nvar _ = bytes.NewBuffer\nvar _ = strconv.Itoa\nvar _ = fmt.Sprintf\nvar _ = json.NewDecoder\nvar _ = io.Copy\nvar _ = url.Parse\nvar _ = gensupport.MarshalJSON\nvar _ = googleapi.Version\nvar _ = errors.New\nvar _ = strings.Replace\nvar _ = context.Canceled\nvar _ = ctxhttp.Do\n\nconst apiId = \"drive:v3\"\nconst apiName = \"drive\"\nconst apiVersion = \"v3\"\nconst basePath = \"https://www.googleapis.com/drive/v3/\"\n\n// OAuth2 scopes used by this API.\nconst (\n\t// View and manage the files in your Google Drive\n\tDriveScope = \"https://www.googleapis.com/auth/drive\"\n\n\t// View and manage its own configuration data in your Google Drive\n\tDriveAppdataScope = \"https://www.googleapis.com/auth/drive.appdata\"\n\n\t// View and manage Google Drive files and folders that you have opened\n\t// or created with this app\n\tDriveFileScope = \"https://www.googleapis.com/auth/drive.file\"\n\n\t// View and manage metadata of files in your Google Drive\n\tDriveMetadataScope = \"https://www.googleapis.com/auth/drive.metadata\"\n\n\t// View metadata for files in your Google Drive\n\tDriveMetadataReadonlyScope = \"https://www.googleapis.com/auth/drive.metadata.readonly\"\n\n\t// View the photos, videos and albums in your Google Photos\n\tDrivePhotosReadonlyScope = \"https://www.googleapis.com/auth/drive.photos.readonly\"\n\n\t// View the files in your Google Drive\n\tDriveReadonlyScope = \"https://www.googleapis.com/auth/drive.readonly\"\n\n\t// Modify your Google Apps Script scripts' behavior\n\tDriveScriptsScope = \"https://www.googleapis.com/auth/drive.scripts\"\n)\n\nfunc New(client *http.Client) (*Service, error) {\n\tif client == nil {\n\t\treturn nil, errors.New(\"client is nil\")\n\t}\n\ts := &Service{client: client, BasePath: basePath}\n\ts.About = NewAboutService(s)\n\ts.Changes = NewChangesService(s)\n\ts.Channels = NewChannelsService(s)\n\ts.Comments = NewCommentsService(s)\n\ts.Files = NewFilesService(s)\n\ts.Permissions = NewPermissionsService(s)\n\ts.Replies = NewRepliesService(s)\n\ts.Revisions = NewRevisionsService(s)\n\treturn s, nil\n}\n\ntype Service struct {\n\tclient    *http.Client\n\tBasePath  string // API endpoint base URL\n\tUserAgent string // optional additional User-Agent fragment\n\n\tAbout *AboutService\n\n\tChanges *ChangesService\n\n\tChannels *ChannelsService\n\n\tComments *CommentsService\n\n\tFiles *FilesService\n\n\tPermissions *PermissionsService\n\n\tReplies *RepliesService\n\n\tRevisions *RevisionsService\n}\n\nfunc (s *Service) userAgent() string {\n\tif s.UserAgent == \"\" {\n\t\treturn googleapi.UserAgent\n\t}\n\treturn googleapi.UserAgent + \" \" + s.UserAgent\n}\n\nfunc NewAboutService(s *Service) *AboutService {\n\trs := &AboutService{s: s}\n\treturn rs\n}\n\ntype AboutService struct {\n\ts *Service\n}\n\nfunc NewChangesService(s *Service) *ChangesService {\n\trs := &ChangesService{s: s}\n\treturn rs\n}\n\ntype ChangesService struct {\n\ts *Service\n}\n\nfunc NewChannelsService(s *Service) *ChannelsService {\n\trs := &ChannelsService{s: s}\n\treturn rs\n}\n\ntype ChannelsService struct {\n\ts *Service\n}\n\nfunc NewCommentsService(s *Service) *CommentsService {\n\trs := &CommentsService{s: s}\n\treturn rs\n}\n\ntype CommentsService struct {\n\ts *Service\n}\n\nfunc NewFilesService(s *Service) *FilesService {\n\trs := &FilesService{s: s}\n\treturn rs\n}\n\ntype FilesService struct {\n\ts *Service\n}\n\nfunc NewPermissionsService(s *Service) *PermissionsService {\n\trs := &PermissionsService{s: s}\n\treturn rs\n}\n\ntype PermissionsService struct {\n\ts *Service\n}\n\nfunc NewRepliesService(s *Service) *RepliesService {\n\trs := &RepliesService{s: s}\n\treturn rs\n}\n\ntype RepliesService struct {\n\ts *Service\n}\n\nfunc NewRevisionsService(s *Service) *RevisionsService {\n\trs := &RevisionsService{s: s}\n\treturn rs\n}\n\ntype RevisionsService struct {\n\ts *Service\n}\n\n// About: Information about the user, the user's Drive, and system\n// capabilities.\ntype About struct {\n\t// AppInstalled: Whether the user has installed the requesting app.\n\tAppInstalled bool `json:\"appInstalled,omitempty\"`\n\n\t// ExportFormats: A map of source MIME type to possible targets for all\n\t// supported exports.\n\tExportFormats map[string][]string `json:\"exportFormats,omitempty\"`\n\n\t// FolderColorPalette: The currently supported folder colors as RGB hex\n\t// strings.\n\tFolderColorPalette []string `json:\"folderColorPalette,omitempty\"`\n\n\t// ImportFormats: A map of source MIME type to possible targets for all\n\t// supported imports.\n\tImportFormats map[string][]string `json:\"importFormats,omitempty\"`\n\n\t// Kind: This is always drive#about.\n\tKind string `json:\"kind,omitempty\"`\n\n\t// MaxImportSizes: A map of maximum import sizes by MIME type, in bytes.\n\tMaxImportSizes map[string]string `json:\"maxImportSizes,omitempty\"`\n\n\t// MaxUploadSize: The maximum upload size in bytes.\n\tMaxUploadSize int64 `json:\"maxUploadSize,omitempty,string\"`\n\n\t// StorageQuota: The user's storage quota limits and usage. All fields\n\t// are measured in bytes.\n\tStorageQuota *AboutStorageQuota `json:\"storageQuota,omitempty\"`\n\n\t// User: The authenticated user.\n\tUser *User `json:\"user,omitempty\"`\n\n\t// ServerResponse contains the HTTP response code and headers from the\n\t// server.\n\tgoogleapi.ServerResponse `json:\"-\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"AppInstalled\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *About) MarshalJSON() ([]byte, error) {\n\ttype noMethod About\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// AboutStorageQuota: The user's storage quota limits and usage. All\n// fields are measured in bytes.\ntype AboutStorageQuota struct {\n\t// Limit: The usage limit, if applicable. This will not be present if\n\t// the user has unlimited storage.\n\tLimit int64 `json:\"limit,omitempty,string\"`\n\n\t// Usage: The total usage across all services.\n\tUsage int64 `json:\"usage,omitempty,string\"`\n\n\t// UsageInDrive: The usage by all files in Google Drive.\n\tUsageInDrive int64 `json:\"usageInDrive,omitempty,string\"`\n\n\t// UsageInDriveTrash: The usage by trashed files in Google Drive.\n\tUsageInDriveTrash int64 `json:\"usageInDriveTrash,omitempty,string\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"Limit\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *AboutStorageQuota) MarshalJSON() ([]byte, error) {\n\ttype noMethod AboutStorageQuota\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// Change: A change to a file.\ntype Change struct {\n\t// File: The updated state of the file. Present if the file has not been\n\t// removed.\n\tFile *File `json:\"file,omitempty\"`\n\n\t// FileId: The ID of the file which has changed.\n\tFileId string `json:\"fileId,omitempty\"`\n\n\t// Kind: This is always drive#change.\n\tKind string `json:\"kind,omitempty\"`\n\n\t// Removed: Whether the file has been removed from the view of the\n\t// changes list, for example by deletion or lost access.\n\tRemoved bool `json:\"removed,omitempty\"`\n\n\t// Time: The time of this change (RFC 3339 date-time).\n\tTime string `json:\"time,omitempty\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"File\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *Change) MarshalJSON() ([]byte, error) {\n\ttype noMethod Change\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// ChangeList: A list of changes for a user.\ntype ChangeList struct {\n\t// Changes: The page of changes.\n\tChanges []*Change `json:\"changes,omitempty\"`\n\n\t// Kind: This is always drive#changeList.\n\tKind string `json:\"kind,omitempty\"`\n\n\t// NewStartPageToken: The starting page token for future changes. This\n\t// will be present only if the end of the current changes list has been\n\t// reached.\n\tNewStartPageToken string `json:\"newStartPageToken,omitempty\"`\n\n\t// NextPageToken: The page token for the next page of changes. This will\n\t// be absent if the end of the current changes list has been reached.\n\tNextPageToken string `json:\"nextPageToken,omitempty\"`\n\n\t// ServerResponse contains the HTTP response code and headers from the\n\t// server.\n\tgoogleapi.ServerResponse `json:\"-\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"Changes\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *ChangeList) MarshalJSON() ([]byte, error) {\n\ttype noMethod ChangeList\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// Channel: An notification channel used to watch for resource changes.\ntype Channel struct {\n\t// Address: The address where notifications are delivered for this\n\t// channel.\n\tAddress string `json:\"address,omitempty\"`\n\n\t// Expiration: Date and time of notification channel expiration,\n\t// expressed as a Unix timestamp, in milliseconds. Optional.\n\tExpiration int64 `json:\"expiration,omitempty,string\"`\n\n\t// Id: A UUID or similar unique string that identifies this channel.\n\tId string `json:\"id,omitempty\"`\n\n\t// Kind: Identifies this as a notification channel used to watch for\n\t// changes to a resource. Value: the fixed string \"api#channel\".\n\tKind string `json:\"kind,omitempty\"`\n\n\t// Params: Additional parameters controlling delivery channel behavior.\n\t// Optional.\n\tParams map[string]string `json:\"params,omitempty\"`\n\n\t// Payload: A Boolean value to indicate whether payload is wanted.\n\t// Optional.\n\tPayload bool `json:\"payload,omitempty\"`\n\n\t// ResourceId: An opaque ID that identifies the resource being watched\n\t// on this channel. Stable across different API versions.\n\tResourceId string `json:\"resourceId,omitempty\"`\n\n\t// ResourceUri: A version-specific identifier for the watched resource.\n\tResourceUri string `json:\"resourceUri,omitempty\"`\n\n\t// Token: An arbitrary string delivered to the target address with each\n\t// notification delivered over this channel. Optional.\n\tToken string `json:\"token,omitempty\"`\n\n\t// Type: The type of delivery mechanism used for this channel.\n\tType string `json:\"type,omitempty\"`\n\n\t// ServerResponse contains the HTTP response code and headers from the\n\t// server.\n\tgoogleapi.ServerResponse `json:\"-\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"Address\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *Channel) MarshalJSON() ([]byte, error) {\n\ttype noMethod Channel\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// Comment: A comment on a file.\ntype Comment struct {\n\t// Anchor: A region of the document represented as a JSON string. See\n\t// anchor documentation for details on how to define and interpret\n\t// anchor properties.\n\tAnchor string `json:\"anchor,omitempty\"`\n\n\t// Author: The user who created the comment.\n\tAuthor *User `json:\"author,omitempty\"`\n\n\t// Content: The plain text content of the comment. This field is used\n\t// for setting the content, while htmlContent should be displayed.\n\tContent string `json:\"content,omitempty\"`\n\n\t// CreatedTime: The time at which the comment was created (RFC 3339\n\t// date-time).\n\tCreatedTime string `json:\"createdTime,omitempty\"`\n\n\t// Deleted: Whether the comment has been deleted. A deleted comment has\n\t// no content.\n\tDeleted bool `json:\"deleted,omitempty\"`\n\n\t// HtmlContent: The content of the comment with HTML formatting.\n\tHtmlContent string `json:\"htmlContent,omitempty\"`\n\n\t// Id: The ID of the comment.\n\tId string `json:\"id,omitempty\"`\n\n\t// Kind: This is always drive#comment.\n\tKind string `json:\"kind,omitempty\"`\n\n\t// ModifiedTime: The last time the comment or any of its replies was\n\t// modified (RFC 3339 date-time).\n\tModifiedTime string `json:\"modifiedTime,omitempty\"`\n\n\t// QuotedFileContent: The file content to which the comment refers,\n\t// typically within the anchor region. For a text file, for example,\n\t// this would be the text at the location of the comment.\n\tQuotedFileContent *CommentQuotedFileContent `json:\"quotedFileContent,omitempty\"`\n\n\t// Replies: The full list of replies to the comment in chronological\n\t// order.\n\tReplies []*Reply `json:\"replies,omitempty\"`\n\n\t// Resolved: Whether the comment has been resolved by one of its\n\t// replies.\n\tResolved bool `json:\"resolved,omitempty\"`\n\n\t// ServerResponse contains the HTTP response code and headers from the\n\t// server.\n\tgoogleapi.ServerResponse `json:\"-\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"Anchor\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *Comment) MarshalJSON() ([]byte, error) {\n\ttype noMethod Comment\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// CommentQuotedFileContent: The file content to which the comment\n// refers, typically within the anchor region. For a text file, for\n// example, this would be the text at the location of the comment.\ntype CommentQuotedFileContent struct {\n\t// MimeType: The MIME type of the quoted content.\n\tMimeType string `json:\"mimeType,omitempty\"`\n\n\t// Value: The quoted content itself. This is interpreted as plain text\n\t// if set through the API.\n\tValue string `json:\"value,omitempty\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"MimeType\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *CommentQuotedFileContent) MarshalJSON() ([]byte, error) {\n\ttype noMethod CommentQuotedFileContent\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// CommentList: A list of comments on a file.\ntype CommentList struct {\n\t// Comments: The page of comments.\n\tComments []*Comment `json:\"comments,omitempty\"`\n\n\t// Kind: This is always drive#commentList.\n\tKind string `json:\"kind,omitempty\"`\n\n\t// NextPageToken: The page token for the next page of comments. This\n\t// will be absent if the end of the comments list has been reached.\n\tNextPageToken string `json:\"nextPageToken,omitempty\"`\n\n\t// ServerResponse contains the HTTP response code and headers from the\n\t// server.\n\tgoogleapi.ServerResponse `json:\"-\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"Comments\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *CommentList) MarshalJSON() ([]byte, error) {\n\ttype noMethod CommentList\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// File: The metadata for a file.\ntype File struct {\n\t// AppProperties: A collection of arbitrary key-value pairs which are\n\t// private to the requesting app.\n\t// Entries with null values are cleared in update and copy requests.\n\tAppProperties map[string]string `json:\"appProperties,omitempty\"`\n\n\t// Capabilities: Capabilities the current user has on the file.\n\tCapabilities *FileCapabilities `json:\"capabilities,omitempty\"`\n\n\t// ContentHints: Additional information about the content of the file.\n\t// These fields are never populated in responses.\n\tContentHints *FileContentHints `json:\"contentHints,omitempty\"`\n\n\t// CreatedTime: The time at which the file was created (RFC 3339\n\t// date-time).\n\tCreatedTime string `json:\"createdTime,omitempty\"`\n\n\t// Description: A short description of the file.\n\tDescription string `json:\"description,omitempty\"`\n\n\t// ExplicitlyTrashed: Whether the file has been explicitly trashed, as\n\t// opposed to recursively trashed from a parent folder.\n\tExplicitlyTrashed bool `json:\"explicitlyTrashed,omitempty\"`\n\n\t// FileExtension: The final component of fullFileExtension. This is only\n\t// available for files with binary content in Drive.\n\tFileExtension string `json:\"fileExtension,omitempty\"`\n\n\t// FolderColorRgb: The color for a folder as an RGB hex string. The\n\t// supported colors are published in the folderColorPalette field of the\n\t// About resource.\n\t// If an unsupported color is specified, the closest color in the\n\t// palette will be used instead.\n\tFolderColorRgb string `json:\"folderColorRgb,omitempty\"`\n\n\t// FullFileExtension: The full file extension extracted from the name\n\t// field. May contain multiple concatenated extensions, such as\n\t// \"tar.gz\". This is only available for files with binary content in\n\t// Drive.\n\t// This is automatically updated when the name field changes, however it\n\t// is not cleared if the new name does not contain a valid extension.\n\tFullFileExtension string `json:\"fullFileExtension,omitempty\"`\n\n\t// HeadRevisionId: The ID of the file's head revision. This is currently\n\t// only available for files with binary content in Drive.\n\tHeadRevisionId string `json:\"headRevisionId,omitempty\"`\n\n\t// IconLink: A static, unauthenticated link to the file's icon.\n\tIconLink string `json:\"iconLink,omitempty\"`\n\n\t// Id: The ID of the file.\n\tId string `json:\"id,omitempty\"`\n\n\t// ImageMediaMetadata: Additional metadata about image media, if\n\t// available.\n\tImageMediaMetadata *FileImageMediaMetadata `json:\"imageMediaMetadata,omitempty\"`\n\n\t// Kind: This is always drive#file.\n\tKind string `json:\"kind,omitempty\"`\n\n\t// LastModifyingUser: The last user to modify the file.\n\tLastModifyingUser *User `json:\"lastModifyingUser,omitempty\"`\n\n\t// Md5Checksum: The MD5 checksum for the content of the file. This is\n\t// only applicable to files with binary content in Drive.\n\tMd5Checksum string `json:\"md5Checksum,omitempty\"`\n\n\t// MimeType: The MIME type of the file.\n\t// Drive will attempt to automatically detect an appropriate value from\n\t// uploaded content if no value is provided. The value cannot be changed\n\t// unless a new revision is uploaded.\n\t// If a file is created with a Google Doc MIME type, the uploaded\n\t// content will be imported if possible. The supported import formats\n\t// are published in the About resource.\n\tMimeType string `json:\"mimeType,omitempty\"`\n\n\t// ModifiedByMeTime: The last time the file was modified by the user\n\t// (RFC 3339 date-time).\n\tModifiedByMeTime string `json:\"modifiedByMeTime,omitempty\"`\n\n\t// ModifiedTime: The last time the file was modified by anyone (RFC 3339\n\t// date-time).\n\t// Note that setting modifiedTime will also update modifiedByMeTime for\n\t// the user.\n\tModifiedTime string `json:\"modifiedTime,omitempty\"`\n\n\t// Name: The name of the file. This is not necessarily unique within a\n\t// folder.\n\tName string `json:\"name,omitempty\"`\n\n\t// OriginalFilename: The original filename of the uploaded content if\n\t// available, or else the original value of the name field. This is only\n\t// available for files with binary content in Drive.\n\tOriginalFilename string `json:\"originalFilename,omitempty\"`\n\n\t// OwnedByMe: Whether the user owns the file.\n\tOwnedByMe bool `json:\"ownedByMe,omitempty\"`\n\n\t// Owners: The owners of the file. Currently, only certain legacy files\n\t// may have more than one owner.\n\tOwners []*User `json:\"owners,omitempty\"`\n\n\t// Parents: The IDs of the parent folders which contain the file.\n\t// If not specified as part of a create request, the file will be placed\n\t// directly in the My Drive folder. Update requests must use the\n\t// addParents and removeParents parameters to modify the values.\n\tParents []string `json:\"parents,omitempty\"`\n\n\t// Permissions: The full list of permissions for the file. This is only\n\t// available if the requesting user can share the file.\n\tPermissions []*Permission `json:\"permissions,omitempty\"`\n\n\t// Properties: A collection of arbitrary key-value pairs which are\n\t// visible to all apps.\n\t// Entries with null values are cleared in update and copy requests.\n\tProperties map[string]string `json:\"properties,omitempty\"`\n\n\t// QuotaBytesUsed: The number of storage quota bytes used by the file.\n\t// This includes the head revision as well as previous revisions with\n\t// keepForever enabled.\n\tQuotaBytesUsed int64 `json:\"quotaBytesUsed,omitempty,string\"`\n\n\t// Shared: Whether the file has been shared.\n\tShared bool `json:\"shared,omitempty\"`\n\n\t// SharedWithMeTime: The time at which the file was shared with the\n\t// user, if applicable (RFC 3339 date-time).\n\tSharedWithMeTime string `json:\"sharedWithMeTime,omitempty\"`\n\n\t// SharingUser: The user who shared the file with the requesting user,\n\t// if applicable.\n\tSharingUser *User `json:\"sharingUser,omitempty\"`\n\n\t// Size: The size of the file's content in bytes. This is only\n\t// applicable to files with binary content in Drive.\n\tSize int64 `json:\"size,omitempty,string\"`\n\n\t// Spaces: The list of spaces which contain the file. The currently\n\t// supported values are 'drive', 'appDataFolder' and 'photos'.\n\tSpaces []string `json:\"spaces,omitempty\"`\n\n\t// Starred: Whether the user has starred the file.\n\tStarred bool `json:\"starred,omitempty\"`\n\n\t// ThumbnailLink: A short-lived link to the file's thumbnail, if\n\t// available. Typically lasts on the order of hours.\n\tThumbnailLink string `json:\"thumbnailLink,omitempty\"`\n\n\t// Trashed: Whether the file has been trashed, either explicitly or from\n\t// a trashed parent folder. Only the owner may trash a file, and other\n\t// users cannot see files in the owner's trash.\n\tTrashed bool `json:\"trashed,omitempty\"`\n\n\t// Version: A monotonically increasing version number for the file. This\n\t// reflects every change made to the file on the server, even those not\n\t// visible to the user.\n\tVersion int64 `json:\"version,omitempty,string\"`\n\n\t// VideoMediaMetadata: Additional metadata about video media. This may\n\t// not be available immediately upon upload.\n\tVideoMediaMetadata *FileVideoMediaMetadata `json:\"videoMediaMetadata,omitempty\"`\n\n\t// ViewedByMe: Whether the file has been viewed by this user.\n\tViewedByMe bool `json:\"viewedByMe,omitempty\"`\n\n\t// ViewedByMeTime: The last time the file was viewed by the user (RFC\n\t// 3339 date-time).\n\tViewedByMeTime string `json:\"viewedByMeTime,omitempty\"`\n\n\t// ViewersCanCopyContent: Whether users with only reader or commenter\n\t// permission can copy the file's content. This affects copy, download,\n\t// and print operations.\n\tViewersCanCopyContent bool `json:\"viewersCanCopyContent,omitempty\"`\n\n\t// WebContentLink: A link for downloading the content of the file in a\n\t// browser. This is only available for files with binary content in\n\t// Drive.\n\tWebContentLink string `json:\"webContentLink,omitempty\"`\n\n\t// WebViewLink: A link for opening the file in a relevant Google editor\n\t// or viewer in a browser.\n\tWebViewLink string `json:\"webViewLink,omitempty\"`\n\n\t// WritersCanShare: Whether users with only writer permission can modify\n\t// the file's permissions.\n\tWritersCanShare bool `json:\"writersCanShare,omitempty\"`\n\n\t// ServerResponse contains the HTTP response code and headers from the\n\t// server.\n\tgoogleapi.ServerResponse `json:\"-\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"AppProperties\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *File) MarshalJSON() ([]byte, error) {\n\ttype noMethod File\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// FileCapabilities: Capabilities the current user has on the file.\ntype FileCapabilities struct {\n\t// CanComment: Whether the user can comment on the file.\n\tCanComment bool `json:\"canComment,omitempty\"`\n\n\t// CanCopy: Whether the user can copy the file.\n\tCanCopy bool `json:\"canCopy,omitempty\"`\n\n\t// CanEdit: Whether the user can edit the file's content.\n\tCanEdit bool `json:\"canEdit,omitempty\"`\n\n\t// CanReadRevisions: Whether the current user has read access to the\n\t// Revisions resource of the file.\n\tCanReadRevisions bool `json:\"canReadRevisions,omitempty\"`\n\n\t// CanShare: Whether the user can modify the file's permissions and\n\t// sharing settings.\n\tCanShare bool `json:\"canShare,omitempty\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"CanComment\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *FileCapabilities) MarshalJSON() ([]byte, error) {\n\ttype noMethod FileCapabilities\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// FileContentHints: Additional information about the content of the\n// file. These fields are never populated in responses.\ntype FileContentHints struct {\n\t// IndexableText: Text to be indexed for the file to improve fullText\n\t// queries. This is limited to 128KB in length and may contain HTML\n\t// elements.\n\tIndexableText string `json:\"indexableText,omitempty\"`\n\n\t// Thumbnail: A thumbnail for the file. This will only be used if Drive\n\t// cannot generate a standard thumbnail.\n\tThumbnail *FileContentHintsThumbnail `json:\"thumbnail,omitempty\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"IndexableText\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *FileContentHints) MarshalJSON() ([]byte, error) {\n\ttype noMethod FileContentHints\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// FileContentHintsThumbnail: A thumbnail for the file. This will only\n// be used if Drive cannot generate a standard thumbnail.\ntype FileContentHintsThumbnail struct {\n\t// Image: The thumbnail data encoded with URL-safe Base64 (RFC 4648\n\t// section 5).\n\tImage string `json:\"image,omitempty\"`\n\n\t// MimeType: The MIME type of the thumbnail.\n\tMimeType string `json:\"mimeType,omitempty\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"Image\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *FileContentHintsThumbnail) MarshalJSON() ([]byte, error) {\n\ttype noMethod FileContentHintsThumbnail\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// FileImageMediaMetadata: Additional metadata about image media, if\n// available.\ntype FileImageMediaMetadata struct {\n\t// Aperture: The aperture used to create the photo (f-number).\n\tAperture float64 `json:\"aperture,omitempty\"`\n\n\t// CameraMake: The make of the camera used to create the photo.\n\tCameraMake string `json:\"cameraMake,omitempty\"`\n\n\t// CameraModel: The model of the camera used to create the photo.\n\tCameraModel string `json:\"cameraModel,omitempty\"`\n\n\t// ColorSpace: The color space of the photo.\n\tColorSpace string `json:\"colorSpace,omitempty\"`\n\n\t// ExposureBias: The exposure bias of the photo (APEX value).\n\tExposureBias float64 `json:\"exposureBias,omitempty\"`\n\n\t// ExposureMode: The exposure mode used to create the photo.\n\tExposureMode string `json:\"exposureMode,omitempty\"`\n\n\t// ExposureTime: The length of the exposure, in seconds.\n\tExposureTime float64 `json:\"exposureTime,omitempty\"`\n\n\t// FlashUsed: Whether a flash was used to create the photo.\n\tFlashUsed bool `json:\"flashUsed,omitempty\"`\n\n\t// FocalLength: The focal length used to create the photo, in\n\t// millimeters.\n\tFocalLength float64 `json:\"focalLength,omitempty\"`\n\n\t// Height: The height of the image in pixels.\n\tHeight int64 `json:\"height,omitempty\"`\n\n\t// IsoSpeed: The ISO speed used to create the photo.\n\tIsoSpeed int64 `json:\"isoSpeed,omitempty\"`\n\n\t// Lens: The lens used to create the photo.\n\tLens string `json:\"lens,omitempty\"`\n\n\t// Location: Geographic location information stored in the image.\n\tLocation *FileImageMediaMetadataLocation `json:\"location,omitempty\"`\n\n\t// MaxApertureValue: The smallest f-number of the lens at the focal\n\t// length used to create the photo (APEX value).\n\tMaxApertureValue float64 `json:\"maxApertureValue,omitempty\"`\n\n\t// MeteringMode: The metering mode used to create the photo.\n\tMeteringMode string `json:\"meteringMode,omitempty\"`\n\n\t// Rotation: The rotation in clockwise degrees from the image's original\n\t// orientation.\n\tRotation int64 `json:\"rotation,omitempty\"`\n\n\t// Sensor: The type of sensor used to create the photo.\n\tSensor string `json:\"sensor,omitempty\"`\n\n\t// SubjectDistance: The distance to the subject of the photo, in meters.\n\tSubjectDistance int64 `json:\"subjectDistance,omitempty\"`\n\n\t// Time: The date and time the photo was taken (EXIF DateTime).\n\tTime string `json:\"time,omitempty\"`\n\n\t// WhiteBalance: The white balance mode used to create the photo.\n\tWhiteBalance string `json:\"whiteBalance,omitempty\"`\n\n\t// Width: The width of the image in pixels.\n\tWidth int64 `json:\"width,omitempty\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"Aperture\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *FileImageMediaMetadata) MarshalJSON() ([]byte, error) {\n\ttype noMethod FileImageMediaMetadata\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// FileImageMediaMetadataLocation: Geographic location information\n// stored in the image.\ntype FileImageMediaMetadataLocation struct {\n\t// Altitude: The altitude stored in the image.\n\tAltitude float64 `json:\"altitude,omitempty\"`\n\n\t// Latitude: The latitude stored in the image.\n\tLatitude float64 `json:\"latitude,omitempty\"`\n\n\t// Longitude: The longitude stored in the image.\n\tLongitude float64 `json:\"longitude,omitempty\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"Altitude\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *FileImageMediaMetadataLocation) MarshalJSON() ([]byte, error) {\n\ttype noMethod FileImageMediaMetadataLocation\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// FileVideoMediaMetadata: Additional metadata about video media. This\n// may not be available immediately upon upload.\ntype FileVideoMediaMetadata struct {\n\t// DurationMillis: The duration of the video in milliseconds.\n\tDurationMillis int64 `json:\"durationMillis,omitempty,string\"`\n\n\t// Height: The height of the video in pixels.\n\tHeight int64 `json:\"height,omitempty\"`\n\n\t// Width: The width of the video in pixels.\n\tWidth int64 `json:\"width,omitempty\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"DurationMillis\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *FileVideoMediaMetadata) MarshalJSON() ([]byte, error) {\n\ttype noMethod FileVideoMediaMetadata\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// FileList: A list of files.\ntype FileList struct {\n\t// Files: The page of files.\n\tFiles []*File `json:\"files,omitempty\"`\n\n\t// Kind: This is always drive#fileList.\n\tKind string `json:\"kind,omitempty\"`\n\n\t// NextPageToken: The page token for the next page of files. This will\n\t// be absent if the end of the files list has been reached.\n\tNextPageToken string `json:\"nextPageToken,omitempty\"`\n\n\t// ServerResponse contains the HTTP response code and headers from the\n\t// server.\n\tgoogleapi.ServerResponse `json:\"-\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"Files\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *FileList) MarshalJSON() ([]byte, error) {\n\ttype noMethod FileList\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// GeneratedIds: A list of generated file IDs which can be provided in\n// create requests.\ntype GeneratedIds struct {\n\t// Ids: The IDs generated for the requesting user in the specified\n\t// space.\n\tIds []string `json:\"ids,omitempty\"`\n\n\t// Kind: This is always drive#generatedIds\n\tKind string `json:\"kind,omitempty\"`\n\n\t// Space: The type of file that can be created with these IDs.\n\tSpace string `json:\"space,omitempty\"`\n\n\t// ServerResponse contains the HTTP response code and headers from the\n\t// server.\n\tgoogleapi.ServerResponse `json:\"-\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"Ids\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *GeneratedIds) MarshalJSON() ([]byte, error) {\n\ttype noMethod GeneratedIds\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// Permission: A permission for a file. A permission grants a user,\n// group, domain or the world access to a file or a folder hierarchy.\ntype Permission struct {\n\t// AllowFileDiscovery: Whether the permission allows the file to be\n\t// discovered through search. This is only applicable for permissions of\n\t// type domain or anyone.\n\tAllowFileDiscovery bool `json:\"allowFileDiscovery,omitempty\"`\n\n\t// DisplayName: A displayable name for users, groups or domains.\n\tDisplayName string `json:\"displayName,omitempty\"`\n\n\t// Domain: The domain to which this permission refers.\n\tDomain string `json:\"domain,omitempty\"`\n\n\t// EmailAddress: The email address of the user or group to which this\n\t// permission refers.\n\tEmailAddress string `json:\"emailAddress,omitempty\"`\n\n\t// Id: The ID of this permission. This is a unique identifier for the\n\t// grantee, and is published in User resources as permissionId.\n\tId string `json:\"id,omitempty\"`\n\n\t// Kind: This is always drive#permission.\n\tKind string `json:\"kind,omitempty\"`\n\n\t// PhotoLink: A link to the user's profile photo, if available.\n\tPhotoLink string `json:\"photoLink,omitempty\"`\n\n\t// Role: The role granted by this permission. Valid values are:\n\t// - owner\n\t// - writer\n\t// - commenter\n\t// - reader\n\tRole string `json:\"role,omitempty\"`\n\n\t// Type: The type of the grantee. Valid values are:\n\t// - user\n\t// - group\n\t// - domain\n\t// - anyone\n\tType string `json:\"type,omitempty\"`\n\n\t// ServerResponse contains the HTTP response code and headers from the\n\t// server.\n\tgoogleapi.ServerResponse `json:\"-\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"AllowFileDiscovery\")\n\t// to unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *Permission) MarshalJSON() ([]byte, error) {\n\ttype noMethod Permission\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// PermissionList: A list of permissions for a file.\ntype PermissionList struct {\n\t// Kind: This is always drive#permissionList.\n\tKind string `json:\"kind,omitempty\"`\n\n\t// Permissions: The full list of permissions.\n\tPermissions []*Permission `json:\"permissions,omitempty\"`\n\n\t// ServerResponse contains the HTTP response code and headers from the\n\t// server.\n\tgoogleapi.ServerResponse `json:\"-\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"Kind\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *PermissionList) MarshalJSON() ([]byte, error) {\n\ttype noMethod PermissionList\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// Reply: A reply to a comment on a file.\ntype Reply struct {\n\t// Action: The action the reply performed to the parent comment. Valid\n\t// values are:\n\t// - resolve\n\t// - reopen\n\tAction string `json:\"action,omitempty\"`\n\n\t// Author: The user who created the reply.\n\tAuthor *User `json:\"author,omitempty\"`\n\n\t// Content: The plain text content of the reply. This field is used for\n\t// setting the content, while htmlContent should be displayed. This is\n\t// required on creates if no action is specified.\n\tContent string `json:\"content,omitempty\"`\n\n\t// CreatedTime: The time at which the reply was created (RFC 3339\n\t// date-time).\n\tCreatedTime string `json:\"createdTime,omitempty\"`\n\n\t// Deleted: Whether the reply has been deleted. A deleted reply has no\n\t// content.\n\tDeleted bool `json:\"deleted,omitempty\"`\n\n\t// HtmlContent: The content of the reply with HTML formatting.\n\tHtmlContent string `json:\"htmlContent,omitempty\"`\n\n\t// Id: The ID of the reply.\n\tId string `json:\"id,omitempty\"`\n\n\t// Kind: This is always drive#reply.\n\tKind string `json:\"kind,omitempty\"`\n\n\t// ModifiedTime: The last time the reply was modified (RFC 3339\n\t// date-time).\n\tModifiedTime string `json:\"modifiedTime,omitempty\"`\n\n\t// ServerResponse contains the HTTP response code and headers from the\n\t// server.\n\tgoogleapi.ServerResponse `json:\"-\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"Action\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *Reply) MarshalJSON() ([]byte, error) {\n\ttype noMethod Reply\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// ReplyList: A list of replies to a comment on a file.\ntype ReplyList struct {\n\t// Kind: This is always drive#replyList.\n\tKind string `json:\"kind,omitempty\"`\n\n\t// NextPageToken: The page token for the next page of replies. This will\n\t// be absent if the end of the replies list has been reached.\n\tNextPageToken string `json:\"nextPageToken,omitempty\"`\n\n\t// Replies: The page of replies.\n\tReplies []*Reply `json:\"replies,omitempty\"`\n\n\t// ServerResponse contains the HTTP response code and headers from the\n\t// server.\n\tgoogleapi.ServerResponse `json:\"-\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"Kind\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *ReplyList) MarshalJSON() ([]byte, error) {\n\ttype noMethod ReplyList\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// Revision: The metadata for a revision to a file.\ntype Revision struct {\n\t// Id: The ID of the revision.\n\tId string `json:\"id,omitempty\"`\n\n\t// KeepForever: Whether to keep this revision forever, even if it is no\n\t// longer the head revision. If not set, the revision will be\n\t// automatically purged 30 days after newer content is uploaded. This\n\t// can be set on a maximum of 200 revisions for a file.\n\t// This field is only applicable to files with binary content in Drive.\n\tKeepForever bool `json:\"keepForever,omitempty\"`\n\n\t// Kind: This is always drive#revision.\n\tKind string `json:\"kind,omitempty\"`\n\n\t// LastModifyingUser: The last user to modify this revision.\n\tLastModifyingUser *User `json:\"lastModifyingUser,omitempty\"`\n\n\t// Md5Checksum: The MD5 checksum of the revision's content. This is only\n\t// applicable to files with binary content in Drive.\n\tMd5Checksum string `json:\"md5Checksum,omitempty\"`\n\n\t// MimeType: The MIME type of the revision.\n\tMimeType string `json:\"mimeType,omitempty\"`\n\n\t// ModifiedTime: The last time the revision was modified (RFC 3339\n\t// date-time).\n\tModifiedTime string `json:\"modifiedTime,omitempty\"`\n\n\t// OriginalFilename: The original filename used to create this revision.\n\t// This is only applicable to files with binary content in Drive.\n\tOriginalFilename string `json:\"originalFilename,omitempty\"`\n\n\t// PublishAuto: Whether subsequent revisions will be automatically\n\t// republished. This is only applicable to Google Docs.\n\tPublishAuto bool `json:\"publishAuto,omitempty\"`\n\n\t// Published: Whether this revision is published. This is only\n\t// applicable to Google Docs.\n\tPublished bool `json:\"published,omitempty\"`\n\n\t// PublishedOutsideDomain: Whether this revision is published outside\n\t// the domain. This is only applicable to Google Docs.\n\tPublishedOutsideDomain bool `json:\"publishedOutsideDomain,omitempty\"`\n\n\t// Size: The size of the revision's content in bytes. This is only\n\t// applicable to files with binary content in Drive.\n\tSize int64 `json:\"size,omitempty,string\"`\n\n\t// ServerResponse contains the HTTP response code and headers from the\n\t// server.\n\tgoogleapi.ServerResponse `json:\"-\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"Id\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *Revision) MarshalJSON() ([]byte, error) {\n\ttype noMethod Revision\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// RevisionList: A list of revisions of a file.\ntype RevisionList struct {\n\t// Kind: This is always drive#revisionList.\n\tKind string `json:\"kind,omitempty\"`\n\n\t// Revisions: The full list of revisions.\n\tRevisions []*Revision `json:\"revisions,omitempty\"`\n\n\t// ServerResponse contains the HTTP response code and headers from the\n\t// server.\n\tgoogleapi.ServerResponse `json:\"-\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"Kind\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *RevisionList) MarshalJSON() ([]byte, error) {\n\ttype noMethod RevisionList\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\ntype StartPageToken struct {\n\t// Kind: This is always drive#startPageToken.\n\tKind string `json:\"kind,omitempty\"`\n\n\t// StartPageToken: The starting page token for listing changes.\n\tStartPageToken string `json:\"startPageToken,omitempty\"`\n\n\t// ServerResponse contains the HTTP response code and headers from the\n\t// server.\n\tgoogleapi.ServerResponse `json:\"-\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"Kind\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *StartPageToken) MarshalJSON() ([]byte, error) {\n\ttype noMethod StartPageToken\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// User: Information about a Drive user.\ntype User struct {\n\t// DisplayName: A plain text displayable name for this user.\n\tDisplayName string `json:\"displayName,omitempty\"`\n\n\t// EmailAddress: The email address of the user. This may not be present\n\t// in certain contexts if the user has not made their email address\n\t// visible to the requester.\n\tEmailAddress string `json:\"emailAddress,omitempty\"`\n\n\t// Kind: This is always drive#user.\n\tKind string `json:\"kind,omitempty\"`\n\n\t// Me: Whether this user is the requesting user.\n\tMe bool `json:\"me,omitempty\"`\n\n\t// PermissionId: The user's ID as visible in Permission resources.\n\tPermissionId string `json:\"permissionId,omitempty\"`\n\n\t// PhotoLink: A link to the user's profile photo, if available.\n\tPhotoLink string `json:\"photoLink,omitempty\"`\n\n\t// ForceSendFields is a list of field names (e.g. \"DisplayName\") to\n\t// unconditionally include in API requests. By default, fields with\n\t// empty values are omitted from API requests. However, any non-pointer,\n\t// non-interface field appearing in ForceSendFields will be sent to the\n\t// server regardless of whether the field is empty or not. This may be\n\t// used to include empty fields in Patch requests.\n\tForceSendFields []string `json:\"-\"`\n}\n\nfunc (s *User) MarshalJSON() ([]byte, error) {\n\ttype noMethod User\n\traw := noMethod(*s)\n\treturn gensupport.MarshalJSON(raw, s.ForceSendFields)\n}\n\n// method id \"drive.about.get\":\n\ntype AboutGetCall struct {\n\ts            *Service\n\turlParams_   gensupport.URLParams\n\tifNoneMatch_ string\n\tctx_         context.Context\n}\n\n// Get: Gets information about the user, the user's Drive, and system\n// capabilities.\nfunc (r *AboutService) Get() *AboutGetCall {\n\tc := &AboutGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *AboutGetCall) Fields(s ...googleapi.Field) *AboutGetCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// IfNoneMatch sets the optional parameter which makes the operation\n// fail if the object's ETag matches the given value. This is useful for\n// getting updates only after the object has changed since the last\n// request. Use googleapi.IsNotModified to check whether the response\n// error from Do is the result of In-None-Match.\nfunc (c *AboutGetCall) IfNoneMatch(entityTag string) *AboutGetCall {\n\tc.ifNoneMatch_ = entityTag\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *AboutGetCall) Context(ctx context.Context) *AboutGetCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *AboutGetCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"about\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"GET\", urls, body)\n\tgoogleapi.SetOpaque(req.URL)\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ifNoneMatch_ != \"\" {\n\t\treq.Header.Set(\"If-None-Match\", c.ifNoneMatch_)\n\t}\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.about.get\" call.\n// Exactly one of *About or error will be non-nil. Any non-2xx status\n// code is an error. Response headers are in either\n// *About.ServerResponse.Header or (if a response was returned at all)\n// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to\n// check whether the returned error was because http.StatusNotModified\n// was returned.\nfunc (c *AboutGetCall) Do(opts ...googleapi.CallOption) (*About, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &About{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Gets information about the user, the user's Drive, and system capabilities.\",\n\t//   \"httpMethod\": \"GET\",\n\t//   \"id\": \"drive.about.get\",\n\t//   \"path\": \"about\",\n\t//   \"response\": {\n\t//     \"$ref\": \"About\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.appdata\",\n\t//     \"https://www.googleapis.com/auth/drive.file\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.photos.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.readonly\"\n\t//   ]\n\t// }\n\n}\n\n// method id \"drive.changes.getStartPageToken\":\n\ntype ChangesGetStartPageTokenCall struct {\n\ts            *Service\n\turlParams_   gensupport.URLParams\n\tifNoneMatch_ string\n\tctx_         context.Context\n}\n\n// GetStartPageToken: Gets the starting pageToken for listing future\n// changes.\nfunc (r *ChangesService) GetStartPageToken() *ChangesGetStartPageTokenCall {\n\tc := &ChangesGetStartPageTokenCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *ChangesGetStartPageTokenCall) Fields(s ...googleapi.Field) *ChangesGetStartPageTokenCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// IfNoneMatch sets the optional parameter which makes the operation\n// fail if the object's ETag matches the given value. This is useful for\n// getting updates only after the object has changed since the last\n// request. Use googleapi.IsNotModified to check whether the response\n// error from Do is the result of In-None-Match.\nfunc (c *ChangesGetStartPageTokenCall) IfNoneMatch(entityTag string) *ChangesGetStartPageTokenCall {\n\tc.ifNoneMatch_ = entityTag\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *ChangesGetStartPageTokenCall) Context(ctx context.Context) *ChangesGetStartPageTokenCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *ChangesGetStartPageTokenCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"changes/startPageToken\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"GET\", urls, body)\n\tgoogleapi.SetOpaque(req.URL)\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ifNoneMatch_ != \"\" {\n\t\treq.Header.Set(\"If-None-Match\", c.ifNoneMatch_)\n\t}\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.changes.getStartPageToken\" call.\n// Exactly one of *StartPageToken or error will be non-nil. Any non-2xx\n// status code is an error. Response headers are in either\n// *StartPageToken.ServerResponse.Header or (if a response was returned\n// at all) in error.(*googleapi.Error).Header. Use\n// googleapi.IsNotModified to check whether the returned error was\n// because http.StatusNotModified was returned.\nfunc (c *ChangesGetStartPageTokenCall) Do(opts ...googleapi.CallOption) (*StartPageToken, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &StartPageToken{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Gets the starting pageToken for listing future changes.\",\n\t//   \"httpMethod\": \"GET\",\n\t//   \"id\": \"drive.changes.getStartPageToken\",\n\t//   \"path\": \"changes/startPageToken\",\n\t//   \"response\": {\n\t//     \"$ref\": \"StartPageToken\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.appdata\",\n\t//     \"https://www.googleapis.com/auth/drive.file\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.photos.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.readonly\"\n\t//   ]\n\t// }\n\n}\n\n// method id \"drive.changes.list\":\n\ntype ChangesListCall struct {\n\ts            *Service\n\turlParams_   gensupport.URLParams\n\tifNoneMatch_ string\n\tctx_         context.Context\n}\n\n// List: Lists changes for a user.\nfunc (r *ChangesService) List(pageToken string) *ChangesListCall {\n\tc := &ChangesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.urlParams_.Set(\"pageToken\", pageToken)\n\treturn c\n}\n\n// IncludeRemoved sets the optional parameter \"includeRemoved\": Whether\n// to include changes indicating that items have left the view of the\n// changes list, for example by deletion or lost access.\nfunc (c *ChangesListCall) IncludeRemoved(includeRemoved bool) *ChangesListCall {\n\tc.urlParams_.Set(\"includeRemoved\", fmt.Sprint(includeRemoved))\n\treturn c\n}\n\n// PageSize sets the optional parameter \"pageSize\": The maximum number\n// of changes to return per page.\nfunc (c *ChangesListCall) PageSize(pageSize int64) *ChangesListCall {\n\tc.urlParams_.Set(\"pageSize\", fmt.Sprint(pageSize))\n\treturn c\n}\n\n// RestrictToMyDrive sets the optional parameter \"restrictToMyDrive\":\n// Whether to restrict the results to changes inside the My Drive\n// hierarchy. This omits changes to files such as those in the\n// Application Data folder or shared files which have not been added to\n// My Drive.\nfunc (c *ChangesListCall) RestrictToMyDrive(restrictToMyDrive bool) *ChangesListCall {\n\tc.urlParams_.Set(\"restrictToMyDrive\", fmt.Sprint(restrictToMyDrive))\n\treturn c\n}\n\n// Spaces sets the optional parameter \"spaces\": A comma-separated list\n// of spaces to query within the user corpus. Supported values are\n// 'drive', 'appDataFolder' and 'photos'.\nfunc (c *ChangesListCall) Spaces(spaces string) *ChangesListCall {\n\tc.urlParams_.Set(\"spaces\", spaces)\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *ChangesListCall) Fields(s ...googleapi.Field) *ChangesListCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// IfNoneMatch sets the optional parameter which makes the operation\n// fail if the object's ETag matches the given value. This is useful for\n// getting updates only after the object has changed since the last\n// request. Use googleapi.IsNotModified to check whether the response\n// error from Do is the result of In-None-Match.\nfunc (c *ChangesListCall) IfNoneMatch(entityTag string) *ChangesListCall {\n\tc.ifNoneMatch_ = entityTag\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *ChangesListCall) Context(ctx context.Context) *ChangesListCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *ChangesListCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"changes\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"GET\", urls, body)\n\tgoogleapi.SetOpaque(req.URL)\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ifNoneMatch_ != \"\" {\n\t\treq.Header.Set(\"If-None-Match\", c.ifNoneMatch_)\n\t}\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.changes.list\" call.\n// Exactly one of *ChangeList or error will be non-nil. Any non-2xx\n// status code is an error. Response headers are in either\n// *ChangeList.ServerResponse.Header or (if a response was returned at\n// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified\n// to check whether the returned error was because\n// http.StatusNotModified was returned.\nfunc (c *ChangesListCall) Do(opts ...googleapi.CallOption) (*ChangeList, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &ChangeList{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Lists changes for a user.\",\n\t//   \"httpMethod\": \"GET\",\n\t//   \"id\": \"drive.changes.list\",\n\t//   \"parameterOrder\": [\n\t//     \"pageToken\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"includeRemoved\": {\n\t//       \"default\": \"true\",\n\t//       \"description\": \"Whether to include changes indicating that items have left the view of the changes list, for example by deletion or lost access.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"boolean\"\n\t//     },\n\t//     \"pageSize\": {\n\t//       \"default\": \"100\",\n\t//       \"description\": \"The maximum number of changes to return per page.\",\n\t//       \"format\": \"int32\",\n\t//       \"location\": \"query\",\n\t//       \"maximum\": \"1000\",\n\t//       \"minimum\": \"1\",\n\t//       \"type\": \"integer\"\n\t//     },\n\t//     \"pageToken\": {\n\t//       \"description\": \"The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response or to the response from the getStartPageToken method.\",\n\t//       \"location\": \"query\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"restrictToMyDrive\": {\n\t//       \"default\": \"false\",\n\t//       \"description\": \"Whether to restrict the results to changes inside the My Drive hierarchy. This omits changes to files such as those in the Application Data folder or shared files which have not been added to My Drive.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"boolean\"\n\t//     },\n\t//     \"spaces\": {\n\t//       \"default\": \"drive\",\n\t//       \"description\": \"A comma-separated list of spaces to query within the user corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"changes\",\n\t//   \"response\": {\n\t//     \"$ref\": \"ChangeList\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.appdata\",\n\t//     \"https://www.googleapis.com/auth/drive.file\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.photos.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.readonly\"\n\t//   ],\n\t//   \"supportsSubscription\": true\n\t// }\n\n}\n\n// method id \"drive.changes.watch\":\n\ntype ChangesWatchCall struct {\n\ts          *Service\n\tchannel    *Channel\n\turlParams_ gensupport.URLParams\n\tctx_       context.Context\n}\n\n// Watch: Subscribes to changes for a user.\nfunc (r *ChangesService) Watch(pageToken string, channel *Channel) *ChangesWatchCall {\n\tc := &ChangesWatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.urlParams_.Set(\"pageToken\", pageToken)\n\tc.channel = channel\n\treturn c\n}\n\n// IncludeRemoved sets the optional parameter \"includeRemoved\": Whether\n// to include changes indicating that items have left the view of the\n// changes list, for example by deletion or lost access.\nfunc (c *ChangesWatchCall) IncludeRemoved(includeRemoved bool) *ChangesWatchCall {\n\tc.urlParams_.Set(\"includeRemoved\", fmt.Sprint(includeRemoved))\n\treturn c\n}\n\n// PageSize sets the optional parameter \"pageSize\": The maximum number\n// of changes to return per page.\nfunc (c *ChangesWatchCall) PageSize(pageSize int64) *ChangesWatchCall {\n\tc.urlParams_.Set(\"pageSize\", fmt.Sprint(pageSize))\n\treturn c\n}\n\n// RestrictToMyDrive sets the optional parameter \"restrictToMyDrive\":\n// Whether to restrict the results to changes inside the My Drive\n// hierarchy. This omits changes to files such as those in the\n// Application Data folder or shared files which have not been added to\n// My Drive.\nfunc (c *ChangesWatchCall) RestrictToMyDrive(restrictToMyDrive bool) *ChangesWatchCall {\n\tc.urlParams_.Set(\"restrictToMyDrive\", fmt.Sprint(restrictToMyDrive))\n\treturn c\n}\n\n// Spaces sets the optional parameter \"spaces\": A comma-separated list\n// of spaces to query within the user corpus. Supported values are\n// 'drive', 'appDataFolder' and 'photos'.\nfunc (c *ChangesWatchCall) Spaces(spaces string) *ChangesWatchCall {\n\tc.urlParams_.Set(\"spaces\", spaces)\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *ChangesWatchCall) Fields(s ...googleapi.Field) *ChangesWatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *ChangesWatchCall) Context(ctx context.Context) *ChangesWatchCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *ChangesWatchCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tbody, err := googleapi.WithoutDataWrapper.JSONReader(c.channel)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tctype := \"application/json\"\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"changes/watch\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"POST\", urls, body)\n\tgoogleapi.SetOpaque(req.URL)\n\treq.Header.Set(\"Content-Type\", ctype)\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.changes.watch\" call.\n// Exactly one of *Channel or error will be non-nil. Any non-2xx status\n// code is an error. Response headers are in either\n// *Channel.ServerResponse.Header or (if a response was returned at all)\n// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to\n// check whether the returned error was because http.StatusNotModified\n// was returned.\nfunc (c *ChangesWatchCall) Do(opts ...googleapi.CallOption) (*Channel, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &Channel{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Subscribes to changes for a user.\",\n\t//   \"httpMethod\": \"POST\",\n\t//   \"id\": \"drive.changes.watch\",\n\t//   \"parameterOrder\": [\n\t//     \"pageToken\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"includeRemoved\": {\n\t//       \"default\": \"true\",\n\t//       \"description\": \"Whether to include changes indicating that items have left the view of the changes list, for example by deletion or lost access.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"boolean\"\n\t//     },\n\t//     \"pageSize\": {\n\t//       \"default\": \"100\",\n\t//       \"description\": \"The maximum number of changes to return per page.\",\n\t//       \"format\": \"int32\",\n\t//       \"location\": \"query\",\n\t//       \"maximum\": \"1000\",\n\t//       \"minimum\": \"1\",\n\t//       \"type\": \"integer\"\n\t//     },\n\t//     \"pageToken\": {\n\t//       \"description\": \"The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response or to the response from the getStartPageToken method.\",\n\t//       \"location\": \"query\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"restrictToMyDrive\": {\n\t//       \"default\": \"false\",\n\t//       \"description\": \"Whether to restrict the results to changes inside the My Drive hierarchy. This omits changes to files such as those in the Application Data folder or shared files which have not been added to My Drive.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"boolean\"\n\t//     },\n\t//     \"spaces\": {\n\t//       \"default\": \"drive\",\n\t//       \"description\": \"A comma-separated list of spaces to query within the user corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"changes/watch\",\n\t//   \"request\": {\n\t//     \"$ref\": \"Channel\",\n\t//     \"parameterName\": \"resource\"\n\t//   },\n\t//   \"response\": {\n\t//     \"$ref\": \"Channel\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.appdata\",\n\t//     \"https://www.googleapis.com/auth/drive.file\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.photos.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.readonly\"\n\t//   ],\n\t//   \"supportsSubscription\": true\n\t// }\n\n}\n\n// method id \"drive.channels.stop\":\n\ntype ChannelsStopCall struct {\n\ts          *Service\n\tchannel    *Channel\n\turlParams_ gensupport.URLParams\n\tctx_       context.Context\n}\n\n// Stop: Stop watching resources through this channel\nfunc (r *ChannelsService) Stop(channel *Channel) *ChannelsStopCall {\n\tc := &ChannelsStopCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.channel = channel\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *ChannelsStopCall) Fields(s ...googleapi.Field) *ChannelsStopCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *ChannelsStopCall) Context(ctx context.Context) *ChannelsStopCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *ChannelsStopCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tbody, err := googleapi.WithoutDataWrapper.JSONReader(c.channel)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tctype := \"application/json\"\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"channels/stop\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"POST\", urls, body)\n\tgoogleapi.SetOpaque(req.URL)\n\treq.Header.Set(\"Content-Type\", ctype)\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.channels.stop\" call.\nfunc (c *ChannelsStopCall) Do(opts ...googleapi.CallOption) error {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n\t// {\n\t//   \"description\": \"Stop watching resources through this channel\",\n\t//   \"httpMethod\": \"POST\",\n\t//   \"id\": \"drive.channels.stop\",\n\t//   \"path\": \"channels/stop\",\n\t//   \"request\": {\n\t//     \"$ref\": \"Channel\",\n\t//     \"parameterName\": \"resource\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.appdata\",\n\t//     \"https://www.googleapis.com/auth/drive.file\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.photos.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.readonly\"\n\t//   ]\n\t// }\n\n}\n\n// method id \"drive.comments.create\":\n\ntype CommentsCreateCall struct {\n\ts          *Service\n\tfileId     string\n\tcomment    *Comment\n\turlParams_ gensupport.URLParams\n\tctx_       context.Context\n}\n\n// Create: Creates a new comment on a file.\nfunc (r *CommentsService) Create(fileId string, comment *Comment) *CommentsCreateCall {\n\tc := &CommentsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\tc.comment = comment\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *CommentsCreateCall) Fields(s ...googleapi.Field) *CommentsCreateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *CommentsCreateCall) Context(ctx context.Context) *CommentsCreateCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *CommentsCreateCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tbody, err := googleapi.WithoutDataWrapper.JSONReader(c.comment)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tctype := \"application/json\"\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}/comments\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"POST\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\": c.fileId,\n\t})\n\treq.Header.Set(\"Content-Type\", ctype)\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.comments.create\" call.\n// Exactly one of *Comment or error will be non-nil. Any non-2xx status\n// code is an error. Response headers are in either\n// *Comment.ServerResponse.Header or (if a response was returned at all)\n// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to\n// check whether the returned error was because http.StatusNotModified\n// was returned.\nfunc (c *CommentsCreateCall) Do(opts ...googleapi.CallOption) (*Comment, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &Comment{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Creates a new comment on a file.\",\n\t//   \"httpMethod\": \"POST\",\n\t//   \"id\": \"drive.comments.create\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}/comments\",\n\t//   \"request\": {\n\t//     \"$ref\": \"Comment\"\n\t//   },\n\t//   \"response\": {\n\t//     \"$ref\": \"Comment\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.file\"\n\t//   ]\n\t// }\n\n}\n\n// method id \"drive.comments.delete\":\n\ntype CommentsDeleteCall struct {\n\ts          *Service\n\tfileId     string\n\tcommentId  string\n\turlParams_ gensupport.URLParams\n\tctx_       context.Context\n}\n\n// Delete: Deletes a comment.\nfunc (r *CommentsService) Delete(fileId string, commentId string) *CommentsDeleteCall {\n\tc := &CommentsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\tc.commentId = commentId\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *CommentsDeleteCall) Fields(s ...googleapi.Field) *CommentsDeleteCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *CommentsDeleteCall) Context(ctx context.Context) *CommentsDeleteCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *CommentsDeleteCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}/comments/{commentId}\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"DELETE\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\":    c.fileId,\n\t\t\"commentId\": c.commentId,\n\t})\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.comments.delete\" call.\nfunc (c *CommentsDeleteCall) Do(opts ...googleapi.CallOption) error {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n\t// {\n\t//   \"description\": \"Deletes a comment.\",\n\t//   \"httpMethod\": \"DELETE\",\n\t//   \"id\": \"drive.comments.delete\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\",\n\t//     \"commentId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"commentId\": {\n\t//       \"description\": \"The ID of the comment.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}/comments/{commentId}\",\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.file\"\n\t//   ]\n\t// }\n\n}\n\n// method id \"drive.comments.get\":\n\ntype CommentsGetCall struct {\n\ts            *Service\n\tfileId       string\n\tcommentId    string\n\turlParams_   gensupport.URLParams\n\tifNoneMatch_ string\n\tctx_         context.Context\n}\n\n// Get: Gets a comment by ID.\nfunc (r *CommentsService) Get(fileId string, commentId string) *CommentsGetCall {\n\tc := &CommentsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\tc.commentId = commentId\n\treturn c\n}\n\n// IncludeDeleted sets the optional parameter \"includeDeleted\": Whether\n// to return deleted comments. Deleted comments will not include their\n// original content.\nfunc (c *CommentsGetCall) IncludeDeleted(includeDeleted bool) *CommentsGetCall {\n\tc.urlParams_.Set(\"includeDeleted\", fmt.Sprint(includeDeleted))\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *CommentsGetCall) Fields(s ...googleapi.Field) *CommentsGetCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// IfNoneMatch sets the optional parameter which makes the operation\n// fail if the object's ETag matches the given value. This is useful for\n// getting updates only after the object has changed since the last\n// request. Use googleapi.IsNotModified to check whether the response\n// error from Do is the result of In-None-Match.\nfunc (c *CommentsGetCall) IfNoneMatch(entityTag string) *CommentsGetCall {\n\tc.ifNoneMatch_ = entityTag\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *CommentsGetCall) Context(ctx context.Context) *CommentsGetCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *CommentsGetCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}/comments/{commentId}\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"GET\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\":    c.fileId,\n\t\t\"commentId\": c.commentId,\n\t})\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ifNoneMatch_ != \"\" {\n\t\treq.Header.Set(\"If-None-Match\", c.ifNoneMatch_)\n\t}\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.comments.get\" call.\n// Exactly one of *Comment or error will be non-nil. Any non-2xx status\n// code is an error. Response headers are in either\n// *Comment.ServerResponse.Header or (if a response was returned at all)\n// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to\n// check whether the returned error was because http.StatusNotModified\n// was returned.\nfunc (c *CommentsGetCall) Do(opts ...googleapi.CallOption) (*Comment, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &Comment{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Gets a comment by ID.\",\n\t//   \"httpMethod\": \"GET\",\n\t//   \"id\": \"drive.comments.get\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\",\n\t//     \"commentId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"commentId\": {\n\t//       \"description\": \"The ID of the comment.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"includeDeleted\": {\n\t//       \"default\": \"false\",\n\t//       \"description\": \"Whether to return deleted comments. Deleted comments will not include their original content.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"boolean\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}/comments/{commentId}\",\n\t//   \"response\": {\n\t//     \"$ref\": \"Comment\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.file\",\n\t//     \"https://www.googleapis.com/auth/drive.readonly\"\n\t//   ]\n\t// }\n\n}\n\n// method id \"drive.comments.list\":\n\ntype CommentsListCall struct {\n\ts            *Service\n\tfileId       string\n\turlParams_   gensupport.URLParams\n\tifNoneMatch_ string\n\tctx_         context.Context\n}\n\n// List: Lists a file's comments.\nfunc (r *CommentsService) List(fileId string) *CommentsListCall {\n\tc := &CommentsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\treturn c\n}\n\n// IncludeDeleted sets the optional parameter \"includeDeleted\": Whether\n// to include deleted comments. Deleted comments will not include their\n// original content.\nfunc (c *CommentsListCall) IncludeDeleted(includeDeleted bool) *CommentsListCall {\n\tc.urlParams_.Set(\"includeDeleted\", fmt.Sprint(includeDeleted))\n\treturn c\n}\n\n// PageSize sets the optional parameter \"pageSize\": The maximum number\n// of comments to return per page.\nfunc (c *CommentsListCall) PageSize(pageSize int64) *CommentsListCall {\n\tc.urlParams_.Set(\"pageSize\", fmt.Sprint(pageSize))\n\treturn c\n}\n\n// PageToken sets the optional parameter \"pageToken\": The token for\n// continuing a previous list request on the next page. This should be\n// set to the value of 'nextPageToken' from the previous response.\nfunc (c *CommentsListCall) PageToken(pageToken string) *CommentsListCall {\n\tc.urlParams_.Set(\"pageToken\", pageToken)\n\treturn c\n}\n\n// StartModifiedTime sets the optional parameter \"startModifiedTime\":\n// The minimum value of 'modifiedTime' for the result comments (RFC 3339\n// date-time).\nfunc (c *CommentsListCall) StartModifiedTime(startModifiedTime string) *CommentsListCall {\n\tc.urlParams_.Set(\"startModifiedTime\", startModifiedTime)\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *CommentsListCall) Fields(s ...googleapi.Field) *CommentsListCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// IfNoneMatch sets the optional parameter which makes the operation\n// fail if the object's ETag matches the given value. This is useful for\n// getting updates only after the object has changed since the last\n// request. Use googleapi.IsNotModified to check whether the response\n// error from Do is the result of In-None-Match.\nfunc (c *CommentsListCall) IfNoneMatch(entityTag string) *CommentsListCall {\n\tc.ifNoneMatch_ = entityTag\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *CommentsListCall) Context(ctx context.Context) *CommentsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *CommentsListCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}/comments\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"GET\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\": c.fileId,\n\t})\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ifNoneMatch_ != \"\" {\n\t\treq.Header.Set(\"If-None-Match\", c.ifNoneMatch_)\n\t}\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.comments.list\" call.\n// Exactly one of *CommentList or error will be non-nil. Any non-2xx\n// status code is an error. Response headers are in either\n// *CommentList.ServerResponse.Header or (if a response was returned at\n// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified\n// to check whether the returned error was because\n// http.StatusNotModified was returned.\nfunc (c *CommentsListCall) Do(opts ...googleapi.CallOption) (*CommentList, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &CommentList{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Lists a file's comments.\",\n\t//   \"httpMethod\": \"GET\",\n\t//   \"id\": \"drive.comments.list\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"includeDeleted\": {\n\t//       \"default\": \"false\",\n\t//       \"description\": \"Whether to include deleted comments. Deleted comments will not include their original content.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"boolean\"\n\t//     },\n\t//     \"pageSize\": {\n\t//       \"default\": \"20\",\n\t//       \"description\": \"The maximum number of comments to return per page.\",\n\t//       \"format\": \"int32\",\n\t//       \"location\": \"query\",\n\t//       \"maximum\": \"100\",\n\t//       \"minimum\": \"1\",\n\t//       \"type\": \"integer\"\n\t//     },\n\t//     \"pageToken\": {\n\t//       \"description\": \"The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"startModifiedTime\": {\n\t//       \"description\": \"The minimum value of 'modifiedTime' for the result comments (RFC 3339 date-time).\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}/comments\",\n\t//   \"response\": {\n\t//     \"$ref\": \"CommentList\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.file\",\n\t//     \"https://www.googleapis.com/auth/drive.readonly\"\n\t//   ]\n\t// }\n\n}\n\n// Pages invokes f for each page of results.\n// A non-nil error returned from f will halt the iteration.\n// The provided context supersedes any context provided to the Context method.\nfunc (c *CommentsListCall) Pages(ctx context.Context, f func(*CommentList) error) error {\n\tc.ctx_ = ctx\n\tdefer c.PageToken(c.urlParams_.Get(\"pageToken\")) // reset paging to original point\n\tfor {\n\t\tx, err := c.Do()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := f(x); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif x.NextPageToken == \"\" {\n\t\t\treturn nil\n\t\t}\n\t\tc.PageToken(x.NextPageToken)\n\t}\n}\n\n// method id \"drive.comments.update\":\n\ntype CommentsUpdateCall struct {\n\ts          *Service\n\tfileId     string\n\tcommentId  string\n\tcomment    *Comment\n\turlParams_ gensupport.URLParams\n\tctx_       context.Context\n}\n\n// Update: Updates a comment with patch semantics.\nfunc (r *CommentsService) Update(fileId string, commentId string, comment *Comment) *CommentsUpdateCall {\n\tc := &CommentsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\tc.commentId = commentId\n\tc.comment = comment\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *CommentsUpdateCall) Fields(s ...googleapi.Field) *CommentsUpdateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *CommentsUpdateCall) Context(ctx context.Context) *CommentsUpdateCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *CommentsUpdateCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tbody, err := googleapi.WithoutDataWrapper.JSONReader(c.comment)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tctype := \"application/json\"\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}/comments/{commentId}\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"PATCH\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\":    c.fileId,\n\t\t\"commentId\": c.commentId,\n\t})\n\treq.Header.Set(\"Content-Type\", ctype)\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.comments.update\" call.\n// Exactly one of *Comment or error will be non-nil. Any non-2xx status\n// code is an error. Response headers are in either\n// *Comment.ServerResponse.Header or (if a response was returned at all)\n// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to\n// check whether the returned error was because http.StatusNotModified\n// was returned.\nfunc (c *CommentsUpdateCall) Do(opts ...googleapi.CallOption) (*Comment, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &Comment{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Updates a comment with patch semantics.\",\n\t//   \"httpMethod\": \"PATCH\",\n\t//   \"id\": \"drive.comments.update\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\",\n\t//     \"commentId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"commentId\": {\n\t//       \"description\": \"The ID of the comment.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}/comments/{commentId}\",\n\t//   \"request\": {\n\t//     \"$ref\": \"Comment\"\n\t//   },\n\t//   \"response\": {\n\t//     \"$ref\": \"Comment\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.file\"\n\t//   ]\n\t// }\n\n}\n\n// method id \"drive.files.copy\":\n\ntype FilesCopyCall struct {\n\ts          *Service\n\tfileId     string\n\tfile       *File\n\turlParams_ gensupport.URLParams\n\tctx_       context.Context\n}\n\n// Copy: Creates a copy of a file and applies any requested updates with\n// patch semantics.\nfunc (r *FilesService) Copy(fileId string, file *File) *FilesCopyCall {\n\tc := &FilesCopyCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\tc.file = file\n\treturn c\n}\n\n// IgnoreDefaultVisibility sets the optional parameter\n// \"ignoreDefaultVisibility\": Whether to ignore the domain's default\n// visibility settings for the created file. Domain administrators can\n// choose to make all uploaded files visible to the domain by default;\n// this parameter bypasses that behavior for the request. Permissions\n// are still inherited from parent folders.\nfunc (c *FilesCopyCall) IgnoreDefaultVisibility(ignoreDefaultVisibility bool) *FilesCopyCall {\n\tc.urlParams_.Set(\"ignoreDefaultVisibility\", fmt.Sprint(ignoreDefaultVisibility))\n\treturn c\n}\n\n// KeepRevisionForever sets the optional parameter\n// \"keepRevisionForever\": Whether to set the 'keepForever' field in the\n// new head revision. This is only applicable to files with binary\n// content in Drive.\nfunc (c *FilesCopyCall) KeepRevisionForever(keepRevisionForever bool) *FilesCopyCall {\n\tc.urlParams_.Set(\"keepRevisionForever\", fmt.Sprint(keepRevisionForever))\n\treturn c\n}\n\n// OcrLanguage sets the optional parameter \"ocrLanguage\": A language\n// hint for OCR processing during image import (ISO 639-1 code).\nfunc (c *FilesCopyCall) OcrLanguage(ocrLanguage string) *FilesCopyCall {\n\tc.urlParams_.Set(\"ocrLanguage\", ocrLanguage)\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *FilesCopyCall) Fields(s ...googleapi.Field) *FilesCopyCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *FilesCopyCall) Context(ctx context.Context) *FilesCopyCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *FilesCopyCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tbody, err := googleapi.WithoutDataWrapper.JSONReader(c.file)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tctype := \"application/json\"\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}/copy\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"POST\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\": c.fileId,\n\t})\n\treq.Header.Set(\"Content-Type\", ctype)\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.files.copy\" call.\n// Exactly one of *File or error will be non-nil. Any non-2xx status\n// code is an error. Response headers are in either\n// *File.ServerResponse.Header or (if a response was returned at all) in\n// error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check\n// whether the returned error was because http.StatusNotModified was\n// returned.\nfunc (c *FilesCopyCall) Do(opts ...googleapi.CallOption) (*File, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &File{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Creates a copy of a file and applies any requested updates with patch semantics.\",\n\t//   \"httpMethod\": \"POST\",\n\t//   \"id\": \"drive.files.copy\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"ignoreDefaultVisibility\": {\n\t//       \"default\": \"false\",\n\t//       \"description\": \"Whether to ignore the domain's default visibility settings for the created file. Domain administrators can choose to make all uploaded files visible to the domain by default; this parameter bypasses that behavior for the request. Permissions are still inherited from parent folders.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"boolean\"\n\t//     },\n\t//     \"keepRevisionForever\": {\n\t//       \"default\": \"false\",\n\t//       \"description\": \"Whether to set the 'keepForever' field in the new head revision. This is only applicable to files with binary content in Drive.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"boolean\"\n\t//     },\n\t//     \"ocrLanguage\": {\n\t//       \"description\": \"A language hint for OCR processing during image import (ISO 639-1 code).\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}/copy\",\n\t//   \"request\": {\n\t//     \"$ref\": \"File\"\n\t//   },\n\t//   \"response\": {\n\t//     \"$ref\": \"File\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.appdata\",\n\t//     \"https://www.googleapis.com/auth/drive.file\",\n\t//     \"https://www.googleapis.com/auth/drive.photos.readonly\"\n\t//   ]\n\t// }\n\n}\n\n// method id \"drive.files.create\":\n\ntype FilesCreateCall struct {\n\ts                *Service\n\tfile             *File\n\turlParams_       gensupport.URLParams\n\tmedia_           io.Reader\n\tresumableBuffer_ *gensupport.ResumableBuffer\n\tmediaType_       string\n\tmediaSize_       int64 // mediaSize, if known.  Used only for calls to progressUpdater_.\n\tprogressUpdater_ googleapi.ProgressUpdater\n\tctx_             context.Context\n}\n\n// Create: Creates a new file.\nfunc (r *FilesService) Create(file *File) *FilesCreateCall {\n\tc := &FilesCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.file = file\n\treturn c\n}\n\n// IgnoreDefaultVisibility sets the optional parameter\n// \"ignoreDefaultVisibility\": Whether to ignore the domain's default\n// visibility settings for the created file. Domain administrators can\n// choose to make all uploaded files visible to the domain by default;\n// this parameter bypasses that behavior for the request. Permissions\n// are still inherited from parent folders.\nfunc (c *FilesCreateCall) IgnoreDefaultVisibility(ignoreDefaultVisibility bool) *FilesCreateCall {\n\tc.urlParams_.Set(\"ignoreDefaultVisibility\", fmt.Sprint(ignoreDefaultVisibility))\n\treturn c\n}\n\n// KeepRevisionForever sets the optional parameter\n// \"keepRevisionForever\": Whether to set the 'keepForever' field in the\n// new head revision. This is only applicable to files with binary\n// content in Drive.\nfunc (c *FilesCreateCall) KeepRevisionForever(keepRevisionForever bool) *FilesCreateCall {\n\tc.urlParams_.Set(\"keepRevisionForever\", fmt.Sprint(keepRevisionForever))\n\treturn c\n}\n\n// OcrLanguage sets the optional parameter \"ocrLanguage\": A language\n// hint for OCR processing during image import (ISO 639-1 code).\nfunc (c *FilesCreateCall) OcrLanguage(ocrLanguage string) *FilesCreateCall {\n\tc.urlParams_.Set(\"ocrLanguage\", ocrLanguage)\n\treturn c\n}\n\n// UseContentAsIndexableText sets the optional parameter\n// \"useContentAsIndexableText\": Whether to use the uploaded content as\n// indexable text.\nfunc (c *FilesCreateCall) UseContentAsIndexableText(useContentAsIndexableText bool) *FilesCreateCall {\n\tc.urlParams_.Set(\"useContentAsIndexableText\", fmt.Sprint(useContentAsIndexableText))\n\treturn c\n}\n\n// Media specifies the media to upload in one or more chunks. The chunk\n// size may be controlled by supplying a MediaOption generated by\n// googleapi.ChunkSize. The chunk size defaults to\n// googleapi.DefaultUploadChunkSize.The Content-Type header used in the\n// upload request will be determined by sniffing the contents of r,\n// unless a MediaOption generated by googleapi.ContentType is\n// supplied.\n// At most one of Media and ResumableMedia may be set.\nfunc (c *FilesCreateCall) Media(r io.Reader, options ...googleapi.MediaOption) *FilesCreateCall {\n\topts := googleapi.ProcessMediaOptions(options)\n\tchunkSize := opts.ChunkSize\n\tif !opts.ForceEmptyContentType {\n\t\tr, c.mediaType_ = gensupport.DetermineContentType(r, opts.ContentType)\n\t}\n\tc.media_, c.resumableBuffer_ = gensupport.PrepareUpload(r, chunkSize)\n\treturn c\n}\n\n// ResumableMedia specifies the media to upload in chunks and can be\n// canceled with ctx.\n//\n// Deprecated: use Media instead.\n//\n// At most one of Media and ResumableMedia may be set. mediaType\n// identifies the MIME media type of the upload, such as \"image/png\". If\n// mediaType is \"\", it will be auto-detected. The provided ctx will\n// supersede any context previously provided to the Context method.\nfunc (c *FilesCreateCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *FilesCreateCall {\n\tc.ctx_ = ctx\n\trdr := gensupport.ReaderAtToReader(r, size)\n\trdr, c.mediaType_ = gensupport.DetermineContentType(rdr, mediaType)\n\tc.resumableBuffer_ = gensupport.NewResumableBuffer(rdr, googleapi.DefaultUploadChunkSize)\n\tc.media_ = nil\n\tc.mediaSize_ = size\n\treturn c\n}\n\n// ProgressUpdater provides a callback function that will be called\n// after every chunk. It should be a low-latency function in order to\n// not slow down the upload operation. This should only be called when\n// using ResumableMedia (as opposed to Media).\nfunc (c *FilesCreateCall) ProgressUpdater(pu googleapi.ProgressUpdater) *FilesCreateCall {\n\tc.progressUpdater_ = pu\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *FilesCreateCall) Fields(s ...googleapi.Field) *FilesCreateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\n// This context will supersede any context previously provided to the\n// ResumableMedia method.\nfunc (c *FilesCreateCall) Context(ctx context.Context) *FilesCreateCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *FilesCreateCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tbody, err := googleapi.WithoutDataWrapper.JSONReader(c.file)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tctype := \"application/json\"\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files\")\n\tif c.media_ != nil || c.resumableBuffer_ != nil {\n\t\turls = strings.Replace(urls, \"https://www.googleapis.com/\", \"https://www.googleapis.com/upload/\", 1)\n\t\tprotocol := \"multipart\"\n\t\tif c.resumableBuffer_ != nil {\n\t\t\tprotocol = \"resumable\"\n\t\t}\n\t\tc.urlParams_.Set(\"uploadType\", protocol)\n\t}\n\turls += \"?\" + c.urlParams_.Encode()\n\tif c.media_ != nil {\n\t\tvar combined io.ReadCloser\n\t\tcombined, ctype = gensupport.CombineBodyMedia(body, ctype, c.media_, c.mediaType_)\n\t\tdefer combined.Close()\n\t\tbody = combined\n\t}\n\treq, _ := http.NewRequest(\"POST\", urls, body)\n\tgoogleapi.SetOpaque(req.URL)\n\tif c.resumableBuffer_ != nil && c.mediaType_ != \"\" {\n\t\treq.Header.Set(\"X-Upload-Content-Type\", c.mediaType_)\n\t}\n\treq.Header.Set(\"Content-Type\", ctype)\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.files.create\" call.\n// Exactly one of *File or error will be non-nil. Any non-2xx status\n// code is an error. Response headers are in either\n// *File.ServerResponse.Header or (if a response was returned at all) in\n// error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check\n// whether the returned error was because http.StatusNotModified was\n// returned.\nfunc (c *FilesCreateCall) Do(opts ...googleapi.CallOption) (*File, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tif c.resumableBuffer_ != nil {\n\t\tloc := res.Header.Get(\"Location\")\n\t\trx := &gensupport.ResumableUpload{\n\t\t\tClient:    c.s.client,\n\t\t\tUserAgent: c.s.userAgent(),\n\t\t\tURI:       loc,\n\t\t\tMedia:     c.resumableBuffer_,\n\t\t\tMediaType: c.mediaType_,\n\t\t\tCallback: func(curr int64) {\n\t\t\t\tif c.progressUpdater_ != nil {\n\t\t\t\t\tc.progressUpdater_(curr, c.mediaSize_)\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\t\tctx := c.ctx_\n\t\tif ctx == nil {\n\t\t\tctx = context.TODO()\n\t\t}\n\t\tres, err = rx.Upload(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tdefer res.Body.Close()\n\t\tif err := googleapi.CheckResponse(res); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tret := &File{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Creates a new file.\",\n\t//   \"httpMethod\": \"POST\",\n\t//   \"id\": \"drive.files.create\",\n\t//   \"mediaUpload\": {\n\t//     \"accept\": [\n\t//       \"*/*\"\n\t//     ],\n\t//     \"maxSize\": \"5120GB\",\n\t//     \"protocols\": {\n\t//       \"resumable\": {\n\t//         \"multipart\": true,\n\t//         \"path\": \"/resumable/upload/drive/v3/files\"\n\t//       },\n\t//       \"simple\": {\n\t//         \"multipart\": true,\n\t//         \"path\": \"/upload/drive/v3/files\"\n\t//       }\n\t//     }\n\t//   },\n\t//   \"parameters\": {\n\t//     \"ignoreDefaultVisibility\": {\n\t//       \"default\": \"false\",\n\t//       \"description\": \"Whether to ignore the domain's default visibility settings for the created file. Domain administrators can choose to make all uploaded files visible to the domain by default; this parameter bypasses that behavior for the request. Permissions are still inherited from parent folders.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"boolean\"\n\t//     },\n\t//     \"keepRevisionForever\": {\n\t//       \"default\": \"false\",\n\t//       \"description\": \"Whether to set the 'keepForever' field in the new head revision. This is only applicable to files with binary content in Drive.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"boolean\"\n\t//     },\n\t//     \"ocrLanguage\": {\n\t//       \"description\": \"A language hint for OCR processing during image import (ISO 639-1 code).\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"useContentAsIndexableText\": {\n\t//       \"default\": \"false\",\n\t//       \"description\": \"Whether to use the uploaded content as indexable text.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"boolean\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files\",\n\t//   \"request\": {\n\t//     \"$ref\": \"File\"\n\t//   },\n\t//   \"response\": {\n\t//     \"$ref\": \"File\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.appdata\",\n\t//     \"https://www.googleapis.com/auth/drive.file\"\n\t//   ],\n\t//   \"supportsMediaUpload\": true,\n\t//   \"supportsSubscription\": true\n\t// }\n\n}\n\n// method id \"drive.files.delete\":\n\ntype FilesDeleteCall struct {\n\ts          *Service\n\tfileId     string\n\turlParams_ gensupport.URLParams\n\tctx_       context.Context\n}\n\n// Delete: Permanently deletes a file owned by the user without moving\n// it to the trash. If the target is a folder, all descendants owned by\n// the user are also deleted.\nfunc (r *FilesService) Delete(fileId string) *FilesDeleteCall {\n\tc := &FilesDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *FilesDeleteCall) Fields(s ...googleapi.Field) *FilesDeleteCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *FilesDeleteCall) Context(ctx context.Context) *FilesDeleteCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *FilesDeleteCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"DELETE\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\": c.fileId,\n\t})\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.files.delete\" call.\nfunc (c *FilesDeleteCall) Do(opts ...googleapi.CallOption) error {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n\t// {\n\t//   \"description\": \"Permanently deletes a file owned by the user without moving it to the trash. If the target is a folder, all descendants owned by the user are also deleted.\",\n\t//   \"httpMethod\": \"DELETE\",\n\t//   \"id\": \"drive.files.delete\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}\",\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.appdata\",\n\t//     \"https://www.googleapis.com/auth/drive.file\"\n\t//   ]\n\t// }\n\n}\n\n// method id \"drive.files.emptyTrash\":\n\ntype FilesEmptyTrashCall struct {\n\ts          *Service\n\turlParams_ gensupport.URLParams\n\tctx_       context.Context\n}\n\n// EmptyTrash: Permanently deletes all of the user's trashed files.\nfunc (r *FilesService) EmptyTrash() *FilesEmptyTrashCall {\n\tc := &FilesEmptyTrashCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *FilesEmptyTrashCall) Fields(s ...googleapi.Field) *FilesEmptyTrashCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *FilesEmptyTrashCall) Context(ctx context.Context) *FilesEmptyTrashCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *FilesEmptyTrashCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/trash\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"DELETE\", urls, body)\n\tgoogleapi.SetOpaque(req.URL)\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.files.emptyTrash\" call.\nfunc (c *FilesEmptyTrashCall) Do(opts ...googleapi.CallOption) error {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n\t// {\n\t//   \"description\": \"Permanently deletes all of the user's trashed files.\",\n\t//   \"httpMethod\": \"DELETE\",\n\t//   \"id\": \"drive.files.emptyTrash\",\n\t//   \"path\": \"files/trash\",\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\"\n\t//   ]\n\t// }\n\n}\n\n// method id \"drive.files.export\":\n\ntype FilesExportCall struct {\n\ts            *Service\n\tfileId       string\n\turlParams_   gensupport.URLParams\n\tifNoneMatch_ string\n\tctx_         context.Context\n}\n\n// Export: Exports a Google Doc to the requested MIME type and returns\n// the exported content.\nfunc (r *FilesService) Export(fileId string, mimeType string) *FilesExportCall {\n\tc := &FilesExportCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\tc.urlParams_.Set(\"mimeType\", mimeType)\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *FilesExportCall) Fields(s ...googleapi.Field) *FilesExportCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// IfNoneMatch sets the optional parameter which makes the operation\n// fail if the object's ETag matches the given value. This is useful for\n// getting updates only after the object has changed since the last\n// request. Use googleapi.IsNotModified to check whether the response\n// error from Do is the result of In-None-Match.\nfunc (c *FilesExportCall) IfNoneMatch(entityTag string) *FilesExportCall {\n\tc.ifNoneMatch_ = entityTag\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do and Download\n// methods. Any pending HTTP request will be aborted if the provided\n// context is canceled.\nfunc (c *FilesExportCall) Context(ctx context.Context) *FilesExportCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *FilesExportCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}/export\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"GET\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\": c.fileId,\n\t})\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ifNoneMatch_ != \"\" {\n\t\treq.Header.Set(\"If-None-Match\", c.ifNoneMatch_)\n\t}\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Download fetches the API endpoint's \"media\" value, instead of the normal\n// API response value. If the returned error is nil, the Response is guaranteed to\n// have a 2xx status code. Callers must close the Response.Body as usual.\nfunc (c *FilesExportCall) Download(opts ...googleapi.CallOption) (*http.Response, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"media\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif err := googleapi.CheckMediaResponse(res); err != nil {\n\t\tres.Body.Close()\n\t\treturn nil, err\n\t}\n\treturn res, nil\n}\n\n// Do executes the \"drive.files.export\" call.\nfunc (c *FilesExportCall) Do(opts ...googleapi.CallOption) error {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n\t// {\n\t//   \"description\": \"Exports a Google Doc to the requested MIME type and returns the exported content.\",\n\t//   \"httpMethod\": \"GET\",\n\t//   \"id\": \"drive.files.export\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\",\n\t//     \"mimeType\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"mimeType\": {\n\t//       \"description\": \"The MIME type of the format requested for this export.\",\n\t//       \"location\": \"query\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}/export\",\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.file\",\n\t//     \"https://www.googleapis.com/auth/drive.readonly\"\n\t//   ],\n\t//   \"supportsMediaDownload\": true\n\t// }\n\n}\n\n// method id \"drive.files.generateIds\":\n\ntype FilesGenerateIdsCall struct {\n\ts            *Service\n\turlParams_   gensupport.URLParams\n\tifNoneMatch_ string\n\tctx_         context.Context\n}\n\n// GenerateIds: Generates a set of file IDs which can be provided in\n// create requests.\nfunc (r *FilesService) GenerateIds() *FilesGenerateIdsCall {\n\tc := &FilesGenerateIdsCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\treturn c\n}\n\n// Count sets the optional parameter \"count\": The number of IDs to\n// return.\nfunc (c *FilesGenerateIdsCall) Count(count int64) *FilesGenerateIdsCall {\n\tc.urlParams_.Set(\"count\", fmt.Sprint(count))\n\treturn c\n}\n\n// Space sets the optional parameter \"space\": The space in which the IDs\n// can be used to create new files. Supported values are 'drive' and\n// 'appDataFolder'.\nfunc (c *FilesGenerateIdsCall) Space(space string) *FilesGenerateIdsCall {\n\tc.urlParams_.Set(\"space\", space)\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *FilesGenerateIdsCall) Fields(s ...googleapi.Field) *FilesGenerateIdsCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// IfNoneMatch sets the optional parameter which makes the operation\n// fail if the object's ETag matches the given value. This is useful for\n// getting updates only after the object has changed since the last\n// request. Use googleapi.IsNotModified to check whether the response\n// error from Do is the result of In-None-Match.\nfunc (c *FilesGenerateIdsCall) IfNoneMatch(entityTag string) *FilesGenerateIdsCall {\n\tc.ifNoneMatch_ = entityTag\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *FilesGenerateIdsCall) Context(ctx context.Context) *FilesGenerateIdsCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *FilesGenerateIdsCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/generateIds\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"GET\", urls, body)\n\tgoogleapi.SetOpaque(req.URL)\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ifNoneMatch_ != \"\" {\n\t\treq.Header.Set(\"If-None-Match\", c.ifNoneMatch_)\n\t}\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.files.generateIds\" call.\n// Exactly one of *GeneratedIds or error will be non-nil. Any non-2xx\n// status code is an error. Response headers are in either\n// *GeneratedIds.ServerResponse.Header or (if a response was returned at\n// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified\n// to check whether the returned error was because\n// http.StatusNotModified was returned.\nfunc (c *FilesGenerateIdsCall) Do(opts ...googleapi.CallOption) (*GeneratedIds, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &GeneratedIds{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Generates a set of file IDs which can be provided in create requests.\",\n\t//   \"httpMethod\": \"GET\",\n\t//   \"id\": \"drive.files.generateIds\",\n\t//   \"parameters\": {\n\t//     \"count\": {\n\t//       \"default\": \"10\",\n\t//       \"description\": \"The number of IDs to return.\",\n\t//       \"format\": \"int32\",\n\t//       \"location\": \"query\",\n\t//       \"maximum\": \"1000\",\n\t//       \"minimum\": \"1\",\n\t//       \"type\": \"integer\"\n\t//     },\n\t//     \"space\": {\n\t//       \"default\": \"drive\",\n\t//       \"description\": \"The space in which the IDs can be used to create new files. Supported values are 'drive' and 'appDataFolder'.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/generateIds\",\n\t//   \"response\": {\n\t//     \"$ref\": \"GeneratedIds\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.appdata\",\n\t//     \"https://www.googleapis.com/auth/drive.file\"\n\t//   ]\n\t// }\n\n}\n\n// method id \"drive.files.get\":\n\ntype FilesGetCall struct {\n\ts            *Service\n\tfileId       string\n\turlParams_   gensupport.URLParams\n\tifNoneMatch_ string\n\tctx_         context.Context\n}\n\n// Get: Gets a file's metadata or content by ID.\nfunc (r *FilesService) Get(fileId string) *FilesGetCall {\n\tc := &FilesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\treturn c\n}\n\n// AcknowledgeAbuse sets the optional parameter \"acknowledgeAbuse\":\n// Whether the user is acknowledging the risk of downloading known\n// malware or other abusive files. This is only applicable when\n// alt=media.\nfunc (c *FilesGetCall) AcknowledgeAbuse(acknowledgeAbuse bool) *FilesGetCall {\n\tc.urlParams_.Set(\"acknowledgeAbuse\", fmt.Sprint(acknowledgeAbuse))\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *FilesGetCall) Fields(s ...googleapi.Field) *FilesGetCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// IfNoneMatch sets the optional parameter which makes the operation\n// fail if the object's ETag matches the given value. This is useful for\n// getting updates only after the object has changed since the last\n// request. Use googleapi.IsNotModified to check whether the response\n// error from Do is the result of In-None-Match.\nfunc (c *FilesGetCall) IfNoneMatch(entityTag string) *FilesGetCall {\n\tc.ifNoneMatch_ = entityTag\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do and Download\n// methods. Any pending HTTP request will be aborted if the provided\n// context is canceled.\nfunc (c *FilesGetCall) Context(ctx context.Context) *FilesGetCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *FilesGetCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"GET\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\": c.fileId,\n\t})\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ifNoneMatch_ != \"\" {\n\t\treq.Header.Set(\"If-None-Match\", c.ifNoneMatch_)\n\t}\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Download fetches the API endpoint's \"media\" value, instead of the normal\n// API response value. If the returned error is nil, the Response is guaranteed to\n// have a 2xx status code. Callers must close the Response.Body as usual.\nfunc (c *FilesGetCall) Download(opts ...googleapi.CallOption) (*http.Response, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"media\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif err := googleapi.CheckMediaResponse(res); err != nil {\n\t\tres.Body.Close()\n\t\treturn nil, err\n\t}\n\treturn res, nil\n}\n\n// Do executes the \"drive.files.get\" call.\n// Exactly one of *File or error will be non-nil. Any non-2xx status\n// code is an error. Response headers are in either\n// *File.ServerResponse.Header or (if a response was returned at all) in\n// error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check\n// whether the returned error was because http.StatusNotModified was\n// returned.\nfunc (c *FilesGetCall) Do(opts ...googleapi.CallOption) (*File, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &File{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Gets a file's metadata or content by ID.\",\n\t//   \"httpMethod\": \"GET\",\n\t//   \"id\": \"drive.files.get\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"acknowledgeAbuse\": {\n\t//       \"default\": \"false\",\n\t//       \"description\": \"Whether the user is acknowledging the risk of downloading known malware or other abusive files. This is only applicable when alt=media.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"boolean\"\n\t//     },\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}\",\n\t//   \"response\": {\n\t//     \"$ref\": \"File\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.appdata\",\n\t//     \"https://www.googleapis.com/auth/drive.file\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.photos.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.readonly\"\n\t//   ],\n\t//   \"supportsMediaDownload\": true,\n\t//   \"supportsSubscription\": true,\n\t//   \"useMediaDownloadService\": true\n\t// }\n\n}\n\n// method id \"drive.files.list\":\n\ntype FilesListCall struct {\n\ts            *Service\n\turlParams_   gensupport.URLParams\n\tifNoneMatch_ string\n\tctx_         context.Context\n}\n\n// List: Lists or searches files.\nfunc (r *FilesService) List() *FilesListCall {\n\tc := &FilesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\treturn c\n}\n\n// Corpus sets the optional parameter \"corpus\": The source of files to\n// list.\n//\n// Possible values:\n//   \"domain\" - Files shared to the user's domain.\n//   \"user\" (default) - Files owned by or shared to the user.\nfunc (c *FilesListCall) Corpus(corpus string) *FilesListCall {\n\tc.urlParams_.Set(\"corpus\", corpus)\n\treturn c\n}\n\n// OrderBy sets the optional parameter \"orderBy\": A comma-separated list\n// of sort keys. Valid keys are 'createdTime', 'folder',\n// 'modifiedByMeTime', 'modifiedTime', 'name', 'quotaBytesUsed',\n// 'recency', 'sharedWithMeTime', 'starred', and 'viewedByMeTime'. Each\n// key sorts ascending by default, but may be reversed with the 'desc'\n// modifier. Example usage: ?orderBy=folder,modifiedTime desc,name.\n// Please note that there is a current limitation for users with\n// approximately one million files in which the requested sort order is\n// ignored.\nfunc (c *FilesListCall) OrderBy(orderBy string) *FilesListCall {\n\tc.urlParams_.Set(\"orderBy\", orderBy)\n\treturn c\n}\n\n// PageSize sets the optional parameter \"pageSize\": The maximum number\n// of files to return per page.\nfunc (c *FilesListCall) PageSize(pageSize int64) *FilesListCall {\n\tc.urlParams_.Set(\"pageSize\", fmt.Sprint(pageSize))\n\treturn c\n}\n\n// PageToken sets the optional parameter \"pageToken\": The token for\n// continuing a previous list request on the next page. This should be\n// set to the value of 'nextPageToken' from the previous response.\nfunc (c *FilesListCall) PageToken(pageToken string) *FilesListCall {\n\tc.urlParams_.Set(\"pageToken\", pageToken)\n\treturn c\n}\n\n// Q sets the optional parameter \"q\": A query for filtering the file\n// results. See the \"Search for Files\" guide for supported syntax.\nfunc (c *FilesListCall) Q(q string) *FilesListCall {\n\tc.urlParams_.Set(\"q\", q)\n\treturn c\n}\n\n// Spaces sets the optional parameter \"spaces\": A comma-separated list\n// of spaces to query within the corpus. Supported values are 'drive',\n// 'appDataFolder' and 'photos'.\nfunc (c *FilesListCall) Spaces(spaces string) *FilesListCall {\n\tc.urlParams_.Set(\"spaces\", spaces)\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *FilesListCall) Fields(s ...googleapi.Field) *FilesListCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// IfNoneMatch sets the optional parameter which makes the operation\n// fail if the object's ETag matches the given value. This is useful for\n// getting updates only after the object has changed since the last\n// request. Use googleapi.IsNotModified to check whether the response\n// error from Do is the result of In-None-Match.\nfunc (c *FilesListCall) IfNoneMatch(entityTag string) *FilesListCall {\n\tc.ifNoneMatch_ = entityTag\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *FilesListCall) Context(ctx context.Context) *FilesListCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *FilesListCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"GET\", urls, body)\n\tgoogleapi.SetOpaque(req.URL)\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ifNoneMatch_ != \"\" {\n\t\treq.Header.Set(\"If-None-Match\", c.ifNoneMatch_)\n\t}\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.files.list\" call.\n// Exactly one of *FileList or error will be non-nil. Any non-2xx status\n// code is an error. Response headers are in either\n// *FileList.ServerResponse.Header or (if a response was returned at\n// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified\n// to check whether the returned error was because\n// http.StatusNotModified was returned.\nfunc (c *FilesListCall) Do(opts ...googleapi.CallOption) (*FileList, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &FileList{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Lists or searches files.\",\n\t//   \"httpMethod\": \"GET\",\n\t//   \"id\": \"drive.files.list\",\n\t//   \"parameters\": {\n\t//     \"corpus\": {\n\t//       \"default\": \"user\",\n\t//       \"description\": \"The source of files to list.\",\n\t//       \"enum\": [\n\t//         \"domain\",\n\t//         \"user\"\n\t//       ],\n\t//       \"enumDescriptions\": [\n\t//         \"Files shared to the user's domain.\",\n\t//         \"Files owned by or shared to the user.\"\n\t//       ],\n\t//       \"location\": \"query\",\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"orderBy\": {\n\t//       \"description\": \"A comma-separated list of sort keys. Valid keys are 'createdTime', 'folder', 'modifiedByMeTime', 'modifiedTime', 'name', 'quotaBytesUsed', 'recency', 'sharedWithMeTime', 'starred', and 'viewedByMeTime'. Each key sorts ascending by default, but may be reversed with the 'desc' modifier. Example usage: ?orderBy=folder,modifiedTime desc,name. Please note that there is a current limitation for users with approximately one million files in which the requested sort order is ignored.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"pageSize\": {\n\t//       \"default\": \"100\",\n\t//       \"description\": \"The maximum number of files to return per page.\",\n\t//       \"format\": \"int32\",\n\t//       \"location\": \"query\",\n\t//       \"maximum\": \"1000\",\n\t//       \"minimum\": \"1\",\n\t//       \"type\": \"integer\"\n\t//     },\n\t//     \"pageToken\": {\n\t//       \"description\": \"The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"q\": {\n\t//       \"description\": \"A query for filtering the file results. See the \\\"Search for Files\\\" guide for supported syntax.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"spaces\": {\n\t//       \"default\": \"drive\",\n\t//       \"description\": \"A comma-separated list of spaces to query within the corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files\",\n\t//   \"response\": {\n\t//     \"$ref\": \"FileList\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.appdata\",\n\t//     \"https://www.googleapis.com/auth/drive.file\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.photos.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.readonly\"\n\t//   ]\n\t// }\n\n}\n\n// Pages invokes f for each page of results.\n// A non-nil error returned from f will halt the iteration.\n// The provided context supersedes any context provided to the Context method.\nfunc (c *FilesListCall) Pages(ctx context.Context, f func(*FileList) error) error {\n\tc.ctx_ = ctx\n\tdefer c.PageToken(c.urlParams_.Get(\"pageToken\")) // reset paging to original point\n\tfor {\n\t\tx, err := c.Do()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := f(x); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif x.NextPageToken == \"\" {\n\t\t\treturn nil\n\t\t}\n\t\tc.PageToken(x.NextPageToken)\n\t}\n}\n\n// method id \"drive.files.update\":\n\ntype FilesUpdateCall struct {\n\ts                *Service\n\tfileId           string\n\tfile             *File\n\turlParams_       gensupport.URLParams\n\tmedia_           io.Reader\n\tresumableBuffer_ *gensupport.ResumableBuffer\n\tmediaType_       string\n\tmediaSize_       int64 // mediaSize, if known.  Used only for calls to progressUpdater_.\n\tprogressUpdater_ googleapi.ProgressUpdater\n\tctx_             context.Context\n}\n\n// Update: Updates a file's metadata and/or content with patch\n// semantics.\nfunc (r *FilesService) Update(fileId string, file *File) *FilesUpdateCall {\n\tc := &FilesUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\tc.file = file\n\treturn c\n}\n\n// AddParents sets the optional parameter \"addParents\": A\n// comma-separated list of parent IDs to add.\nfunc (c *FilesUpdateCall) AddParents(addParents string) *FilesUpdateCall {\n\tc.urlParams_.Set(\"addParents\", addParents)\n\treturn c\n}\n\n// KeepRevisionForever sets the optional parameter\n// \"keepRevisionForever\": Whether to set the 'keepForever' field in the\n// new head revision. This is only applicable to files with binary\n// content in Drive.\nfunc (c *FilesUpdateCall) KeepRevisionForever(keepRevisionForever bool) *FilesUpdateCall {\n\tc.urlParams_.Set(\"keepRevisionForever\", fmt.Sprint(keepRevisionForever))\n\treturn c\n}\n\n// OcrLanguage sets the optional parameter \"ocrLanguage\": A language\n// hint for OCR processing during image import (ISO 639-1 code).\nfunc (c *FilesUpdateCall) OcrLanguage(ocrLanguage string) *FilesUpdateCall {\n\tc.urlParams_.Set(\"ocrLanguage\", ocrLanguage)\n\treturn c\n}\n\n// RemoveParents sets the optional parameter \"removeParents\": A\n// comma-separated list of parent IDs to remove.\nfunc (c *FilesUpdateCall) RemoveParents(removeParents string) *FilesUpdateCall {\n\tc.urlParams_.Set(\"removeParents\", removeParents)\n\treturn c\n}\n\n// UseContentAsIndexableText sets the optional parameter\n// \"useContentAsIndexableText\": Whether to use the uploaded content as\n// indexable text.\nfunc (c *FilesUpdateCall) UseContentAsIndexableText(useContentAsIndexableText bool) *FilesUpdateCall {\n\tc.urlParams_.Set(\"useContentAsIndexableText\", fmt.Sprint(useContentAsIndexableText))\n\treturn c\n}\n\n// Media specifies the media to upload in one or more chunks. The chunk\n// size may be controlled by supplying a MediaOption generated by\n// googleapi.ChunkSize. The chunk size defaults to\n// googleapi.DefaultUploadChunkSize.The Content-Type header used in the\n// upload request will be determined by sniffing the contents of r,\n// unless a MediaOption generated by googleapi.ContentType is\n// supplied.\n// At most one of Media and ResumableMedia may be set.\nfunc (c *FilesUpdateCall) Media(r io.Reader, options ...googleapi.MediaOption) *FilesUpdateCall {\n\topts := googleapi.ProcessMediaOptions(options)\n\tchunkSize := opts.ChunkSize\n\tif !opts.ForceEmptyContentType {\n\t\tr, c.mediaType_ = gensupport.DetermineContentType(r, opts.ContentType)\n\t}\n\tc.media_, c.resumableBuffer_ = gensupport.PrepareUpload(r, chunkSize)\n\treturn c\n}\n\n// ResumableMedia specifies the media to upload in chunks and can be\n// canceled with ctx.\n//\n// Deprecated: use Media instead.\n//\n// At most one of Media and ResumableMedia may be set. mediaType\n// identifies the MIME media type of the upload, such as \"image/png\". If\n// mediaType is \"\", it will be auto-detected. The provided ctx will\n// supersede any context previously provided to the Context method.\nfunc (c *FilesUpdateCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *FilesUpdateCall {\n\tc.ctx_ = ctx\n\trdr := gensupport.ReaderAtToReader(r, size)\n\trdr, c.mediaType_ = gensupport.DetermineContentType(rdr, mediaType)\n\tc.resumableBuffer_ = gensupport.NewResumableBuffer(rdr, googleapi.DefaultUploadChunkSize)\n\tc.media_ = nil\n\tc.mediaSize_ = size\n\treturn c\n}\n\n// ProgressUpdater provides a callback function that will be called\n// after every chunk. It should be a low-latency function in order to\n// not slow down the upload operation. This should only be called when\n// using ResumableMedia (as opposed to Media).\nfunc (c *FilesUpdateCall) ProgressUpdater(pu googleapi.ProgressUpdater) *FilesUpdateCall {\n\tc.progressUpdater_ = pu\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *FilesUpdateCall) Fields(s ...googleapi.Field) *FilesUpdateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\n// This context will supersede any context previously provided to the\n// ResumableMedia method.\nfunc (c *FilesUpdateCall) Context(ctx context.Context) *FilesUpdateCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *FilesUpdateCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tbody, err := googleapi.WithoutDataWrapper.JSONReader(c.file)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tctype := \"application/json\"\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}\")\n\tif c.media_ != nil || c.resumableBuffer_ != nil {\n\t\turls = strings.Replace(urls, \"https://www.googleapis.com/\", \"https://www.googleapis.com/upload/\", 1)\n\t\tprotocol := \"multipart\"\n\t\tif c.resumableBuffer_ != nil {\n\t\t\tprotocol = \"resumable\"\n\t\t}\n\t\tc.urlParams_.Set(\"uploadType\", protocol)\n\t}\n\turls += \"?\" + c.urlParams_.Encode()\n\tif c.media_ != nil {\n\t\tvar combined io.ReadCloser\n\t\tcombined, ctype = gensupport.CombineBodyMedia(body, ctype, c.media_, c.mediaType_)\n\t\tdefer combined.Close()\n\t\tbody = combined\n\t}\n\treq, _ := http.NewRequest(\"PATCH\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\": c.fileId,\n\t})\n\tif c.resumableBuffer_ != nil && c.mediaType_ != \"\" {\n\t\treq.Header.Set(\"X-Upload-Content-Type\", c.mediaType_)\n\t}\n\treq.Header.Set(\"Content-Type\", ctype)\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.files.update\" call.\n// Exactly one of *File or error will be non-nil. Any non-2xx status\n// code is an error. Response headers are in either\n// *File.ServerResponse.Header or (if a response was returned at all) in\n// error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check\n// whether the returned error was because http.StatusNotModified was\n// returned.\nfunc (c *FilesUpdateCall) Do(opts ...googleapi.CallOption) (*File, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tif c.resumableBuffer_ != nil {\n\t\tloc := res.Header.Get(\"Location\")\n\t\trx := &gensupport.ResumableUpload{\n\t\t\tClient:    c.s.client,\n\t\t\tUserAgent: c.s.userAgent(),\n\t\t\tURI:       loc,\n\t\t\tMedia:     c.resumableBuffer_,\n\t\t\tMediaType: c.mediaType_,\n\t\t\tCallback: func(curr int64) {\n\t\t\t\tif c.progressUpdater_ != nil {\n\t\t\t\t\tc.progressUpdater_(curr, c.mediaSize_)\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\t\tctx := c.ctx_\n\t\tif ctx == nil {\n\t\t\tctx = context.TODO()\n\t\t}\n\t\tres, err = rx.Upload(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tdefer res.Body.Close()\n\t\tif err := googleapi.CheckResponse(res); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tret := &File{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Updates a file's metadata and/or content with patch semantics.\",\n\t//   \"httpMethod\": \"PATCH\",\n\t//   \"id\": \"drive.files.update\",\n\t//   \"mediaUpload\": {\n\t//     \"accept\": [\n\t//       \"*/*\"\n\t//     ],\n\t//     \"maxSize\": \"5120GB\",\n\t//     \"protocols\": {\n\t//       \"resumable\": {\n\t//         \"multipart\": true,\n\t//         \"path\": \"/resumable/upload/drive/v3/files/{fileId}\"\n\t//       },\n\t//       \"simple\": {\n\t//         \"multipart\": true,\n\t//         \"path\": \"/upload/drive/v3/files/{fileId}\"\n\t//       }\n\t//     }\n\t//   },\n\t//   \"parameterOrder\": [\n\t//     \"fileId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"addParents\": {\n\t//       \"description\": \"A comma-separated list of parent IDs to add.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"keepRevisionForever\": {\n\t//       \"default\": \"false\",\n\t//       \"description\": \"Whether to set the 'keepForever' field in the new head revision. This is only applicable to files with binary content in Drive.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"boolean\"\n\t//     },\n\t//     \"ocrLanguage\": {\n\t//       \"description\": \"A language hint for OCR processing during image import (ISO 639-1 code).\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"removeParents\": {\n\t//       \"description\": \"A comma-separated list of parent IDs to remove.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"useContentAsIndexableText\": {\n\t//       \"default\": \"false\",\n\t//       \"description\": \"Whether to use the uploaded content as indexable text.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"boolean\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}\",\n\t//   \"request\": {\n\t//     \"$ref\": \"File\"\n\t//   },\n\t//   \"response\": {\n\t//     \"$ref\": \"File\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.appdata\",\n\t//     \"https://www.googleapis.com/auth/drive.file\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata\",\n\t//     \"https://www.googleapis.com/auth/drive.scripts\"\n\t//   ],\n\t//   \"supportsMediaUpload\": true\n\t// }\n\n}\n\n// method id \"drive.files.watch\":\n\ntype FilesWatchCall struct {\n\ts          *Service\n\tfileId     string\n\tchannel    *Channel\n\turlParams_ gensupport.URLParams\n\tctx_       context.Context\n}\n\n// Watch: Subscribes to changes to a file\nfunc (r *FilesService) Watch(fileId string, channel *Channel) *FilesWatchCall {\n\tc := &FilesWatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\tc.channel = channel\n\treturn c\n}\n\n// AcknowledgeAbuse sets the optional parameter \"acknowledgeAbuse\":\n// Whether the user is acknowledging the risk of downloading known\n// malware or other abusive files. This is only applicable when\n// alt=media.\nfunc (c *FilesWatchCall) AcknowledgeAbuse(acknowledgeAbuse bool) *FilesWatchCall {\n\tc.urlParams_.Set(\"acknowledgeAbuse\", fmt.Sprint(acknowledgeAbuse))\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *FilesWatchCall) Fields(s ...googleapi.Field) *FilesWatchCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do and Download\n// methods. Any pending HTTP request will be aborted if the provided\n// context is canceled.\nfunc (c *FilesWatchCall) Context(ctx context.Context) *FilesWatchCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *FilesWatchCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tbody, err := googleapi.WithoutDataWrapper.JSONReader(c.channel)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tctype := \"application/json\"\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}/watch\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"POST\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\": c.fileId,\n\t})\n\treq.Header.Set(\"Content-Type\", ctype)\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Download fetches the API endpoint's \"media\" value, instead of the normal\n// API response value. If the returned error is nil, the Response is guaranteed to\n// have a 2xx status code. Callers must close the Response.Body as usual.\nfunc (c *FilesWatchCall) Download(opts ...googleapi.CallOption) (*http.Response, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"media\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif err := googleapi.CheckMediaResponse(res); err != nil {\n\t\tres.Body.Close()\n\t\treturn nil, err\n\t}\n\treturn res, nil\n}\n\n// Do executes the \"drive.files.watch\" call.\n// Exactly one of *Channel or error will be non-nil. Any non-2xx status\n// code is an error. Response headers are in either\n// *Channel.ServerResponse.Header or (if a response was returned at all)\n// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to\n// check whether the returned error was because http.StatusNotModified\n// was returned.\nfunc (c *FilesWatchCall) Do(opts ...googleapi.CallOption) (*Channel, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &Channel{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Subscribes to changes to a file\",\n\t//   \"httpMethod\": \"POST\",\n\t//   \"id\": \"drive.files.watch\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"acknowledgeAbuse\": {\n\t//       \"default\": \"false\",\n\t//       \"description\": \"Whether the user is acknowledging the risk of downloading known malware or other abusive files. This is only applicable when alt=media.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"boolean\"\n\t//     },\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}/watch\",\n\t//   \"request\": {\n\t//     \"$ref\": \"Channel\",\n\t//     \"parameterName\": \"resource\"\n\t//   },\n\t//   \"response\": {\n\t//     \"$ref\": \"Channel\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.appdata\",\n\t//     \"https://www.googleapis.com/auth/drive.file\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.photos.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.readonly\"\n\t//   ],\n\t//   \"supportsMediaDownload\": true,\n\t//   \"supportsSubscription\": true,\n\t//   \"useMediaDownloadService\": true\n\t// }\n\n}\n\n// method id \"drive.permissions.create\":\n\ntype PermissionsCreateCall struct {\n\ts          *Service\n\tfileId     string\n\tpermission *Permission\n\turlParams_ gensupport.URLParams\n\tctx_       context.Context\n}\n\n// Create: Creates a permission for a file.\nfunc (r *PermissionsService) Create(fileId string, permission *Permission) *PermissionsCreateCall {\n\tc := &PermissionsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\tc.permission = permission\n\treturn c\n}\n\n// EmailMessage sets the optional parameter \"emailMessage\": A custom\n// message to include in the notification email.\nfunc (c *PermissionsCreateCall) EmailMessage(emailMessage string) *PermissionsCreateCall {\n\tc.urlParams_.Set(\"emailMessage\", emailMessage)\n\treturn c\n}\n\n// SendNotificationEmail sets the optional parameter\n// \"sendNotificationEmail\": Whether to send a notification email when\n// sharing to users or groups. This defaults to true for users and\n// groups, and is not allowed for other requests. It must not be\n// disabled for ownership transfers.\nfunc (c *PermissionsCreateCall) SendNotificationEmail(sendNotificationEmail bool) *PermissionsCreateCall {\n\tc.urlParams_.Set(\"sendNotificationEmail\", fmt.Sprint(sendNotificationEmail))\n\treturn c\n}\n\n// TransferOwnership sets the optional parameter \"transferOwnership\":\n// Whether to transfer ownership to the specified user and downgrade the\n// current owner to a writer. This parameter is required as an\n// acknowledgement of the side effect.\nfunc (c *PermissionsCreateCall) TransferOwnership(transferOwnership bool) *PermissionsCreateCall {\n\tc.urlParams_.Set(\"transferOwnership\", fmt.Sprint(transferOwnership))\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *PermissionsCreateCall) Fields(s ...googleapi.Field) *PermissionsCreateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *PermissionsCreateCall) Context(ctx context.Context) *PermissionsCreateCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *PermissionsCreateCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tbody, err := googleapi.WithoutDataWrapper.JSONReader(c.permission)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tctype := \"application/json\"\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}/permissions\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"POST\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\": c.fileId,\n\t})\n\treq.Header.Set(\"Content-Type\", ctype)\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.permissions.create\" call.\n// Exactly one of *Permission or error will be non-nil. Any non-2xx\n// status code is an error. Response headers are in either\n// *Permission.ServerResponse.Header or (if a response was returned at\n// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified\n// to check whether the returned error was because\n// http.StatusNotModified was returned.\nfunc (c *PermissionsCreateCall) Do(opts ...googleapi.CallOption) (*Permission, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &Permission{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Creates a permission for a file.\",\n\t//   \"httpMethod\": \"POST\",\n\t//   \"id\": \"drive.permissions.create\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"emailMessage\": {\n\t//       \"description\": \"A custom message to include in the notification email.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"sendNotificationEmail\": {\n\t//       \"description\": \"Whether to send a notification email when sharing to users or groups. This defaults to true for users and groups, and is not allowed for other requests. It must not be disabled for ownership transfers.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"boolean\"\n\t//     },\n\t//     \"transferOwnership\": {\n\t//       \"default\": \"false\",\n\t//       \"description\": \"Whether to transfer ownership to the specified user and downgrade the current owner to a writer. This parameter is required as an acknowledgement of the side effect.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"boolean\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}/permissions\",\n\t//   \"request\": {\n\t//     \"$ref\": \"Permission\"\n\t//   },\n\t//   \"response\": {\n\t//     \"$ref\": \"Permission\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.file\"\n\t//   ]\n\t// }\n\n}\n\n// method id \"drive.permissions.delete\":\n\ntype PermissionsDeleteCall struct {\n\ts            *Service\n\tfileId       string\n\tpermissionId string\n\turlParams_   gensupport.URLParams\n\tctx_         context.Context\n}\n\n// Delete: Deletes a permission.\nfunc (r *PermissionsService) Delete(fileId string, permissionId string) *PermissionsDeleteCall {\n\tc := &PermissionsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\tc.permissionId = permissionId\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *PermissionsDeleteCall) Fields(s ...googleapi.Field) *PermissionsDeleteCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *PermissionsDeleteCall) Context(ctx context.Context) *PermissionsDeleteCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *PermissionsDeleteCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}/permissions/{permissionId}\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"DELETE\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\":       c.fileId,\n\t\t\"permissionId\": c.permissionId,\n\t})\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.permissions.delete\" call.\nfunc (c *PermissionsDeleteCall) Do(opts ...googleapi.CallOption) error {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n\t// {\n\t//   \"description\": \"Deletes a permission.\",\n\t//   \"httpMethod\": \"DELETE\",\n\t//   \"id\": \"drive.permissions.delete\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\",\n\t//     \"permissionId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"permissionId\": {\n\t//       \"description\": \"The ID of the permission.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}/permissions/{permissionId}\",\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.file\"\n\t//   ]\n\t// }\n\n}\n\n// method id \"drive.permissions.get\":\n\ntype PermissionsGetCall struct {\n\ts            *Service\n\tfileId       string\n\tpermissionId string\n\turlParams_   gensupport.URLParams\n\tifNoneMatch_ string\n\tctx_         context.Context\n}\n\n// Get: Gets a permission by ID.\nfunc (r *PermissionsService) Get(fileId string, permissionId string) *PermissionsGetCall {\n\tc := &PermissionsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\tc.permissionId = permissionId\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *PermissionsGetCall) Fields(s ...googleapi.Field) *PermissionsGetCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// IfNoneMatch sets the optional parameter which makes the operation\n// fail if the object's ETag matches the given value. This is useful for\n// getting updates only after the object has changed since the last\n// request. Use googleapi.IsNotModified to check whether the response\n// error from Do is the result of In-None-Match.\nfunc (c *PermissionsGetCall) IfNoneMatch(entityTag string) *PermissionsGetCall {\n\tc.ifNoneMatch_ = entityTag\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *PermissionsGetCall) Context(ctx context.Context) *PermissionsGetCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *PermissionsGetCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}/permissions/{permissionId}\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"GET\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\":       c.fileId,\n\t\t\"permissionId\": c.permissionId,\n\t})\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ifNoneMatch_ != \"\" {\n\t\treq.Header.Set(\"If-None-Match\", c.ifNoneMatch_)\n\t}\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.permissions.get\" call.\n// Exactly one of *Permission or error will be non-nil. Any non-2xx\n// status code is an error. Response headers are in either\n// *Permission.ServerResponse.Header or (if a response was returned at\n// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified\n// to check whether the returned error was because\n// http.StatusNotModified was returned.\nfunc (c *PermissionsGetCall) Do(opts ...googleapi.CallOption) (*Permission, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &Permission{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Gets a permission by ID.\",\n\t//   \"httpMethod\": \"GET\",\n\t//   \"id\": \"drive.permissions.get\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\",\n\t//     \"permissionId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"permissionId\": {\n\t//       \"description\": \"The ID of the permission.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}/permissions/{permissionId}\",\n\t//   \"response\": {\n\t//     \"$ref\": \"Permission\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.file\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.photos.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.readonly\"\n\t//   ]\n\t// }\n\n}\n\n// method id \"drive.permissions.list\":\n\ntype PermissionsListCall struct {\n\ts            *Service\n\tfileId       string\n\turlParams_   gensupport.URLParams\n\tifNoneMatch_ string\n\tctx_         context.Context\n}\n\n// List: Lists a file's permissions.\nfunc (r *PermissionsService) List(fileId string) *PermissionsListCall {\n\tc := &PermissionsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *PermissionsListCall) Fields(s ...googleapi.Field) *PermissionsListCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// IfNoneMatch sets the optional parameter which makes the operation\n// fail if the object's ETag matches the given value. This is useful for\n// getting updates only after the object has changed since the last\n// request. Use googleapi.IsNotModified to check whether the response\n// error from Do is the result of In-None-Match.\nfunc (c *PermissionsListCall) IfNoneMatch(entityTag string) *PermissionsListCall {\n\tc.ifNoneMatch_ = entityTag\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *PermissionsListCall) Context(ctx context.Context) *PermissionsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *PermissionsListCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}/permissions\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"GET\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\": c.fileId,\n\t})\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ifNoneMatch_ != \"\" {\n\t\treq.Header.Set(\"If-None-Match\", c.ifNoneMatch_)\n\t}\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.permissions.list\" call.\n// Exactly one of *PermissionList or error will be non-nil. Any non-2xx\n// status code is an error. Response headers are in either\n// *PermissionList.ServerResponse.Header or (if a response was returned\n// at all) in error.(*googleapi.Error).Header. Use\n// googleapi.IsNotModified to check whether the returned error was\n// because http.StatusNotModified was returned.\nfunc (c *PermissionsListCall) Do(opts ...googleapi.CallOption) (*PermissionList, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &PermissionList{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Lists a file's permissions.\",\n\t//   \"httpMethod\": \"GET\",\n\t//   \"id\": \"drive.permissions.list\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}/permissions\",\n\t//   \"response\": {\n\t//     \"$ref\": \"PermissionList\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.file\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.photos.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.readonly\"\n\t//   ]\n\t// }\n\n}\n\n// method id \"drive.permissions.update\":\n\ntype PermissionsUpdateCall struct {\n\ts            *Service\n\tfileId       string\n\tpermissionId string\n\tpermission   *Permission\n\turlParams_   gensupport.URLParams\n\tctx_         context.Context\n}\n\n// Update: Updates a permission with patch semantics.\nfunc (r *PermissionsService) Update(fileId string, permissionId string, permission *Permission) *PermissionsUpdateCall {\n\tc := &PermissionsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\tc.permissionId = permissionId\n\tc.permission = permission\n\treturn c\n}\n\n// TransferOwnership sets the optional parameter \"transferOwnership\":\n// Whether to transfer ownership to the specified user and downgrade the\n// current owner to a writer. This parameter is required as an\n// acknowledgement of the side effect.\nfunc (c *PermissionsUpdateCall) TransferOwnership(transferOwnership bool) *PermissionsUpdateCall {\n\tc.urlParams_.Set(\"transferOwnership\", fmt.Sprint(transferOwnership))\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *PermissionsUpdateCall) Fields(s ...googleapi.Field) *PermissionsUpdateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *PermissionsUpdateCall) Context(ctx context.Context) *PermissionsUpdateCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *PermissionsUpdateCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tbody, err := googleapi.WithoutDataWrapper.JSONReader(c.permission)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tctype := \"application/json\"\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}/permissions/{permissionId}\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"PATCH\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\":       c.fileId,\n\t\t\"permissionId\": c.permissionId,\n\t})\n\treq.Header.Set(\"Content-Type\", ctype)\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.permissions.update\" call.\n// Exactly one of *Permission or error will be non-nil. Any non-2xx\n// status code is an error. Response headers are in either\n// *Permission.ServerResponse.Header or (if a response was returned at\n// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified\n// to check whether the returned error was because\n// http.StatusNotModified was returned.\nfunc (c *PermissionsUpdateCall) Do(opts ...googleapi.CallOption) (*Permission, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &Permission{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Updates a permission with patch semantics.\",\n\t//   \"httpMethod\": \"PATCH\",\n\t//   \"id\": \"drive.permissions.update\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\",\n\t//     \"permissionId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"permissionId\": {\n\t//       \"description\": \"The ID of the permission.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"transferOwnership\": {\n\t//       \"default\": \"false\",\n\t//       \"description\": \"Whether to transfer ownership to the specified user and downgrade the current owner to a writer. This parameter is required as an acknowledgement of the side effect.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"boolean\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}/permissions/{permissionId}\",\n\t//   \"request\": {\n\t//     \"$ref\": \"Permission\"\n\t//   },\n\t//   \"response\": {\n\t//     \"$ref\": \"Permission\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.file\"\n\t//   ]\n\t// }\n\n}\n\n// method id \"drive.replies.create\":\n\ntype RepliesCreateCall struct {\n\ts          *Service\n\tfileId     string\n\tcommentId  string\n\treply      *Reply\n\turlParams_ gensupport.URLParams\n\tctx_       context.Context\n}\n\n// Create: Creates a new reply to a comment.\nfunc (r *RepliesService) Create(fileId string, commentId string, reply *Reply) *RepliesCreateCall {\n\tc := &RepliesCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\tc.commentId = commentId\n\tc.reply = reply\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *RepliesCreateCall) Fields(s ...googleapi.Field) *RepliesCreateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *RepliesCreateCall) Context(ctx context.Context) *RepliesCreateCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *RepliesCreateCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tbody, err := googleapi.WithoutDataWrapper.JSONReader(c.reply)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tctype := \"application/json\"\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}/comments/{commentId}/replies\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"POST\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\":    c.fileId,\n\t\t\"commentId\": c.commentId,\n\t})\n\treq.Header.Set(\"Content-Type\", ctype)\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.replies.create\" call.\n// Exactly one of *Reply or error will be non-nil. Any non-2xx status\n// code is an error. Response headers are in either\n// *Reply.ServerResponse.Header or (if a response was returned at all)\n// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to\n// check whether the returned error was because http.StatusNotModified\n// was returned.\nfunc (c *RepliesCreateCall) Do(opts ...googleapi.CallOption) (*Reply, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &Reply{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Creates a new reply to a comment.\",\n\t//   \"httpMethod\": \"POST\",\n\t//   \"id\": \"drive.replies.create\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\",\n\t//     \"commentId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"commentId\": {\n\t//       \"description\": \"The ID of the comment.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}/comments/{commentId}/replies\",\n\t//   \"request\": {\n\t//     \"$ref\": \"Reply\"\n\t//   },\n\t//   \"response\": {\n\t//     \"$ref\": \"Reply\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.file\"\n\t//   ]\n\t// }\n\n}\n\n// method id \"drive.replies.delete\":\n\ntype RepliesDeleteCall struct {\n\ts          *Service\n\tfileId     string\n\tcommentId  string\n\treplyId    string\n\turlParams_ gensupport.URLParams\n\tctx_       context.Context\n}\n\n// Delete: Deletes a reply.\nfunc (r *RepliesService) Delete(fileId string, commentId string, replyId string) *RepliesDeleteCall {\n\tc := &RepliesDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\tc.commentId = commentId\n\tc.replyId = replyId\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *RepliesDeleteCall) Fields(s ...googleapi.Field) *RepliesDeleteCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *RepliesDeleteCall) Context(ctx context.Context) *RepliesDeleteCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *RepliesDeleteCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}/comments/{commentId}/replies/{replyId}\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"DELETE\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\":    c.fileId,\n\t\t\"commentId\": c.commentId,\n\t\t\"replyId\":   c.replyId,\n\t})\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.replies.delete\" call.\nfunc (c *RepliesDeleteCall) Do(opts ...googleapi.CallOption) error {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n\t// {\n\t//   \"description\": \"Deletes a reply.\",\n\t//   \"httpMethod\": \"DELETE\",\n\t//   \"id\": \"drive.replies.delete\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\",\n\t//     \"commentId\",\n\t//     \"replyId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"commentId\": {\n\t//       \"description\": \"The ID of the comment.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"replyId\": {\n\t//       \"description\": \"The ID of the reply.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}/comments/{commentId}/replies/{replyId}\",\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.file\"\n\t//   ]\n\t// }\n\n}\n\n// method id \"drive.replies.get\":\n\ntype RepliesGetCall struct {\n\ts            *Service\n\tfileId       string\n\tcommentId    string\n\treplyId      string\n\turlParams_   gensupport.URLParams\n\tifNoneMatch_ string\n\tctx_         context.Context\n}\n\n// Get: Gets a reply by ID.\nfunc (r *RepliesService) Get(fileId string, commentId string, replyId string) *RepliesGetCall {\n\tc := &RepliesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\tc.commentId = commentId\n\tc.replyId = replyId\n\treturn c\n}\n\n// IncludeDeleted sets the optional parameter \"includeDeleted\": Whether\n// to return deleted replies. Deleted replies will not include their\n// original content.\nfunc (c *RepliesGetCall) IncludeDeleted(includeDeleted bool) *RepliesGetCall {\n\tc.urlParams_.Set(\"includeDeleted\", fmt.Sprint(includeDeleted))\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *RepliesGetCall) Fields(s ...googleapi.Field) *RepliesGetCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// IfNoneMatch sets the optional parameter which makes the operation\n// fail if the object's ETag matches the given value. This is useful for\n// getting updates only after the object has changed since the last\n// request. Use googleapi.IsNotModified to check whether the response\n// error from Do is the result of In-None-Match.\nfunc (c *RepliesGetCall) IfNoneMatch(entityTag string) *RepliesGetCall {\n\tc.ifNoneMatch_ = entityTag\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *RepliesGetCall) Context(ctx context.Context) *RepliesGetCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *RepliesGetCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}/comments/{commentId}/replies/{replyId}\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"GET\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\":    c.fileId,\n\t\t\"commentId\": c.commentId,\n\t\t\"replyId\":   c.replyId,\n\t})\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ifNoneMatch_ != \"\" {\n\t\treq.Header.Set(\"If-None-Match\", c.ifNoneMatch_)\n\t}\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.replies.get\" call.\n// Exactly one of *Reply or error will be non-nil. Any non-2xx status\n// code is an error. Response headers are in either\n// *Reply.ServerResponse.Header or (if a response was returned at all)\n// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to\n// check whether the returned error was because http.StatusNotModified\n// was returned.\nfunc (c *RepliesGetCall) Do(opts ...googleapi.CallOption) (*Reply, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &Reply{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Gets a reply by ID.\",\n\t//   \"httpMethod\": \"GET\",\n\t//   \"id\": \"drive.replies.get\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\",\n\t//     \"commentId\",\n\t//     \"replyId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"commentId\": {\n\t//       \"description\": \"The ID of the comment.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"includeDeleted\": {\n\t//       \"default\": \"false\",\n\t//       \"description\": \"Whether to return deleted replies. Deleted replies will not include their original content.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"boolean\"\n\t//     },\n\t//     \"replyId\": {\n\t//       \"description\": \"The ID of the reply.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}/comments/{commentId}/replies/{replyId}\",\n\t//   \"response\": {\n\t//     \"$ref\": \"Reply\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.file\",\n\t//     \"https://www.googleapis.com/auth/drive.readonly\"\n\t//   ]\n\t// }\n\n}\n\n// method id \"drive.replies.list\":\n\ntype RepliesListCall struct {\n\ts            *Service\n\tfileId       string\n\tcommentId    string\n\turlParams_   gensupport.URLParams\n\tifNoneMatch_ string\n\tctx_         context.Context\n}\n\n// List: Lists a comment's replies.\nfunc (r *RepliesService) List(fileId string, commentId string) *RepliesListCall {\n\tc := &RepliesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\tc.commentId = commentId\n\treturn c\n}\n\n// IncludeDeleted sets the optional parameter \"includeDeleted\": Whether\n// to include deleted replies. Deleted replies will not include their\n// original content.\nfunc (c *RepliesListCall) IncludeDeleted(includeDeleted bool) *RepliesListCall {\n\tc.urlParams_.Set(\"includeDeleted\", fmt.Sprint(includeDeleted))\n\treturn c\n}\n\n// PageSize sets the optional parameter \"pageSize\": The maximum number\n// of replies to return per page.\nfunc (c *RepliesListCall) PageSize(pageSize int64) *RepliesListCall {\n\tc.urlParams_.Set(\"pageSize\", fmt.Sprint(pageSize))\n\treturn c\n}\n\n// PageToken sets the optional parameter \"pageToken\": The token for\n// continuing a previous list request on the next page. This should be\n// set to the value of 'nextPageToken' from the previous response.\nfunc (c *RepliesListCall) PageToken(pageToken string) *RepliesListCall {\n\tc.urlParams_.Set(\"pageToken\", pageToken)\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *RepliesListCall) Fields(s ...googleapi.Field) *RepliesListCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// IfNoneMatch sets the optional parameter which makes the operation\n// fail if the object's ETag matches the given value. This is useful for\n// getting updates only after the object has changed since the last\n// request. Use googleapi.IsNotModified to check whether the response\n// error from Do is the result of In-None-Match.\nfunc (c *RepliesListCall) IfNoneMatch(entityTag string) *RepliesListCall {\n\tc.ifNoneMatch_ = entityTag\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *RepliesListCall) Context(ctx context.Context) *RepliesListCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *RepliesListCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}/comments/{commentId}/replies\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"GET\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\":    c.fileId,\n\t\t\"commentId\": c.commentId,\n\t})\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ifNoneMatch_ != \"\" {\n\t\treq.Header.Set(\"If-None-Match\", c.ifNoneMatch_)\n\t}\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.replies.list\" call.\n// Exactly one of *ReplyList or error will be non-nil. Any non-2xx\n// status code is an error. Response headers are in either\n// *ReplyList.ServerResponse.Header or (if a response was returned at\n// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified\n// to check whether the returned error was because\n// http.StatusNotModified was returned.\nfunc (c *RepliesListCall) Do(opts ...googleapi.CallOption) (*ReplyList, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &ReplyList{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Lists a comment's replies.\",\n\t//   \"httpMethod\": \"GET\",\n\t//   \"id\": \"drive.replies.list\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\",\n\t//     \"commentId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"commentId\": {\n\t//       \"description\": \"The ID of the comment.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"includeDeleted\": {\n\t//       \"default\": \"false\",\n\t//       \"description\": \"Whether to include deleted replies. Deleted replies will not include their original content.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"boolean\"\n\t//     },\n\t//     \"pageSize\": {\n\t//       \"default\": \"20\",\n\t//       \"description\": \"The maximum number of replies to return per page.\",\n\t//       \"format\": \"int32\",\n\t//       \"location\": \"query\",\n\t//       \"maximum\": \"100\",\n\t//       \"minimum\": \"1\",\n\t//       \"type\": \"integer\"\n\t//     },\n\t//     \"pageToken\": {\n\t//       \"description\": \"The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}/comments/{commentId}/replies\",\n\t//   \"response\": {\n\t//     \"$ref\": \"ReplyList\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.file\",\n\t//     \"https://www.googleapis.com/auth/drive.readonly\"\n\t//   ]\n\t// }\n\n}\n\n// Pages invokes f for each page of results.\n// A non-nil error returned from f will halt the iteration.\n// The provided context supersedes any context provided to the Context method.\nfunc (c *RepliesListCall) Pages(ctx context.Context, f func(*ReplyList) error) error {\n\tc.ctx_ = ctx\n\tdefer c.PageToken(c.urlParams_.Get(\"pageToken\")) // reset paging to original point\n\tfor {\n\t\tx, err := c.Do()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := f(x); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif x.NextPageToken == \"\" {\n\t\t\treturn nil\n\t\t}\n\t\tc.PageToken(x.NextPageToken)\n\t}\n}\n\n// method id \"drive.replies.update\":\n\ntype RepliesUpdateCall struct {\n\ts          *Service\n\tfileId     string\n\tcommentId  string\n\treplyId    string\n\treply      *Reply\n\turlParams_ gensupport.URLParams\n\tctx_       context.Context\n}\n\n// Update: Updates a reply with patch semantics.\nfunc (r *RepliesService) Update(fileId string, commentId string, replyId string, reply *Reply) *RepliesUpdateCall {\n\tc := &RepliesUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\tc.commentId = commentId\n\tc.replyId = replyId\n\tc.reply = reply\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *RepliesUpdateCall) Fields(s ...googleapi.Field) *RepliesUpdateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *RepliesUpdateCall) Context(ctx context.Context) *RepliesUpdateCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *RepliesUpdateCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tbody, err := googleapi.WithoutDataWrapper.JSONReader(c.reply)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tctype := \"application/json\"\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}/comments/{commentId}/replies/{replyId}\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"PATCH\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\":    c.fileId,\n\t\t\"commentId\": c.commentId,\n\t\t\"replyId\":   c.replyId,\n\t})\n\treq.Header.Set(\"Content-Type\", ctype)\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.replies.update\" call.\n// Exactly one of *Reply or error will be non-nil. Any non-2xx status\n// code is an error. Response headers are in either\n// *Reply.ServerResponse.Header or (if a response was returned at all)\n// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to\n// check whether the returned error was because http.StatusNotModified\n// was returned.\nfunc (c *RepliesUpdateCall) Do(opts ...googleapi.CallOption) (*Reply, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &Reply{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Updates a reply with patch semantics.\",\n\t//   \"httpMethod\": \"PATCH\",\n\t//   \"id\": \"drive.replies.update\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\",\n\t//     \"commentId\",\n\t//     \"replyId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"commentId\": {\n\t//       \"description\": \"The ID of the comment.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"replyId\": {\n\t//       \"description\": \"The ID of the reply.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}/comments/{commentId}/replies/{replyId}\",\n\t//   \"request\": {\n\t//     \"$ref\": \"Reply\"\n\t//   },\n\t//   \"response\": {\n\t//     \"$ref\": \"Reply\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.file\"\n\t//   ]\n\t// }\n\n}\n\n// method id \"drive.revisions.delete\":\n\ntype RevisionsDeleteCall struct {\n\ts          *Service\n\tfileId     string\n\trevisionId string\n\turlParams_ gensupport.URLParams\n\tctx_       context.Context\n}\n\n// Delete: Permanently deletes a revision. This method is only\n// applicable to files with binary content in Drive.\nfunc (r *RevisionsService) Delete(fileId string, revisionId string) *RevisionsDeleteCall {\n\tc := &RevisionsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\tc.revisionId = revisionId\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *RevisionsDeleteCall) Fields(s ...googleapi.Field) *RevisionsDeleteCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *RevisionsDeleteCall) Context(ctx context.Context) *RevisionsDeleteCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *RevisionsDeleteCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}/revisions/{revisionId}\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"DELETE\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\":     c.fileId,\n\t\t\"revisionId\": c.revisionId,\n\t})\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.revisions.delete\" call.\nfunc (c *RevisionsDeleteCall) Do(opts ...googleapi.CallOption) error {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n\t// {\n\t//   \"description\": \"Permanently deletes a revision. This method is only applicable to files with binary content in Drive.\",\n\t//   \"httpMethod\": \"DELETE\",\n\t//   \"id\": \"drive.revisions.delete\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\",\n\t//     \"revisionId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"revisionId\": {\n\t//       \"description\": \"The ID of the revision.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}/revisions/{revisionId}\",\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.appdata\",\n\t//     \"https://www.googleapis.com/auth/drive.file\"\n\t//   ]\n\t// }\n\n}\n\n// method id \"drive.revisions.get\":\n\ntype RevisionsGetCall struct {\n\ts            *Service\n\tfileId       string\n\trevisionId   string\n\turlParams_   gensupport.URLParams\n\tifNoneMatch_ string\n\tctx_         context.Context\n}\n\n// Get: Gets a revision's metadata or content by ID.\nfunc (r *RevisionsService) Get(fileId string, revisionId string) *RevisionsGetCall {\n\tc := &RevisionsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\tc.revisionId = revisionId\n\treturn c\n}\n\n// AcknowledgeAbuse sets the optional parameter \"acknowledgeAbuse\":\n// Whether the user is acknowledging the risk of downloading known\n// malware or other abusive files. This is only applicable when\n// alt=media.\nfunc (c *RevisionsGetCall) AcknowledgeAbuse(acknowledgeAbuse bool) *RevisionsGetCall {\n\tc.urlParams_.Set(\"acknowledgeAbuse\", fmt.Sprint(acknowledgeAbuse))\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *RevisionsGetCall) Fields(s ...googleapi.Field) *RevisionsGetCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// IfNoneMatch sets the optional parameter which makes the operation\n// fail if the object's ETag matches the given value. This is useful for\n// getting updates only after the object has changed since the last\n// request. Use googleapi.IsNotModified to check whether the response\n// error from Do is the result of In-None-Match.\nfunc (c *RevisionsGetCall) IfNoneMatch(entityTag string) *RevisionsGetCall {\n\tc.ifNoneMatch_ = entityTag\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do and Download\n// methods. Any pending HTTP request will be aborted if the provided\n// context is canceled.\nfunc (c *RevisionsGetCall) Context(ctx context.Context) *RevisionsGetCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *RevisionsGetCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}/revisions/{revisionId}\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"GET\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\":     c.fileId,\n\t\t\"revisionId\": c.revisionId,\n\t})\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ifNoneMatch_ != \"\" {\n\t\treq.Header.Set(\"If-None-Match\", c.ifNoneMatch_)\n\t}\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Download fetches the API endpoint's \"media\" value, instead of the normal\n// API response value. If the returned error is nil, the Response is guaranteed to\n// have a 2xx status code. Callers must close the Response.Body as usual.\nfunc (c *RevisionsGetCall) Download(opts ...googleapi.CallOption) (*http.Response, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"media\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif err := googleapi.CheckMediaResponse(res); err != nil {\n\t\tres.Body.Close()\n\t\treturn nil, err\n\t}\n\treturn res, nil\n}\n\n// Do executes the \"drive.revisions.get\" call.\n// Exactly one of *Revision or error will be non-nil. Any non-2xx status\n// code is an error. Response headers are in either\n// *Revision.ServerResponse.Header or (if a response was returned at\n// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified\n// to check whether the returned error was because\n// http.StatusNotModified was returned.\nfunc (c *RevisionsGetCall) Do(opts ...googleapi.CallOption) (*Revision, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &Revision{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Gets a revision's metadata or content by ID.\",\n\t//   \"httpMethod\": \"GET\",\n\t//   \"id\": \"drive.revisions.get\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\",\n\t//     \"revisionId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"acknowledgeAbuse\": {\n\t//       \"default\": \"false\",\n\t//       \"description\": \"Whether the user is acknowledging the risk of downloading known malware or other abusive files. This is only applicable when alt=media.\",\n\t//       \"location\": \"query\",\n\t//       \"type\": \"boolean\"\n\t//     },\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"revisionId\": {\n\t//       \"description\": \"The ID of the revision.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}/revisions/{revisionId}\",\n\t//   \"response\": {\n\t//     \"$ref\": \"Revision\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.appdata\",\n\t//     \"https://www.googleapis.com/auth/drive.file\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.photos.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.readonly\"\n\t//   ],\n\t//   \"supportsMediaDownload\": true,\n\t//   \"useMediaDownloadService\": true\n\t// }\n\n}\n\n// method id \"drive.revisions.list\":\n\ntype RevisionsListCall struct {\n\ts            *Service\n\tfileId       string\n\turlParams_   gensupport.URLParams\n\tifNoneMatch_ string\n\tctx_         context.Context\n}\n\n// List: Lists a file's revisions.\nfunc (r *RevisionsService) List(fileId string) *RevisionsListCall {\n\tc := &RevisionsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *RevisionsListCall) Fields(s ...googleapi.Field) *RevisionsListCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// IfNoneMatch sets the optional parameter which makes the operation\n// fail if the object's ETag matches the given value. This is useful for\n// getting updates only after the object has changed since the last\n// request. Use googleapi.IsNotModified to check whether the response\n// error from Do is the result of In-None-Match.\nfunc (c *RevisionsListCall) IfNoneMatch(entityTag string) *RevisionsListCall {\n\tc.ifNoneMatch_ = entityTag\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *RevisionsListCall) Context(ctx context.Context) *RevisionsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *RevisionsListCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}/revisions\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"GET\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\": c.fileId,\n\t})\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ifNoneMatch_ != \"\" {\n\t\treq.Header.Set(\"If-None-Match\", c.ifNoneMatch_)\n\t}\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.revisions.list\" call.\n// Exactly one of *RevisionList or error will be non-nil. Any non-2xx\n// status code is an error. Response headers are in either\n// *RevisionList.ServerResponse.Header or (if a response was returned at\n// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified\n// to check whether the returned error was because\n// http.StatusNotModified was returned.\nfunc (c *RevisionsListCall) Do(opts ...googleapi.CallOption) (*RevisionList, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &RevisionList{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Lists a file's revisions.\",\n\t//   \"httpMethod\": \"GET\",\n\t//   \"id\": \"drive.revisions.list\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}/revisions\",\n\t//   \"response\": {\n\t//     \"$ref\": \"RevisionList\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.appdata\",\n\t//     \"https://www.googleapis.com/auth/drive.file\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata\",\n\t//     \"https://www.googleapis.com/auth/drive.metadata.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.photos.readonly\",\n\t//     \"https://www.googleapis.com/auth/drive.readonly\"\n\t//   ]\n\t// }\n\n}\n\n// method id \"drive.revisions.update\":\n\ntype RevisionsUpdateCall struct {\n\ts          *Service\n\tfileId     string\n\trevisionId string\n\trevision   *Revision\n\turlParams_ gensupport.URLParams\n\tctx_       context.Context\n}\n\n// Update: Updates a revision with patch semantics.\nfunc (r *RevisionsService) Update(fileId string, revisionId string, revision *Revision) *RevisionsUpdateCall {\n\tc := &RevisionsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.fileId = fileId\n\tc.revisionId = revisionId\n\tc.revision = revision\n\treturn c\n}\n\n// Fields allows partial responses to be retrieved. See\n// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n// for more information.\nfunc (c *RevisionsUpdateCall) Fields(s ...googleapi.Field) *RevisionsUpdateCall {\n\tc.urlParams_.Set(\"fields\", googleapi.CombineFields(s))\n\treturn c\n}\n\n// Context sets the context to be used in this call's Do method. Any\n// pending HTTP request will be aborted if the provided context is\n// canceled.\nfunc (c *RevisionsUpdateCall) Context(ctx context.Context) *RevisionsUpdateCall {\n\tc.ctx_ = ctx\n\treturn c\n}\n\nfunc (c *RevisionsUpdateCall) doRequest(alt string) (*http.Response, error) {\n\tvar body io.Reader = nil\n\tbody, err := googleapi.WithoutDataWrapper.JSONReader(c.revision)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tctype := \"application/json\"\n\tc.urlParams_.Set(\"alt\", alt)\n\turls := googleapi.ResolveRelative(c.s.BasePath, \"files/{fileId}/revisions/{revisionId}\")\n\turls += \"?\" + c.urlParams_.Encode()\n\treq, _ := http.NewRequest(\"PATCH\", urls, body)\n\tgoogleapi.Expand(req.URL, map[string]string{\n\t\t\"fileId\":     c.fileId,\n\t\t\"revisionId\": c.revisionId,\n\t})\n\treq.Header.Set(\"Content-Type\", ctype)\n\treq.Header.Set(\"User-Agent\", c.s.userAgent())\n\tif c.ctx_ != nil {\n\t\treturn ctxhttp.Do(c.ctx_, c.s.client, req)\n\t}\n\treturn c.s.client.Do(req)\n}\n\n// Do executes the \"drive.revisions.update\" call.\n// Exactly one of *Revision or error will be non-nil. Any non-2xx status\n// code is an error. Response headers are in either\n// *Revision.ServerResponse.Header or (if a response was returned at\n// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified\n// to check whether the returned error was because\n// http.StatusNotModified was returned.\nfunc (c *RevisionsUpdateCall) Do(opts ...googleapi.CallOption) (*Revision, error) {\n\tgensupport.SetOptions(c.urlParams_, opts...)\n\tres, err := c.doRequest(\"json\")\n\tif res != nil && res.StatusCode == http.StatusNotModified {\n\t\tif res.Body != nil {\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn nil, &googleapi.Error{\n\t\t\tCode:   res.StatusCode,\n\t\t\tHeader: res.Header,\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer googleapi.CloseBody(res)\n\tif err := googleapi.CheckResponse(res); err != nil {\n\t\treturn nil, err\n\t}\n\tret := &Revision{\n\t\tServerResponse: googleapi.ServerResponse{\n\t\t\tHeader:         res.Header,\n\t\t\tHTTPStatusCode: res.StatusCode,\n\t\t},\n\t}\n\tif err := json.NewDecoder(res.Body).Decode(&ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n\t// {\n\t//   \"description\": \"Updates a revision with patch semantics.\",\n\t//   \"httpMethod\": \"PATCH\",\n\t//   \"id\": \"drive.revisions.update\",\n\t//   \"parameterOrder\": [\n\t//     \"fileId\",\n\t//     \"revisionId\"\n\t//   ],\n\t//   \"parameters\": {\n\t//     \"fileId\": {\n\t//       \"description\": \"The ID of the file.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     },\n\t//     \"revisionId\": {\n\t//       \"description\": \"The ID of the revision.\",\n\t//       \"location\": \"path\",\n\t//       \"required\": true,\n\t//       \"type\": \"string\"\n\t//     }\n\t//   },\n\t//   \"path\": \"files/{fileId}/revisions/{revisionId}\",\n\t//   \"request\": {\n\t//     \"$ref\": \"Revision\"\n\t//   },\n\t//   \"response\": {\n\t//     \"$ref\": \"Revision\"\n\t//   },\n\t//   \"scopes\": [\n\t//     \"https://www.googleapis.com/auth/drive\",\n\t//     \"https://www.googleapis.com/auth/drive.appdata\",\n\t//     \"https://www.googleapis.com/auth/drive.file\"\n\t//   ]\n\t// }\n\n}\n"
  },
  {
    "path": "vendor/google.golang.org/api/gensupport/backoff.go",
    "content": "// Copyright 2016 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage gensupport\n\nimport (\n\t\"math/rand\"\n\t\"time\"\n)\n\ntype BackoffStrategy interface {\n\t// Pause returns the duration of the next pause and true if the operation should be\n\t// retried, or false if no further retries should be attempted.\n\tPause() (time.Duration, bool)\n\n\t// Reset restores the strategy to its initial state.\n\tReset()\n}\n\n// ExponentialBackoff performs exponential backoff as per https://en.wikipedia.org/wiki/Exponential_backoff.\n// The initial pause time is given by Base.\n// Once the total pause time exceeds Max, Pause will indicate no further retries.\ntype ExponentialBackoff struct {\n\tBase  time.Duration\n\tMax   time.Duration\n\ttotal time.Duration\n\tn     uint\n}\n\nfunc (eb *ExponentialBackoff) Pause() (time.Duration, bool) {\n\tif eb.total > eb.Max {\n\t\treturn 0, false\n\t}\n\n\t// The next pause is selected from randomly from [0, 2^n * Base).\n\td := time.Duration(rand.Int63n((1 << eb.n) * int64(eb.Base)))\n\teb.total += d\n\teb.n++\n\treturn d, true\n}\n\nfunc (eb *ExponentialBackoff) Reset() {\n\teb.n = 0\n\teb.total = 0\n}\n"
  },
  {
    "path": "vendor/google.golang.org/api/gensupport/buffer.go",
    "content": "// Copyright 2016 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage gensupport\n\nimport (\n\t\"bytes\"\n\t\"io\"\n\n\t\"google.golang.org/api/googleapi\"\n)\n\n// ResumableBuffer buffers data from an io.Reader to support uploading media in retryable chunks.\ntype ResumableBuffer struct {\n\tmedia io.Reader\n\n\tchunk []byte // The current chunk which is pending upload.  The capacity is the chunk size.\n\terr   error  // Any error generated when populating chunk by reading media.\n\n\t// The absolute position of chunk in the underlying media.\n\toff int64\n}\n\nfunc NewResumableBuffer(media io.Reader, chunkSize int) *ResumableBuffer {\n\treturn &ResumableBuffer{media: media, chunk: make([]byte, 0, chunkSize)}\n}\n\n// Chunk returns the current buffered chunk, the offset in the underlying media\n// from which the chunk is drawn, and the size of the chunk.\n// Successive calls to Chunk return the same chunk between calls to Next.\nfunc (rb *ResumableBuffer) Chunk() (chunk io.Reader, off int64, size int, err error) {\n\t// There may already be data in chunk if Next has not been called since the previous call to Chunk.\n\tif rb.err == nil && len(rb.chunk) == 0 {\n\t\trb.err = rb.loadChunk()\n\t}\n\treturn bytes.NewReader(rb.chunk), rb.off, len(rb.chunk), rb.err\n}\n\n// loadChunk will read from media into chunk, up to the capacity of chunk.\nfunc (rb *ResumableBuffer) loadChunk() error {\n\tbufSize := cap(rb.chunk)\n\trb.chunk = rb.chunk[:bufSize]\n\n\tread := 0\n\tvar err error\n\tfor err == nil && read < bufSize {\n\t\tvar n int\n\t\tn, err = rb.media.Read(rb.chunk[read:])\n\t\tread += n\n\t}\n\trb.chunk = rb.chunk[:read]\n\treturn err\n}\n\n// Next advances to the next chunk, which will be returned by the next call to Chunk.\n// Calls to Next without a corresponding prior call to Chunk will have no effect.\nfunc (rb *ResumableBuffer) Next() {\n\trb.off += int64(len(rb.chunk))\n\trb.chunk = rb.chunk[0:0]\n}\n\ntype readerTyper struct {\n\tio.Reader\n\tgoogleapi.ContentTyper\n}\n\n// ReaderAtToReader adapts a ReaderAt to be used as a Reader.\n// If ra implements googleapi.ContentTyper, then the returned reader\n// will also implement googleapi.ContentTyper, delegating to ra.\nfunc ReaderAtToReader(ra io.ReaderAt, size int64) io.Reader {\n\tr := io.NewSectionReader(ra, 0, size)\n\tif typer, ok := ra.(googleapi.ContentTyper); ok {\n\t\treturn readerTyper{r, typer}\n\t}\n\treturn r\n}\n"
  },
  {
    "path": "vendor/google.golang.org/api/gensupport/doc.go",
    "content": "// Copyright 2016 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Package gensupport is an internal implementation detail used by code\n// generated by the google-api-go-generator tool.\n//\n// This package may be modified at any time without regard for backwards\n// compatibility. It should not be used directly by API users.\npackage gensupport\n"
  },
  {
    "path": "vendor/google.golang.org/api/gensupport/json.go",
    "content": "// Copyright 2015 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage gensupport\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"reflect\"\n\t\"strings\"\n)\n\n// MarshalJSON returns a JSON encoding of schema containing only selected fields.\n// A field is selected if:\n//   * it has a non-empty value, or\n//     * its field name is present in forceSendFields, and\n//     * it is not a nil pointer or nil interface.\n// The JSON key for each selected field is taken from the field's json: struct tag.\nfunc MarshalJSON(schema interface{}, forceSendFields []string) ([]byte, error) {\n\tif len(forceSendFields) == 0 {\n\t\treturn json.Marshal(schema)\n\t}\n\n\tmustInclude := make(map[string]struct{})\n\tfor _, f := range forceSendFields {\n\t\tmustInclude[f] = struct{}{}\n\t}\n\n\tdataMap, err := schemaToMap(schema, mustInclude)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn json.Marshal(dataMap)\n}\n\nfunc schemaToMap(schema interface{}, mustInclude map[string]struct{}) (map[string]interface{}, error) {\n\tm := make(map[string]interface{})\n\ts := reflect.ValueOf(schema)\n\tst := s.Type()\n\n\tfor i := 0; i < s.NumField(); i++ {\n\t\tjsonTag := st.Field(i).Tag.Get(\"json\")\n\t\tif jsonTag == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\ttag, err := parseJSONTag(jsonTag)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif tag.ignore {\n\t\t\tcontinue\n\t\t}\n\n\t\tv := s.Field(i)\n\t\tf := st.Field(i)\n\t\tif !includeField(v, f, mustInclude) {\n\t\t\tcontinue\n\t\t}\n\n\t\t// nil maps are treated as empty maps.\n\t\tif f.Type.Kind() == reflect.Map && v.IsNil() {\n\t\t\tm[tag.apiName] = map[string]string{}\n\t\t\tcontinue\n\t\t}\n\n\t\t// nil slices are treated as empty slices.\n\t\tif f.Type.Kind() == reflect.Slice && v.IsNil() {\n\t\t\tm[tag.apiName] = []bool{}\n\t\t\tcontinue\n\t\t}\n\n\t\tif tag.stringFormat {\n\t\t\tm[tag.apiName] = formatAsString(v, f.Type.Kind())\n\t\t} else {\n\t\t\tm[tag.apiName] = v.Interface()\n\t\t}\n\t}\n\treturn m, nil\n}\n\n// formatAsString returns a string representation of v, dereferencing it first if possible.\nfunc formatAsString(v reflect.Value, kind reflect.Kind) string {\n\tif kind == reflect.Ptr && !v.IsNil() {\n\t\tv = v.Elem()\n\t}\n\n\treturn fmt.Sprintf(\"%v\", v.Interface())\n}\n\n// jsonTag represents a restricted version of the struct tag format used by encoding/json.\n// It is used to describe the JSON encoding of fields in a Schema struct.\ntype jsonTag struct {\n\tapiName      string\n\tstringFormat bool\n\tignore       bool\n}\n\n// parseJSONTag parses a restricted version of the struct tag format used by encoding/json.\n// The format of the tag must match that generated by the Schema.writeSchemaStruct method\n// in the api generator.\nfunc parseJSONTag(val string) (jsonTag, error) {\n\tif val == \"-\" {\n\t\treturn jsonTag{ignore: true}, nil\n\t}\n\n\tvar tag jsonTag\n\n\ti := strings.Index(val, \",\")\n\tif i == -1 || val[:i] == \"\" {\n\t\treturn tag, fmt.Errorf(\"malformed json tag: %s\", val)\n\t}\n\n\ttag = jsonTag{\n\t\tapiName: val[:i],\n\t}\n\n\tswitch val[i+1:] {\n\tcase \"omitempty\":\n\tcase \"omitempty,string\":\n\t\ttag.stringFormat = true\n\tdefault:\n\t\treturn tag, fmt.Errorf(\"malformed json tag: %s\", val)\n\t}\n\n\treturn tag, nil\n}\n\n// Reports whether the struct field \"f\" with value \"v\" should be included in JSON output.\nfunc includeField(v reflect.Value, f reflect.StructField, mustInclude map[string]struct{}) bool {\n\t// The regular JSON encoding of a nil pointer is \"null\", which means \"delete this field\".\n\t// Therefore, we could enable field deletion by honoring pointer fields' presence in the mustInclude set.\n\t// However, many fields are not pointers, so there would be no way to delete these fields.\n\t// Rather than partially supporting field deletion, we ignore mustInclude for nil pointer fields.\n\t// Deletion will be handled by a separate mechanism.\n\tif f.Type.Kind() == reflect.Ptr && v.IsNil() {\n\t\treturn false\n\t}\n\n\t// The \"any\" type is represented as an interface{}.  If this interface\n\t// is nil, there is no reasonable representation to send.  We ignore\n\t// these fields, for the same reasons as given above for pointers.\n\tif f.Type.Kind() == reflect.Interface && v.IsNil() {\n\t\treturn false\n\t}\n\n\t_, ok := mustInclude[f.Name]\n\treturn ok || !isEmptyValue(v)\n}\n\n// isEmptyValue reports whether v is the empty value for its type.  This\n// implementation is based on that of the encoding/json package, but its\n// correctness does not depend on it being identical. What's important is that\n// this function return false in situations where v should not be sent as part\n// of a PATCH operation.\nfunc isEmptyValue(v reflect.Value) bool {\n\tswitch v.Kind() {\n\tcase reflect.Array, reflect.Map, reflect.Slice, reflect.String:\n\t\treturn v.Len() == 0\n\tcase reflect.Bool:\n\t\treturn !v.Bool()\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn v.Int() == 0\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\treturn v.Uint() == 0\n\tcase reflect.Float32, reflect.Float64:\n\t\treturn v.Float() == 0\n\tcase reflect.Interface, reflect.Ptr:\n\t\treturn v.IsNil()\n\t}\n\treturn false\n}\n"
  },
  {
    "path": "vendor/google.golang.org/api/gensupport/media.go",
    "content": "// Copyright 2016 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage gensupport\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"mime/multipart\"\n\t\"net/http\"\n\t\"net/textproto\"\n\n\t\"google.golang.org/api/googleapi\"\n)\n\nconst sniffBuffSize = 512\n\nfunc newContentSniffer(r io.Reader) *contentSniffer {\n\treturn &contentSniffer{r: r}\n}\n\n// contentSniffer wraps a Reader, and reports the content type determined by sniffing up to 512 bytes from the Reader.\ntype contentSniffer struct {\n\tr     io.Reader\n\tstart []byte // buffer for the sniffed bytes.\n\terr   error  // set to any error encountered while reading bytes to be sniffed.\n\n\tctype   string // set on first sniff.\n\tsniffed bool   // set to true on first sniff.\n}\n\nfunc (cs *contentSniffer) Read(p []byte) (n int, err error) {\n\t// Ensure that the content type is sniffed before any data is consumed from Reader.\n\t_, _ = cs.ContentType()\n\n\tif len(cs.start) > 0 {\n\t\tn := copy(p, cs.start)\n\t\tcs.start = cs.start[n:]\n\t\treturn n, nil\n\t}\n\n\t// We may have read some bytes into start while sniffing, even if the read ended in an error.\n\t// We should first return those bytes, then the error.\n\tif cs.err != nil {\n\t\treturn 0, cs.err\n\t}\n\n\t// Now we have handled all bytes that were buffered while sniffing.  Now just delegate to the underlying reader.\n\treturn cs.r.Read(p)\n}\n\n// ContentType returns the sniffed content type, and whether the content type was succesfully sniffed.\nfunc (cs *contentSniffer) ContentType() (string, bool) {\n\tif cs.sniffed {\n\t\treturn cs.ctype, cs.ctype != \"\"\n\t}\n\tcs.sniffed = true\n\t// If ReadAll hits EOF, it returns err==nil.\n\tcs.start, cs.err = ioutil.ReadAll(io.LimitReader(cs.r, sniffBuffSize))\n\n\t// Don't try to detect the content type based on possibly incomplete data.\n\tif cs.err != nil {\n\t\treturn \"\", false\n\t}\n\n\tcs.ctype = http.DetectContentType(cs.start)\n\treturn cs.ctype, true\n}\n\n// DetermineContentType determines the content type of the supplied reader.\n// If the content type is already known, it can be specified via ctype.\n// Otherwise, the content of media will be sniffed to determine the content type.\n// If media implements googleapi.ContentTyper (deprecated), this will be used\n// instead of sniffing the content.\n// After calling DetectContentType the caller must not perform further reads on\n// media, but rather read from the Reader that is returned.\nfunc DetermineContentType(media io.Reader, ctype string) (io.Reader, string) {\n\t// Note: callers could avoid calling DetectContentType if ctype != \"\",\n\t// but doing the check inside this function reduces the amount of\n\t// generated code.\n\tif ctype != \"\" {\n\t\treturn media, ctype\n\t}\n\n\t// For backwards compatability, allow clients to set content\n\t// type by providing a ContentTyper for media.\n\tif typer, ok := media.(googleapi.ContentTyper); ok {\n\t\treturn media, typer.ContentType()\n\t}\n\n\tsniffer := newContentSniffer(media)\n\tif ctype, ok := sniffer.ContentType(); ok {\n\t\treturn sniffer, ctype\n\t}\n\t// If content type could not be sniffed, reads from sniffer will eventually fail with an error.\n\treturn sniffer, \"\"\n}\n\ntype typeReader struct {\n\tio.Reader\n\ttyp string\n}\n\n// multipartReader combines the contents of multiple readers to creat a multipart/related HTTP body.\n// Close must be called if reads from the multipartReader are abandoned before reaching EOF.\ntype multipartReader struct {\n\tpr       *io.PipeReader\n\tpipeOpen bool\n\tctype    string\n}\n\nfunc newMultipartReader(parts []typeReader) *multipartReader {\n\tmp := &multipartReader{pipeOpen: true}\n\tvar pw *io.PipeWriter\n\tmp.pr, pw = io.Pipe()\n\tmpw := multipart.NewWriter(pw)\n\tmp.ctype = \"multipart/related; boundary=\" + mpw.Boundary()\n\tgo func() {\n\t\tfor _, part := range parts {\n\t\t\tw, err := mpw.CreatePart(typeHeader(part.typ))\n\t\t\tif err != nil {\n\t\t\t\tmpw.Close()\n\t\t\t\tpw.CloseWithError(fmt.Errorf(\"googleapi: CreatePart failed: %v\", err))\n\t\t\t\treturn\n\t\t\t}\n\t\t\t_, err = io.Copy(w, part.Reader)\n\t\t\tif err != nil {\n\t\t\t\tmpw.Close()\n\t\t\t\tpw.CloseWithError(fmt.Errorf(\"googleapi: Copy failed: %v\", err))\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tmpw.Close()\n\t\tpw.Close()\n\t}()\n\treturn mp\n}\n\nfunc (mp *multipartReader) Read(data []byte) (n int, err error) {\n\treturn mp.pr.Read(data)\n}\n\nfunc (mp *multipartReader) Close() error {\n\tif !mp.pipeOpen {\n\t\treturn nil\n\t}\n\tmp.pipeOpen = false\n\treturn mp.pr.Close()\n}\n\n// CombineBodyMedia combines a json body with media content to create a multipart/related HTTP body.\n// It returns a ReadCloser containing the combined body, and the overall \"multipart/related\" content type, with random boundary.\n//\n// The caller must call Close on the returned ReadCloser if reads are abandoned before reaching EOF.\nfunc CombineBodyMedia(body io.Reader, bodyContentType string, media io.Reader, mediaContentType string) (io.ReadCloser, string) {\n\tmp := newMultipartReader([]typeReader{\n\t\t{body, bodyContentType},\n\t\t{media, mediaContentType},\n\t})\n\treturn mp, mp.ctype\n}\n\nfunc typeHeader(contentType string) textproto.MIMEHeader {\n\th := make(textproto.MIMEHeader)\n\tif contentType != \"\" {\n\t\th.Set(\"Content-Type\", contentType)\n\t}\n\treturn h\n}\n\n// PrepareUpload determines whether the data in the supplied reader should be\n// uploaded in a single request, or in sequential chunks.\n// chunkSize is the size of the chunk that media should be split into.\n// If chunkSize is non-zero and the contents of media do not fit in a single\n// chunk (or there is an error reading media), then media will be returned as a\n// ResumableBuffer.  Otherwise, media will be returned as a Reader.\n//\n// After PrepareUpload has been called, media should no longer be used: the\n// media content should be accessed via one of the return values.\nfunc PrepareUpload(media io.Reader, chunkSize int) (io.Reader,\n\t*ResumableBuffer) {\n\tif chunkSize == 0 { // do not chunk\n\t\treturn media, nil\n\t}\n\n\trb := NewResumableBuffer(media, chunkSize)\n\trdr, _, _, err := rb.Chunk()\n\n\tif err == io.EOF { // we can upload this in a single request\n\t\treturn rdr, nil\n\t}\n\t// err might be a non-EOF error. If it is, the next call to rb.Chunk will\n\t// return the same error. Returning a ResumableBuffer ensures that this error\n\t// will be handled at some point.\n\n\treturn nil, rb\n}\n"
  },
  {
    "path": "vendor/google.golang.org/api/gensupport/params.go",
    "content": "// Copyright 2015 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage gensupport\n\nimport (\n\t\"net/url\"\n\n\t\"google.golang.org/api/googleapi\"\n)\n\n// URLParams is a simplified replacement for url.Values\n// that safely builds up URL parameters for encoding.\ntype URLParams map[string][]string\n\n// Get returns the first value for the given key, or \"\".\nfunc (u URLParams) Get(key string) string {\n\tvs := u[key]\n\tif len(vs) == 0 {\n\t\treturn \"\"\n\t}\n\treturn vs[0]\n}\n\n// Set sets the key to value.\n// It replaces any existing values.\nfunc (u URLParams) Set(key, value string) {\n\tu[key] = []string{value}\n}\n\n// SetMulti sets the key to an array of values.\n// It replaces any existing values.\n// Note that values must not be modified after calling SetMulti\n// so the caller is responsible for making a copy if necessary.\nfunc (u URLParams) SetMulti(key string, values []string) {\n\tu[key] = values\n}\n\n// Encode encodes the values into ``URL encoded'' form\n// (\"bar=baz&foo=quux\") sorted by key.\nfunc (u URLParams) Encode() string {\n\treturn url.Values(u).Encode()\n}\n\nfunc SetOptions(u URLParams, opts ...googleapi.CallOption) {\n\tfor _, o := range opts {\n\t\tu.Set(o.Get())\n\t}\n}\n"
  },
  {
    "path": "vendor/google.golang.org/api/gensupport/resumable.go",
    "content": "// Copyright 2016 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage gensupport\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"sync\"\n\t\"time\"\n\n\t\"golang.org/x/net/context\"\n\t\"golang.org/x/net/context/ctxhttp\"\n)\n\nconst (\n\t// statusResumeIncomplete is the code returned by the Google uploader\n\t// when the transfer is not yet complete.\n\tstatusResumeIncomplete = 308\n\n\t// statusTooManyRequests is returned by the storage API if the\n\t// per-project limits have been temporarily exceeded. The request\n\t// should be retried.\n\t// https://cloud.google.com/storage/docs/json_api/v1/status-codes#standardcodes\n\tstatusTooManyRequests = 429\n)\n\n// ResumableUpload is used by the generated APIs to provide resumable uploads.\n// It is not used by developers directly.\ntype ResumableUpload struct {\n\tClient *http.Client\n\t// URI is the resumable resource destination provided by the server after specifying \"&uploadType=resumable\".\n\tURI       string\n\tUserAgent string // User-Agent for header of the request\n\t// Media is the object being uploaded.\n\tMedia *ResumableBuffer\n\t// MediaType defines the media type, e.g. \"image/jpeg\".\n\tMediaType string\n\n\tmu       sync.Mutex // guards progress\n\tprogress int64      // number of bytes uploaded so far\n\n\t// Callback is an optional function that will be periodically called with the cumulative number of bytes uploaded.\n\tCallback func(int64)\n\n\t// If not specified, a default exponential backoff strategy will be used.\n\tBackoff BackoffStrategy\n}\n\n// Progress returns the number of bytes uploaded at this point.\nfunc (rx *ResumableUpload) Progress() int64 {\n\trx.mu.Lock()\n\tdefer rx.mu.Unlock()\n\treturn rx.progress\n}\n\n// doUploadRequest performs a single HTTP request to upload data.\n// off specifies the offset in rx.Media from which data is drawn.\n// size is the number of bytes in data.\n// final specifies whether data is the final chunk to be uploaded.\nfunc (rx *ResumableUpload) doUploadRequest(ctx context.Context, data io.Reader, off, size int64, final bool) (*http.Response, error) {\n\treq, err := http.NewRequest(\"POST\", rx.URI, data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.ContentLength = size\n\tvar contentRange string\n\tif final {\n\t\tif size == 0 {\n\t\t\tcontentRange = fmt.Sprintf(\"bytes */%v\", off)\n\t\t} else {\n\t\t\tcontentRange = fmt.Sprintf(\"bytes %v-%v/%v\", off, off+size-1, off+size)\n\t\t}\n\t} else {\n\t\tcontentRange = fmt.Sprintf(\"bytes %v-%v/*\", off, off+size-1)\n\t}\n\treq.Header.Set(\"Content-Range\", contentRange)\n\treq.Header.Set(\"Content-Type\", rx.MediaType)\n\treq.Header.Set(\"User-Agent\", rx.UserAgent)\n\treturn ctxhttp.Do(ctx, rx.Client, req)\n\n}\n\n// reportProgress calls a user-supplied callback to report upload progress.\n// If old==updated, the callback is not called.\nfunc (rx *ResumableUpload) reportProgress(old, updated int64) {\n\tif updated-old == 0 {\n\t\treturn\n\t}\n\trx.mu.Lock()\n\trx.progress = updated\n\trx.mu.Unlock()\n\tif rx.Callback != nil {\n\t\trx.Callback(updated)\n\t}\n}\n\n// transferChunk performs a single HTTP request to upload a single chunk from rx.Media.\nfunc (rx *ResumableUpload) transferChunk(ctx context.Context) (*http.Response, error) {\n\tchunk, off, size, err := rx.Media.Chunk()\n\n\tdone := err == io.EOF\n\tif !done && err != nil {\n\t\treturn nil, err\n\t}\n\n\tres, err := rx.doUploadRequest(ctx, chunk, off, int64(size), done)\n\tif err != nil {\n\t\treturn res, err\n\t}\n\n\tif res.StatusCode == statusResumeIncomplete || res.StatusCode == http.StatusOK {\n\t\trx.reportProgress(off, off+int64(size))\n\t}\n\n\tif res.StatusCode == statusResumeIncomplete {\n\t\trx.Media.Next()\n\t}\n\treturn res, nil\n}\n\nfunc contextDone(ctx context.Context) bool {\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\n// Upload starts the process of a resumable upload with a cancellable context.\n// It retries using the provided back off strategy until cancelled or the\n// strategy indicates to stop retrying.\n// It is called from the auto-generated API code and is not visible to the user.\n// rx is private to the auto-generated API code.\n// Exactly one of resp or err will be nil.  If resp is non-nil, the caller must call resp.Body.Close.\nfunc (rx *ResumableUpload) Upload(ctx context.Context) (resp *http.Response, err error) {\n\tvar pause time.Duration\n\tbackoff := rx.Backoff\n\tif backoff == nil {\n\t\tbackoff = DefaultBackoffStrategy()\n\t}\n\n\tfor {\n\t\t// Ensure that we return in the case of cancelled context, even if pause is 0.\n\t\tif contextDone(ctx) {\n\t\t\treturn nil, ctx.Err()\n\t\t}\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn nil, ctx.Err()\n\t\tcase <-time.After(pause):\n\t\t}\n\n\t\tresp, err = rx.transferChunk(ctx)\n\n\t\tvar status int\n\t\tif resp != nil {\n\t\t\tstatus = resp.StatusCode\n\t\t}\n\n\t\t// Check if we should retry the request.\n\t\tif shouldRetry(status, err) {\n\t\t\tvar retry bool\n\t\t\tpause, retry = backoff.Pause()\n\t\t\tif retry {\n\t\t\t\tif resp != nil && resp.Body != nil {\n\t\t\t\t\tresp.Body.Close()\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\t// If the chunk was uploaded successfully, but there's still\n\t\t// more to go, upload the next chunk without any delay.\n\t\tif status == statusResumeIncomplete {\n\t\t\tpause = 0\n\t\t\tbackoff.Reset()\n\t\t\tresp.Body.Close()\n\t\t\tcontinue\n\t\t}\n\n\t\t// It's possible for err and resp to both be non-nil here, but we expose a simpler\n\t\t// contract to our callers: exactly one of resp and err will be non-nil.  This means\n\t\t// that any response body must be closed here before returning a non-nil error.\n\t\tif err != nil {\n\t\t\tif resp != nil && resp.Body != nil {\n\t\t\t\tresp.Body.Close()\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\n\t\treturn resp, nil\n\t}\n}\n"
  },
  {
    "path": "vendor/google.golang.org/api/gensupport/retry.go",
    "content": "package gensupport\n\nimport (\n\t\"io\"\n\t\"net\"\n\t\"net/http\"\n\t\"time\"\n\n\t\"golang.org/x/net/context\"\n)\n\n// Retry invokes the given function, retrying it multiple times if the connection failed or\n// the HTTP status response indicates the request should be attempted again. ctx may be nil.\nfunc Retry(ctx context.Context, f func() (*http.Response, error), backoff BackoffStrategy) (*http.Response, error) {\n\tfor {\n\t\tresp, err := f()\n\n\t\tvar status int\n\t\tif resp != nil {\n\t\t\tstatus = resp.StatusCode\n\t\t}\n\n\t\t// Return if we shouldn't retry.\n\t\tpause, retry := backoff.Pause()\n\t\tif !shouldRetry(status, err) || !retry {\n\t\t\treturn resp, err\n\t\t}\n\n\t\t// Ensure the response body is closed, if any.\n\t\tif resp != nil && resp.Body != nil {\n\t\t\tresp.Body.Close()\n\t\t}\n\n\t\t// Pause, but still listen to ctx.Done if context is not nil.\n\t\tvar done <-chan struct{}\n\t\tif ctx != nil {\n\t\t\tdone = ctx.Done()\n\t\t}\n\t\tselect {\n\t\tcase <-done:\n\t\t\treturn nil, ctx.Err()\n\t\tcase <-time.After(pause):\n\t\t}\n\t}\n}\n\n// DefaultBackoffStrategy returns a default strategy to use for retrying failed upload requests.\nfunc DefaultBackoffStrategy() BackoffStrategy {\n\treturn &ExponentialBackoff{\n\t\tBase: 250 * time.Millisecond,\n\t\tMax:  16 * time.Second,\n\t}\n}\n\n// shouldRetry returns true if the HTTP response / error indicates that the\n// request should be attempted again.\nfunc shouldRetry(status int, err error) bool {\n\t// Retry for 5xx response codes.\n\tif 500 <= status && status < 600 {\n\t\treturn true\n\t}\n\n\t// Retry on statusTooManyRequests{\n\tif status == statusTooManyRequests {\n\t\treturn true\n\t}\n\n\t// Retry on unexpected EOFs and temporary network errors.\n\tif err == io.ErrUnexpectedEOF {\n\t\treturn true\n\t}\n\tif err, ok := err.(net.Error); ok {\n\t\treturn err.Temporary()\n\t}\n\n\treturn false\n}\n"
  },
  {
    "path": "vendor/google.golang.org/api/googleapi/googleapi.go",
    "content": "// Copyright 2011 Google Inc. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Package googleapi contains the common code shared by all Google API\n// libraries.\npackage googleapi\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"strings\"\n\n\t\"google.golang.org/api/googleapi/internal/uritemplates\"\n)\n\n// ContentTyper is an interface for Readers which know (or would like\n// to override) their Content-Type. If a media body doesn't implement\n// ContentTyper, the type is sniffed from the content using\n// http.DetectContentType.\ntype ContentTyper interface {\n\tContentType() string\n}\n\n// A SizeReaderAt is a ReaderAt with a Size method.\n// An io.SectionReader implements SizeReaderAt.\ntype SizeReaderAt interface {\n\tio.ReaderAt\n\tSize() int64\n}\n\n// ServerResponse is embedded in each Do response and\n// provides the HTTP status code and header sent by the server.\ntype ServerResponse struct {\n\t// HTTPStatusCode is the server's response status code.\n\t// When using a resource method's Do call, this will always be in the 2xx range.\n\tHTTPStatusCode int\n\t// Header contains the response header fields from the server.\n\tHeader http.Header\n}\n\nconst (\n\tVersion = \"0.5\"\n\n\t// UserAgent is the header string used to identify this package.\n\tUserAgent = \"google-api-go-client/\" + Version\n\n\t// The default chunk size to use for resumable uplods if not specified by the user.\n\tDefaultUploadChunkSize = 8 * 1024 * 1024\n\n\t// The minimum chunk size that can be used for resumable uploads.  All\n\t// user-specified chunk sizes must be multiple of this value.\n\tMinUploadChunkSize = 256 * 1024\n)\n\n// Error contains an error response from the server.\ntype Error struct {\n\t// Code is the HTTP response status code and will always be populated.\n\tCode int `json:\"code\"`\n\t// Message is the server response message and is only populated when\n\t// explicitly referenced by the JSON server response.\n\tMessage string `json:\"message\"`\n\t// Body is the raw response returned by the server.\n\t// It is often but not always JSON, depending on how the request fails.\n\tBody string\n\t// Header contains the response header fields from the server.\n\tHeader http.Header\n\n\tErrors []ErrorItem\n}\n\n// ErrorItem is a detailed error code & message from the Google API frontend.\ntype ErrorItem struct {\n\t// Reason is the typed error code. For example: \"some_example\".\n\tReason string `json:\"reason\"`\n\t// Message is the human-readable description of the error.\n\tMessage string `json:\"message\"`\n}\n\nfunc (e *Error) Error() string {\n\tif len(e.Errors) == 0 && e.Message == \"\" {\n\t\treturn fmt.Sprintf(\"googleapi: got HTTP response code %d with body: %v\", e.Code, e.Body)\n\t}\n\tvar buf bytes.Buffer\n\tfmt.Fprintf(&buf, \"googleapi: Error %d: \", e.Code)\n\tif e.Message != \"\" {\n\t\tfmt.Fprintf(&buf, \"%s\", e.Message)\n\t}\n\tif len(e.Errors) == 0 {\n\t\treturn strings.TrimSpace(buf.String())\n\t}\n\tif len(e.Errors) == 1 && e.Errors[0].Message == e.Message {\n\t\tfmt.Fprintf(&buf, \", %s\", e.Errors[0].Reason)\n\t\treturn buf.String()\n\t}\n\tfmt.Fprintln(&buf, \"\\nMore details:\")\n\tfor _, v := range e.Errors {\n\t\tfmt.Fprintf(&buf, \"Reason: %s, Message: %s\\n\", v.Reason, v.Message)\n\t}\n\treturn buf.String()\n}\n\ntype errorReply struct {\n\tError *Error `json:\"error\"`\n}\n\n// CheckResponse returns an error (of type *Error) if the response\n// status code is not 2xx.\nfunc CheckResponse(res *http.Response) error {\n\tif res.StatusCode >= 200 && res.StatusCode <= 299 {\n\t\treturn nil\n\t}\n\tslurp, err := ioutil.ReadAll(res.Body)\n\tif err == nil {\n\t\tjerr := new(errorReply)\n\t\terr = json.Unmarshal(slurp, jerr)\n\t\tif err == nil && jerr.Error != nil {\n\t\t\tif jerr.Error.Code == 0 {\n\t\t\t\tjerr.Error.Code = res.StatusCode\n\t\t\t}\n\t\t\tjerr.Error.Body = string(slurp)\n\t\t\treturn jerr.Error\n\t\t}\n\t}\n\treturn &Error{\n\t\tCode:   res.StatusCode,\n\t\tBody:   string(slurp),\n\t\tHeader: res.Header,\n\t}\n}\n\n// IsNotModified reports whether err is the result of the\n// server replying with http.StatusNotModified.\n// Such error values are sometimes returned by \"Do\" methods\n// on calls when If-None-Match is used.\nfunc IsNotModified(err error) bool {\n\tif err == nil {\n\t\treturn false\n\t}\n\tae, ok := err.(*Error)\n\treturn ok && ae.Code == http.StatusNotModified\n}\n\n// CheckMediaResponse returns an error (of type *Error) if the response\n// status code is not 2xx. Unlike CheckResponse it does not assume the\n// body is a JSON error document.\nfunc CheckMediaResponse(res *http.Response) error {\n\tif res.StatusCode >= 200 && res.StatusCode <= 299 {\n\t\treturn nil\n\t}\n\tslurp, _ := ioutil.ReadAll(io.LimitReader(res.Body, 1<<20))\n\tres.Body.Close()\n\treturn &Error{\n\t\tCode: res.StatusCode,\n\t\tBody: string(slurp),\n\t}\n}\n\ntype MarshalStyle bool\n\nvar WithDataWrapper = MarshalStyle(true)\nvar WithoutDataWrapper = MarshalStyle(false)\n\nfunc (wrap MarshalStyle) JSONReader(v interface{}) (io.Reader, error) {\n\tbuf := new(bytes.Buffer)\n\tif wrap {\n\t\tbuf.Write([]byte(`{\"data\": `))\n\t}\n\terr := json.NewEncoder(buf).Encode(v)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif wrap {\n\t\tbuf.Write([]byte(`}`))\n\t}\n\treturn buf, nil\n}\n\n// endingWithErrorReader from r until it returns an error.  If the\n// final error from r is io.EOF and e is non-nil, e is used instead.\ntype endingWithErrorReader struct {\n\tr io.Reader\n\te error\n}\n\nfunc (er endingWithErrorReader) Read(p []byte) (n int, err error) {\n\tn, err = er.r.Read(p)\n\tif err == io.EOF && er.e != nil {\n\t\terr = er.e\n\t}\n\treturn\n}\n\n// countingWriter counts the number of bytes it receives to write, but\n// discards them.\ntype countingWriter struct {\n\tn *int64\n}\n\nfunc (w countingWriter) Write(p []byte) (int, error) {\n\t*w.n += int64(len(p))\n\treturn len(p), nil\n}\n\n// ProgressUpdater is a function that is called upon every progress update of a resumable upload.\n// This is the only part of a resumable upload (from googleapi) that is usable by the developer.\n// The remaining usable pieces of resumable uploads is exposed in each auto-generated API.\ntype ProgressUpdater func(current, total int64)\n\ntype MediaOption interface {\n\tsetOptions(o *MediaOptions)\n}\n\ntype contentTypeOption string\n\nfunc (ct contentTypeOption) setOptions(o *MediaOptions) {\n\to.ContentType = string(ct)\n\tif o.ContentType == \"\" {\n\t\to.ForceEmptyContentType = true\n\t}\n}\n\n// ContentType returns a MediaOption which sets the Content-Type header for media uploads.\n// If ctype is empty, the Content-Type header will be omitted.\nfunc ContentType(ctype string) MediaOption {\n\treturn contentTypeOption(ctype)\n}\n\ntype chunkSizeOption int\n\nfunc (cs chunkSizeOption) setOptions(o *MediaOptions) {\n\tsize := int(cs)\n\tif size%MinUploadChunkSize != 0 {\n\t\tsize += MinUploadChunkSize - (size % MinUploadChunkSize)\n\t}\n\to.ChunkSize = size\n}\n\n// ChunkSize returns a MediaOption which sets the chunk size for media uploads.\n// size will be rounded up to the nearest multiple of 256K.\n// Media which contains fewer than size bytes will be uploaded in a single request.\n// Media which contains size bytes or more will be uploaded in separate chunks.\n// If size is zero, media will be uploaded in a single request.\nfunc ChunkSize(size int) MediaOption {\n\treturn chunkSizeOption(size)\n}\n\n// MediaOptions stores options for customizing media upload.  It is not used by developers directly.\ntype MediaOptions struct {\n\tContentType           string\n\tForceEmptyContentType bool\n\n\tChunkSize int\n}\n\n// ProcessMediaOptions stores options from opts in a MediaOptions.\n// It is not used by developers directly.\nfunc ProcessMediaOptions(opts []MediaOption) *MediaOptions {\n\tmo := &MediaOptions{ChunkSize: DefaultUploadChunkSize}\n\tfor _, o := range opts {\n\t\to.setOptions(mo)\n\t}\n\treturn mo\n}\n\nfunc ResolveRelative(basestr, relstr string) string {\n\tu, _ := url.Parse(basestr)\n\trel, _ := url.Parse(relstr)\n\tu = u.ResolveReference(rel)\n\tus := u.String()\n\tus = strings.Replace(us, \"%7B\", \"{\", -1)\n\tus = strings.Replace(us, \"%7D\", \"}\", -1)\n\treturn us\n}\n\n// has4860Fix is whether this Go environment contains the fix for\n// http://golang.org/issue/4860\nvar has4860Fix bool\n\n// init initializes has4860Fix by checking the behavior of the net/http package.\nfunc init() {\n\tr := http.Request{\n\t\tURL: &url.URL{\n\t\t\tScheme: \"http\",\n\t\t\tOpaque: \"//opaque\",\n\t\t},\n\t}\n\tb := &bytes.Buffer{}\n\tr.Write(b)\n\thas4860Fix = bytes.HasPrefix(b.Bytes(), []byte(\"GET http\"))\n}\n\n// SetOpaque sets u.Opaque from u.Path such that HTTP requests to it\n// don't alter any hex-escaped characters in u.Path.\nfunc SetOpaque(u *url.URL) {\n\tu.Opaque = \"//\" + u.Host + u.Path\n\tif !has4860Fix {\n\t\tu.Opaque = u.Scheme + \":\" + u.Opaque\n\t}\n}\n\n// Expand subsitutes any {encoded} strings in the URL passed in using\n// the map supplied.\n//\n// This calls SetOpaque to avoid encoding of the parameters in the URL path.\nfunc Expand(u *url.URL, expansions map[string]string) {\n\texpanded, err := uritemplates.Expand(u.Path, expansions)\n\tif err == nil {\n\t\tu.Path = expanded\n\t\tSetOpaque(u)\n\t}\n}\n\n// CloseBody is used to close res.Body.\n// Prior to calling Close, it also tries to Read a small amount to see an EOF.\n// Not seeing an EOF can prevent HTTP Transports from reusing connections.\nfunc CloseBody(res *http.Response) {\n\tif res == nil || res.Body == nil {\n\t\treturn\n\t}\n\t// Justification for 3 byte reads: two for up to \"\\r\\n\" after\n\t// a JSON/XML document, and then 1 to see EOF if we haven't yet.\n\t// TODO(bradfitz): detect Go 1.3+ and skip these reads.\n\t// See https://codereview.appspot.com/58240043\n\t// and https://codereview.appspot.com/49570044\n\tbuf := make([]byte, 1)\n\tfor i := 0; i < 3; i++ {\n\t\t_, err := res.Body.Read(buf)\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t}\n\tres.Body.Close()\n\n}\n\n// VariantType returns the type name of the given variant.\n// If the map doesn't contain the named key or the value is not a []interface{}, \"\" is returned.\n// This is used to support \"variant\" APIs that can return one of a number of different types.\nfunc VariantType(t map[string]interface{}) string {\n\ts, _ := t[\"type\"].(string)\n\treturn s\n}\n\n// ConvertVariant uses the JSON encoder/decoder to fill in the struct 'dst' with the fields found in variant 'v'.\n// This is used to support \"variant\" APIs that can return one of a number of different types.\n// It reports whether the conversion was successful.\nfunc ConvertVariant(v map[string]interface{}, dst interface{}) bool {\n\tvar buf bytes.Buffer\n\terr := json.NewEncoder(&buf).Encode(v)\n\tif err != nil {\n\t\treturn false\n\t}\n\treturn json.Unmarshal(buf.Bytes(), dst) == nil\n}\n\n// A Field names a field to be retrieved with a partial response.\n// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse\n//\n// Partial responses can dramatically reduce the amount of data that must be sent to your application.\n// In order to request partial responses, you can specify the full list of fields\n// that your application needs by adding the Fields option to your request.\n//\n// Field strings use camelCase with leading lower-case characters to identify fields within the response.\n//\n// For example, if your response has a \"NextPageToken\" and a slice of \"Items\" with \"Id\" fields,\n// you could request just those fields like this:\n//\n//     svc.Events.List().Fields(\"nextPageToken\", \"items/id\").Do()\n//\n// or if you were also interested in each Item's \"Updated\" field, you can combine them like this:\n//\n//     svc.Events.List().Fields(\"nextPageToken\", \"items(id,updated)\").Do()\n//\n// More information about field formatting can be found here:\n// https://developers.google.com/+/api/#fields-syntax\n//\n// Another way to find field names is through the Google API explorer:\n// https://developers.google.com/apis-explorer/#p/\ntype Field string\n\n// CombineFields combines fields into a single string.\nfunc CombineFields(s []Field) string {\n\tr := make([]string, len(s))\n\tfor i, v := range s {\n\t\tr[i] = string(v)\n\t}\n\treturn strings.Join(r, \",\")\n}\n\n// A CallOption is an optional argument to an API call.\n// It should be treated as an opaque value by users of Google APIs.\n//\n// A CallOption is something that configures an API call in a way that is\n// not specific to that API; for instance, controlling the quota user for\n// an API call is common across many APIs, and is thus a CallOption.\ntype CallOption interface {\n\tGet() (key, value string)\n}\n\n// QuotaUser returns a CallOption that will set the quota user for a call.\n// The quota user can be used by server-side applications to control accounting.\n// It can be an arbitrary string up to 40 characters, and will override UserIP\n// if both are provided.\nfunc QuotaUser(u string) CallOption { return quotaUser(u) }\n\ntype quotaUser string\n\nfunc (q quotaUser) Get() (string, string) { return \"quotaUser\", string(q) }\n\n// UserIP returns a CallOption that will set the \"userIp\" parameter of a call.\n// This should be the IP address of the originating request.\nfunc UserIP(ip string) CallOption { return userIP(ip) }\n\ntype userIP string\n\nfunc (i userIP) Get() (string, string) { return \"userIp\", string(i) }\n\n// Trace returns a CallOption that enables diagnostic tracing for a call.\n// traceToken is an ID supplied by Google support.\nfunc Trace(traceToken string) CallOption { return traceTok(traceToken) }\n\ntype traceTok string\n\nfunc (t traceTok) Get() (string, string) { return \"trace\", \"token:\" + string(t) }\n\n// TODO: Fields too\n"
  },
  {
    "path": "vendor/google.golang.org/api/googleapi/internal/uritemplates/LICENSE",
    "content": "Copyright (c) 2013 Joshua Tacoma\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 of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject 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, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "vendor/google.golang.org/api/googleapi/internal/uritemplates/uritemplates.go",
    "content": "// Copyright 2013 Joshua Tacoma. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Package uritemplates is a level 3 implementation of RFC 6570 (URI\n// Template, http://tools.ietf.org/html/rfc6570).\n// uritemplates does not support composite values (in Go: slices or maps)\n// and so does not qualify as a level 4 implementation.\npackage uritemplates\n\nimport (\n\t\"bytes\"\n\t\"errors\"\n\t\"regexp\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar (\n\tunreserved = regexp.MustCompile(\"[^A-Za-z0-9\\\\-._~]\")\n\treserved   = regexp.MustCompile(\"[^A-Za-z0-9\\\\-._~:/?#[\\\\]@!$&'()*+,;=]\")\n\tvalidname  = regexp.MustCompile(\"^([A-Za-z0-9_\\\\.]|%[0-9A-Fa-f][0-9A-Fa-f])+$\")\n\thex        = []byte(\"0123456789ABCDEF\")\n)\n\nfunc pctEncode(src []byte) []byte {\n\tdst := make([]byte, len(src)*3)\n\tfor i, b := range src {\n\t\tbuf := dst[i*3 : i*3+3]\n\t\tbuf[0] = 0x25\n\t\tbuf[1] = hex[b/16]\n\t\tbuf[2] = hex[b%16]\n\t}\n\treturn dst\n}\n\nfunc escape(s string, allowReserved bool) string {\n\tif allowReserved {\n\t\treturn string(reserved.ReplaceAllFunc([]byte(s), pctEncode))\n\t}\n\treturn string(unreserved.ReplaceAllFunc([]byte(s), pctEncode))\n}\n\n// A uriTemplate is a parsed representation of a URI template.\ntype uriTemplate struct {\n\traw   string\n\tparts []templatePart\n}\n\n// parse parses a URI template string into a uriTemplate object.\nfunc parse(rawTemplate string) (*uriTemplate, error) {\n\tsplit := strings.Split(rawTemplate, \"{\")\n\tparts := make([]templatePart, len(split)*2-1)\n\tfor i, s := range split {\n\t\tif i == 0 {\n\t\t\tif strings.Contains(s, \"}\") {\n\t\t\t\treturn nil, errors.New(\"unexpected }\")\n\t\t\t}\n\t\t\tparts[i].raw = s\n\t\t\tcontinue\n\t\t}\n\t\tsubsplit := strings.Split(s, \"}\")\n\t\tif len(subsplit) != 2 {\n\t\t\treturn nil, errors.New(\"malformed template\")\n\t\t}\n\t\texpression := subsplit[0]\n\t\tvar err error\n\t\tparts[i*2-1], err = parseExpression(expression)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tparts[i*2].raw = subsplit[1]\n\t}\n\treturn &uriTemplate{\n\t\traw:   rawTemplate,\n\t\tparts: parts,\n\t}, nil\n}\n\ntype templatePart struct {\n\traw           string\n\tterms         []templateTerm\n\tfirst         string\n\tsep           string\n\tnamed         bool\n\tifemp         string\n\tallowReserved bool\n}\n\ntype templateTerm struct {\n\tname     string\n\texplode  bool\n\ttruncate int\n}\n\nfunc parseExpression(expression string) (result templatePart, err error) {\n\tswitch expression[0] {\n\tcase '+':\n\t\tresult.sep = \",\"\n\t\tresult.allowReserved = true\n\t\texpression = expression[1:]\n\tcase '.':\n\t\tresult.first = \".\"\n\t\tresult.sep = \".\"\n\t\texpression = expression[1:]\n\tcase '/':\n\t\tresult.first = \"/\"\n\t\tresult.sep = \"/\"\n\t\texpression = expression[1:]\n\tcase ';':\n\t\tresult.first = \";\"\n\t\tresult.sep = \";\"\n\t\tresult.named = true\n\t\texpression = expression[1:]\n\tcase '?':\n\t\tresult.first = \"?\"\n\t\tresult.sep = \"&\"\n\t\tresult.named = true\n\t\tresult.ifemp = \"=\"\n\t\texpression = expression[1:]\n\tcase '&':\n\t\tresult.first = \"&\"\n\t\tresult.sep = \"&\"\n\t\tresult.named = true\n\t\tresult.ifemp = \"=\"\n\t\texpression = expression[1:]\n\tcase '#':\n\t\tresult.first = \"#\"\n\t\tresult.sep = \",\"\n\t\tresult.allowReserved = true\n\t\texpression = expression[1:]\n\tdefault:\n\t\tresult.sep = \",\"\n\t}\n\trawterms := strings.Split(expression, \",\")\n\tresult.terms = make([]templateTerm, len(rawterms))\n\tfor i, raw := range rawterms {\n\t\tresult.terms[i], err = parseTerm(raw)\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn result, err\n}\n\nfunc parseTerm(term string) (result templateTerm, err error) {\n\t// TODO(djd): Remove \"*\" suffix parsing once we check that no APIs have\n\t// mistakenly used that attribute.\n\tif strings.HasSuffix(term, \"*\") {\n\t\tresult.explode = true\n\t\tterm = term[:len(term)-1]\n\t}\n\tsplit := strings.Split(term, \":\")\n\tif len(split) == 1 {\n\t\tresult.name = term\n\t} else if len(split) == 2 {\n\t\tresult.name = split[0]\n\t\tvar parsed int64\n\t\tparsed, err = strconv.ParseInt(split[1], 10, 0)\n\t\tresult.truncate = int(parsed)\n\t} else {\n\t\terr = errors.New(\"multiple colons in same term\")\n\t}\n\tif !validname.MatchString(result.name) {\n\t\terr = errors.New(\"not a valid name: \" + result.name)\n\t}\n\tif result.explode && result.truncate > 0 {\n\t\terr = errors.New(\"both explode and prefix modifers on same term\")\n\t}\n\treturn result, err\n}\n\n// Expand expands a URI template with a set of values to produce a string.\nfunc (t *uriTemplate) Expand(values map[string]string) string {\n\tvar buf bytes.Buffer\n\tfor _, p := range t.parts {\n\t\tp.expand(&buf, values)\n\t}\n\treturn buf.String()\n}\n\nfunc (tp *templatePart) expand(buf *bytes.Buffer, values map[string]string) {\n\tif len(tp.raw) > 0 {\n\t\tbuf.WriteString(tp.raw)\n\t\treturn\n\t}\n\tvar first = true\n\tfor _, term := range tp.terms {\n\t\tvalue, exists := values[term.name]\n\t\tif !exists {\n\t\t\tcontinue\n\t\t}\n\t\tif first {\n\t\t\tbuf.WriteString(tp.first)\n\t\t\tfirst = false\n\t\t} else {\n\t\t\tbuf.WriteString(tp.sep)\n\t\t}\n\t\ttp.expandString(buf, term, value)\n\t}\n}\n\nfunc (tp *templatePart) expandName(buf *bytes.Buffer, name string, empty bool) {\n\tif tp.named {\n\t\tbuf.WriteString(name)\n\t\tif empty {\n\t\t\tbuf.WriteString(tp.ifemp)\n\t\t} else {\n\t\t\tbuf.WriteString(\"=\")\n\t\t}\n\t}\n}\n\nfunc (tp *templatePart) expandString(buf *bytes.Buffer, t templateTerm, s string) {\n\tif len(s) > t.truncate && t.truncate > 0 {\n\t\ts = s[:t.truncate]\n\t}\n\ttp.expandName(buf, t.name, len(s) == 0)\n\tbuf.WriteString(escape(s, tp.allowReserved))\n}\n"
  },
  {
    "path": "vendor/google.golang.org/api/googleapi/internal/uritemplates/utils.go",
    "content": "// Copyright 2016 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage uritemplates\n\nfunc Expand(path string, values map[string]string) (string, error) {\n\ttemplate, err := parse(path)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn template.Expand(values), nil\n}\n"
  },
  {
    "path": "vendor/google.golang.org/api/googleapi/types.go",
    "content": "// Copyright 2013 Google Inc. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage googleapi\n\nimport (\n\t\"encoding/json\"\n\t\"strconv\"\n)\n\n// Int64s is a slice of int64s that marshal as quoted strings in JSON.\ntype Int64s []int64\n\nfunc (q *Int64s) UnmarshalJSON(raw []byte) error {\n\t*q = (*q)[:0]\n\tvar ss []string\n\tif err := json.Unmarshal(raw, &ss); err != nil {\n\t\treturn err\n\t}\n\tfor _, s := range ss {\n\t\tv, err := strconv.ParseInt(s, 10, 64)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t*q = append(*q, int64(v))\n\t}\n\treturn nil\n}\n\n// Int32s is a slice of int32s that marshal as quoted strings in JSON.\ntype Int32s []int32\n\nfunc (q *Int32s) UnmarshalJSON(raw []byte) error {\n\t*q = (*q)[:0]\n\tvar ss []string\n\tif err := json.Unmarshal(raw, &ss); err != nil {\n\t\treturn err\n\t}\n\tfor _, s := range ss {\n\t\tv, err := strconv.ParseInt(s, 10, 32)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t*q = append(*q, int32(v))\n\t}\n\treturn nil\n}\n\n// Uint64s is a slice of uint64s that marshal as quoted strings in JSON.\ntype Uint64s []uint64\n\nfunc (q *Uint64s) UnmarshalJSON(raw []byte) error {\n\t*q = (*q)[:0]\n\tvar ss []string\n\tif err := json.Unmarshal(raw, &ss); err != nil {\n\t\treturn err\n\t}\n\tfor _, s := range ss {\n\t\tv, err := strconv.ParseUint(s, 10, 64)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t*q = append(*q, uint64(v))\n\t}\n\treturn nil\n}\n\n// Uint32s is a slice of uint32s that marshal as quoted strings in JSON.\ntype Uint32s []uint32\n\nfunc (q *Uint32s) UnmarshalJSON(raw []byte) error {\n\t*q = (*q)[:0]\n\tvar ss []string\n\tif err := json.Unmarshal(raw, &ss); err != nil {\n\t\treturn err\n\t}\n\tfor _, s := range ss {\n\t\tv, err := strconv.ParseUint(s, 10, 32)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t*q = append(*q, uint32(v))\n\t}\n\treturn nil\n}\n\n// Float64s is a slice of float64s that marshal as quoted strings in JSON.\ntype Float64s []float64\n\nfunc (q *Float64s) UnmarshalJSON(raw []byte) error {\n\t*q = (*q)[:0]\n\tvar ss []string\n\tif err := json.Unmarshal(raw, &ss); err != nil {\n\t\treturn err\n\t}\n\tfor _, s := range ss {\n\t\tv, err := strconv.ParseFloat(s, 64)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t*q = append(*q, float64(v))\n\t}\n\treturn nil\n}\n\nfunc quotedList(n int, fn func(dst []byte, i int) []byte) ([]byte, error) {\n\tdst := make([]byte, 0, 2+n*10) // somewhat arbitrary\n\tdst = append(dst, '[')\n\tfor i := 0; i < n; i++ {\n\t\tif i > 0 {\n\t\t\tdst = append(dst, ',')\n\t\t}\n\t\tdst = append(dst, '\"')\n\t\tdst = fn(dst, i)\n\t\tdst = append(dst, '\"')\n\t}\n\tdst = append(dst, ']')\n\treturn dst, nil\n}\n\nfunc (s Int64s) MarshalJSON() ([]byte, error) {\n\treturn quotedList(len(s), func(dst []byte, i int) []byte {\n\t\treturn strconv.AppendInt(dst, s[i], 10)\n\t})\n}\n\nfunc (s Int32s) MarshalJSON() ([]byte, error) {\n\treturn quotedList(len(s), func(dst []byte, i int) []byte {\n\t\treturn strconv.AppendInt(dst, int64(s[i]), 10)\n\t})\n}\n\nfunc (s Uint64s) MarshalJSON() ([]byte, error) {\n\treturn quotedList(len(s), func(dst []byte, i int) []byte {\n\t\treturn strconv.AppendUint(dst, s[i], 10)\n\t})\n}\n\nfunc (s Uint32s) MarshalJSON() ([]byte, error) {\n\treturn quotedList(len(s), func(dst []byte, i int) []byte {\n\t\treturn strconv.AppendUint(dst, uint64(s[i]), 10)\n\t})\n}\n\nfunc (s Float64s) MarshalJSON() ([]byte, error) {\n\treturn quotedList(len(s), func(dst []byte, i int) []byte {\n\t\treturn strconv.AppendFloat(dst, s[i], 'g', -1, 64)\n\t})\n}\n\n/*\n * Helper routines for simplifying the creation of optional fields of basic type.\n */\n\n// Bool is a helper routine that allocates a new bool value\n// to store v and returns a pointer to it.\nfunc Bool(v bool) *bool { return &v }\n\n// Int32 is a helper routine that allocates a new int32 value\n// to store v and returns a pointer to it.\nfunc Int32(v int32) *int32 { return &v }\n\n// Int64 is a helper routine that allocates a new int64 value\n// to store v and returns a pointer to it.\nfunc Int64(v int64) *int64 { return &v }\n\n// Float64 is a helper routine that allocates a new float64 value\n// to store v and returns a pointer to it.\nfunc Float64(v float64) *float64 { return &v }\n\n// Uint32 is a helper routine that allocates a new uint32 value\n// to store v and returns a pointer to it.\nfunc Uint32(v uint32) *uint32 { return &v }\n\n// Uint64 is a helper routine that allocates a new uint64 value\n// to store v and returns a pointer to it.\nfunc Uint64(v uint64) *uint64 { return &v }\n\n// String is a helper routine that allocates a new string value\n// to store v and returns a pointer to it.\nfunc String(v string) *string { return &v }\n"
  }
]